Skip to content

Commit

Permalink
rework "Authentic Logo Screen" and "Fast File Select" (HarbourMasters…
Browse files Browse the repository at this point in the history
…#4939)

* skip z_title with button press

* use `RegisterShipInitFunc`

* rip out a bunch of custom ztitle code

* ok now it's almost fully back to vanilla

* titles are back for a limited time

enjoy #Skipping

* move old customizations into new custom draw

* finally getting the hang of this shipinit thing

* vb should let it snow

* boot sequence logic

* clean up logic to better handle changing boot sequence settings

* remove fast file select stuff

* remove authentic logo screen setting

* about window - not super pretty but not ugly imo

* maybe this fixes windows

* maybe alloca? idk why it's working in other files

* just pulling in every include hoping something works

* Revert

This reverts commit c1d02c9.

* try some macro fixing magic

* fix another c vs cpp thing

* do it without an extra var

* make `GitCommitHashTruncated` a private member on `AboutWindow` instead of truncating on draw

* move logo asset defs to `soh_assets.h`

* Apply suggestions from code review

Co-authored-by: Archez <[email protected]>

* VB_SHOULDN'T

---------

Co-authored-by: Archez <[email protected]>
  • Loading branch information
briaguya-ai and Archez authored Jan 24, 2025
1 parent 6d94cf9 commit 388eb48
Show file tree
Hide file tree
Showing 16 changed files with 423 additions and 241 deletions.
7 changes: 7 additions & 0 deletions soh/assets/soh_assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,10 @@ static const ALIGN_ASSET(2) char gLinkAdultGoronTunicSkel[] = dgLinkAdultGoronTu

#define dgLinkAdultZoraTunicSkel "__OTR__objects/object_link_boy_zora/gLinkAdultZoraTunicSkel"
static const ALIGN_ASSET(2) char gLinkAdultZoraTunicSkel[] = dgLinkAdultZoraTunicSkel;

// LUS Logo
#define dgShipLogoDL "__OTR__textures/nintendo_rogo_static/gShipLogoDL"
static const ALIGN_ASSET(2) char gShipLogoDL[] = dgShipLogoDL;

#define dnintendo_rogo_static_Tex_LUS_000000 "__OTR__textures/nintendo_rogo_static/nintendo_rogo_static_Tex_LUS_000000"
static const ALIGN_ASSET(2) char nintendo_rogo_static_Tex_LUS_000000[] = dnintendo_rogo_static_Tex_LUS_000000;
5 changes: 5 additions & 0 deletions soh/include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,12 @@ extern GraphicsContext* __gfxCtx;
: (((a2) >= (a3)) ? (a2) : (((a3) >= (a1)) ? (a1) : (a3))))

#define MATRIX_TOMTX(dest) Matrix_ToMtx(dest, __FILE__, __LINE__)
#ifdef __cplusplus
#define MATRIX_NEWMTX(gfxCtx) Matrix_NewMtx(gfxCtx, const_cast<char*>(__FILE__), __LINE__)
#else
#define MATRIX_NEWMTX(gfxCtx) Matrix_NewMtx(gfxCtx, __FILE__, __LINE__)
#endif

#define MATRIX_CHECKFLOATS(mf) Matrix_CheckFloats(mf, __FILE__, __LINE__)

#define ZELDA_ARENA_MALLOC_DEBUG(size) ZeldaArena_MallocDebug(size, __FILE__, __LINE__)
Expand Down
103 changes: 103 additions & 0 deletions soh/soh/AboutWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#include "AboutWindow.h"
#include <imgui.h>
#include <soh/GameVersions.h>
#include "soh/ResourceManagerHelpers.h"

extern "C" {
#include "variables.h"
}

AboutWindow::~AboutWindow() {
SPDLOG_TRACE("destruct about window");
}

void AboutWindow::InitElement() {
mIsTaggedVersion = gGitCommitTag[0] != 0;

strncpy(mGitCommitHashTruncated, (char*)gGitCommitHash, 7);
mGitCommitHashTruncated[7] = 0;
}

void AboutWindow::Draw() {
if (!IsVisible()) {
return;
}

ImGuiWindowFlags windowFlags = ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoDocking |
ImGuiWindowFlags_NoScrollWithMouse |
ImGuiWindowFlags_NoScrollbar;

ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(16 * ImGui::GetIO().FontGlobalScale, 8 * ImGui::GetIO().FontGlobalScale));

if (!ImGui::Begin(GetName().c_str(), &mIsVisible, windowFlags)) {
ImGui::End();
} else {
DrawElement();
ImGui::End();
}

ImGui::PopStyleVar();

// Sync up the IsVisible flag if it was changed by ImGui
SyncVisibilityConsoleVariable();
}

const char* AboutWindow::GetGameVersionString(uint32_t index) {
uint32_t gameVersion = ResourceMgr_GetGameVersion(index);
switch (gameVersion) {
case OOT_NTSC_US_10:
return "NTSC-U 1.0";
case OOT_NTSC_US_11:
return "NTSC-U 1.1";
case OOT_NTSC_US_12:
return "NTSC-U 1.2";
case OOT_PAL_10:
return "PAL 1.0";
case OOT_PAL_11:
return "PAL 1.1";
case OOT_PAL_GC:
return "PAL GC";
case OOT_PAL_MQ:
return "PAL MQ";
case OOT_PAL_GC_DBG1:
case OOT_PAL_GC_DBG2:
return "PAL GC-D";
case OOT_PAL_GC_MQ_DBG:
return "PAL MQ-D";
case OOT_IQUE_CN:
return "IQUE CN";
case OOT_IQUE_TW:
return "IQUE TW";
default:
return "UNKNOWN";
}
}

void AboutWindow::DrawElement() {
// The icon is already padded - adjust for that
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
cursorPos.x -= 16 * ImGui::GetIO().FontGlobalScale;
ImGui::SetCursorScreenPos(cursorPos);

ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), ImVec2(64.0f * ImGui::GetIO().FontGlobalScale, 64.0f * ImGui::GetIO().FontGlobalScale));

ImGui::SameLine();

ImGui::BeginGroup();
ImGui::Text("Ship of Harkinian");
if (mIsTaggedVersion) {
ImGui::Text("%s", gBuildVersion);
} else {
ImGui::Text("%s", gGitBranch);
ImGui::Text("%s", mGitCommitHashTruncated);
}
ImGui::EndGroup();

ImGui::Dummy(ImVec2(0, 2 * ImGui::GetIO().FontGlobalScale));
ImGui::Text("Game Archives:");
for (uint32_t i = 0; i < ResourceMgr_GetNumGameVersions(); i++) {
ImGui::BulletText(GetGameVersionString(i));
}
}
20 changes: 20 additions & 0 deletions soh/soh/AboutWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <libultraship/libultraship.h>

class AboutWindow : public Ship::GuiWindow {
public:
using GuiWindow::GuiWindow;
~AboutWindow();

private:
void InitElement() override;
void Draw() override;
void DrawElement() override;
void UpdateElement() override {};

const char* GetGameVersionString(uint32_t index);

bool mIsTaggedVersion;
char mGitCommitHashTruncated[8];
};
47 changes: 0 additions & 47 deletions soh/soh/Enhancements/bootcommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"

uint8_t gLoadFileSelect = 0, gSkipLogoTest = 0;

extern BootCommandFunc BootCommands_Command_SkipLogo(char** argv, s32 argc);
extern BootCommandFunc BootCommands_Command_LoadFileSelect(char** argv, s32 argc);

static BootCommand sCommands[] = { { "--skiplogo", BootCommands_Command_SkipLogo },
{ "--loadfileselect", BootCommands_Command_LoadFileSelect } };

void BootCommands_Init()
{
// Clears vars to prevent randomizer menu from being disabled
Expand All @@ -32,42 +24,3 @@ void BootCommands_Init()
CVarRegisterInteger(CVAR_IMGUI_CONTROLLER_NAV, 1); // always enable controller nav on switch/wii u
#endif
}

//void BootCommands_ParseBootArgs(char* str)
void BootCommands_ParseBootArgs(s32 argc, char** argv)
{
s32 i;

// Parse the commands
for (i = 0; i < argc; i++) {
s32 j;

for (j = 0; j < ARRAY_COUNT(sCommands); j++) {
if (!strcmp(argv[i], sCommands[j].name)) {
s32 numArgsProcessed = sCommands[j].func(&argv[i], argc - i);
i += numArgsProcessed;
break;
}
}
}
}

/*
* Command Name: --skiplogo
* Description: Skips the N64 Logo Screen
* Arguments: None
*/
BootCommandFunc BootCommands_Command_SkipLogo(char** argv, s32 argc) {
gSkipLogoTest = 1;
return 0;
}

/*
* Command Name: --loadfileselect
* Description: Loads the file select screen on bootup.
* Arguments: None
*/
BootCommandFunc BootCommands_Command_LoadFileSelect(char** argv, s32 argc) {
gLoadFileSelect = 1;
return 0;
}
13 changes: 0 additions & 13 deletions soh/soh/Enhancements/bootcommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
#include <libultraship/libultra.h>
#include <z64.h>

typedef s32 (*BootCommandFunc)(char** argv, s32 argc); // Returns the number of arguments it read

typedef struct BootCommand
{
char* name;
BootCommandFunc func;
} BootCommand;

extern uint8_t gLoadFileSelect;
extern uint8_t gSkipLogoTest;

void BootCommands_Init();
//void BootCommands_ParseBootArgs(char* str);
void BootCommands_ParseBootArgs(s32 argc, char** argv);

#endif
Loading

0 comments on commit 388eb48

Please sign in to comment.