Add DJUI Gradients, fix version clipping and camera unlock
Some checks are pending
Build coop / build-ubuntu (push) Waiting to run
Build coop / build-windows (push) Waiting to run
Build coop / build-macos-arm (push) Waiting to run
Build coop / build-macos-intel (push) Waiting to run

This commit is contained in:
Agent X 2025-04-05 16:07:10 -04:00
parent 211ad82937
commit bcfd4ace75
24 changed files with 77 additions and 28 deletions

View file

@ -166,6 +166,7 @@ DJUI_SCALE = "Stupnice DJUI"
DJUI_FONT = "DJUI Font"
AUTO = "Automatický"
CENTER = "Střed"
GRADIENTS = "Gradienty"
FONT_NORMAL = "Normální"
FONT_ALIASED = "Hladký"
LIGHT_THEME = "Světlo"

View file

@ -166,6 +166,7 @@ DJUI_SCALE = "DJUI Schaal"
DJUI_FONT = "DJUI-lettertype"
AUTO = "Automatisch"
CENTER = "Centreren"
GRADIENTS = "Kleurverlopen"
FONT_NORMAL = "Normaal"
FONT_ALIASED = "Glad"
LIGHT_THEME = "Licht"

View file

@ -166,6 +166,7 @@ DJUI_SCALE = "DJUI Scale"
DJUI_FONT = "DJUI Font"
AUTO = "Auto"
CENTER = "DJUI Center"
GRADIENTS = "DJUI Gradients"
FONT_NORMAL = "Normal"
FONT_ALIASED = "Aliased"
LIGHT_THEME = "Light"

View file

@ -166,6 +166,7 @@ DJUI_SCALE = "Échelle DJUI"
DJUI_FONT = "Police DJUI"
AUTO = "Automatique"
CENTER = "Centrer le menu"
GRADIENTS = "Dégradés"
FONT_NORMAL = "Normal"
FONT_ALIASED = "Lisse"
LIGHT_THEME = "Clair"

View file

@ -166,6 +166,7 @@ DJUI_SCALE = "DJUI-Skala"
DJUI_FONT = "DJUI-Schriftart"
AUTO = "Automatisch"
CENTER = "Zentrieren"
GRADIENTS = "Farbverläufe"
FONT_NORMAL = "Normal"
FONT_ALIASED = "Glatt"
LIGHT_THEME = "Litch"

View file

@ -164,6 +164,7 @@ DJUI_SCALE = "Scala DJUI"
DJUI_FONT = "Font DJUI"
AUTO = "Automatico"
CENTER = "Centrare"
GRADIENTS = "Gradienti"
FONT_NORMAL = "Normale"
FONT_ALIASED = "Liscio"
LIGHT_THEME = "Luce"

View file

@ -166,6 +166,7 @@ DJUI_SCALE = "DJUIのサイズ"
DJUI_FONT = "DJUIのフォント"
AUTO = "自動"
CENTER = "中心にDJUIを表示"
GRADIENTS = "グラデーション"
FONT_NORMAL = "普通"
FONT_ALIASED = "エイリアス"
LIGHT_THEME = "ライト"

View file

@ -166,6 +166,7 @@ DJUI_SCALE = "Skala DJUI"
DJUI_FONT = "Czcionka DJUI"
AUTO = "Automatyczna"
CENTER = "Wyśrodkowane"
GRADIENTS = "Gradienty"
FONT_NORMAL = "Normalna"
FONT_ALIASED = "Wygładzona"
LIGHT_THEME = "Jasny"

View file

@ -166,6 +166,7 @@ DJUI_SCALE = "Tamanho da DJUI"
DJUI_FONT = "Fonte da DJUI"
AUTO = "Automático"
CENTER = "Centralizar"
GRADIENTS = "Gradientes"
FONT_NORMAL = "Normal"
FONT_ALIASED = "Suave"
LIGHT_THEME = "Claro"

View file

@ -165,6 +165,7 @@ DJUI_SCALE = "Шкала DJUI"
DJUI_FONT = "Шрифт DJUI"
AUTO = "Автоматический"
CENTER = "Центр"
GRADIENTS = "Градиенты"
FONT_NORMAL = "Обычный"
FONT_ALIASED = "Гладкий"
LIGHT_THEME = "Свет"

View file

@ -166,6 +166,7 @@ DJUI_SCALE = "Tamaño de DJUI"
DJUI_FONT = "Fuente DJUI"
AUTO = "Automático"
CENTER = "Centrar"
GRADIENTS = "Gradientes"
FONT_NORMAL = "Normal"
FONT_ALIASED = "Alias"
LIGHT_THEME = "Claro"

View file

@ -199,6 +199,7 @@ bool configDjuiThemeCenter = false;
#else
bool configDjuiThemeCenter = true;
#endif
bool configDjuiThemeGradients = true;
unsigned int configDjuiThemeFont = FONT_NORMAL;
unsigned int configDjuiScale = 0;
// other
@ -344,6 +345,7 @@ static const struct ConfigOption options[] = {
// DJUI settings
{.name = "djui_theme", .type = CONFIG_TYPE_UINT, .uintValue = &configDjuiTheme},
{.name = "djui_theme_center", .type = CONFIG_TYPE_BOOL, .boolValue = &configDjuiThemeCenter},
{.name = "djui_theme_gradients", .type = CONFIG_TYPE_BOOL, .boolValue = &configDjuiThemeGradients},
{.name = "djui_theme_font", .type = CONFIG_TYPE_UINT, .uintValue = &configDjuiThemeFont},
{.name = "djui_scale", .type = CONFIG_TYPE_UINT, .uintValue = &configDjuiScale},
// other

View file

@ -145,6 +145,7 @@ extern char configDestId[MAX_CONFIG_STRING];
// DJUI settings
extern unsigned int configDjuiTheme;
extern bool configDjuiThemeCenter;
extern bool configDjuiThemeGradients;
extern unsigned int configDjuiThemeFont;
extern unsigned int configDjuiScale;
// other

View file

@ -27,6 +27,7 @@ bool gDjuiInMainMenu = true;
bool gDjuiInPlayerMenu = false;
bool gDjuiDisabled = false;
bool gDjuiShuttingDown = false;
bool gDjuiChangingTheme = false;
static bool sDjuiInited = false;
static struct DjuiRoot* sDjuiRootBehind = NULL;

View file

@ -82,6 +82,10 @@ void djui_base_set_alignment(struct DjuiBase* base, enum DjuiHAlign hAlign, enum
base->vAlign = vAlign;
}
void djui_base_set_gradient(struct DjuiBase* base, bool gradient) {
base->gradient = gradient;
}
/////////////
// utility //
/////////////
@ -441,6 +445,7 @@ void djui_base_init(struct DjuiBase* parent, struct DjuiBase* base, bool (*rende
djui_base_set_enabled(base, true);
djui_base_set_size(base, 64, 64);
djui_base_set_color(base, 255, 255, 255, 255);
djui_base_set_gradient(base, configDjuiThemeGradients);
base->get_cursor_hover_location = djui_base_get_cursor_hover_location;
base->render = render;
base->destroy = destroy;

View file

@ -41,6 +41,7 @@ struct DjuiBase {
struct DjuiInteractable* interactable;
bool addChildrenToHead;
bool abandonAfterChildRenderFail;
bool gradient;
s64 tag;
bool bTag;
void (*get_cursor_hover_location)(struct DjuiBase*, f32* x, f32* y);
@ -63,6 +64,7 @@ void djui_base_set_border_color(struct DjuiBase* base, u8 r, u8 g, u8 b, u8 a);
void djui_base_set_padding(struct DjuiBase* base, f32 top, f32 right, f32 bottom, f32 left);
void djui_base_set_padding_type(struct DjuiBase* base, enum DjuiScreenValueType topType, enum DjuiScreenValueType rightType, enum DjuiScreenValueType bottomType, enum DjuiScreenValueType leftType);
void djui_base_set_alignment(struct DjuiBase* base, enum DjuiHAlign hAlign, enum DjuiVAlign vAlign);
void djui_base_set_gradient(struct DjuiBase* base, bool gradient);
void djui_base_compute(struct DjuiBase* base);
void djui_base_compute_tree(struct DjuiBase* base);

View file

@ -27,6 +27,13 @@ void djui_gfx_displaylist_end(void) {
gSPDisplayList(gDisplayListHead++, dl_djui_display_list_end);
}
static const Vtx vertex_djui_menu_rect[] = {
{{{ 0, -1, 0 }, 0, { 0, 0 }, { 0x96, 0x96, 0x96, 0xff }}},
{{{ 1, -1, 0 }, 0, { 0, 0 }, { 0x96, 0x96, 0x96, 0xff }}},
{{{ 1, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}},
{{{ 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}},
};
static const Vtx vertex_djui_simple_rect[] = {
{{{ 0, -1, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}},
{{{ 1, -1, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}},
@ -34,6 +41,16 @@ static const Vtx vertex_djui_simple_rect[] = {
{{{ 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}},
};
const Gfx dl_djui_menu_rect[] = {
gsDPPipeSync(),
gsSPClearGeometryMode(G_LIGHTING),
gsDPSetCombineMode(G_CC_FADE, G_CC_FADE),
gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2),
gsSPVertexNonGlobal(vertex_djui_menu_rect, 4, 0),
gsSP2Triangles(0, 1, 2, 0x0, 0, 2, 3, 0x0),
gsSPEndDisplayList(),
};
const Gfx dl_djui_simple_rect[] = {
gsDPPipeSync(),
gsSPClearGeometryMode(G_LIGHTING),
@ -134,8 +151,8 @@ void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize,
// I don't know why adding 1 to all of the UVs seems to fix rendering, but it does...
// this should be tested carefully. it definitely fixes some stuff, but what does it break?
f32 offsetX = font ? -1024.0f / (f32)w : 1;
f32 offsetY = font ? -1024.0f / (f32)h : 1;
f32 offsetX = (font ? -1024.0f / (f32)w : 0) + 1;
f32 offsetY = (font ? -1024.0f / (f32)h : 0) + 1;
vtx[0] = (Vtx) {{{ 0, -1, 0 }, 0, { ( tileX * 2048.0f) / (f32)w + offsetX, ((tileY + tileH) * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}};
vtx[2] = (Vtx) {{{ 1 * aspect, 0, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w + offsetX, ( tileY * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}};
vtx[1] = (Vtx) {{{ 1 * aspect, -1, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w + offsetX, ((tileY + tileH) * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}};

View file

@ -5,6 +5,7 @@
#define DJUI_MTX_PUSH 1
#define DJUI_MTX_NOPUSH 2
extern const Gfx dl_djui_menu_rect[];
extern const Gfx dl_djui_simple_rect[];
extern const Gfx dl_djui_img_begin[];
extern const Gfx dl_djui_img_end[];

View file

@ -638,6 +638,7 @@ struct DjuiInputbox* djui_inputbox_create(struct DjuiBase* parent, u16 bufferSiz
djui_base_init(parent, base, djui_inputbox_render, djui_inputbox_destroy);
djui_base_set_size(base, 200, 32);
djui_base_set_border_width(base, 2);
djui_base_set_gradient(base, false);
djui_inputbox_set_text_color(inputbox, 0, 0, 0, 255);
djui_interactable_create(base, djui_inputbox_update_style);
djui_interactable_hook_cursor_down(base, djui_inputbox_on_cursor_down_begin, djui_inputbox_on_cursor_down, NULL);

View file

@ -191,6 +191,7 @@ void djui_panel_update(void) {
}
extern bool gDjuiShuttingDown;
extern bool gDjuiChangingTheme;
void djui_panel_shutdown(void) {
static bool sShuttingDown = false;
if (sShuttingDown) { return; }
@ -224,7 +225,7 @@ void djui_panel_shutdown(void) {
gDjuiPanelMainCreated = false;
gDjuiPanelPauseCreated = false;
djui_cursor_set_visible(false);
if (!gDjuiShuttingDown) {
if (!gDjuiShuttingDown && !gDjuiChangingTheme) {
configfile_save(configfile_name());
if (gDjuiInMainMenu) {
gDjuiInMainMenu = false;

View file

@ -37,6 +37,27 @@ struct MainMenuSounds gMainMenuSounds[] = {
{ "Stage Music", STAGE_MUSIC },
};
static char* sLevelChoices[18] = {
"CG",
"BOB",
"WF",
"WMOTR",
"JRB",
"SSL",
"TTM",
"SL",
"BBH",
"LLL",
"THI",
"HMC",
"CCM",
"RR",
"BITDW",
"PSS",
"TTC",
"WDW"
};
void djui_panel_main_menu_create(struct DjuiBase* caller);
static void djui_panel_level_menu(UNUSED struct DjuiBase* caller) {
@ -65,7 +86,9 @@ static void djui_panel_staff_roll(UNUSED struct DjuiBase* caller) {
djui_panel_main_menu_create(NULL);
}
extern bool gDjuiChangingTheme;
static void djui_panel_menu_options_djui_setting_change(UNUSED struct DjuiBase* caller) {
gDjuiChangingTheme = true;
if (gDjuiInMainMenu) {
djui_panel_shutdown();
gDjuiInMainMenu = true;
@ -87,6 +110,7 @@ static void djui_panel_menu_options_djui_setting_change(UNUSED struct DjuiBase*
djui_text_set_font(gDjuiPauseOptions, gDjuiFonts[configDjuiThemeFont == 0 ? FONT_NORMAL : FONT_ALIASED]);
djui_text_set_text(gDjuiPauseOptions, DLANG(MISC, R_BUTTON));
}
gDjuiChangingTheme = false;
smlua_call_event_hooks(HOOK_ON_DJUI_THEME_CHANGED);
}
@ -99,6 +123,7 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) {
{
djui_checkbox_create(body, DLANG(DJUI_THEMES, CENTER), &configDjuiThemeCenter, djui_panel_menu_options_djui_setting_change);
djui_checkbox_create(body, DLANG(DJUI_THEMES, GRADIENTS), &configDjuiThemeGradients, djui_panel_menu_options_djui_setting_change);
char* themeChoices[DJUI_THEME_MAX];
for (int i = 0; i < DJUI_THEME_MAX; i++) {
@ -113,28 +138,6 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) {
djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_FONT), djuiFontChoices, 2, &configDjuiThemeFont, djui_panel_menu_options_djui_setting_change);
if (gDjuiInMainMenu) {
// get level choices
char* levelChoices[18] = {
"CG",
"BOB",
"WF",
"WMOTR",
"JRB",
"SSL",
"TTM",
"SL",
"BBH",
"LLL",
"THI",
"HMC",
"CCM",
"RR",
"BITDW",
"PSS",
"TTC",
"WDW"
};
// copy sound choices from gMainMenuSounds
int numSounds = sizeof(gMainMenuSounds) / sizeof(gMainMenuSounds[0]);
// if stage roll is on, we shouldn't be allowed to use Stage Music, so remove the entry
@ -148,7 +151,7 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) {
soundChoices[i] = gMainMenuSounds[i].name;
}
struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(body, DLANG(MENU_OPTIONS, LEVEL), levelChoices, 18, &configMenuLevel, NULL);
struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(body, DLANG(MENU_OPTIONS, LEVEL), sLevelChoices, 18, &configMenuLevel, NULL);
djui_base_set_enabled(&selectionbox1->base, !(configMenuRandom || configMenuStaffRoll));
sLevelBox = selectionbox1;
djui_selectionbox_create(body, DLANG(MENU_OPTIONS, MUSIC), soundChoices, numSounds, &configMenuSound, NULL);

View file

@ -261,12 +261,15 @@ static void djui_panel_player_edit_palette_create(struct DjuiBase* caller) {
sSliderR = djui_slider_create(body, DLANG(PLAYER, RED), &sSliderChannels[0], 0, 255, djui_panel_player_edit_palette_red_changed);
djui_base_set_color(&sSliderR->rectValue->base, 255, 0, 0, 255);
djui_base_set_gradient(&sSliderR->rectValue->base, false);
sSliderR->updateRectValueColor = false;
sSliderG = djui_slider_create(body, DLANG(PLAYER, GREEN), &sSliderChannels[1], 0, 255, djui_panel_player_edit_palette_green_changed);
djui_base_set_color(&sSliderG->rectValue->base, 0, 255, 0, 255);
djui_base_set_gradient(&sSliderG->rectValue->base, false);
sSliderG->updateRectValueColor = false;
sSliderB = djui_slider_create(body, DLANG(PLAYER, BLUE), &sSliderChannels[2], 0, 255, djui_panel_player_edit_palette_blue_changed);
djui_base_set_color(&sSliderB->rectValue->base, 0, 0, 255, 255);
djui_base_set_gradient(&sSliderB->rectValue->base, false);
sSliderB->updateRectValueColor = false;
struct DjuiRect* space = djui_rect_create(body);
@ -280,6 +283,7 @@ static void djui_panel_player_edit_palette_create(struct DjuiBase* caller) {
struct DjuiRect* rectValue = djui_rect_create(&space->base);
djui_base_set_size_type(&rectValue->base, DJUI_SVT_RELATIVE, DJUI_SVT_RELATIVE);
djui_base_set_color(&rectValue->base, sSliderChannels[0], sSliderChannels[1], sSliderChannels[2], 255);
djui_base_set_gradient(&rectValue->base, false);
sColorRect = rectValue;
struct DjuiRect* rect2 = djui_rect_container_create(body, 32);

View file

@ -21,7 +21,7 @@ bool djui_rect_render(struct DjuiBase* base) {
// render
gDPSetEnvColor(gDisplayListHead++, base->color.r, base->color.g, base->color.b, base->color.a);
gSPDisplayList(gDisplayListHead++, dl_djui_simple_rect);
gSPDisplayList(gDisplayListHead++, base->gradient ? dl_djui_menu_rect : dl_djui_simple_rect);
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
return true;

View file

@ -2,7 +2,7 @@
#include "djui.h"
#define DJUI_THEME_CENTERED_WIDTH 1.3f
#define DJUI_THEME_CENTERED_HEIGHT 0.9f
#define DJUI_THEME_CENTERED_HEIGHT 0.921f
enum DjuiThemeType {
DJUI_THEME_LIGHT,