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 {
public:
struct Flags {
// Load and render overworld sprites to the screen. Unstable.
bool kDrawOverworldSprites = false;
// Bitmap manager abstraction to manage graphics bin of ROM.
bool kUseBitmapManager = true;
// Log instructions to the GUI debugger.
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;

View File

@@ -208,15 +208,21 @@ absl::Status Controller::CreateRenderer() {
}
absl::Status Controller::CreateGuiContext() const {
IMGUI_CHECKVERSION();
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
ImGui_ImplSDL2_InitForSDLRenderer(window_.get(), renderer_.get());
ImGui_ImplSDLRenderer2_Init(renderer_.get());
// Load available fonts
const ImGuiIO &io = ImGui::GetIO();
// Define constants
static const char *KARLA_REGULAR = "assets/font/Karla-Regular.ttf";
static const char *ROBOTO_MEDIUM = "assets/font/Roboto-Medium.ttf";

View File

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