add imgui input experiment flag

This commit is contained in:
scawful
2023-11-18 00:02:07 -05:00
parent 299770922c
commit b5ce6b96d7
3 changed files with 21 additions and 4 deletions

View File

@@ -12,9 +12,19 @@ namespace core {
class ExperimentFlags { class ExperimentFlags {
public: public:
struct Flags { struct Flags {
// Load and render overworld sprites to the screen. Unstable.
bool kDrawOverworldSprites = false; bool kDrawOverworldSprites = false;
// Bitmap manager abstraction to manage graphics bin of ROM.
bool kUseBitmapManager = true; bool kUseBitmapManager = true;
// Log instructions to the GUI debugger.
bool kLogInstructions = true; bool kLogInstructions = true;
// Flag to enable ImGui input config flags. Currently is
// handled manually by controller class but should be
// ported away from that eventually.
bool kUseNewImGuiInput = false;
}; };
ExperimentFlags() = default; ExperimentFlags() = default;

View File

@@ -208,15 +208,21 @@ absl::Status Controller::CreateRenderer() {
} }
absl::Status Controller::CreateGuiContext() const { absl::Status Controller::CreateGuiContext() const {
IMGUI_CHECKVERSION();
ImGui::CreateContext(); ImGui::CreateContext();
ImGuiIO &io = ImGui::GetIO();
if (flags()->kUseNewImGuiInput) {
io.ConfigFlags |=
ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |=
ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
}
// Initialize ImGui for SDL // Initialize ImGui for SDL
ImGui_ImplSDL2_InitForSDLRenderer(window_.get(), renderer_.get()); ImGui_ImplSDL2_InitForSDLRenderer(window_.get(), renderer_.get());
ImGui_ImplSDLRenderer2_Init(renderer_.get()); ImGui_ImplSDLRenderer2_Init(renderer_.get());
// Load available fonts
const ImGuiIO &io = ImGui::GetIO();
// Define constants // Define constants
static const char *KARLA_REGULAR = "assets/font/Karla-Regular.ttf"; static const char *KARLA_REGULAR = "assets/font/Karla-Regular.ttf";
static const char *ROBOTO_MEDIUM = "assets/font/Roboto-Medium.ttf"; static const char *ROBOTO_MEDIUM = "assets/font/Roboto-Medium.ttf";

View File

@@ -10,6 +10,7 @@
#include <memory> #include <memory>
#include "absl/status/status.h" #include "absl/status/status.h"
#include "app/core/common.h"
#include "app/editor/master_editor.h" #include "app/editor/master_editor.h"
#include "app/gui/icons.h" #include "app/gui/icons.h"
#include "app/gui/style.h" #include "app/gui/style.h"
@@ -20,7 +21,7 @@ namespace yaze {
namespace app { namespace app {
namespace core { namespace core {
class Controller { class Controller : public ExperimentFlags {
public: public:
bool IsActive() const; bool IsActive() const;
absl::Status OnEntry(); absl::Status OnEntry();