15 #ifndef SCENE_LAB_EDITOR_GUI_H_
16 #define SCENE_LAB_EDITOR_GUI_H_
22 #include <unordered_map>
23 #include "flatui/flatui.h"
24 #include "fplbase/asset_manager.h"
25 #include "fplbase/renderer.h"
26 #include "scene_lab/entity_system_adapter.h"
28 #include "scene_lab_config_generated.h"
45 fplbase::AssetManager* asset_manager,
46 fplbase::InputSystem* input_system, fplbase::Renderer* renderer,
47 flatui::FontManager* font_manager);
70 void DrawGui(
const mathfu::vec2& virtual_resolution);
116 for (
auto iter = component_guis_.begin(); iter != component_guis_.end();
136 const std::string& menu_title_string() {
return menu_title_string_; }
137 void set_menu_title_string(
const std::string& s) { menu_title_string_ = s; }
141 components_to_show_[component] = b;
144 MATHFU_DEFINE_CLASS_SIMD_AWARE_NEW_DELETE
156 kToggleLockCameraHeight,
171 enum WindowState { kNormal, kMaximized };
173 static const int kToolbarHeight = 30;
174 static const int kIndent = 3;
175 static const int kFontSize = 18;
178 void CommitComponentData(
const GenericComponentId& component);
181 void SendUpdateEvent();
185 void CaptureMouseClicks();
188 void DrawEditEntityUI();
190 void DrawEntityListUI();
192 void DrawSettingsUI();
194 void DrawPrototypeListUI();
196 void DrawEntityComponent(
const GenericComponentId& component);
198 void DrawEntityFamily();
204 void BeginDrawEditView();
206 void FinishDrawEditView();
209 flatui::Event TextButton(
const char* text,
const char*
id,
float size);
212 void EntityButton(
const GenericEntityId& entity,
float size);
215 void GetVirtualResolution(mathfu::vec2* resolution_output);
218 EntitySystemAdapter* entity_system_adapter();
220 const SceneLabConfig* config_;
221 SceneLab* scene_lab_;
222 fplbase::AssetManager* asset_manager_;
223 fplbase::InputSystem* input_system_;
224 fplbase::Renderer* renderer_;
225 flatui::FontManager* font_manager_;
228 GenericEntityId edit_entity_;
231 GenericEntityId changed_edit_entity_;
232 std::unordered_map<GenericComponentId, std::unique_ptr<FlatbufferEditor>>
234 GenericComponentId auto_commit_component_;
235 GenericComponentId auto_revert_component_;
236 GenericComponentId auto_recreate_component_;
238 std::unordered_map<GenericComponentId, bool>
240 std::vector<GenericComponentId> component_list_;
241 std::vector<std::string> prototype_list_;
243 std::string entity_list_filter_;
244 std::string prototype_list_filter_;
245 std::string menu_title_string_;
247 mathfu::vec4 bg_edit_ui_color_;
248 mathfu::vec4 bg_toolbar_color_;
249 mathfu::vec4 bg_button_color_;
250 mathfu::vec4 bg_hover_color_;
251 mathfu::vec4 bg_click_color_;
253 mathfu::vec4 text_button_color_;
254 mathfu::vec4 text_normal_color_;
255 mathfu::vec4 text_disabled_color_;
256 mathfu::vec4 text_editable_color_;
257 mathfu::vec4 text_modified_color_;
258 mathfu::vec4 text_error_color_;
260 mathfu::vec2 scroll_offset_[kEditViewCount];
261 mathfu::vec2 virtual_resolution_;
262 GuiButton button_pressed_;
263 WindowState edit_window_state_;
266 int mouse_mode_index_;
270 bool mouse_in_window_;
271 bool keyboard_in_use_;
272 bool prompting_for_exit_;
273 bool updated_via_gui_;
274 bool lock_camera_height_;
279 #endif // SCENE_LAB_EDITOR_GUI_H_
Definition: editor_gui.h:38
bool keyboard_in_use() const
If we've taken ownership of the keyboard (generally when a editable field is being edited)...
Definition: editor_gui.h:88
EditorGui(const SceneLabConfig *config, SceneLab *scene_lab, fplbase::AssetManager *asset_manager, fplbase::InputSystem *input_system, fplbase::Renderer *renderer, flatui::FontManager *font_manager)
Initialize the user interface.
void SetEditEntity(const GenericEntityId &entity)
Choose which entity we are currently editing.
bool CanDeselectEntity() const
Should we let the editor deselect this as the current entity? Probably not if we've made any changes...
Definition: editor_gui.h:112
Definition: scene_lab.h:40
void CommitEntityData()
Write the entity fields that were changed to the entity_data_ flatbuffer, then import the changed fla...
void Render()
Render the GUI, then update based on button presses.
unsigned int mouse_mode_index() const
Returns which mouse mode index we have selected.
Definition: editor_gui.h:132
void DrawGui(const mathfu::vec2 &virtual_resolution)
Either call Render() above, or call the following sequence if you are using FlatUI elsewhere: ...
void FinishRender()
Finish drawing the GUI, and update input.
bool CanExit()
Should we let the editor exit? Not if there are pending changes.
bool lock_camera_height() const
Should camera movement in Scene Lab be parallel to the ground, so your camera's height doesn't change...
Definition: editor_gui.h:92
GenericEntityId edit_entity() const
Get the entity we are currently editing.
Definition: editor_gui.h:97
An on-screen representation of a Flatbuffer, which can be edited by the user.
bool flatbuffer_modified() const
Has the Flatbuffer data been modified? If so, you probably want to reload whatever is using it...
Definition: flatbuffer_editor.h:100
void Activate()
Turn on the GUI. This should be called when Scene Lab is activated.
void ClearEntityData()
Clear all cached or modified data that we have for the edit entity.
Definition: editor_gui.h:102
bool mouse_in_window() const
Is the mouse pointer over a GUI element? If true, you should ignore mouse clicks as the user is click...
Definition: editor_gui.h:83
bool show_physics() const
Does the user want you to show the current entity's physics?
Definition: editor_gui.h:129
bool InputCaptured() const
Is the GUI capturing mouse and/or keyboard input? Returns true if you should ignore mouse and keyboar...
Definition: editor_gui.h:79
void set_mouse_mode_index(int m)
Set which mouse mode index the user wants to use.
Definition: editor_gui.h:134
void StartRender()
Prepare to draw the GUI.
bool EntityModified() const
Has the entity's flatbuffer been modified?
Definition: editor_gui.h:115
void EntityUpdated(const GenericEntityId &entity)
"Entity Updated" callback for Scene Lab; if the entity is updated externally, we reload its data by c...
void SetShowComponentDataView(const GenericComponentId &component, bool b)
Set whether to expand the given component's data.
Definition: editor_gui.h:140
void Deactivate()
Turn off the GUI. This should be called when Scene Lab is deactivated.
Definition: editor_gui.h:53
Definition: flatbuffer_editor.h:43