9 if (argc > 1 && argv[1] && argv[1][0]) {
10 return sdsnew(argv[1]);
29 "This will discard unsaved configuration changes and %s. Continue?",
33 const SDL_MessageBoxButtonData buttons[] = {
34 {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1,
"Discard"},
35 {SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0,
"Cancel"},
38 const SDL_MessageBoxData message_box = {
39 SDL_MESSAGEBOX_WARNING,
41 "Discard unsaved changes?",
43 (int)SDL_arraysize(buttons),
53 if (!igBeginMenuBar()) {
57 if (igMenuItem_Bool(
"Save",
"Ctrl+S",
false,
true)) {
61 if (igMenuItem_Bool(
"Load",
"Ctrl+O",
false,
true)
66 if (igMenuItem_Bool(
"Reset to Defaults",
NULL,
false,
true)) {
74 if (igShortcut_Nil(ImGuiMod_Ctrl | ImGuiKey_S, ImGuiInputFlags_RouteGlobal)) {
78 if (igShortcut_Nil(ImGuiMod_Ctrl | ImGuiKey_O, ImGuiInputFlags_RouteGlobal)
85 const char *value = getenv(name);
86 return value && value[0] && strcmp(value,
"0") != 0;
90 const ImGuiKey key = (ImGuiKey)(chord & ~ImGuiMod_Mask_);
91 const ImGuiKeyRoutingData *route = igGetShortcutRoutingData(chord);
92 const ImGuiKeyData *key_data = igGetKeyData_Key(key);
94 igTableNextRow(ImGuiTableRowFlags_None, 0.0f);
96 igTextUnformatted(label,
NULL);
98 igTextUnformatted(igGetKeyChordName(chord),
NULL);
102 igText(
"0x%08X / %u", route->RoutingCurr, route->RoutingCurrScore);
104 igTextDisabled(
"none");
109 "down=%d pressed=%d chord=%d duration=%.02f",
110 igIsKeyDown_ID(key, 0),
111 igIsKeyPressed_InputFlags(key, ImGuiInputFlags_None, 0),
112 igIsKeyChordPressed_InputFlags(chord, ImGuiInputFlags_None, 0),
113 key_data ? key_data->DownDuration : -1.0f
118 if (!
state->show_shortcut_debug) {
123 "DttR Shortcut Debug",
125 ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings
132 "##shortcut_debug_routes",
134 ImGuiTableFlags_BordersInnerH | ImGuiTableFlags_BordersOuterH,
135 (ImVec2_c){0.0f, 0.0f},
138 igTableSetupColumn(
"Action", ImGuiTableColumnFlags_None, 0.0f, 0);
139 igTableSetupColumn(
"Chord", ImGuiTableColumnFlags_None, 0.0f, 0);
140 igTableSetupColumn(
"Route", ImGuiTableColumnFlags_None, 0.0f, 0);
141 igTableSetupColumn(
"Input", ImGuiTableColumnFlags_None, 0.0f, 0);
154 sdsfree(config_path);
156 SDL_MESSAGEBOX_ERROR,
158 "Config path is too long.",
164 sdsfree(config_path);
208 while (SDL_PollEvent(&
event)) {
250 if (!SDL_InitSubSystem(SDL_INIT_GAMEPAD)) {
251 char status[
sizeof(
state.status)];
255 "Failed to initialize gamepad support: %s",
270 ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoScrollbar
271 | ImGuiWindowFlags_NoScrollWithMouse
280 SDL_QuitSubSystem(SDL_INIT_GAMEPAD);
const DTTR_BackendState * state
void void DWORD HANDLE event
DTTR_Graphics_COM_DirectDrawSurface7 DWORD flags void NULL
void DTTR_Config_SetDefaults(DTTR_Config *config)
Resets a config object to built-in defaults.
#define DTTR_CONFIG_FILENAME
void DTTR_ImGuiDialog_End(DTTR_ImGuiDialogContext *ctx)
void DTTR_ImGuiDialog_DrawHeader(const DTTR_ImGuiDialogContext *ctx, const char *title, const char *version)
void DTTR_ImGuiDialog_Render(DTTR_ImGuiDialogContext *ctx)
bool DTTR_ImGuiDialog_RefreshScale(DTTR_ImGuiDialogContext *ctx)
bool DTTR_ImGuiDialog_BeginRoot(DTTR_ImGuiDialogContext *ctx, const char *title, ImGuiWindowFlags flags)
void DTTR_ImGuiDialog_EndRoot()
void DTTR_ImGuiDialog_NewFrame(const DTTR_ImGuiDialogContext *ctx)
void DTTR_ImGuiDialog_ProcessEvent(const DTTR_ImGuiDialogContext *ctx, const SDL_Event *event, bool *running)
void DTTR_ImGuiDialog_Shutdown()
bool DTTR_ImGuiDialog_Begin(DTTR_ImGuiDialogContext *ctx, const char *title, int width, int height)
union SDL_Event SDL_Event
sds DTTR_Path_ModuleSibling(void *module, const char *relative_path)
bool DTTR_Path_CopySds(char *out, size_t out_size, sds value)
bool DTTR_SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
bool DTTR_SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window)
static game_data_source source
static bool confirm_discard_changes(const DTTR_ImGuiDialogContext *ctx, const config_ui_state *state, const char *action)
static void draw_shortcut_debug_row(const char *label, ImGuiKeyChord chord)
static sds config_path_from_args(int argc, char **argv)
static void process_events(const DTTR_ImGuiDialogContext *ctx, config_ui_state *state, bool *running)
static const char *const CONFIG_DEBUG_SHORTCUTS_ENV
static bool init_state_from_args(config_ui_state *state, int argc, char **argv)
static void draw_shortcut_debug_window(const config_ui_state *state)
static void handle_shortcuts(const DTTR_ImGuiDialogContext *ctx, config_ui_state *state)
static void draw_toolbar(const DTTR_ImGuiDialogContext *ctx, config_ui_state *state)
static bool env_flag_enabled(const char *name)
int dttr_config_main(int argc, char **argv)
static void draw_ui(const DTTR_ImGuiDialogContext *ctx, config_ui_state *state)
static const char *const CONFIG_WINDOW_TITLE
void capture_source(config_ui_state *state, int new_source)
void load_config(config_ui_state *state)
void set_mods_dir_from_config_path(config_ui_state *state)
bool begin_padded_panel(const DTTR_ImGuiDialogContext *ctx)
bool config_has_unsaved_changes(const config_ui_state *state)
void save_config(config_ui_state *state)
bool begin_config_content_region(const DTTR_ImGuiDialogContext *ctx, const config_ui_state *state)
void draw_tabs(const DTTR_ImGuiDialogContext *ctx, config_ui_state *state)
void add_scaled_vertical_spacing(const DTTR_ImGuiDialogContext *ctx, float height)
void draw_footer_text(const DTTR_ImGuiDialogContext *ctx, const config_ui_state *state)
void sync_rows_from_config(config_ui_state *state)
void cancel_binding(config_ui_state *state)
int source_from_event(const SDL_Event *event)
void request_reset_defaults(const DTTR_ImGuiDialogContext *ctx, config_ui_state *state)
int config_window_width()
#define DTTR_CONFIG_UI_WINDOW_H
bool event_cancels_binding(const SDL_Event *event)
#define DTTR_CONFIG_UI_HEADER_TOP_SPACING
void end_config_content_region()
void set_status(config_ui_state *state, const char *status)