forked from HarbourMasters/Shipwright
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add menu files, hook menu up to window system.
Temporarily rename new menu's UIWidgets to UIWidgets2 to allow both menu systems to coexist temporarily.
- Loading branch information
1 parent
1f65bde
commit 0a2d2b7
Showing
12 changed files
with
3,340 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#include "ShipUtils.h" | ||
#include <libultraship/libultraship.h> | ||
//#include "assets/2s2h_assets.h" | ||
|
||
extern "C" { | ||
#include "z64.h" | ||
#include "functions.h" | ||
#include "macros.h" | ||
|
||
extern float OTRGetAspectRatio(); | ||
|
||
extern f32 sNESFontWidths[160]; | ||
extern const char* fontTbl[156]; | ||
//extern TexturePtr gItemIcons[131]; | ||
//extern TexturePtr gQuestIcons[14]; | ||
//extern TexturePtr gBombersNotebookPhotos[24]; | ||
} | ||
|
||
constexpr f32 fourByThree = 4.0f / 3.0f; | ||
|
||
// Gets the additional ratio of the screen compared to the original 4:3 ratio, clamping to 1 if smaller | ||
extern "C" f32 Ship_GetExtendedAspectRatioMultiplier() { | ||
f32 currentRatio = OTRGetAspectRatio(); | ||
return MAX(currentRatio / fourByThree, 1.0f); | ||
} | ||
|
||
// Enables Extended Culling options on specific actors by applying an inverse ratio of the draw distance slider | ||
// to the projected Z value of the actor. This tricks distance checks without having to replace hardcoded values. | ||
// Requires that Ship_ExtendedCullingActorRestoreProjectedPos is called within the same function scope. | ||
extern "C" void Ship_ExtendedCullingActorAdjustProjectedZ(Actor* actor) { | ||
s32 multiplier = CVarGetInteger("gEnhancements.Graphics.IncreaseActorDrawDistance", 1); | ||
multiplier = MAX(multiplier, 1); | ||
if (multiplier > 1) { | ||
actor->projectedPos.z /= multiplier; | ||
} | ||
} | ||
|
||
// Enables Extended Culling options on specific actors by applying an inverse ratio of the widescreen aspect ratio | ||
// to the projected X value of the actor. This tricks distance checks without having to replace hardcoded values. | ||
// Requires that Ship_ExtendedCullingActorRestoreProjectedPos is called within the same function scope. | ||
extern "C" void Ship_ExtendedCullingActorAdjustProjectedX(Actor* actor) { | ||
if (CVarGetInteger("gEnhancements.Graphics.ActorCullingAccountsForWidescreen", 0)) { | ||
f32 ratioAdjusted = Ship_GetExtendedAspectRatioMultiplier(); | ||
actor->projectedPos.x /= ratioAdjusted; | ||
} | ||
} | ||
|
||
// Restores the projectedPos values on the actor after modifications from the Extended Culling hacks | ||
//extern "C" void Ship_ExtendedCullingActorRestoreProjectedPos(PlayState* play, Actor* actor) { | ||
// f32 invW = 0.0f; | ||
// Actor_GetProjectedPos(play, &actor->world.pos, &actor->projectedPos, &invW); | ||
//} | ||
|
||
extern "C" bool Ship_IsCStringEmpty(const char* str) { | ||
return str == NULL || str[0] == '\0'; | ||
} | ||
|
||
// Build vertex coordinates for a quad command | ||
// In order of top left, top right, bottom left, then bottom right | ||
// Supports flipping the texture horizontally | ||
extern "C" void Ship_CreateQuadVertexGroup(Vtx* vtxList, s32 xStart, s32 yStart, s32 width, s32 height, u8 flippedH) { | ||
vtxList[0].v.ob[0] = xStart; | ||
vtxList[0].v.ob[1] = yStart; | ||
vtxList[0].v.tc[0] = (flippedH ? width : 0) << 5; | ||
vtxList[0].v.tc[1] = 0 << 5; | ||
|
||
vtxList[1].v.ob[0] = xStart + width; | ||
vtxList[1].v.ob[1] = yStart; | ||
vtxList[1].v.tc[0] = (flippedH ? width * 2 : width) << 5; | ||
vtxList[1].v.tc[1] = 0 << 5; | ||
|
||
vtxList[2].v.ob[0] = xStart; | ||
vtxList[2].v.ob[1] = yStart + height; | ||
vtxList[2].v.tc[0] = (flippedH ? width : 0) << 5; | ||
vtxList[2].v.tc[1] = height << 5; | ||
|
||
vtxList[3].v.ob[0] = xStart + width; | ||
vtxList[3].v.ob[1] = yStart + height; | ||
vtxList[3].v.tc[0] = (flippedH ? width * 2 : width) << 5; | ||
vtxList[3].v.tc[1] = height << 5; | ||
} | ||
|
||
extern "C" f32 Ship_GetCharFontWidthNES(u8 character) { | ||
u8 adjustedChar = character - ' '; | ||
|
||
if (adjustedChar >= ARRAY_COUNTU(sNESFontWidths)) { | ||
return 0.0f; | ||
} | ||
|
||
return sNESFontWidths[adjustedChar]; | ||
} | ||
|
||
//extern "C" TexturePtr Ship_GetCharFontTextureNES(u8 character) { | ||
// u8 adjustedChar = character - ' '; | ||
// | ||
// if (adjustedChar >= ARRAY_COUNTU(sNESFontWidths)) { | ||
// return (TexturePtr)gEmptyTexture; | ||
// } | ||
// | ||
// return (TexturePtr)fontTbl[adjustedChar]; | ||
//} | ||
|
||
//void LoadGuiTextures() { | ||
// for (TexturePtr entry : gItemIcons) { | ||
// const char* path = static_cast<const char*>(entry); | ||
// Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(path, path, ImVec4(1, 1, 1, 1)); | ||
// } | ||
// for (TexturePtr entry : gQuestIcons) { | ||
// const char* path = static_cast<const char*>(entry); | ||
// Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(path, path, ImVec4(1, 1, 1, 1)); | ||
// } | ||
// for (TexturePtr entry : gBombersNotebookPhotos) { | ||
// const char* path = static_cast<const char*>(entry); | ||
// Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(path, path, ImVec4(1, 1, 1, 1)); | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef SHIP_UTILS_H | ||
#define SHIP_UTILS_H | ||
|
||
#include <libultraship/libultraship.h> | ||
//#include "PR/ultratypes.h" | ||
|
||
#ifdef __cplusplus | ||
|
||
void LoadGuiTextures(); | ||
|
||
extern "C" { | ||
#endif | ||
|
||
struct PlayState; | ||
struct Actor; | ||
|
||
f32 Ship_GetExtendedAspectRatioMultiplier(); | ||
void Ship_ExtendedCullingActorAdjustProjectedZ(Actor* actor); | ||
void Ship_ExtendedCullingActorAdjustProjectedX(Actor* actor); | ||
void Ship_ExtendedCullingActorRestoreProjectedPos(PlayState* play, Actor* actor); | ||
|
||
bool Ship_IsCStringEmpty(const char* str); | ||
void Ship_CreateQuadVertexGroup(Vtx* vtxList, s32 xStart, s32 yStart, s32 width, s32 height, u8 flippedH); | ||
f32 Ship_GetCharFontWidthNES(u8 character); | ||
//TexturePtr Ship_GetCharFontTextureNES(u8 character); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // SHIP_UTILS_H |
Oops, something went wrong.