mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-28 12:22:20 -05:00
Better ammo rendering (#3844)
* Better ammo rendering * Update soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c Co-authored-by: Archez <Archez@users.noreply.github.com> * Update z_kaleido_scope_PAL.c * Rename gBetterAmmoRendering to gEnhancements.BetterAmmoRendering --------- Co-authored-by: Archez <Archez@users.noreply.github.com>
This commit is contained in:
parent
c1365b3263
commit
7cdd33a01d
@ -1149,6 +1149,8 @@ void DrawEnhancementsMenu() {
|
|||||||
UIWidgets::Tooltip("Space between text characters (useful for HD font textures)");
|
UIWidgets::Tooltip("Space between text characters (useful for HD font textures)");
|
||||||
UIWidgets::PaddedEnhancementCheckbox("More info in file select", "gFileSelectMoreInfo", true, false);
|
UIWidgets::PaddedEnhancementCheckbox("More info in file select", "gFileSelectMoreInfo", true, false);
|
||||||
UIWidgets::Tooltip("Shows what items you have collected in the file select screen, like in N64 randomizer");
|
UIWidgets::Tooltip("Shows what items you have collected in the file select screen, like in N64 randomizer");
|
||||||
|
UIWidgets::PaddedEnhancementCheckbox("Better ammo rendering in pause menu", "gEnhancements.BetterAmmoRendering", true, false);
|
||||||
|
UIWidgets::Tooltip("Ammo counts in the pause menu will work correctly regardless of the position of items in the inventory");
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,23 @@ static s16 sAmmoVtxOffset[] = {
|
|||||||
0, 2, 4, 6, 99, 99, 8, 99, 10, 99, 99, 99, 99, 99, 12,
|
0, 2, 4, 6, 99, 99, 8, 99, 10, 99, 99, 99, 99, 99, 12,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static s16 sAllAmmoVtxOffset[] = {
|
||||||
|
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46
|
||||||
|
};
|
||||||
|
|
||||||
extern const char* _gAmmoDigit0Tex[];
|
extern const char* _gAmmoDigit0Tex[];
|
||||||
|
|
||||||
|
s8 ItemInSlotUsesAmmo(s16 slot) {
|
||||||
|
s16 item = gSaveContext.inventory.items[slot];
|
||||||
|
return item == ITEM_STICK ||
|
||||||
|
item == ITEM_NUT ||
|
||||||
|
item == ITEM_BOMB ||
|
||||||
|
item == ITEM_BOW ||
|
||||||
|
item == ITEM_SLINGSHOT ||
|
||||||
|
item == ITEM_BOMBCHU ||
|
||||||
|
item == ITEM_BEAN;
|
||||||
|
}
|
||||||
|
|
||||||
void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, s16 item, int slot) {
|
void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, s16 item, int slot) {
|
||||||
s16 ammo;
|
s16 ammo;
|
||||||
s16 i;
|
s16 i;
|
||||||
@ -55,7 +70,7 @@ void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx,
|
|||||||
gDPPipeSync(POLY_KAL_DISP++);
|
gDPPipeSync(POLY_KAL_DISP++);
|
||||||
|
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[slot] + 31) * 4], 4, 0);
|
gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[((CVarGetInteger("gEnhancements.BetterAmmoRendering", 0) ? sAllAmmoVtxOffset[slot] : sAmmoVtxOffset[slot]) + 31) * 4], 4, 0);
|
||||||
|
|
||||||
gDPLoadTextureBlock(POLY_KAL_DISP++, ((u8*)_gAmmoDigit0Tex[i]), G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 0,
|
gDPLoadTextureBlock(POLY_KAL_DISP++, ((u8*)_gAmmoDigit0Tex[i]), G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 0,
|
||||||
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
|
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
|
||||||
@ -64,7 +79,7 @@ void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx,
|
|||||||
gSP1Quadrangle(POLY_KAL_DISP++, 0, 2, 3, 1, 0);
|
gSP1Quadrangle(POLY_KAL_DISP++, 0, 2, 3, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[slot] + 32) * 4], 4, 0);
|
gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[((CVarGetInteger("gEnhancements.BetterAmmoRendering", 0) ? sAllAmmoVtxOffset[slot] : sAmmoVtxOffset[slot]) + 32) * 4], 4, 0);
|
||||||
|
|
||||||
gDPLoadTextureBlock(POLY_KAL_DISP++, ((u8*)_gAmmoDigit0Tex[ammo]), G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 0,
|
gDPLoadTextureBlock(POLY_KAL_DISP++, ((u8*)_gAmmoDigit0Tex[ammo]), G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 0,
|
||||||
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
|
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
|
||||||
@ -764,8 +779,10 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
|
|||||||
gDPSetCombineLERP(POLY_KAL_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE,
|
gDPSetCombineLERP(POLY_KAL_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE,
|
||||||
ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0);
|
ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0);
|
||||||
|
|
||||||
for (i = 0; i < 15; i++) {
|
u8 gBetterAmmoRendering = CVarGetInteger("gEnhancements.BetterAmmoRendering", 0);
|
||||||
if ((gAmmoItems[i] != ITEM_NONE) && (gSaveContext.inventory.items[i] != ITEM_NONE)) {
|
|
||||||
|
for (i = 0; i < (gBetterAmmoRendering ? 24 : 15); i++) {
|
||||||
|
if ((gBetterAmmoRendering ? ItemInSlotUsesAmmo(i) : gAmmoItems[i] != ITEM_NONE) && (gSaveContext.inventory.items[i] != ITEM_NONE)) {
|
||||||
KaleidoScope_DrawAmmoCount(pauseCtx, play->state.gfxCtx, gSaveContext.inventory.items[i], i);
|
KaleidoScope_DrawAmmoCount(pauseCtx, play->state.gfxCtx, gSaveContext.inventory.items[i], i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2703,6 +2703,8 @@ s16 func_80823A0C(PlayState* play, Vtx* vtx, s16 pageIndex, s16 arg3) {
|
|||||||
|
|
||||||
static s16 D_8082B11C[] = { 0, 4, 8, 12, 24, 32, 56 };
|
static s16 D_8082B11C[] = { 0, 4, 8, 12, 24, 32, 56 };
|
||||||
|
|
||||||
|
static s16 D_8082B11C_all[] = { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 96 };
|
||||||
|
|
||||||
static s16 D_8082B12C[] = { -114, 12, 44, 76 };
|
static s16 D_8082B12C[] = { -114, 12, 44, 76 };
|
||||||
|
|
||||||
static u8 D_8082B134[] = { 1, 5, 9, 13 };
|
static u8 D_8082B134[] = { 1, 5, 9, 13 };
|
||||||
@ -2825,7 +2827,7 @@ void KaleidoScope_InitVertices(PlayState* play, GraphicsContext* gfxCtx) {
|
|||||||
pauseCtx->cursorVtx[19].v.tc[1] = 0x400;
|
pauseCtx->cursorVtx[19].v.tc[1] = 0x400;
|
||||||
|
|
||||||
// 24 items, 7 "item selected" backgrounds, 14 ammo digits (2 each for 7 items) -- then 4 vertices for each
|
// 24 items, 7 "item selected" backgrounds, 14 ammo digits (2 each for 7 items) -- then 4 vertices for each
|
||||||
pauseCtx->itemVtx = Graph_Alloc(gfxCtx, (24 + 7 + 14) * 4 * sizeof(Vtx));
|
pauseCtx->itemVtx = Graph_Alloc(gfxCtx, (24 + 7 + 2 * (CVarGetInteger("gEnhancements.BetterAmmoRendering", 0) ? ARRAY_COUNT(D_8082B11C_all) : ARRAY_COUNT(D_8082B11C))) * 4 * sizeof(Vtx));
|
||||||
|
|
||||||
for (phi_t4 = 0, phi_t2 = 0, phi_t5 = 58; phi_t4 < 4; phi_t4++, phi_t5 -= 32) {
|
for (phi_t4 = 0, phi_t2 = 0, phi_t5 = 58; phi_t4 < 4; phi_t4++, phi_t5 -= 32) {
|
||||||
for (phi_t1 = -96, phi_t3 = 0; phi_t3 < 6; phi_t3++, phi_t2 += 4, phi_t1 += 32) {
|
for (phi_t1 = -96, phi_t3 = 0; phi_t3 < 6; phi_t3++, phi_t2 += 4, phi_t1 += 32) {
|
||||||
@ -2915,8 +2917,10 @@ void KaleidoScope_InitVertices(PlayState* play, GraphicsContext* gfxCtx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (phi_t3 = 0; phi_t3 < 7; phi_t3++) {
|
u8 gBetterAmmoRendering = CVarGetInteger("gEnhancements.BetterAmmoRendering", 0);
|
||||||
phi_t4 = D_8082B11C[phi_t3];
|
|
||||||
|
for (phi_t3 = 0; phi_t3 < (gBetterAmmoRendering ? ARRAY_COUNT(D_8082B11C_all) : ARRAY_COUNT(D_8082B11C)); phi_t3++) {
|
||||||
|
phi_t4 = gBetterAmmoRendering ? D_8082B11C_all[phi_t3] : D_8082B11C[phi_t3];
|
||||||
|
|
||||||
pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 2].v.ob[0] =
|
pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 2].v.ob[0] =
|
||||||
pauseCtx->itemVtx[phi_t4].v.ob[0];
|
pauseCtx->itemVtx[phi_t4].v.ob[0];
|
||||||
|
Loading…
Reference in New Issue
Block a user