102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
ui.c File Reference
#include <dttr_imgui.h>
#include <dttr_loader_ui.h>
#include <dttr_sdl.h>
#include <stdbool.h>
#include <stdio.h>

Go to the source code of this file.

Macros

#define DTTR_LOADER_UI_WINDOW_W   560
#define DTTR_LOADER_UI_WINDOW_H   190
#define DTTR_LOADER_UI_BUTTON_W   160.0f
#define DTTR_LOADER_UI_BUTTON_H   28.0f
#define DTTR_LOADER_UI_BUTTON_SPACING   8.0f
#define DTTR_LOADER_UI_TEXT_PADDING_X   18.0f
#define DTTR_LOADER_UI_TEXT_PADDING_Y   16.0f
#define DTTR_VERSION   "unknown"

Functions

static DTTR_LoaderUIChoice native_choose_game_source ()
static float button_spacing (const DTTR_ImGuiDialogContext *ctx)
static float button_row_width (const DTTR_ImGuiDialogContext *ctx, size_t button_count)
static ImVec2_c button_size (const DTTR_ImGuiDialogContext *ctx)
static bool draw_source_button (const DTTR_ImGuiDialogContext *ctx, const char *id, const char *label, DTTR_LoaderUIChoice choice, DTTR_LoaderUIChoice *result, bool *running)
static bool draw_disc_button (const DTTR_ImGuiDialogContext *ctx, size_t disc_index, const DTTR_LoaderUIDiscCandidate *disc_candidates, DTTR_LoaderUIChoice *result, bool *running)
static void same_button_row (const DTTR_ImGuiDialogContext *ctx)
static size_t clamp_disc_candidate_count (size_t disc_candidate_count)
static void draw_browse_buttons (const DTTR_ImGuiDialogContext *ctx, DTTR_LoaderUIChoice *result, bool *running)
static void draw_source_buttons (const DTTR_ImGuiDialogContext *ctx, const DTTR_LoaderUIDiscCandidate *disc_candidates, size_t disc_candidate_count, DTTR_LoaderUIChoice *result, bool *running)
DTTR_LoaderUIChoice DTTR_LoaderUI_ChooseGameSource (const DTTR_LoaderUIDiscCandidate *disc_candidates, size_t disc_candidate_count)
void DTTR_LoaderUI_ShowError (const char *title, const char *message)

Variables

static const char *const WINDOW_TITLE = "DttR: Specify Game Files"
static const char *const HEADER_TITLE = "102 Patches: Detours to the Rescue!"
static const char *const GAME_SOURCE_MESSAGE
static const char *const ERROR_TITLE = "DttR: Error"

Macro Definition Documentation

◆ DTTR_LOADER_UI_BUTTON_H

#define DTTR_LOADER_UI_BUTTON_H   28.0f

Definition at line 11 of file ui.c.

Referenced by button_size().

◆ DTTR_LOADER_UI_BUTTON_SPACING

#define DTTR_LOADER_UI_BUTTON_SPACING   8.0f

Definition at line 12 of file ui.c.

Referenced by button_spacing().

◆ DTTR_LOADER_UI_BUTTON_W

#define DTTR_LOADER_UI_BUTTON_W   160.0f

Definition at line 10 of file ui.c.

Referenced by button_row_width(), and button_size().

◆ DTTR_LOADER_UI_TEXT_PADDING_X

#define DTTR_LOADER_UI_TEXT_PADDING_X   18.0f

Definition at line 13 of file ui.c.

Referenced by DTTR_LoaderUI_ChooseGameSource().

◆ DTTR_LOADER_UI_TEXT_PADDING_Y

#define DTTR_LOADER_UI_TEXT_PADDING_Y   16.0f

Definition at line 14 of file ui.c.

Referenced by DTTR_LoaderUI_ChooseGameSource().

◆ DTTR_LOADER_UI_WINDOW_H

#define DTTR_LOADER_UI_WINDOW_H   190

Definition at line 9 of file ui.c.

Referenced by DTTR_LoaderUI_ChooseGameSource().

◆ DTTR_LOADER_UI_WINDOW_W

#define DTTR_LOADER_UI_WINDOW_W   560

Definition at line 8 of file ui.c.

Referenced by DTTR_LoaderUI_ChooseGameSource().

◆ DTTR_VERSION

#define DTTR_VERSION   "unknown"

Definition at line 17 of file ui.c.

Function Documentation

◆ button_row_width()

float button_row_width ( const DTTR_ImGuiDialogContext * ctx,
size_t button_count )
static

Definition at line 56 of file ui.c.

References button_spacing(), ctx, DTTR_ImGuiDialog_ScaledFloat(), DTTR_LOADER_UI_BUTTON_W, and float.

Referenced by draw_source_buttons().

◆ button_size()

ImVec2_c button_size ( const DTTR_ImGuiDialogContext * ctx)
static

Definition at line 66 of file ui.c.

References ctx, DTTR_ImGuiDialog_ScaledFloat(), DTTR_LOADER_UI_BUTTON_H, and DTTR_LOADER_UI_BUTTON_W.

Referenced by draw_source_button().

◆ button_spacing()

float button_spacing ( const DTTR_ImGuiDialogContext * ctx)
static

Definition at line 52 of file ui.c.

References ctx, DTTR_ImGuiDialog_ScaledFloat(), and DTTR_LOADER_UI_BUTTON_SPACING.

Referenced by button_row_width(), and same_button_row().

◆ clamp_disc_candidate_count()

size_t clamp_disc_candidate_count ( size_t disc_candidate_count)
static

Definition at line 114 of file ui.c.

References DTTR_LOADER_UI_MAX_DISC_CANDIDATES.

Referenced by DTTR_LoaderUI_ChooseGameSource().

◆ draw_browse_buttons()

void draw_browse_buttons ( const DTTR_ImGuiDialogContext * ctx,
DTTR_LoaderUIChoice * result,
bool * running )
static

◆ draw_disc_button()

bool draw_disc_button ( const DTTR_ImGuiDialogContext * ctx,
size_t disc_index,
const DTTR_LoaderUIDiscCandidate * disc_candidates,
DTTR_LoaderUIChoice * result,
bool * running )
static

Definition at line 90 of file ui.c.

References ctx, draw_source_button(), and DTTR_LoaderUI_DiscChoiceForIndex().

Referenced by draw_source_buttons().

◆ draw_source_button()

bool draw_source_button ( const DTTR_ImGuiDialogContext * ctx,
const char * id,
const char * label,
DTTR_LoaderUIChoice choice,
DTTR_LoaderUIChoice * result,
bool * running )
static

Definition at line 73 of file ui.c.

References button_size(), ctx, and DTTR_ImGuiDialog_Button().

Referenced by draw_browse_buttons(), and draw_disc_button().

◆ draw_source_buttons()

void draw_source_buttons ( const DTTR_ImGuiDialogContext * ctx,
const DTTR_LoaderUIDiscCandidate * disc_candidates,
size_t disc_candidate_count,
DTTR_LoaderUIChoice * result,
bool * running )
static

◆ DTTR_LoaderUI_ChooseGameSource()

◆ DTTR_LoaderUI_ShowError()

void DTTR_LoaderUI_ShowError ( const char * title,
const char * message )

◆ native_choose_game_source()

◆ same_button_row()

void same_button_row ( const DTTR_ImGuiDialogContext * ctx)
static

Definition at line 110 of file ui.c.

References button_spacing(), and ctx.

Referenced by draw_browse_buttons(), and draw_source_buttons().

Variable Documentation

◆ ERROR_TITLE

const char* const ERROR_TITLE = "DttR: Error"
static

Definition at line 25 of file ui.c.

◆ GAME_SOURCE_MESSAGE

const char* const GAME_SOURCE_MESSAGE
static
Initial value:
= "Select either a directory containing the 102 Dalmatians: Puppies to the Rescue "
"files, the original game disc, or an ISO image."

Definition at line 22 of file ui.c.

Referenced by DTTR_LoaderUI_ChooseGameSource(), and native_choose_game_source().

◆ HEADER_TITLE

const char* const HEADER_TITLE = "102 Patches: Detours to the Rescue!"
static

Definition at line 21 of file ui.c.

◆ WINDOW_TITLE

const char* const WINDOW_TITLE = "DttR: Specify Game Files"
static

Definition at line 20 of file ui.c.

Referenced by DTTR_LoaderUI_ChooseGameSource(), and native_choose_game_source().