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
00017 class UI
00018 {
00019 public:
00020
00021 UI (void);
00022
00023 ~UI (void);
00024
00025
00026 enum Icon
00027 {
00028 BLANK_ICON = 0,
00029 LAUNCH_ICON,
00030 X_ICON,
00031 PATH_ICON
00032 };
00033
00034
00035 struct Button
00036 {
00037
00038 Icon icon;
00039
00040
00041 int id;
00042
00043
00044 std::string desc;
00045 };
00046
00047 void ClearButtons (void);
00048
00049 void AddButton (Button &b);
00050 void AddButton (Icon icon, int id, std::string desc);
00051
00052 void SetButtons (std::vector<Button> &buttons);
00053
00054
00055 void SetDesc (const std::string& desc);
00056
00057
00058 enum Mode
00059 {
00060
00061 SELECT_NOTHING = 0,
00062
00063 SELECT_POINT,
00064
00065 DRAG_POINT,
00066
00067 SELECT_OBSTACLE
00068 };
00069 void SetMode (Mode m);
00070
00071
00072 enum EventType
00073 {
00074
00075 NO_EVENT = 0,
00076
00077 BUTTON_PRESSED,
00078
00079 BUTTON_RELEASED,
00080
00081 BUTTON_ABORTED,
00082
00083 POINT_SELECTED,
00084
00085 OBSTACLE_SELECTED,
00086
00087 ESCAPE_PRESSED
00088 };
00089
00090 struct Event
00091 {
00092 EventType type;
00093
00094 int id;
00095
00096 Vector point;
00097 };
00098
00099 Event GetEvent (void);
00100
00101
00102 void OnPress (IO_Window *win, const IO_Key &k);
00103
00104 void OnRelease (IO_Window *win, const IO_Key &k);
00105
00106
00107 void Update (IO_Window *win);
00108
00109
00110 void Render (void);
00111
00112 void Overlay (const GUI *gui);
00113
00114
00115 void LaunchPoint (Vector &p, Vector &v);
00116
00117 void StopPoint (void);
00118
00119 void RemovePoint (Vector &p);
00120
00121 private:
00122
00123 void DrawIcon (Icon id);
00124
00125
00126 int WhichButton (IO_Window *win);
00127
00128 std::list<Point>::iterator WhichPoint (IO_Window *win);
00129
00130
00131 void DoDesc (void);
00132
00133
00134 std::vector<Button> buttons;
00135
00136
00137 int selected;
00138
00139 int pressed;
00140
00141
00142 Mode mode;
00143
00144
00145 std::string def_desc;
00146
00147 std::string cur_desc;
00148
00149
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
00158 Event event;
00159
00160
00161 Texture *square;
00162 };
00163
00164 #endif