Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 713 vs 714 for /trunk/Source Code/GUI/Headers/GUI.h

Diff revisions: vs.
  @@ -68,10 +68,11 @@
68 68
69 69 /// Graphical User Interface
70 70
71 + class SceneGUIElements;
71 72 DEFINE_SINGLETON_EXT1(GUI, Input::InputAggregatorInterface)
73 + public:
72 74 typedef hashMapImpl<ULL, std::pair<GUIElement*, bool/*last state*/>> GUIMap;
73 - typedef hashMapImpl<I64, GUIMap> GUIMapPerScene;
74 -
75 + typedef hashMapImpl<I64, SceneGUIElements*> GUIMapPerScene;
75 76 typedef DELEGATE_CBK_PARAM<I64> ButtonCallback;
76 77
77 78 public:
  @@ -90,24 +91,15 @@
90 91 const vec4<U8>& color,
91 92 const stringImpl& text,
92 93 U32 fontSize = 16);
93 - GUIText* addGlobalText(ULL ID,
94 - const vec2<I32>& position,
95 - const stringImpl& font,
96 - const vec4<U8>& color,
97 - const stringImpl& text,
98 - U32 fontSize = 16);
99 94 /// Modify a text label
100 95 GUIText* modifyText(ULL ID, const stringImpl& text);
101 - GUIText* modifyGlobalText(ULL ID, const stringImpl& text);
96 +
102 97
103 98 GUIMessageBox* addMsgBox(ULL ID,
104 99 const stringImpl& title,
105 100 const stringImpl& message,
106 101 const vec2<I32>& offsetFromCentre = vec2<I32>(0));
107 - GUIMessageBox* addGlobalMsgBox(ULL ID,
108 - const stringImpl& title,
109 - const stringImpl& message,
110 - const vec2<I32>& offsetFromCentre = vec2<I32>(0));
102 +
111 103 /// Add a button with a specific callback.
112 104 /// The root of the window positioning system is bottom left, so 100,60 will
113 105 /// place the button 100 pixels to the right and 60 up
  @@ -118,43 +110,32 @@
118 110 const vec2<U32>& dimensions,
119 111 ButtonCallback callback,
120 112 const stringImpl& rootSheetID = "");
121 - GUIButton* addGlobalButton(ULL ID,
122 - const stringImpl& text,
123 - const vec2<I32>& position,
124 - const vec2<U32>& dimensions,
125 - ButtonCallback callback,
126 - const stringImpl& rootSheetID = "");
113 +
127 114 /// Add a flash element -DEPRECATED-
128 115 GUIFlash* addFlash(ULL ID,
129 116 stringImpl movie,
130 117 const vec2<U32>& position,
131 118 const vec2<U32>& extent);
132 - GUIFlash* addGlobalFlash(ULL ID,
133 - stringImpl movie,
134 - const vec2<U32>& position,
135 - const vec2<U32>& extent);
119 +
136 120 /// Get a pointer to our console window
137 121 inline GUIConsole* const getConsole() { return _console; }
138 122 inline const GUIEditor& getEditor() { return GUIEditor::instance(); }
123 +
139 124 /// Get a pointer to an element by name/id
140 125 template<typename T = GUIElement>
141 - inline T* getGuiElement(I64 sceneID, ULL elementName) {
142 - static_assert(std::is_base_of<GUIElement, T>::value, "getGuiElement error: Target is not a valid GUI item");
143 - return static_cast<T*>(_guiStack[sceneID][elementName].first);
126 + inline T* getGUIElement(I64 sceneID, ULL elementName) {
127 + static_assert(std::is_base_of<GUIElement, T>::value,
128 + "getGuiElement error: Target is not a valid GUI item");
129 +
130 + return static_cast<T*>(getGUIElementImpl(sceneID, elementName));
144 131 }
132 +
145 133 template<typename T = GUIElement>
146 - inline T* getGuiElement(I64 sceneID, I64 elementID) {
147 - static_assert(std::is_base_of<GUIElement, T>::value, "getGuiElement error: Target is not a valid GUI item");
148 - const GUIMap& guiStackForScene = _guiStack[sceneID];
149 -
150 - GUIElement* element = nullptr;
151 - for (GUIMap::value_type it : guiStackForScene) {
152 - if (it.second.first->getGUID() == elementID) {
153 - element = it.second.first;
154 - break;
155 - }
156 - }
157 - return static_cast<T*>(element);
134 + inline T* getGUIElement(I64 sceneID, I64 elementID) {
135 + static_assert(std::is_base_of<GUIElement, T>::value,
136 + "getGuiElement error: Target is not a valid GUI item");
137 +
138 + return static_cast<T*>(getGUIElementImpl(sceneID, elementID));
158 139 }
159 140 /// Used by CEGUI to setup rendering (D3D/OGL/OGRE/etc)
160 141 bool bindRenderer(CEGUI::Renderer& renderer);
  @@ -206,11 +187,18 @@
206 187 return _activeScene;
207 188 }
208 189
190 + protected:
191 + friend class SceneGUIElements;
192 + CEGUI::Window* _rootSheet; //< gui root Window
193 + stringImpl _defaultGUIScheme;
194 +
209 195 private:
210 196 GUI(); //< Constructor
211 197 ~GUI(); //< Destructor
212 198 void draw() const;
213 - void addElement(ULL id, I64 sceneID, GUIElement* element);
199 + void addElement(ULL id, GUIElement* element);
200 + GUIElement* getGUIElementImpl(I64 sceneID, ULL elementName) const;
201 + GUIElement* getGUIElementImpl(I64 sceneID, I64 elementID) const;
214 202
215 203 private:
216 204 bool _init; //< Set to true when the GUI has finished loading
  @@ -222,8 +210,6 @@
222 210 //general purpose messages
223 211 U64 _textRenderInterval; //< We should avoid rendering text as fast as possible
224 212 //for performance reasons
225 - CEGUI::Window* _rootSheet; //< gui root Window
226 - stringImpl _defaultGUIScheme;
227 213 ShaderProgram_ptr _guiShader; //<Used to apply color for text for now
228 214
229 215 /// Each scene has its own gui elements! (0 = global)
  @@ -236,7 +222,8 @@
236 222 vectorImpl<std::pair<I64, I64>> _debugDisplayEntries;
237 223
238 224 /// All the GUI elements created per scene
239 - GUIMapPerScene _guiStack;
225 + GUIMapPerScene _guiStack;
226 + GUIMap _guiGlobalStack;
240 227 END_SINGLETON
241 228
242 229 }; // namespace Divide