palette editor cutscene fixes, press Z to toggle cap (#54)

this removes the forced taking cap off while in the palette editor. press Z to remove cap now.
it also fixes various problems that could happen that would cause the cap to stay off when it shouldn't. also fixed the taking off cap custom action sometimes playing the animation all the way through when it shouldn't.

translations by DeepL, eros, Flower35 and Skeltan
This commit is contained in:
Isaac0-dev 2024-06-07 19:41:22 +10:00 committed by GitHub
parent c811b4ebdf
commit 16400321e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 93 additions and 71 deletions

View file

@ -333,6 +333,7 @@ EDIT_PALETTE = "Upravit barvy"
PRESET_NAME = "Název" PRESET_NAME = "Název"
DELETE_PRESET = "Smazat" DELETE_PRESET = "Smazat"
SAVE_PRESET = "Uložit" SAVE_PRESET = "Uložit"
CAP_TOGGLE = "Stisknutím tlačítka Z přepnete čepici pro nošení."
[PALETTE] [PALETTE]
MARIO = "Mario" MARIO = "Mario"

View file

@ -333,6 +333,7 @@ EDIT_PALETTE = "Bewerk Palet"
PRESET_NAME = "Naam" PRESET_NAME = "Naam"
DELETE_PRESET = "Verwijderen" DELETE_PRESET = "Verwijderen"
SAVE_PRESET = "Opslaan" SAVE_PRESET = "Opslaan"
CAP_TOGGLE = "Druk op Z om te wisselen tussen de draagmuts."
[PALETTE] [PALETTE]
MARIO = "Mario" MARIO = "Mario"

View file

@ -333,6 +333,7 @@ EDIT_PALETTE = "Edit Palette"
PRESET_NAME = "Preset Name" PRESET_NAME = "Preset Name"
DELETE_PRESET = "Delete Preset" DELETE_PRESET = "Delete Preset"
SAVE_PRESET = "Save Preset" SAVE_PRESET = "Save Preset"
CAP_TOGGLE = "Press Z to toggle wearing cap."
[PALETTE] [PALETTE]
MARIO = "Mario" MARIO = "Mario"

View file

@ -333,6 +333,7 @@ EDIT_PALETTE = "Modifier la palette"
PRESET_NAME = "Nom" PRESET_NAME = "Nom"
DELETE_PRESET = "Supprimer" DELETE_PRESET = "Supprimer"
SAVE_PRESET = "Enregistrer" SAVE_PRESET = "Enregistrer"
CAP_TOGGLE = "Appuyez sur Z pour mettre ou enlever la casquette."
[PALETTE] [PALETTE]
MARIO = "Mario" MARIO = "Mario"

View file

@ -333,6 +333,7 @@ EDIT_PALETTE = "Palette bearbeiten"
PRESET_NAME = "Name" PRESET_NAME = "Name"
DELETE_PRESET = "Löschen" DELETE_PRESET = "Löschen"
SAVE_PRESET = "Speichern" SAVE_PRESET = "Speichern"
CAP_TOGGLE = "Drücken Sie Z, um das Tragen der Kappe umzuschalten."
[PALETTE] [PALETTE]
MARIO = "Mario" MARIO = "Mario"

View file

@ -331,6 +331,7 @@ EDIT_PALETTE = "Modifica Palette"
PRESET_NAME = "Nome" PRESET_NAME = "Nome"
DELETE_PRESET = "Eliminare" DELETE_PRESET = "Eliminare"
SAVE_PRESET = "Salvare" SAVE_PRESET = "Salvare"
CAP_TOGGLE = "Premere Z per attivare il cappuccio di protezione."
[PALETTE] [PALETTE]
MARIO = "Mario" MARIO = "Mario"

View file

@ -333,6 +333,7 @@ EDIT_PALETTE = "Edytuj Palete"
PRESET_NAME = "Nazwa presetu" PRESET_NAME = "Nazwa presetu"
DELETE_PRESET = "Usuń preset" DELETE_PRESET = "Usuń preset"
SAVE_PRESET = "Zapisz preset" SAVE_PRESET = "Zapisz preset"
CAP_TOGGLE = "Naciśnij Z, aby zdjąć lub założyć czapkę."
[PALETTE] [PALETTE]
MARIO = "Mario" MARIO = "Mario"

View file

@ -333,6 +333,7 @@ EDIT_PALETTE = "Editar paleta"
PRESET_NAME = "Nome" PRESET_NAME = "Nome"
DELETE_PRESET = "Excluir" DELETE_PRESET = "Excluir"
SAVE_PRESET = "Salvar" SAVE_PRESET = "Salvar"
CAP_TOGGLE = "Prima Z para alternar a capa de proteção."
[PALETTE] [PALETTE]
MARIO = "Mario" MARIO = "Mario"

View file

@ -332,6 +332,7 @@ EDIT_PALETTE = "Редактировать палитру"
PRESET_NAME = "Имя" PRESET_NAME = "Имя"
DELETE_PRESET = "Удалить" DELETE_PRESET = "Удалить"
SAVE_PRESET = "Сохранить" SAVE_PRESET = "Сохранить"
CAP_TOGGLE = "Нажмите Z, чтобы переключить режим ношения шапки."
[PALETTE] [PALETTE]
MARIO = "Марио" MARIO = "Марио"

View file

@ -333,6 +333,7 @@ EDIT_PALETTE = "Editar Paleta"
PRESET_NAME = "Nombre" PRESET_NAME = "Nombre"
DELETE_PRESET = "Eliminar" DELETE_PRESET = "Eliminar"
SAVE_PRESET = "Guardar" SAVE_PRESET = "Guardar"
CAP_TOGGLE = "Pulsa Z para poner o quitar la gorra."
[PALETTE] [PALETTE]
MARIO = "Mario" MARIO = "Mario"
@ -410,4 +411,4 @@ SEARCH = "Buscar"
NONE_FOUND = "No se han encontrado partidas." NONE_FOUND = "No se han encontrado partidas."
[CHANGELOG] [CHANGELOG]
CHANGELOG_TITLE = "REGISTRO DE CAMBIOS" CHANGELOG_TITLE = "REGISTRO DE CAMBIOS"

View file

@ -3348,8 +3348,9 @@ void update_camera(struct Camera *c) {
gLakituState.lastFrameAction = sMarioCamState->action; gLakituState.lastFrameAction = sMarioCamState->action;
// Make sure the palette editor cutscene is properly reset // Make sure the palette editor cutscene is properly reset
if (c->paletteEditorCap && c->cutscene != CUTSCENE_PALETTE_EDITOR && (gMarioState->flags & MARIO_CAP_ON_HEAD) == 0) { struct MarioState *m = gMarioState;
cutscene_put_cap_on(gMarioState); if (c->paletteEditorCap && c->cutscene != CUTSCENE_PALETTE_EDITOR && !(m->flags & MARIO_CAP_ON_HEAD) && m->action != ACT_PUTTING_ON_CAP) {
cutscene_put_cap_on(m);
c->paletteEditorCap = false; c->paletteEditorCap = false;
} }
} }
@ -10865,18 +10866,37 @@ void cutscene_palette_editor(struct Camera *c) {
if (!gInPlayerMenu) { if (!gInPlayerMenu) {
if (c->paletteEditorCap) { if (c->paletteEditorCap) {
if (!(m->flags & MARIO_CAP_ON_HEAD)) { if (m->action == ACT_IDLE && !(m->flags & MARIO_CAP_ON_HEAD)) {
set_mario_action(m, ACT_PUTTING_ON_CAP, 0); set_mario_action(m, ACT_PUTTING_ON_CAP, 0);
} }
c->paletteEditorCap = false;
} }
gCutsceneTimer = CUTSCENE_STOP; gCutsceneTimer = CUTSCENE_STOP;
c->cutscene = 0; c->cutscene = 0;
return; return;
} }
if (m->action == ACT_IDLE && m->flags & MARIO_CAP_ON_HEAD) {
set_mario_action(m, ACT_TAKING_OFF_CAP, 0); static bool pressed = false;
c->paletteEditorCap = true; if (gInteractablePad.button & PAD_BUTTON_Z) {
if (!pressed && m->action != ACT_TAKING_OFF_CAP && m->action != ACT_PUTTING_ON_CAP) {
if (m->flags & MARIO_CAP_ON_HEAD) {
if (m->action == ACT_IDLE) {
set_mario_action(m, ACT_TAKING_OFF_CAP, 0);
} else {
cutscene_take_cap_off(m);
gCamera->paletteEditorCap = true;
}
} else {
if (m->action == ACT_IDLE) {
set_mario_action(m, ACT_PUTTING_ON_CAP, 0);
} else {
cutscene_put_cap_on(m);
gCamera->paletteEditorCap = false;
}
}
}
pressed = true;
} else {
pressed = false;
} }
c->pos[0] = m->pos[0] + (0x200 * sins(m->faceAngle[1])); c->pos[0] = m->pos[0] + (0x200 * sins(m->faceAngle[1]));

View file

@ -1863,12 +1863,13 @@ s32 act_squished(struct MarioState *m) {
s32 act_putting_on_cap(struct MarioState *m) { s32 act_putting_on_cap(struct MarioState *m) {
s32 animFrame = set_character_animation(m, CHAR_ANIM_PUT_CAP_ON); s32 animFrame = set_character_animation(m, CHAR_ANIM_PUT_CAP_ON);
if (animFrame == 0 && !m->area->camera->paletteEditorCap) { if (animFrame == 0 && !gCamera->paletteEditorCap) {
enable_time_stop_if_alone(); enable_time_stop_if_alone();
} }
if (animFrame == 28) { if (animFrame == 28) {
cutscene_put_cap_on(m); cutscene_put_cap_on(m);
gCamera->paletteEditorCap = false;
} }
if (is_anim_at_end(m)) { if (is_anim_at_end(m)) {
@ -1885,16 +1886,19 @@ s32 act_taking_off_cap(struct MarioState *m) {
s16 animFrame = set_character_animation(m, CHAR_ANIM_TAKE_CAP_OFF_THEN_ON); s16 animFrame = set_character_animation(m, CHAR_ANIM_TAKE_CAP_OFF_THEN_ON);
switch (animFrame) { switch (animFrame) {
case 0: case 0:
if (!m->area->camera->paletteEditorCap) { if (!gCamera->paletteEditorCap) {
enable_time_stop_if_alone(); enable_time_stop_if_alone();
} }
break; break;
case 12: case 12:
cutscene_take_cap_off(m); cutscene_take_cap_off(m);
if (gCamera->cutscene == CUTSCENE_PALETTE_EDITOR) { gCamera->paletteEditorCap = true; }
break; break;
case 30: default:
set_mario_action(m, ACT_IDLE, 0); if (animFrame >= 30) {
disable_time_stop(); set_mario_action(m, ACT_IDLE, 0);
disable_time_stop();
}
break; break;
} }

View file

@ -4,6 +4,7 @@
#define PAD_BUTTON_A ((u16)(1 << 15)) #define PAD_BUTTON_A ((u16)(1 << 15))
#define PAD_BUTTON_B ((u16)(1 << 14)) #define PAD_BUTTON_B ((u16)(1 << 14))
#define PAD_BUTTON_Z ((u16)(1 << 13))
#define PAD_BUTTON_START ((u16)(1 << 12)) #define PAD_BUTTON_START ((u16)(1 << 12))
#define MOUSE_BUTTON_1 ((u16)(1 << 0)) #define MOUSE_BUTTON_1 ((u16)(1 << 0))

View file

@ -338,8 +338,8 @@ static void djui_panel_player_prevent_demo(struct DjuiBase* caller) {
} }
static void djui_panel_player_update_camera_cutscene(void) { static void djui_panel_player_update_camera_cutscene(void) {
if (gMarioState->area && gMarioState->area->camera && gMarioState->area->camera->cutscene == 0) { if (gCamera && gCamera->cutscene == 0) {
gMarioState->area->camera->cutscene = CUTSCENE_PALETTE_EDITOR; gCamera->cutscene = CUTSCENE_PALETTE_EDITOR;
} }
} }
@ -412,7 +412,7 @@ void djui_panel_player_create(struct DjuiBase* caller) {
if (sPalettePresetIndex >= gPresetPaletteCount) { if (sPalettePresetIndex >= gPresetPaletteCount) {
sPalettePresetIndex = 0; sPalettePresetIndex = 0;
} }
for (int i = 0; i < gPresetPaletteCount; i++) { for (int i = 0; i < gPresetPaletteCount; i++) {
palettePresets[i + 1] = gPresetPalettes[i].name; palettePresets[i + 1] = gPresetPalettes[i].name;
@ -425,6 +425,13 @@ void djui_panel_player_create(struct DjuiBase* caller) {
djui_button_create(body, DLANG(PLAYER, EDIT_PALETTE), DJUI_BUTTON_STYLE_NORMAL, djui_panel_player_edit_palette_create); djui_button_create(body, DLANG(PLAYER, EDIT_PALETTE), DJUI_BUTTON_STYLE_NORMAL, djui_panel_player_edit_palette_create);
djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back); djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back);
{
struct DjuiText *text = djui_text_create(body, DLANG(PLAYER, CAP_TOGGLE));
djui_text_set_alignment(text, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
djui_base_set_size_type(&text->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&text->base, 1.0f, 64);
}
} }
struct DjuiPanel* p = djui_panel_add(caller, panel, NULL); struct DjuiPanel* p = djui_panel_add(caller, panel, NULL);

View file

@ -574,60 +574,17 @@ static int smlua__set_field(lua_State* L) {
void smlua_cobject_init_globals(void) { void smlua_cobject_init_globals(void) {
lua_State* L = gLuaState; lua_State* L = gLuaState;
{ #define EXPOSE_GLOBAL_ARRAY(lot, ptr, iterator) \
lua_newtable(L); { \
int t = lua_gettop(gLuaState); lua_newtable(L); \
for (s32 i = 0; i < MAX_PLAYERS; i++) { int t = lua_gettop(gLuaState); \
lua_pushinteger(L, i); for (s32 i = 0; i < iterator; i++) { \
smlua_push_object(L, LOT_MARIOSTATE, &gMarioStates[i]); lua_pushinteger(L, i); \
lua_settable(L, t); smlua_push_object(L, lot, &ptr[i]); \
} lua_settable(L, t); \
lua_setglobal(L, "gMarioStates"); } \
} lua_setglobal(L, #ptr); \
} \
{
lua_newtable(L);
int t = lua_gettop(gLuaState);
for (s32 i = 0; i < MAX_PLAYERS; i++) {
lua_pushinteger(L, i);
smlua_push_object(L, LOT_NETWORKPLAYER, &gNetworkPlayers[i]);
lua_settable(L, t);
}
lua_setglobal(L, "gNetworkPlayers");
}
{
lua_newtable(L);
int t = lua_gettop(gLuaState);
for (s32 i = 0; i < gActiveMods.entryCount; i++) {
lua_pushinteger(L, i);
smlua_push_object(L, LOT_MOD, gActiveMods.entries[i]);
lua_settable(L, t);
}
lua_setglobal(L, "gActiveMods");
}
{
lua_newtable(L);
int t = lua_gettop(gLuaState);
for (s32 i = 0; i < CT_MAX; i++) {
lua_pushinteger(L, i);
smlua_push_object(L, LOT_CHARACTER, &gCharacters[i]);
lua_settable(L, t);
}
lua_setglobal(L, "gCharacters");
}
{
lua_newtable(L);
int t = lua_gettop(gLuaState);
for (s32 i = 0; i < MAX_PLAYERS; i++) {
lua_pushinteger(L, i);
smlua_push_object(L, LOT_CONTROLLER, &gControllers[i]);
lua_settable(L, t);
}
lua_setglobal(L, "gControllers");
}
#define EXPOSE_GLOBAL(lot, ptr) \ #define EXPOSE_GLOBAL(lot, ptr) \
{ \ { \
@ -641,13 +598,36 @@ void smlua_cobject_init_globals(void) {
lua_setglobal(L, name); \ lua_setglobal(L, name); \
} \ } \
// Array structs
EXPOSE_GLOBAL_ARRAY(LOT_MARIOSTATE, gMarioStates, MAX_PLAYERS);
EXPOSE_GLOBAL_ARRAY(LOT_NETWORKPLAYER, gNetworkPlayers, MAX_PLAYERS);
{
lua_newtable(L);
int t = lua_gettop(gLuaState);
for (s32 i = 0; i < gActiveMods.entryCount; i++) {
lua_pushinteger(L, i);
smlua_push_object(L, LOT_MOD, gActiveMods.entries[i]);
lua_settable(L, t);
}
lua_setglobal(L, "gActiveMods");
}
EXPOSE_GLOBAL_ARRAY(LOT_CHARACTER, gCharacters, CT_MAX);
EXPOSE_GLOBAL_ARRAY(LOT_CONTROLLER, gControllers, MAX_PLAYERS);
// Structs
EXPOSE_GLOBAL_WITH_NAME(LOT_GLOBALTEXTURES, gGlobalTextures, "gTextures"); EXPOSE_GLOBAL_WITH_NAME(LOT_GLOBALTEXTURES, gGlobalTextures, "gTextures");
EXPOSE_GLOBAL_WITH_NAME(LOT_GLOBALOBJECTANIMATIONS, gGlobalObjectAnimations, "gObjectAnimations"); EXPOSE_GLOBAL_WITH_NAME(LOT_GLOBALOBJECTANIMATIONS, gGlobalObjectAnimations, "gObjectAnimations");
EXPOSE_GLOBAL(LOT_PAINTINGVALUES, gPaintingValues); EXPOSE_GLOBAL(LOT_PAINTINGVALUES, gPaintingValues);
EXPOSE_GLOBAL(LOT_GLOBALOBJECTCOLLISIONDATA, gGlobalObjectCollisionData); // I wish we named this gObjectCollisionData EXPOSE_GLOBAL(LOT_GLOBALOBJECTCOLLISIONDATA, gGlobalObjectCollisionData);
EXPOSE_GLOBAL(LOT_LEVELVALUES, gLevelValues); EXPOSE_GLOBAL(LOT_LEVELVALUES, gLevelValues);