Unravel Engine C++ Reference
Loading...
Searching...
No Matches
hub.h
Go to the documentation of this file.
1#pragma once
2
3#include <base/basetypes.hpp>
4#include <context/context.hpp>
5#include <ospp/event.h>
6
7#include "panels/panel.h"
8
9namespace unravel
10{
11
12class hub
13{
14public:
15 hub(rtti::context& ctx);
16 auto init(rtti::context& ctx) -> bool;
17 auto deinit(rtti::context& ctx) -> bool;
18
19 void open_project_settings(rtti::context& ctx, const std::string& hint);
20
21 auto get_panels() -> imgui_panels& { return panels_; }
22 auto get_panels() const -> const imgui_panels& { return panels_; }
23
24private:
25
26 void on_project_opened(rtti::context& ctx);
27 void on_frame_update(rtti::context& ctx, delta_t dt);
28 void on_frame_before_render(rtti::context& ctx, delta_t dt);
29 void on_frame_render(rtti::context& ctx, delta_t dt);
30 void on_frame_ui_render(rtti::context& ctx, delta_t dt);
31 void on_play_before_begin(rtti::context& ctx);
32 void on_play_begin(rtti::context& ctx);
33 void on_play_after_end(rtti::context& ctx);
34 void on_script_recompile(rtti::context& ctx, const std::string& protocol, uint64_t version);
35 void on_os_event(rtti::context& ctx, os::event& e);
36
37 void on_start_page_render(rtti::context& ctx);
38 void on_opened_project_render(rtti::context& ctx);
39
40 void render_projects_list_view(rtti::context& ctx);
41 void render_new_project_creator_view(rtti::context& ctx);
42 void render_project_remover_view(rtti::context& ctx);
43 void render_project_samples_view(rtti::context& ctx);
44 // Draw a project card with consistent styling
45 auto draw_project_card(const std::string& id,
46 const std::string& name,
47 const std::string& directory,
48 const std::chrono::system_clock::time_point& last_modified,
49 const std::string& engine_version = {},
50 bool is_selected = false,
51 bool enable_interaction = true,
52 float form_width = 0.0f) -> bool;
53
54 // Draw a sample card (name, description, opens url on click)
55 auto draw_sample_card(const std::string& id,
56 const std::string& name,
57 const std::string& description,
58 const std::string& url,
59 float form_width = 0.0f) -> bool;
60
61 std::shared_ptr<int> sentinel_ = std::make_shared<int>(0);
62
63 imgui_panels panels_{};
64
65 enum class view_state
66 {
67 projects_list,
68 new_project_creator,
69 project_remover,
70 project_samples
71 };
72
73 view_state current_view_{view_state::projects_list};
74 std::string project_name_{};
75 std::string project_directory_{};
76 std::string project_to_remove_{};
77 std::string selected_project_{};
78};
79} // namespace unravel
auto get_panels() const -> const imgui_panels &
Definition hub.h:22
void open_project_settings(rtti::context &ctx, const std::string &hint)
Definition hub.cpp:408
auto deinit(rtti::context &ctx) -> bool
Definition hub.cpp:399
auto get_panels() -> imgui_panels &
Definition hub.h:21
auto init(rtti::context &ctx) -> bool
Definition hub.cpp:390
hub(rtti::context &ctx)
Definition hub.cpp:371
std::chrono::duration< float > delta_t
const char * description
std::string name
Definition hub.cpp:33