* 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. * Finish implementing new menu. Rename 2ship UIWidgets to UIWidgets2 to complete facilitation of both menus working for now. * More preliminary setup * More prepwork, begin on settings options * Finish settings, add enhancements windows * Fix search function not looking past first columns. * Add dev tool windows * Finish dev tools * Add about window * Fully replace about window * Remove moved menu items from menubar, add more windows to new menu * Implement WindowButtonOptions. Add ability to not embed popout windows when not popped out. Add ability to hide the button for WindowButtons. Fix Entrance Tracker from showing when not enabled. * Fix entrance tracker settings embedded display. Fix entrance tracker settings window original size declaration. * Initial implementation of themed radio button widget. * Move "About" section to second column of general. Fix sidebar sections starting in second column. * Restore Entrance Tracker `Draw()` to allow for custom styling. * Fix combobox positioning formatting. Fix color picker end spacing. Convert everything in check tracker settings to UIWidgets2 (except color pickers and section headers). Make all tracker windows not embed. * Minor cleanup * Fix main volume defaults & mirror jitter fix removal on dev * Improve color picker with RGB/RGBA options. Not finished. * Finish creating CVarColorPicker and implement for Check Tracker background color. Fix tracker and network prefixes. * Finish check tracker settings and convert check tracker. * Port all Cheats menu except for Beta Quest * Port over Beta Quest to new menu * Remove old cheats menu * Port cutscene skips to modern menu * Port Timesaver Enhancements to new menu * Port the Items and Item Count Messages submenu * Port Difficulty Options to new Menu * Removes options that have been ported thus far. * Port "Reduced Clutter" options to new menu * Add forgotten callbacks to Hyper Enemies/Bosses * Copy StateButton to UIWidgets2, and implement custom padding for them in the tracker. * Ports some pause menu related settinga * Change tracker window active title color. Make state buttons smaller in tracker to get more info on screen. * Convert window title active theming to all windows. * Port the rest of Enhancements->Gameplay to new menu * Port the "Graphics" Enhancements to new menu * Ports Fixes over to the Modern Menu * Ported Restorations to Modern Menu * Ported Extra Modes to new menu * Port Autosave and Boot Sequence to modern menu * Cleans up some leftover data for ported buttons * Ports Enhancement Presets to new menu * Port Additional timers to new menu. Removes Enhancements from old menu * Cleans up some unused stuff * Ports Randomizer Enhancements to modern menu * Convert Item Tracker Settings. Something's wrong with the comboboxes in a second column of a table. * Fix combobox alignment and label position calculations. * Convert Entrance Tracker window. * Save Editor Info tab finished. Added `PushStyleInput` and `PushStyleTabs` for Info tab. Fixed some indentation in entrance tracker source. Added font push to tracker windows. * Increase size of all icons in save editor. * Convert flag groups to child windows for automatic sizing and border drawing. * Flags tab completed. Finished inventory tab. * Convert save editor help hover to UIWidgets2. * Various fixes and corrections * Start cosmetics editor, fix theme colors not updating * Cosmetics editor conversion progress * Remove Mac internal resolution restrictions. * Copy over advanced resolution partial and enable most options as a custom widget. * Add size to float sliders, more cosmetics editor progress * Fix incorrect cvar for notifications * Radio button & header color options, more cosmetics editor progress * Finish cosmetics editor conversion * Create and apply THEME_COLOR macro. Resides in SohGui for easy access to mSohMenu. * Move ResolutionEditor to SohGui directory. * Add labels to build info. Fix slider width calculations. * Fix some advanced resolution widget hiding. * Fully implement Advanced Resolution options. Fix graphics settings formatting. Improve slider label position calculations. Implement Clamp options on sliders. * Finish save editor. Convert save editor code to `using namespace UIWidgets2`. Fix search crashing on time splits window. Remove `SetLastItemHoverText` from `UIWidgets2`. * Unify cvar sectioning in time splits. * Add InputString and InputInt widgets, and corresponding CVar Widgets * Adds Widget Type for Inputs, not currently used. * Convert Sail to modern menu * Add Combobox that takes a vector of std::strings * Convert checkbox and combobx to new widgets * Add Tristate checkbox * Convert sliders and tristate checkboxes * Convert top half of Rando window * remove/replace remainder of UIWidgets usage in option.cpp * Converts tricks, locations, and removes old UIWidgets refs * Fix windows build errors * Remove Tri-State checkboxes * Use PushStyleInput instead of PushStyleSlider lol oops didn't realize it was a thing in Ship. * Rebase and address review comments * Convert Crowd Control to modern menu. * Fix build error * Audio editor progress * Re-add CVar SaveOnNextFrame calls to Resolution Editor. Remove old Resolution Editor files. * Convert TimeSplits to new menu. Fix a few enum warnings. * Decrease padding on Arrow Buttons * Audio editor + gameplay stats done * Give Randomizer Menu more screen real-estate * Port plandomizer menu * Fix slider width calculation and allow combobox LabelPosition::None * Fix None labelPos and slider width for inline labels * Fix all slider value label insertions. Convert Collision Viewer. * Minor Collision Viewer enum change. Convert Actor Viewer. * Theme/convert Message Viewer. * Add font to Message Viewer. Theme Value Viewer. * DL Viewer and SohModals themed. * Convert Input Viewer. * Missed some color settings in Input Viewer. Removed UIWidgets references from Controller Config, and restored SoH version. * Remove UIWidgets.hpp include from multiple files. * Completely remove old UIWidgets. Rename UIWidgets2 to UIWidgets. Move Accessibility and Language options to new menu. * Fix Gfx Debugger not showing up. Remove menubar registration. * Fix clearCvars references. * Fix passing std::string to const char* argument. * enum name spacing --------- Co-authored-by: aMannus <mannusmenting@gmail.com> Co-authored-by: Christopher Leggett <chris@leggett.dev>
116 lines
4.4 KiB
C++
116 lines
4.4 KiB
C++
#include "ShipUtils.h"
|
|
#include <libultraship/libultraship.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));
|
|
// }
|
|
//}
|