Refactor flags and add Font Manager to settings editor
Simplified `ExperimentFlags` by removing unused flags and updated `Controller` to no longer inherit from it. Refactored `FlagsMenu` to separate flag categories into individual methods for better organization. Enhanced settings editor with a new "Font Manager" tab and updated `DrawGeneralSettings` to use the new flag category methods. Added `DrawFontManager` function for font management.
This commit is contained in:
@@ -56,12 +56,6 @@ class ExperimentFlags {
|
||||
// Attempt to run the dungeon room draw routine when opening a room.
|
||||
bool kDrawDungeonRoomGraphics = true;
|
||||
|
||||
// Use the new platform specific file dialog wrappers.
|
||||
bool kNewFileDialogWrapper = true;
|
||||
|
||||
// Uses texture streaming from SDL for my dynamic updates.
|
||||
bool kLoadTexturesAsStreaming = true;
|
||||
|
||||
// Save dungeon map edits to the Rom.
|
||||
bool kSaveDungeonMaps = false;
|
||||
|
||||
@@ -113,10 +107,6 @@ class ExperimentFlags {
|
||||
"\n";
|
||||
result += "kDrawDungeonRoomGraphics: " +
|
||||
std::to_string(get().kDrawDungeonRoomGraphics) + "\n";
|
||||
result += "kNewFileDialogWrapper: " +
|
||||
std::to_string(get().kNewFileDialogWrapper) + "\n";
|
||||
result += "kLoadTexturesAsStreaming: " +
|
||||
std::to_string(get().kLoadTexturesAsStreaming) + "\n";
|
||||
result +=
|
||||
"kSaveDungeonMaps: " + std::to_string(get().kSaveDungeonMaps) + "\n";
|
||||
result += "kLogToConsole: " + std::to_string(get().kLogToConsole) + "\n";
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace core {
|
||||
* This class is responsible for managing the main window and the
|
||||
* main editor. It is the main entry point for the application.
|
||||
*/
|
||||
class Controller : public ExperimentFlags {
|
||||
class Controller {
|
||||
public:
|
||||
bool IsActive() const { return active_; }
|
||||
absl::Status OnEntry(std::string filename = "");
|
||||
|
||||
@@ -15,45 +15,42 @@ using ImGui::MenuItem;
|
||||
using ImGui::Separator;
|
||||
|
||||
struct FlagsMenu {
|
||||
void Draw() {
|
||||
if (BeginMenu("Overworld Flags")) {
|
||||
Checkbox("Enable Overworld Sprites",
|
||||
&ExperimentFlags::get().overworld.kDrawOverworldSprites);
|
||||
Separator();
|
||||
Checkbox("Save Overworld Maps",
|
||||
&ExperimentFlags::get().overworld.kSaveOverworldMaps);
|
||||
Checkbox("Save Overworld Entrances",
|
||||
&ExperimentFlags::get().overworld.kSaveOverworldEntrances);
|
||||
Checkbox("Save Overworld Exits",
|
||||
&ExperimentFlags::get().overworld.kSaveOverworldExits);
|
||||
Checkbox("Save Overworld Items",
|
||||
&ExperimentFlags::get().overworld.kSaveOverworldItems);
|
||||
Checkbox("Save Overworld Properties",
|
||||
&ExperimentFlags::get().overworld.kSaveOverworldProperties);
|
||||
Checkbox("Load Custom Overworld",
|
||||
&ExperimentFlags::get().overworld.kLoadCustomOverworld);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
void DrawOverworldFlags() {
|
||||
Checkbox("Enable Overworld Sprites",
|
||||
&ExperimentFlags::get().overworld.kDrawOverworldSprites);
|
||||
Separator();
|
||||
Checkbox("Save Overworld Maps",
|
||||
&ExperimentFlags::get().overworld.kSaveOverworldMaps);
|
||||
Checkbox("Save Overworld Entrances",
|
||||
&ExperimentFlags::get().overworld.kSaveOverworldEntrances);
|
||||
Checkbox("Save Overworld Exits",
|
||||
&ExperimentFlags::get().overworld.kSaveOverworldExits);
|
||||
Checkbox("Save Overworld Items",
|
||||
&ExperimentFlags::get().overworld.kSaveOverworldItems);
|
||||
Checkbox("Save Overworld Properties",
|
||||
&ExperimentFlags::get().overworld.kSaveOverworldProperties);
|
||||
Checkbox("Load Custom Overworld",
|
||||
&ExperimentFlags::get().overworld.kLoadCustomOverworld);
|
||||
}
|
||||
|
||||
if (BeginMenu("Dungeon Flags")) {
|
||||
Checkbox("Draw Dungeon Room Graphics",
|
||||
&ExperimentFlags::get().kDrawDungeonRoomGraphics);
|
||||
Separator();
|
||||
Checkbox("Save Dungeon Maps", &ExperimentFlags::get().kSaveDungeonMaps);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
void DrawDungeonFlags() {
|
||||
Checkbox("Draw Dungeon Room Graphics",
|
||||
&ExperimentFlags::get().kDrawDungeonRoomGraphics);
|
||||
Separator();
|
||||
Checkbox("Save Dungeon Maps", &ExperimentFlags::get().kSaveDungeonMaps);
|
||||
}
|
||||
|
||||
Checkbox("Use built-in file dialog",
|
||||
&ExperimentFlags::get().kNewFileDialogWrapper);
|
||||
Checkbox("Enable Console Logging", &ExperimentFlags::get().kLogToConsole);
|
||||
Checkbox("Enable Texture Streaming",
|
||||
&ExperimentFlags::get().kLoadTexturesAsStreaming);
|
||||
Checkbox("Log Instructions to Debugger",
|
||||
&ExperimentFlags::get().kLogInstructions);
|
||||
void DrawResourceFlags() {
|
||||
Checkbox("Save All Palettes", &ExperimentFlags::get().kSaveAllPalettes);
|
||||
Checkbox("Save Gfx Groups", &ExperimentFlags::get().kSaveGfxGroups);
|
||||
Checkbox("Save Graphics Sheets",
|
||||
&ExperimentFlags::get().kSaveGraphicsSheet);
|
||||
&ExperimentFlags::get().kSaveGraphicsSheet);
|
||||
}
|
||||
|
||||
void DrawSystemFlags() {
|
||||
Checkbox("Enable Console Logging", &ExperimentFlags::get().kLogToConsole);
|
||||
Checkbox("Log Instructions to Emulator Debugger",
|
||||
&ExperimentFlags::get().kLogInstructions);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "app/editor/system/settings_editor.h"
|
||||
|
||||
#include "app/gui/style.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "app/editor/system/flags.h"
|
||||
#include "imgui/imgui.h"
|
||||
@@ -34,6 +35,10 @@ absl::Status SettingsEditor::Update() {
|
||||
DrawGeneralSettings();
|
||||
EndTabItem();
|
||||
}
|
||||
if (BeginTabItem("Font Manager")) {
|
||||
gui::DrawFontManager();
|
||||
EndTabItem();
|
||||
}
|
||||
if (BeginTabItem("Keyboard Shortcuts")) {
|
||||
EndTabItem();
|
||||
}
|
||||
@@ -44,28 +49,44 @@ absl::Status SettingsEditor::Update() {
|
||||
}
|
||||
|
||||
void SettingsEditor::DrawGeneralSettings() {
|
||||
if (BeginTable("##SettingsTable", 2,
|
||||
static FlagsMenu flags;
|
||||
|
||||
if (BeginTable("##SettingsTable", 4,
|
||||
ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable |
|
||||
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable)) {
|
||||
TableSetupColumn("Experiment Flags", ImGuiTableColumnFlags_WidthFixed,
|
||||
250.0f);
|
||||
TableSetupColumn("General Setting", ImGuiTableColumnFlags_WidthStretch,
|
||||
TableSetupColumn("System Flags", ImGuiTableColumnFlags_WidthStretch);
|
||||
TableSetupColumn("Overworld Flags", ImGuiTableColumnFlags_WidthStretch);
|
||||
TableSetupColumn("Dungeon Flags", ImGuiTableColumnFlags_WidthStretch);
|
||||
TableSetupColumn("Resource Flags", ImGuiTableColumnFlags_WidthStretch,
|
||||
0.0f);
|
||||
|
||||
TableHeadersRow();
|
||||
|
||||
TableNextColumn();
|
||||
if (BeginChild("##GeneralSettingsStyleWrapper", ImVec2(0, 0),
|
||||
if (BeginChild("##SystemFlags", ImVec2(0, 0),
|
||||
ImGuiChildFlags_FrameStyle)) {
|
||||
static FlagsMenu flags;
|
||||
flags.Draw();
|
||||
flags.DrawSystemFlags();
|
||||
EndChild();
|
||||
}
|
||||
|
||||
TableNextColumn();
|
||||
if (BeginChild("##GeneralSettingsWrapper", ImVec2(0, 0),
|
||||
ImGuiChildFlags_FrameStyle)) {
|
||||
Text("TODO: Add some settings here");
|
||||
if (BeginChild("##OverworldFlags", ImVec2(0, 0),
|
||||
ImGuiChildFlags_FrameStyle)) {
|
||||
flags.DrawOverworldFlags();
|
||||
EndChild();
|
||||
}
|
||||
|
||||
TableNextColumn();
|
||||
if (BeginChild("##DungeonFlags", ImVec2(0, 0),
|
||||
ImGuiChildFlags_FrameStyle)) {
|
||||
flags.DrawDungeonFlags();
|
||||
EndChild();
|
||||
}
|
||||
|
||||
TableNextColumn();
|
||||
if (BeginChild("##ResourceFlags", ImVec2(0, 0),
|
||||
ImGuiChildFlags_FrameStyle)) {
|
||||
flags.DrawResourceFlags();
|
||||
EndChild();
|
||||
}
|
||||
|
||||
|
||||
@@ -749,5 +749,34 @@ void TextWithSeparators(const absl::string_view &text) {
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
void DrawFontManager() {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImFontAtlas* atlas = io.Fonts;
|
||||
static ImFont* current_font = atlas->Fonts[0];
|
||||
static int current_font_index = 0;
|
||||
static int font_size = 16;
|
||||
static bool font_selected = false;
|
||||
ImGui::Text("Current Font: %s", current_font->GetDebugName());
|
||||
ImGui::Text("Font Size: %d", font_size);
|
||||
if (ImGui::BeginCombo("Fonts", current_font->GetDebugName())) {
|
||||
for (int i = 0; i < atlas->Fonts.Size; i++) {
|
||||
bool is_selected = (current_font == atlas->Fonts[i]);
|
||||
if (ImGui::Selectable(atlas->Fonts[i]->GetDebugName(), is_selected)) {
|
||||
current_font = atlas->Fonts[i];
|
||||
current_font_index = i;
|
||||
font_selected = true;
|
||||
}
|
||||
if (is_selected) {
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (ImGui::SliderInt("Font Size", &font_size, 8, 32)) {
|
||||
current_font->Scale = font_size / 16.0f;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gui
|
||||
} // namespace yaze
|
||||
|
||||
@@ -66,6 +66,8 @@ void DrawDisplaySettings(ImGuiStyle *ref = nullptr);
|
||||
|
||||
void TextWithSeparators(const absl::string_view &text);
|
||||
|
||||
void DrawFontManager();
|
||||
|
||||
static const char *ExampleNames[] = {
|
||||
"Artichoke", "Arugula", "Asparagus", "Avocado",
|
||||
"Bamboo Shoots", "Bean Sprouts", "Beans", "Beet",
|
||||
|
||||
Reference in New Issue
Block a user