Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

ui.h

00001 #ifndef UI_H
00002 #define UI_H
00003 
00004 #include <vector>
00005 #include <list>
00006 #include <string>
00007 
00008 #include "ConMath.h"
00009 #include "point.h"
00010 
00011 class IO_Window;
00012 class GUI;
00013 class Texture;
00014 class IO_Key;
00015 
00016 /* the user interface (more or less just the mouse clicking stuff) */
00017 class UI
00018 {
00019 public:
00020   /* constructor */
00021   UI (void);
00022   /* destructor */
00023   ~UI (void);
00024 
00025   /* list of icons supplied by the UI */
00026   enum Icon
00027   {
00028     BLANK_ICON = 0,
00029     LAUNCH_ICON,
00030     X_ICON,
00031     PATH_ICON
00032   };
00033 
00034   /* external specification for a button on the side tool bar */
00035   struct Button
00036   {
00037     /* icon ID (from central index above) */
00038     Icon icon;
00039 
00040     /* the id returned when the button triggers an event */
00041     int id;
00042 
00043     /* description displayed to user in status bar */
00044     std::string desc;
00045   };
00046   /* clear all the buttons off the tool bar */
00047   void ClearButtons (void);
00048   /* add a button to the end of the tool bar */
00049   void AddButton (Button &b);
00050   void AddButton (Icon icon, int id, std::string desc);
00051   /* set the buttons all at once */
00052   void SetButtons (std::vector<Button> &buttons);
00053 
00054   /* set default status bar text (when nothing is highlighted) */
00055   void SetDesc (const std::string& desc);
00056 
00057   /* set what's clickable (and how it's clickable) */
00058   enum Mode
00059   {
00060     /* neither obstacles nor points can be selected */
00061     SELECT_NOTHING = 0,
00062     /* points can be selected (produces an event) */
00063     SELECT_POINT,
00064     /* points can be dragged around (produces no events) */
00065     DRAG_POINT,
00066     /* obstacles can be selected (produces an event) */
00067     SELECT_OBSTACLE
00068   };
00069   void SetMode (Mode m);
00070 
00071   /* event types */
00072   enum EventType
00073   {
00074     /* nothing happened since the last poll */
00075     NO_EVENT = 0,
00076     /* a button was pressed (but not released yet) */
00077     BUTTON_PRESSED,
00078     /* a button was released */
00079     BUTTON_RELEASED,
00080     /* the user clicked on the button, moved the mouse off it, then released */
00081     BUTTON_ABORTED,
00082     /* a point was selected */
00083     POINT_SELECTED,
00084     /* an obstacle was selected */
00085     OBSTACLE_SELECTED,
00086     /* escape was pressed */
00087     ESCAPE_PRESSED
00088   };
00089   /* event structure */
00090   struct Event
00091   {
00092     EventType type;
00093     /* id of button/obstacle */
00094     int id;
00095     /* location of point */
00096     Vector point;
00097   };
00098   /* poll for events (the event queue has size one, so do this often) */
00099   Event GetEvent (void);
00100 
00101   /* send key press events to the UI */
00102   void OnPress (IO_Window *win, const IO_Key &k);
00103   /* send key release events to the UI */
00104   void OnRelease (IO_Window *win, const IO_Key &k);
00105 
00106   /* update the UI */
00107   void Update (IO_Window *win);
00108 
00109   /* render the 3D portion of the UI */
00110   void Render (void);
00111   /* render the 2D portion of the UI */
00112   void Overlay (const GUI *gui);
00113 
00114   /* launch a point */
00115   void LaunchPoint (Vector &p, Vector &v);
00116   /* stop the point just launched */
00117   void StopPoint (void);
00118   /* remove a point */
00119   void RemovePoint (Vector &p);
00120 
00121 private:
00122   /* draw an icon */
00123   void DrawIcon (Icon id);
00124 
00125   /* determine which button the mouse is over (returns -1 for none) */
00126   int WhichButton (IO_Window *win);
00127   /* determine which point the mouse is over (returns -1 for none) */
00128   std::list<Point>::iterator WhichPoint (IO_Window *win);
00129 
00130   /* set the description text to whatever it should be */
00131   void DoDesc (void);
00132 
00133   /* list of buttons */
00134   std::vector<Button> buttons;
00135 
00136   /* which button has mouse over it (-1 for none) */
00137   int selected;
00138   /* which button is pressed (-1 for none) */
00139   int pressed;
00140 
00141   /* mode */
00142   Mode mode;
00143 
00144   /* default description text */
00145   std::string def_desc;
00146   /* current description text */
00147   std::string cur_desc;
00148 
00149   /* point deployment (big hack) */
00150   std::list<Point> points;
00151   Timer pt;
00152   bool launching, dragging;
00153   Vector launch_v;
00154   double drag_d;
00155   Point *draggie;
00156 
00157   /* event 'queue' */
00158   Event event;
00159 
00160   /* textures */
00161   Texture *square;
00162 };
00163 
00164 #endif

Generated on Fri Jan 12 14:15:02 2007 for Construct by  doxygen 1.4.3-20050530