1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
#include "BenMenuBar.h"
#include <imgui.h>
#include "UIWidgets.hpp"
#include <string>
#include <fast/Fast3dGui.h>
namespace BenGui {
void DrawMenuBarIcon() {
static bool gameIconLoaded = false;
if (!gameIconLoaded) {
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetRawInstance()->GetWindow()->GetGui())
->LoadTextureFromRawImage("Game_Icon", "textures/icons/g2ShipIcon.png");
gameIconLoaded = true;
}
if (std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetRawInstance()->GetWindow()->GetGui())
->HasTextureByName("Game_Icon")) {
#ifdef __SWITCH__
ImVec2 iconSize = ImVec2(20.0f, 20.0f);
float posScale = 1.0f;
#elif defined(__WIIU__)
ImVec2 iconSize = ImVec2(16.0f * 2, 16.0f * 2);
float posScale = 2.0f;
#else
ImVec2 iconSize = ImVec2(16.0f, 16.0f);
float posScale = 1.0f;
#endif
ImGui::SetCursorPos(ImVec2(5, 5) * posScale);
ImGui::Image(std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetRawInstance()->GetWindow()->GetGui())
->GetTextureByName("Game_Icon"),
iconSize);
ImGui::SameLine();
ImGui::SetCursorPos(ImVec2(25, 0) * posScale);
}
}
void DrawBenMenu() {
if (UIWidgets::BeginMenu("2Ship")) {
if (UIWidgets::MenuItem("Hide Menu Bar",
#if !defined(__SWITCH__) && !defined(__WIIU__)
"F1"
#else
"[-]"
#endif
)) {
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetMenuBar()->ToggleVisibility();
}
#if !defined(__SWITCH__) && !defined(__WIIU__)
if (UIWidgets::MenuItem("Toggle Fullscreen", "F11")) {
Ship::Context::GetRawInstance()->GetWindow()->ToggleFullscreen();
}
#endif
if (UIWidgets::MenuItem("Reset",
#ifdef __APPLE__
"Command-R"
#elif !defined(__SWITCH__) && !defined(__WIIU__)
"Ctrl+R"
#else
""
#endif
)) {
std::reinterpret_pointer_cast<Ship::ConsoleWindow>(
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))
->Dispatch("reset");
}
#if !defined(__SWITCH__) && !defined(__WIIU__)
if (UIWidgets::MenuItem("Open App Files Folder")) {
std::string filesPath = Ship::Context::GetRawInstance()->GetAppDirectoryPath();
SDL_OpenURL(std::string("file:///" + std::filesystem::absolute(filesPath).string()).c_str());
}
if (UIWidgets::MenuItem("Quit")) {
Ship::Context::GetRawInstance()->GetWindow()->Close();
}
#endif
ImGui::EndMenu();
}
}
void BenMenuBar::InitElement() {
}
void BenMenuBar::DrawElement() {
if (ImGui::BeginMenuBar()) {
DrawMenuBarIcon();
static ImVec2 sWindowPadding(8.0f, 8.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, sWindowPadding);
ImGui::SetCursorPosY(0.0f);
DrawBenMenu();
ImGui::SetCursorPosY(0.0f);
if (UIWidgets::BeginMenu("New Menu")) {
ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets::ColorValues.at(UIWidgets::Colors::Orange));
ImGui::SeparatorText("NOTICE");
ImGui::PopStyleColor();
ImGui::Text(
"All settings have now been moved to the new menu,\nwhich can be accessed with the Esc button.");
ImGui::EndMenu();
}
ImGui::PopStyleVar(1);
ImGui::EndMenuBar();
}
}
} // namespace BenGui
|