mirror of
https://github.com/BanjoRecomp/BanjoRecomp
synced 2026-07-11 05:04:45 -04:00
changes up to swapping to recompfrontend library
This commit is contained in:
@@ -13,7 +13,9 @@ namespace banjo {
|
||||
// TODO: Move loading configs to the runtime once we have a way to allow per-project customization.
|
||||
void load_config();
|
||||
void save_config();
|
||||
|
||||
bool read_json_with_backups(const std::filesystem::path& path, nlohmann::json& json_out);
|
||||
bool save_json_with_backups(const std::filesystem::path& path, const nlohmann::json& json_data);
|
||||
|
||||
void reset_input_bindings();
|
||||
void reset_cont_input_bindings(int profile_index);
|
||||
void reset_kb_input_bindings(int profile_index);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "common/rt64_user_configuration.h"
|
||||
#include "ultramodern/renderer_context.hpp"
|
||||
#include "librecomp/config.hpp"
|
||||
#include "librecomp/mods.hpp"
|
||||
|
||||
namespace RT64 {
|
||||
@@ -54,7 +55,7 @@ namespace banjo {
|
||||
|
||||
// Texture pack enable option. Must be an enum with two options.
|
||||
// The first option is treated as disabled and the second option is treated as enabled.
|
||||
bool is_texture_pack_enable_config_option(const recomp::mods::ConfigOption& option, bool show_errors);
|
||||
bool is_texture_pack_enable_config_option(const recomp::config::ConfigOption& option, bool show_errors);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -45,7 +45,10 @@ namespace recomp {
|
||||
#define DEFINE_RECOMP_UI_INPUTS() \
|
||||
DEFINE_INPUT(TOGGLE_MENU, 0, "Toggle Menu") \
|
||||
DEFINE_INPUT(ACCEPT_MENU, 0, "Accept (Menu)") \
|
||||
DEFINE_INPUT(APPLY_MENU, 0, "Apply (Menu)")
|
||||
DEFINE_INPUT(BACK_MENU, 0, "Back (Menu)") \
|
||||
DEFINE_INPUT(APPLY_MENU, 0, "Apply (Menu)") \
|
||||
DEFINE_INPUT(TAB_LEFT_MENU, 0, "Tab Left (Menu)") \
|
||||
DEFINE_INPUT(TAB_RIGHT_MENU, 0, "Tab Right (Menu)")
|
||||
|
||||
#define DEFINE_ALL_INPUTS() \
|
||||
DEFINE_N64_BUTTON_INPUTS() \
|
||||
@@ -130,7 +133,10 @@ namespace recomp {
|
||||
|
||||
std::vector<InputField> toggle_menu;
|
||||
std::vector<InputField> accept_menu;
|
||||
std::vector<InputField> back_menu;
|
||||
std::vector<InputField> apply_menu;
|
||||
std::vector<InputField> tab_left_menu;
|
||||
std::vector<InputField> tab_right_menu;
|
||||
};
|
||||
|
||||
inline const std::vector<InputField>& get_default_mapping_for_input(const DefaultN64Mappings& defaults, const GameInput input) {
|
||||
@@ -156,7 +162,10 @@ namespace recomp {
|
||||
case GameInput::Y_AXIS_NEG: return defaults.analog_down;
|
||||
case GameInput::TOGGLE_MENU: return defaults.toggle_menu;
|
||||
case GameInput::ACCEPT_MENU: return defaults.accept_menu;
|
||||
case GameInput::BACK_MENU: return defaults.back_menu;
|
||||
case GameInput::APPLY_MENU: return defaults.apply_menu;
|
||||
case GameInput::TAB_LEFT_MENU: return defaults.tab_left_menu;
|
||||
case GameInput::TAB_RIGHT_MENU: return defaults.tab_right_menu;
|
||||
default: return empty_input_field;
|
||||
}
|
||||
}
|
||||
|
||||
+40
-3
@@ -10,11 +10,13 @@
|
||||
|
||||
#include "SDL.h"
|
||||
#include "RmlUi/Core.h"
|
||||
#include "recomp_input.h"
|
||||
|
||||
#include "../src/ui/util/hsv.h"
|
||||
#include "../src/ui/util/bem.h"
|
||||
#include "../src/ui/elements/ui_button.h"
|
||||
#include "../src/ui/elements/ui_theme.h"
|
||||
#include "../src/ui/elements/ui_types.h"
|
||||
|
||||
#include "../src/ui/core/ui_context.h"
|
||||
|
||||
@@ -61,7 +63,7 @@ namespace recompui {
|
||||
ContextId get_config_context_id();
|
||||
ContextId get_config_sub_menu_context_id();
|
||||
|
||||
enum class ConfigTab {
|
||||
enum class ConfigTabId {
|
||||
General,
|
||||
Controls,
|
||||
Graphics,
|
||||
@@ -70,8 +72,8 @@ namespace recompui {
|
||||
Debug,
|
||||
};
|
||||
|
||||
void set_config_tab(ConfigTab tab);
|
||||
int config_tab_to_index(ConfigTab tab);
|
||||
void set_config_tab(ConfigTabId tab);
|
||||
int config_tab_to_index(ConfigTabId tab);
|
||||
Rml::ElementTabSet* get_config_tabset();
|
||||
Rml::Element* get_mod_tab();
|
||||
void set_config_tabset_mod_nav();
|
||||
@@ -133,6 +135,41 @@ namespace recompui {
|
||||
void release_image(const std::string &src);
|
||||
|
||||
void drop_files(const std::list<std::filesystem::path> &file_list);
|
||||
void report_removed_element(Rml::Element* element);
|
||||
|
||||
namespace menu_action_mapping {
|
||||
struct key_map {
|
||||
// End result menu action
|
||||
const MenuAction action;
|
||||
// Mapped input from controller
|
||||
const recomp::GameInput input;
|
||||
// SDL key code from controller -> keyboard
|
||||
const int sdl;
|
||||
// RML key identifier passed to rmlui
|
||||
const Rml::Input::KeyIdentifier rml;
|
||||
};
|
||||
|
||||
static const key_map accept = { MenuAction::Accept, recomp::GameInput::ACCEPT_MENU, SDLK_RETURN, Rml::Input::KI_RETURN };
|
||||
static const key_map apply = { MenuAction::Apply, recomp::GameInput::APPLY_MENU, SDLK_f, Rml::Input::KI_F };
|
||||
static const key_map back = { MenuAction::Back, recomp::GameInput::BACK_MENU, SDLK_F15, Rml::Input::KI_F15 };
|
||||
static const key_map toggle = { MenuAction::Toggle, recomp::GameInput::TOGGLE_MENU, SDLK_ESCAPE, Rml::Input::KI_ESCAPE };
|
||||
static const key_map tab_left = { MenuAction::TabLeft, recomp::GameInput::TAB_LEFT_MENU, SDLK_F16, Rml::Input::KI_F16 };
|
||||
static const key_map tab_right = { MenuAction::TabRight, recomp::GameInput::TAB_RIGHT_MENU, SDLK_F17, Rml::Input::KI_F17 };
|
||||
|
||||
static const std::unordered_map<Rml::Input::KeyIdentifier, key_map> rml_key_to_action {
|
||||
{ accept.rml, accept },
|
||||
{ apply.rml, apply },
|
||||
{ back.rml, back },
|
||||
{ toggle.rml, toggle },
|
||||
{ tab_left.rml, tab_left },
|
||||
{ tab_right.rml, tab_right }
|
||||
};
|
||||
|
||||
MenuAction menu_action_from_rml_key(const Rml::Input::KeyIdentifier& key);
|
||||
};
|
||||
|
||||
// Constant that represents an input that doesn't have a promptfont icon associated with it.
|
||||
extern const std::string unknown_input;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user