mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-21 05:43:42 -07:00
Wii U: Several fixes and improvements (#1608)
* WiiU: fix more scaling issues * Wii U: batch depth reads * Wii U: remove file buffering Doesn't seem to to do much anymore * Remove "missing_gcc_functions.c" to avoid conflicts * Wii U: Fix random_device usage random_device will always be seeded with a constant seed and will return the same number sequence every time * Wii U: Improve software keyboard * Wii U: Fix console input text width
This commit is contained in:
parent
7fb8902e7f
commit
677c4845f6
18 changed files with 147 additions and 89 deletions
|
@ -385,7 +385,6 @@ set(Source_Files__src__boot
|
|||
"src/boot/idle.c"
|
||||
"src/boot/is_debug.c"
|
||||
"src/boot/logutils.c"
|
||||
"src/boot/missing_gcc_functions.c"
|
||||
"src/boot/stackcheck.c"
|
||||
"src/boot/viconfig.c"
|
||||
"src/boot/yaz0.c"
|
||||
|
|
|
@ -40,13 +40,13 @@ const char* MarginCvarList[] {
|
|||
ImVec4 GetRandomValue(int MaximumPossible){
|
||||
ImVec4 NewColor;
|
||||
unsigned long range = 255 - 0;
|
||||
#ifndef __SWITCH__
|
||||
#if !defined(__SWITCH__) && !defined(__WIIU__)
|
||||
std::random_device rd;
|
||||
std::mt19937 rng(rd());
|
||||
#else
|
||||
#else
|
||||
size_t seed = std::hash<std::string>{}(std::to_string(rand()));
|
||||
std::mt19937_64 rng(seed);
|
||||
#endif
|
||||
#endif
|
||||
std::uniform_int_distribution<int> dist(0, 255 - 1);
|
||||
|
||||
NewColor.x = (float)(dist(rng)) / 255;
|
||||
|
@ -55,9 +55,9 @@ ImVec4 GetRandomValue(int MaximumPossible){
|
|||
return NewColor;
|
||||
}
|
||||
void GetRandomColorRGB(CosmeticsColorSection* ColorSection, int SectionSize){
|
||||
#ifdef __SWITCH__
|
||||
#if defined(__SWITCH__) || defined(__WIIU__)
|
||||
srand(time(NULL));
|
||||
#endif
|
||||
#endif
|
||||
for (int i = 0; i < SectionSize; i++){
|
||||
CosmeticsColorIndividual* Element = ColorSection[i].Element;
|
||||
ImVec4 colors = Element->ModifiedColor;
|
||||
|
@ -343,7 +343,11 @@ void DrawRandomizeResetButton(const std::string Identifier, CosmeticsColorSectio
|
|||
ImGui::TableSetupColumn(Col1Name.c_str(), FlagsCell, TablesCellsWidth/2);
|
||||
ImGui::TableSetupColumn(Col2Name.c_str(), FlagsCell, TablesCellsWidth/2);
|
||||
Table_InitHeader(false);
|
||||
#ifdef __WIIU__
|
||||
if(ImGui::Button(RNG_BtnText.c_str(), ImVec2( ImGui::GetContentRegionAvail().x, 20.0f * 2.0f))){
|
||||
#else
|
||||
if(ImGui::Button(RNG_BtnText.c_str(), ImVec2( ImGui::GetContentRegionAvail().x, 20.0f))){
|
||||
#endif
|
||||
CVar_SetS32("gHudColors", 2);
|
||||
CVar_SetS32("gUseNaviCol", 1);
|
||||
CVar_SetS32("gUseKeeseCol", 1);
|
||||
|
@ -358,7 +362,11 @@ void DrawRandomizeResetButton(const std::string Identifier, CosmeticsColorSectio
|
|||
}
|
||||
UIWidgets::Tooltip(Tooltip_RNG.c_str());
|
||||
Table_NextCol();
|
||||
#ifdef __WIIU__
|
||||
if(ImGui::Button(Reset_BtnText.c_str(), ImVec2( ImGui::GetContentRegionAvail().x, 20.0f * 2.0f))){
|
||||
#else
|
||||
if(ImGui::Button(Reset_BtnText.c_str(), ImVec2( ImGui::GetContentRegionAvail().x, 20.0f))){
|
||||
#endif
|
||||
GetDefaultColorRGB(ColorSection, SectionSize);
|
||||
}
|
||||
UIWidgets::Tooltip("Enable/Disable custom Link's tunics colors\nIf disabled you will have original colors for Link's tunics.");
|
||||
|
|
|
@ -15,7 +15,11 @@ void Random_Init(uint32_t seed) {
|
|||
uint32_t Random(int min, int max) {
|
||||
if (!init) {
|
||||
//No seed given, get a random number from device to seed
|
||||
#if !defined(__SWITCH__) && !defined(__WIIU__)
|
||||
const auto seed = static_cast<uint32_t>(std::random_device{}());
|
||||
#else
|
||||
uint32_t seed = static_cast<uint32_t>(std::hash<std::string>{}(std::to_string(rand())));
|
||||
#endif
|
||||
Random_Init(seed);
|
||||
}
|
||||
std::uniform_int_distribution<uint32_t> distribution(min, max-1);
|
||||
|
|
|
@ -704,8 +704,13 @@ void LabeledComboBoxRightAligned(const char* label, const char* cvar, std::vecto
|
|||
s32 currentValue = CVar_GetS32(cvar, defaultValue);
|
||||
std::string hiddenLabel = "##" + std::string(cvar);
|
||||
ImGui::Text(label);
|
||||
#ifdef __WIIU__
|
||||
ImGui::SameLine(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize(options[currentValue].c_str()).x * 1.0f + 40.0f));
|
||||
ImGui::PushItemWidth((ImGui::CalcTextSize(options[currentValue].c_str()).x * 1.0f) + 60.0f);
|
||||
#else
|
||||
ImGui::SameLine(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize(options[currentValue].c_str()).x * 1.0f + 20.0f));
|
||||
ImGui::PushItemWidth((ImGui::CalcTextSize(options[currentValue].c_str()).x * 1.0f) + 30.0f);
|
||||
#endif
|
||||
if (ImGui::BeginCombo(hiddenLabel.c_str(), options[currentValue].c_str())) {
|
||||
for (int i = 0; i < options.size(); i++) {
|
||||
if (ImGui::Selectable(options[i].c_str())) {
|
||||
|
|
|
@ -600,7 +600,7 @@ namespace GameMenuBar {
|
|||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
|
||||
#ifdef __SWITCH__
|
||||
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 110.0f);
|
||||
#elif __WIIU__
|
||||
#elif defined(__WIIU__)
|
||||
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f * 2);
|
||||
#else
|
||||
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f);
|
||||
|
@ -1106,7 +1106,11 @@ namespace GameMenuBar {
|
|||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f));
|
||||
#ifdef __WIIU__
|
||||
static ImVec2 buttonSize(200.0f * 2.0f, 0.0f);
|
||||
#else
|
||||
static ImVec2 buttonSize(200.0f, 0.0f);
|
||||
#endif
|
||||
if (ImGui::Button(GetWindowButtonText("Cosmetics Editor", CVar_GetS32("gCosmeticsEditorEnabled", 0)).c_str(), buttonSize))
|
||||
{
|
||||
bool currentValue = CVar_GetS32("gCosmeticsEditorEnabled", 0);
|
||||
|
@ -1164,7 +1168,7 @@ namespace GameMenuBar {
|
|||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
|
||||
#ifdef __SWITCH__
|
||||
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 110.0f);
|
||||
#elif __WIIU__
|
||||
#elif defined(__WIIU__)
|
||||
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f * 2);
|
||||
#else
|
||||
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f);
|
||||
|
@ -1398,7 +1402,11 @@ namespace GameMenuBar {
|
|||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0,0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f));
|
||||
#ifdef __WIIU__
|
||||
static ImVec2 buttonSize(160.0f * 2.0f, 0.0f);
|
||||
#else
|
||||
static ImVec2 buttonSize(160.0f, 0.0f);
|
||||
#endif
|
||||
if (ImGui::Button(GetWindowButtonText("Stats", CVar_GetS32("gStatsEnabled", 0)).c_str(), buttonSize))
|
||||
{
|
||||
bool currentValue = CVar_GetS32("gStatsEnabled", 0);
|
||||
|
@ -1454,7 +1462,11 @@ namespace GameMenuBar {
|
|||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f));
|
||||
#ifdef __WIIU__
|
||||
static ImVec2 buttonSize(200.0f * 2.0f, 0.0f);
|
||||
#else
|
||||
static ImVec2 buttonSize(200.0f, 0.0f);
|
||||
#endif
|
||||
if (ImGui::Button(GetWindowButtonText("Randomizer Settings", CVar_GetS32("gRandomizerSettingsEnabled", 0)).c_str(), buttonSize))
|
||||
{
|
||||
bool currentValue = CVar_GetS32("gRandomizerSettingsEnabled", 0);
|
||||
|
|
|
@ -196,11 +196,6 @@ void SaveManager::Init() {
|
|||
if (std::filesystem::exists(sGlobalPath)) {
|
||||
std::ifstream input(sGlobalPath);
|
||||
|
||||
#ifdef __WIIU__
|
||||
alignas(0x40) char buffer[8192];
|
||||
input.rdbuf()->pubsetbuf(buffer, sizeof(buffer));
|
||||
#endif
|
||||
|
||||
nlohmann::json globalBlock;
|
||||
input >> globalBlock;
|
||||
|
||||
|
@ -522,19 +517,13 @@ void SaveManager::SaveFile(int fileNum) {
|
|||
section.second.second();
|
||||
}
|
||||
|
||||
#ifdef __SWITCH__
|
||||
#if defined(__SWITCH__) || defined(__WIIU__)
|
||||
FILE* w = fopen(GetFileName(fileNum).c_str(), "w");
|
||||
std::string json_string = baseBlock.dump(4);
|
||||
fwrite(json_string.c_str(), sizeof(char), json_string.length(), w);
|
||||
fclose(w);
|
||||
#else
|
||||
|
||||
std::ofstream output(GetFileName(fileNum));
|
||||
|
||||
#ifdef __WIIU__
|
||||
alignas(0x40) char buffer[8192];
|
||||
output.rdbuf()->pubsetbuf(buffer, sizeof(buffer));
|
||||
#endif
|
||||
output << std::setw(4) << baseBlock << std::endl;
|
||||
#endif
|
||||
|
||||
|
@ -547,13 +536,8 @@ void SaveManager::SaveGlobal() {
|
|||
globalBlock["audioSetting"] = gSaveContext.audioSetting;
|
||||
globalBlock["zTargetSetting"] = gSaveContext.zTargetSetting;
|
||||
globalBlock["language"] = gSaveContext.language;
|
||||
|
||||
std::ofstream output("Save/global.sav");
|
||||
|
||||
#ifdef __WIIU__
|
||||
alignas(0x40) char buffer[8192];
|
||||
output.rdbuf()->pubsetbuf(buffer, sizeof(buffer));
|
||||
#endif
|
||||
|
||||
output << std::setw(4) << globalBlock << std::endl;
|
||||
}
|
||||
|
||||
|
@ -563,11 +547,6 @@ void SaveManager::LoadFile(int fileNum) {
|
|||
|
||||
std::ifstream input(GetFileName(fileNum));
|
||||
|
||||
#ifdef __WIIU__
|
||||
alignas(0x40) char buffer[8192];
|
||||
input.rdbuf()->pubsetbuf(buffer, sizeof(buffer));
|
||||
#endif
|
||||
|
||||
nlohmann::json saveBlock;
|
||||
input >> saveBlock;
|
||||
if (!saveBlock.contains("version")) {
|
||||
|
@ -1558,11 +1537,6 @@ void SaveManager::ConvertFromUnversioned() {
|
|||
|
||||
std::ifstream input("oot_save.sav", std::ios::binary);
|
||||
|
||||
#ifdef __WIIU__
|
||||
alignas(0x40) char buffer[8192];
|
||||
input.rdbuf()->pubsetbuf(buffer, sizeof(buffer));
|
||||
#endif
|
||||
|
||||
std::vector<char> data(std::istreambuf_iterator<char>(input), {});
|
||||
input.close();
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@ namespace UIWidgets {
|
|||
if (PlusMinusButton) {
|
||||
#ifdef __SWITCH__
|
||||
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 110.0f);
|
||||
#elif __WIIU__
|
||||
#elif defined(__WIIU__)
|
||||
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f * 2);
|
||||
#else
|
||||
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f);
|
||||
|
@ -439,9 +439,9 @@ namespace UIWidgets {
|
|||
std::string FullName = "Random";
|
||||
FullName += MakeInvisible;
|
||||
if (ImGui::Button(FullName.c_str())) {
|
||||
#ifdef __SWITCH__
|
||||
#if defined(__SWITCH__) || defined(__WIIU__)
|
||||
srand(time(NULL));
|
||||
#endif
|
||||
#endif
|
||||
ImVec4 color = GetRandomValue(255);
|
||||
colors->x = color.x;
|
||||
colors->y = color.y;
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#include "global.h"
|
||||
|
||||
// Define functions needed for the GCC build here.
|
||||
|
||||
|
||||
|
||||
f32 __floatundisf(u32 c) {
|
||||
return (f32)c;
|
||||
}
|
||||
|
||||
f64 __floatundidf(u32 c) {
|
||||
return (f64)c;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue