mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-21 19:45:10 +00:00
more fixes and dynos cleanup (#520)
- fix paginated panels when a page doesn't exist anymore - fix colored mod names carrying over to other mod names in lobby mod lists - even more dynos cleanup - remove unused code - more clean up for dynos levels code (mostly just better code layout)
This commit is contained in:
parent
d1ffab4219
commit
2c0b112cba
4 changed files with 89 additions and 110 deletions
|
@ -785,7 +785,6 @@ void DynOS_UpdateGfx();
|
|||
bool DynOS_IsTransitionActive();
|
||||
void DynOS_Mod_Update();
|
||||
void DynOS_Mod_Shutdown();
|
||||
void DynOS_ReturnToMainMenu();
|
||||
|
||||
//
|
||||
// Gfx
|
||||
|
|
|
@ -4,7 +4,6 @@ extern "C" {
|
|||
#include "game/save_file.h"
|
||||
#include "levels/scripts.h"
|
||||
#include "pc/lua/utils/smlua_level_utils.h"
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -16,6 +15,12 @@ extern const BehaviorScript *sWarpBhvSpawnTable[];
|
|||
#include "engine/level_script.h"
|
||||
}
|
||||
|
||||
#define DYNOS_LEVEL_MOD_INDEX_VANILLA (-1)
|
||||
|
||||
extern void *gDynosLevelScriptsOriginal[LEVEL_COUNT];
|
||||
|
||||
void DynOS_Level_ParseScript(const void *aScript, s32 (*aPreprocessFunction)(u8, void *));
|
||||
|
||||
//
|
||||
// Data
|
||||
//
|
||||
|
@ -38,10 +43,7 @@ struct DynosLevelScript {
|
|||
s32 mModIndex;
|
||||
};
|
||||
|
||||
#define DYNOS_LEVEL_MOD_INDEX_VANILLA (-1)
|
||||
|
||||
static DynosLevelScript sDynosLevelScripts[LEVEL_COUNT] = { { NULL, DYNOS_LEVEL_MOD_INDEX_VANILLA } };
|
||||
extern void *gDynosLevelScriptsOriginal[LEVEL_COUNT];
|
||||
static Array<DynosWarp> sDynosLevelWarps[LEVEL_COUNT] = { Array<DynosWarp>() };
|
||||
|
||||
u64 DynOS_Level_CmdGet(void *aCmd, u64 aOffset) {
|
||||
|
@ -55,8 +57,6 @@ LvlCmd *DynOS_Level_CmdNext(LvlCmd *aCmd) {
|
|||
return (LvlCmd*) (u64(aCmd) + _Offset);
|
||||
}
|
||||
|
||||
void DynOS_Level_ParseScript(const void *aScript, s32 (*aPreprocessFunction)(u8, void *));
|
||||
|
||||
//
|
||||
// Init
|
||||
//
|
||||
|
@ -66,15 +66,15 @@ static s32 DynOS_Level_PreprocessMasterScript(u8 aType, void *aCmd) {
|
|||
static s32 sDynosLevelNum = -1;
|
||||
|
||||
if (sDynosScriptExecLevelTable) {
|
||||
switch (aType) {
|
||||
|
||||
// JUMP_IF
|
||||
if (aType == 0x0C) {
|
||||
case 0x0C: {
|
||||
sDynosLevelNum = (s32) DynOS_Level_CmdGet(aCmd, 0x04);
|
||||
return 0;
|
||||
}
|
||||
} return 0;
|
||||
|
||||
// EXECUTE
|
||||
if (aType == 0x00) {
|
||||
case 0x00: {
|
||||
void *_Script = (void *) DynOS_Level_CmdGet(aCmd, 0x0C);
|
||||
if (sDynosLevelNum >= 0 && sDynosLevelNum < LEVEL_COUNT && !sDynosLevelScripts[sDynosLevelNum].mLevelScript) {
|
||||
sDynosLevelScripts[sDynosLevelNum].mLevelScript = _Script;
|
||||
|
@ -82,11 +82,11 @@ static s32 DynOS_Level_PreprocessMasterScript(u8 aType, void *aCmd) {
|
|||
gDynosLevelScriptsOriginal[sDynosLevelNum] = _Script;
|
||||
}
|
||||
sDynosLevelNum = -1;
|
||||
return 2;
|
||||
}
|
||||
} return 2;
|
||||
|
||||
// EXIT or SLEEP
|
||||
if (aType == 0x02 || aType == 0x03) {
|
||||
case 0x02:
|
||||
case 0x03:
|
||||
return 3;
|
||||
}
|
||||
} else if (aType == 0x06) { // JUMP_LINK
|
||||
|
@ -97,67 +97,62 @@ static s32 DynOS_Level_PreprocessMasterScript(u8 aType, void *aCmd) {
|
|||
}
|
||||
|
||||
static s32 sDynosCurrentLevelNum;
|
||||
static s32 DynOS_Level_PreprocessScript(u8 aType, void *aCmd) {
|
||||
static u8 sDynosAreaIndex = 0;
|
||||
static auto _GetWarpStruct = [](u8 aArea, u8 aId) -> DynosWarp * {
|
||||
static u8 sDynosAreaIndex = 0;
|
||||
|
||||
inline static DynosWarp *DynOS_Level_GetWarpStruct(u8 aId) {
|
||||
for (s32 i = 0; i != sDynosLevelWarps[sDynosCurrentLevelNum].Count(); ++i) {
|
||||
if (sDynosLevelWarps[sDynosCurrentLevelNum][i].mArea == aArea &&
|
||||
if (sDynosLevelWarps[sDynosCurrentLevelNum][i].mArea == sDynosAreaIndex &&
|
||||
sDynosLevelWarps[sDynosCurrentLevelNum][i].mId == aId) {
|
||||
return &sDynosLevelWarps[sDynosCurrentLevelNum][i];
|
||||
}
|
||||
}
|
||||
DynosWarp _Warp;
|
||||
_Warp.mArea = aArea;
|
||||
_Warp.mArea = sDynosAreaIndex;
|
||||
_Warp.mId = aId;
|
||||
sDynosLevelWarps[sDynosCurrentLevelNum].Add(_Warp);
|
||||
return &sDynosLevelWarps[sDynosCurrentLevelNum][sDynosLevelWarps[sDynosCurrentLevelNum].Count() - 1];
|
||||
};
|
||||
};
|
||||
|
||||
static s32 DynOS_Level_PreprocessScript(u8 aType, void *aCmd) {
|
||||
switch (aType) {
|
||||
|
||||
// AREA
|
||||
if (aType == 0x1F) {
|
||||
case 0x1F: {
|
||||
sDynosAreaIndex = (u8) DynOS_Level_CmdGet(aCmd, 2);
|
||||
}
|
||||
} break;
|
||||
|
||||
// OBJECT
|
||||
else if (aType == 0x24) {
|
||||
case 0x24: {
|
||||
const BehaviorScript *bhv = (const BehaviorScript *) DynOS_Level_CmdGet(aCmd, 20);
|
||||
for (s32 i = 0; i < 20; ++i) {
|
||||
if (sWarpBhvSpawnTable[i] == bhv) {
|
||||
DynosWarp *_Warp = _GetWarpStruct(sDynosAreaIndex, ((((u32) DynOS_Level_CmdGet(aCmd, 16)) >> 16) & 0xFF));
|
||||
DynosWarp *_Warp = DynOS_Level_GetWarpStruct(((((u32) DynOS_Level_CmdGet(aCmd, 16)) >> 16) & 0xFF));
|
||||
if (_Warp->mType == -1) {
|
||||
_Warp->mType = i;
|
||||
_Warp->mPosX = (s16) DynOS_Level_CmdGet(aCmd, 4);
|
||||
_Warp->mPosY = (s16) DynOS_Level_CmdGet(aCmd, 6);
|
||||
_Warp->mPosZ = (s16) DynOS_Level_CmdGet(aCmd, 8);
|
||||
_Warp->mAngle = (s16)((((s32)((s16) DynOS_Level_CmdGet(aCmd, 12))) * 0x8000) / 180);
|
||||
_Warp->mAngle = ((s16) DynOS_Level_CmdGet(aCmd, 12) * 0x8000) / 180;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
// WARP_NODE
|
||||
else if (aType == 0x26) {
|
||||
DynosWarp *_Warp = _GetWarpStruct(sDynosAreaIndex, (u8) DynOS_Level_CmdGet(aCmd, 2));
|
||||
// WARP_NODE or PAINTING_WARP_NODE
|
||||
case 0x26:
|
||||
case 0x27: {
|
||||
DynosWarp *_Warp = DynOS_Level_GetWarpStruct((u8) DynOS_Level_CmdGet(aCmd, 2));
|
||||
if (_Warp->mDestLevel == 0) {
|
||||
_Warp->mDestLevel = (u8) DynOS_Level_CmdGet(aCmd, 3);
|
||||
_Warp->mDestArea = (u8) DynOS_Level_CmdGet(aCmd, 4);
|
||||
_Warp->mDestId = (u8) DynOS_Level_CmdGet(aCmd, 5);
|
||||
}
|
||||
}
|
||||
|
||||
// PAINTING_WARP_NODE
|
||||
else if (aType == 0x27) {
|
||||
DynosWarp *_Warp = _GetWarpStruct(sDynosAreaIndex, (u8) DynOS_Level_CmdGet(aCmd, 2));
|
||||
if (_Warp->mDestLevel == 0) {
|
||||
_Warp->mDestLevel = (u8) DynOS_Level_CmdGet(aCmd, 3);
|
||||
_Warp->mDestArea = (u8) DynOS_Level_CmdGet(aCmd, 4);
|
||||
_Warp->mDestId = (u8) DynOS_Level_CmdGet(aCmd, 5);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
// SLEEP or SLEEP_BEFORE_EXIT
|
||||
else if (aType == 0x03 || aType == 0x04) {
|
||||
case 0x03:
|
||||
case 0x04:
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -170,7 +165,7 @@ void DynOS_Level_Init() {
|
|||
if (!sInited) {
|
||||
|
||||
// Level warps
|
||||
for (sDynosCurrentLevelNum = 0; sDynosCurrentLevelNum != LEVEL_COUNT; ++sDynosCurrentLevelNum) {
|
||||
for (sDynosCurrentLevelNum = 0; sDynosCurrentLevelNum < LEVEL_COUNT; ++sDynosCurrentLevelNum) {
|
||||
sDynosLevelScripts[sDynosCurrentLevelNum].mLevelScript = gDynosLevelScriptsOriginal[sDynosCurrentLevelNum];
|
||||
sDynosLevelScripts[sDynosCurrentLevelNum].mModIndex = DYNOS_LEVEL_MOD_INDEX_VANILLA;
|
||||
if (sDynosLevelScripts[sDynosCurrentLevelNum].mLevelScript) {
|
||||
|
|
|
@ -1,25 +1,8 @@
|
|||
#include "dynos.cpp.h"
|
||||
extern "C" {
|
||||
#include "sm64.h"
|
||||
#include "level_commands.h"
|
||||
#include "game/level_update.h"
|
||||
#include "game/object_list_processor.h"
|
||||
extern s16 gMenuMode;
|
||||
extern s8 gDialogBoxState;
|
||||
#ifdef OMM_DEFINES_H
|
||||
extern void omm_opt_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Main Menu
|
||||
//
|
||||
|
||||
void DynOS_ReturnToMainMenu() {
|
||||
level_set_transition(0, NULL);
|
||||
gDialogBoxState = 0;
|
||||
gMenuMode = -1;
|
||||
fade_into_special_warp(-2, 0);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -28,6 +28,8 @@ static s32 djui_paginated_get_count(struct DjuiPaginated* paginated) {
|
|||
|
||||
void djui_paginated_update_page_buttons(struct DjuiPaginated* paginated) {
|
||||
s32 count = djui_paginated_get_count(paginated);
|
||||
paginated->startIndex = MIN(paginated->startIndex, count);
|
||||
|
||||
char pageNumString[32] = { 0 };
|
||||
snprintf(pageNumString, 32, "%d/%d", paginated->startIndex / paginated->showCount + 1, (count - 1) / paginated->showCount + 1);
|
||||
djui_text_set_text(sPageNumText, pageNumString);
|
||||
|
|
Loading…
Reference in a new issue