Path: blob/master/SonicMania/Objects/Menu/DASetup.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: DASetup Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectDASetup *DASetup;1011void DASetup_Update(void) {}1213void DASetup_LateUpdate(void) {}1415void DASetup_StaticUpdate(void)16{17if (!DASetup->initialized) {18DASetup_SetupUI();19DASetup->initialized = true;20}2122EntityFXFade *fade = DASetup->fxFade;23if (DASetup->returnToMenu && fade->timer == 512) {24Music_FadeOut(0.02);25RSDK.SetScene("Presentation", "Menu");26RSDK.LoadScene();27}2829EntityUIControl *control = DASetup->control;30if (!control->childHasFocus)31control->childHasFocus = true;32}3334void DASetup_Draw(void) {}3536void DASetup_Create(void *data) {}3738void DASetup_StageLoad(void)39{4041foreach_all(UIControl, control)42{43DASetup->control = control;44control->processButtonInputCB = DASetup_State_ManageControl;45}4647foreach_all(FXFade, fade) { DASetup->fxFade = fade; }4849foreach_all(UIInfoLabel, label)50{51if (DASetup->trackTitleLabel) {52if (!DASetup->trackSelLabel) {53DASetup->trackSelLabel = label;54foreach_break;55}56}57else {58DASetup->trackTitleLabel = label;59}60}6162int32 trackCount = 0;63foreach_all(Music, track) { DASetup->trackList[trackCount++] = track; }6465DASetup->trackCount = trackCount;66DASetup->activeTrack = TRACK_NONE;6768DASetup->sfxEmerald = RSDK.GetSfx("Special/Emerald.wav");69DASetup->sfxMedal = RSDK.GetSfx("Special/Medal.wav");70DASetup->sfxSSExit = RSDK.GetSfx("Special/SSExit.wav");71DASetup->sfxScoreTotal = RSDK.GetSfx("Global/ScoreTotal.wav");72}7374void DASetup_DisplayTrack(int32 trackID)75{76char buffer[0x10];77String text;78INIT_STRING(text);7980EntityUIInfoLabel *trackTitleLabel = DASetup->trackTitleLabel;81EntityMusic *trackCountTrack = DASetup->trackList[trackID];8283memset(buffer, 0, 0x10 * sizeof(char));84strcpy(&buffer[2], " - ");85buffer[0] = (trackID / 10) + '0';86buffer[1] = trackID - 10 * (trackID / 10) + '0';87RSDK.SetString(&text, buffer);88RSDK.AppendString(&text, &trackCountTrack->soundTestTitle);89UIInfoLabel_SetString(trackTitleLabel, &text);90}9192bool32 DASetup_HandleMedallionDebug(void)93{94ProgressRAM *progress = GameProgress_GetProgressRAM();9596if (globals->medallionDebug && progress) {97switch (DASetup->trackID) {98case 8: // Act Clear/1UP - unlock all zones99if (GameProgress_CheckZoneClear()) {100RSDK.PlaySfx(DASetup->sfxScoreTotal, false, 255);101return true;102}103break;104105case 44: // Blue Spheres/ERZ Pinch Mode - unlock all medals (silver first if not all unlocked, if all unlocked then gold)106if (progress->silverMedalCount < 32) {107GameProgress_GiveMedal(globals->blueSpheresID, 1);108GameProgress_ShuffleBSSID();109RSDK.PlaySfx(DASetup->sfxMedal, false, 255);110return true;111}112else if (progress->goldMedalCount < 32) {113GameProgress_GiveMedal(globals->blueSpheresID, 2);114GameProgress_ShuffleBSSID();115RSDK.PlaySfx(DASetup->sfxMedal, false, 255);116return true;117}118break;119120case 46: // Super/Blue Spheres - unlock all121if (!progress->allGoldMedals) {122GameProgress_UnlockAll();123GameProgress_LockAllSpecialClear();124RSDK.PlaySfx(DASetup->sfxEmerald, false, 255);125return true;126}127break;128129case 48: // Game Over/Credits - reset progress130if (progress->silverMedalCount > 0 || progress->zoneCleared[0]) {131GameProgress_ClearProgress();132progress->allSpecialCleared = false;133RSDK.PlaySfx(DASetup->sfxSSExit, false, 255);134return true;135}136break;137138default: break;139}140}141142return false;143}144145void DASetup_SetupUI(void)146{147String buffer;148INIT_STRING(buffer);149150TitleBG_SetupFX();151DASetup_DisplayTrack(0);152EntityUIInfoLabel *trackSelLabel = DASetup->trackSelLabel;153Localization_GetString(&buffer, STR_SELECTATRACK);154#if MANIA_USE_PLUS155LogHelpers_PrintString(&buffer);156#endif157UIInfoLabel_SetString(trackSelLabel, &buffer);158}159160void DASetup_State_ManageControl(void)161{162int32 prevTrack = DASetup->trackID;163if (UIControl->anyRightPress)164DASetup->trackID++;165else if (UIControl->anyLeftPress)166DASetup->trackID--;167else if (UIControl->anyUpPress)168DASetup->trackID += 10;169else if (UIControl->anyDownPress)170DASetup->trackID -= 10;171172if (DASetup->trackID < 0)173DASetup->trackID += DASetup->trackCount;174if (DASetup->trackID >= DASetup->trackCount)175DASetup->trackID -= DASetup->trackCount;176177if (prevTrack != DASetup->trackID) {178RSDK.PlaySfx(UIWidgets->sfxBleep, false, 255);179DASetup_DisplayTrack(DASetup->trackID);180}181182if (UIControl->anyConfirmPress) {183if (DASetup->activeTrack == DASetup->trackID) {184Music_Stop();185DASetup->activeTrack = TRACK_NONE;186}187else {188EntityMusic *track = DASetup->trackList[DASetup->trackID];189if (!DASetup_HandleMedallionDebug()) {190if (track->trackFile.length) {191DASetup->activeTrack = DASetup->trackID;192Music_PlayTrackPtr(track);193}194else {195DASetup->activeTrack = TRACK_NONE;196Music_Stop();197}198}199}200}201202if (!DASetup->returnToMenu && UIControl->anyBackPress) {203DASetup->returnToMenu = true;204205EntityFXFade *fade = DASetup->fxFade;206fade->state = FXFade_State_FadeOut;207fade->timer = 0;208}209}210211#if GAME_INCLUDE_EDITOR212void DASetup_EditorDraw(void) {}213214void DASetup_EditorLoad(void) {}215#endif216217void DASetup_Serialize(void) {}218219220