Added Archipelago connection status in game, todo refactor and clean up

This commit is contained in:
Jerom Venneker
2025-07-22 21:54:59 +02:00
parent 4f1ebbc3d5
commit 7859b548be
4 changed files with 115 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -466,6 +466,10 @@ 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;
// Archipelago Item Icons
#define dgArchipelagoItemTex "__OTR__textures/parameter_static/gArchipelagoOutline"
static const ALIGN_ASSET(2) char gArchipelagoItemTex[] = dgArchipelagoItemTex;
// Archipelago Item Models
#define dgArchipelagoItemDL "__OTR__objects/object_archipelago_item/gArchipelagoItemDL"
static const ALIGN_ASSET(2) char gArchipelagoItemDL[] = dgArchipelagoItemDL;

View File

@@ -1069,6 +1069,7 @@ void Interface_LoadItemIcon1(PlayState* play, u16 button);
void Interface_LoadItemIcon2(PlayState* play, u16 button);
void func_80084BF4(PlayState* play, u16 flag);
uint16_t Interface_DrawTextLine(GraphicsContext* gfx, char text[], int16_t x, int16_t y, uint16_t colorR, uint16_t colorG, uint16_t colorB, uint16_t colorA, float textScale, uint8_t textShadow);
uint16_t Interface_DrawTextLine_overlay(GraphicsContext* gfx, char text[], int16_t x, int16_t y, uint16_t colorR, uint16_t colorG, uint16_t colorB, uint16_t colorA, float textScale, uint8_t textShadow);
u8 Item_Give(PlayState* play, u8 item);
u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry);
u8 Item_CheckObtainability(u8 item);

View File

@@ -12,6 +12,7 @@
#include "soh/Enhancements/custom-message/CustomMessageInterfaceAddon.h"
#include "soh/Enhancements/cosmetics/cosmeticsTypes.h"
#include "soh/Enhancements/enhancementTypes.h"
#include "soh/Enhancements/FileSelectEnhancements.h"
#include "soh/ShipUtils.h"
#include <string.h>
@@ -3424,6 +3425,45 @@ void Interface_DrawLineupTick(PlayState* play) {
CLOSE_DISPS(play->state.gfxCtx);
}
void Interface_DrawArchipelagoStatusString(PlayState* play) {
s16 posX = OTRGetRectDimensionFromLeftEdge(28);
s16 posY = SCREEN_HEIGHT - 15;
int32_t scale = R_TEXT_CHAR_SCALE * 0.2f;
int32_t sTexSize = (scale / 100.0f) * 64.0f;
int32_t sTexScale = 1024.0f / (scale / 100.0f);
gDPLoadTextureBlock(play->state.gfxCtx->overlay.p++, gArchipelagoItemTex, G_IM_FMT_RGBA, G_IM_SIZ_32b, 64, 64, 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 0, 0, G_TX_NOLOD, G_TX_NOLOD);
gSPWideTextureRectangle(play->state.gfxCtx->overlay.p++, posX << 2, posY << 2, (posX + sTexSize) << 2,
(posY + sTexSize) << 2, G_TX_RENDERTILE, 0, 0, sTexScale, sTexScale);
//SPWideTextureRectangle(OVERLAY_DISP++, ((rMagicBarX + gSaveContext.magicCapacity) + 8) << 2, magicBarY << 2,
// ((rMagicBarX + gSaveContext.magicCapacity) + 16) << 2, (magicBarY + 16) << 2,
// G_TX_RENDERTILE, 256, 0, 1 << 10, 1 << 10);
posX += 13;
uint8_t language = (gSaveContext.language == LANGUAGE_JPN) ? LANGUAGE_ENG : gSaveContext.language;
char* statusText = SohFileSelect_GetArchipelagoSettingText(ASM_NOT_CONNECTED, language);
switch(CVarGetInteger(CVAR_REMOTE_ARCHIPELAGO("ConnectionStatus"), 0)) {
case 0: // Not Connected
statusText = SohFileSelect_GetArchipelagoSettingText(ASM_NOT_CONNECTED, language);
break;
case 1: // Connecting
case 2: // Connection error, retrying
case 3: // Connected
statusText = SohFileSelect_GetArchipelagoSettingText(ASM_CONNECTING, language);
break;
case 4: // Connected + Locations Scouted
statusText = SohFileSelect_GetArchipelagoSettingText(ASM_CONNECTED, language);
break;
}
Interface_DrawTextLine_overlay(play->state.gfxCtx, statusText, posX, posY, 255, 255, 255, 255, 0.8f, true);
}
void Interface_DrawMagicBar(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
s16 magicDrop = R_MAGIC_BAR_LARGE_Y - R_MAGIC_BAR_SMALL_Y + 2;
@@ -5397,6 +5437,10 @@ void Interface_Draw(PlayState* play) {
Interface_DrawLineupTick(play);
}
if(IS_ARCHIPELAGO) {
Interface_DrawArchipelagoStatusString(play);
}
if (fullUi || gSaveContext.magicState > MAGIC_STATE_IDLE) {
Interface_DrawMagicBar(play);
}
@@ -6936,6 +6980,41 @@ void Interface_DrawTextCharacter(GraphicsContext* gfx, int16_t x, int16_t y, voi
CLOSE_DISPS(gfx);
}
void Interface_DrawTextCharacter_overlay(GraphicsContext* gfx, int16_t x, int16_t y, void* texture, uint16_t colorR,
uint16_t colorG, uint16_t colorB, uint16_t colorA, float textScale,
uint8_t textShadow) {
int32_t scale = R_TEXT_CHAR_SCALE * textScale;
int32_t sCharTexSize = (scale / 100.0f) * 16.0f;
int32_t sCharTexScale = 1024.0f / (scale / 100.0f);
OPEN_DISPS(gfx);
gDPPipeSync(OVERLAY_DISP++);
gDPLoadTextureBlock_4b(OVERLAY_DISP++, texture, G_IM_FMT_I, FONT_CHAR_TEX_WIDTH, FONT_CHAR_TEX_HEIGHT, 0,
G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
G_TX_NOLOD);
if (textShadow) {
// Draw drop shadow
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, colorA);
gSPWideTextureRectangle(OVERLAY_DISP++, (x + R_TEXT_DROP_SHADOW_OFFSET) << 2, (y + R_TEXT_DROP_SHADOW_OFFSET) << 2,
(x + R_TEXT_DROP_SHADOW_OFFSET + sCharTexSize) << 2,
(y + R_TEXT_DROP_SHADOW_OFFSET + sCharTexSize) << 2, G_TX_RENDERTILE, 0, 0, sCharTexScale,
sCharTexScale);
}
gDPPipeSync(OVERLAY_DISP++);
// Draw normal text
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, colorR, colorG, colorB, colorA);
gSPWideTextureRectangle(OVERLAY_DISP++, x << 2, y << 2, (x + sCharTexSize) << 2, (y + sCharTexSize) << 2,
G_TX_RENDERTILE, 0, 0, sCharTexScale, sCharTexScale);
CLOSE_DISPS(gfx);
}
uint16_t Interface_DrawTextLine(GraphicsContext* gfx, char text[], int16_t x, int16_t y, uint16_t colorR,
uint16_t colorG, uint16_t colorB, uint16_t colorA, float textScale,
uint8_t textShadow) {
@@ -6966,3 +7045,34 @@ uint16_t Interface_DrawTextLine(GraphicsContext* gfx, char text[], int16_t x, in
return kerningOffset;
}
uint16_t Interface_DrawTextLine_overlay(GraphicsContext* gfx, char text[], int16_t x, int16_t y, uint16_t colorR,
uint16_t colorG, uint16_t colorB, uint16_t colorA, float textScale,
uint8_t textShadow) {
uint16_t textureIndex;
uint16_t kerningOffset = 0;
uint16_t lineOffset = 0;
void* texture;
const char* processedText = Interface_ReplaceSpecialCharacters(text);
uint8_t textLength = strlen(processedText);
for (uint16_t i = 0; i < textLength; i++) {
if (processedText[i] == '\n') {
lineOffset += 15 * textScale;
kerningOffset = 0;
} else {
textureIndex = processedText[i] - 32;
if (textureIndex != 0) {
texture = Ship_GetCharFontTexture(processedText[i]);
Interface_DrawTextCharacter_overlay(gfx, (int16_t)(x + kerningOffset), (int16_t)(y + lineOffset), texture, colorR, colorG, colorB,
colorA, textScale, textShadow);
}
kerningOffset +=
(uint16_t)(Ship_GetCharFontWidth(processedText[i]) * (R_TEXT_CHAR_SCALE / 100.0f) * textScale);
}
}
return kerningOffset;
}