Fixed to work with latest libultra

This commit is contained in:
KiritoDv
2024-05-08 13:01:48 -06:00
parent 9195394e7a
commit a09909ac23
29 changed files with 141 additions and 140 deletions
+8 -7
View File
@@ -1,6 +1,7 @@
#include "Engine.h"
#include "StringHelper.h"
#include "ui/ImguiUI.h"
#include "ZAPDUtils/Utils/StringHelper.h"
#include "libultraship/src/Context.h"
#include "resource/type/ResourceType.h"
#include "resource/importers/GenericArrayFactory.h"
@@ -22,13 +23,13 @@ GameEngine* GameEngine::Instance;
GameEngine::GameEngine() {
std::vector<std::string> OTRFiles;
if (const std::string cube_path = LUS::Context::GetPathRelativeToAppDirectory("mkcube.otr"); std::filesystem::exists(cube_path)) {
if (const std::string cube_path = Ship::Context::GetPathRelativeToAppDirectory("mkcube.otr"); std::filesystem::exists(cube_path)) {
OTRFiles.push_back(cube_path);
}
if (const std::string sm64_otr_path = LUS::Context::GetPathRelativeToAppBundle("sm64.otr"); std::filesystem::exists(sm64_otr_path)) {
if (const std::string sm64_otr_path = Ship::Context::GetPathRelativeToAppBundle("sm64.otr"); std::filesystem::exists(sm64_otr_path)) {
OTRFiles.push_back(sm64_otr_path);
}
if (const std::string patches_path = LUS::Context::GetPathRelativeToAppDirectory("mods"); !patches_path.empty() && std::filesystem::exists(patches_path)) {
if (const std::string patches_path = Ship::Context::GetPathRelativeToAppDirectory("mods"); !patches_path.empty() && std::filesystem::exists(patches_path)) {
if (std::filesystem::is_directory(patches_path)) {
for (const auto&p: std::filesystem::recursive_directory_iterator(patches_path)) {
if (StringHelper::IEquals(p.path().extension().string(), ".otr")) {
@@ -38,7 +39,7 @@ GameEngine::GameEngine() {
}
}
this->context = LUS::Context::CreateInstance("Spaghettify", "skart64", "spaghettify.cfg.json", OTRFiles, {}, 3);
this->context = Ship::Context::CreateInstance("Spaghettify", "skart64", "spaghettify.cfg.json", OTRFiles, {}, 3);
auto loader = context->GetResourceManager()->GetResourceLoader();
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryVec3fV0>(), RESOURCE_FORMAT_BINARY, "Vec3f", static_cast<uint32_t>(SF64::ResourceType::Vec3f), 0);
@@ -62,7 +63,7 @@ bool ShouldClearTextureCacheAtEndOfFrame = false;
void GameEngine::StartFrame() const{
using LUS::KbScancode;
using Ship::KbScancode;
const int32_t dwScancode = this->context->GetWindow()->GetLastScancode();
this->context->GetWindow()->SetLastScancode(-1);
@@ -99,7 +100,7 @@ void GameEngine::ProcessGfxCommands(Gfx* commands) {
}
extern "C" uint32_t GameEngine_GetSampleRate() {
auto player = LUS::Context::GetInstance()->GetAudio()->GetAudioPlayer();
auto player = Ship::Context::GetInstance()->GetAudio()->GetAudioPlayer();
if (player == nullptr) {
return 0;
}
+1 -1
View File
@@ -18,7 +18,7 @@ class GameEngine {
public:
static GameEngine* Instance;
std::shared_ptr<LUS::Context> context;
std::shared_ptr<Ship::Context> context;
GameEngine();
static void Create();
+6 -6
View File
@@ -10,12 +10,12 @@ extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) {
char* imgData = (char*)dl;
if (GameEngine_OTRSigCheck(imgData) == 1) {
auto resource = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(imgData);
auto resource = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(imgData);
auto res = std::static_pointer_cast<LUS::DisplayList>(resource);
dl = &res->Instructions[0];
dl->words.trace.file = imgData;
dl->words.trace.idx = 0;
dl->words.trace.valid = true;
// dl->words.trace.file = imgData;
// dl->words.trace.idx = 0;
// dl->words.trace.valid = true;
}
__gSPDisplayList(pkt, dl);
@@ -34,7 +34,7 @@ extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) {
auto data = reinterpret_cast<char*>(texAddr);
if (texAddr != 0 && GameEngine_OTRSigCheck(data)) {
const auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(data);
const auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(data);
const auto type = static_cast<LUS::ResourceType>(res->GetInitData()->Type);
switch(type) {
@@ -51,4 +51,4 @@ extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) {
}
__gSPInvalidateTexCache(pkt, texAddr);
}
}
@@ -3,13 +3,13 @@
#include "spdlog/spdlog.h"
namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryGenericArrayV0::ReadResource(std::shared_ptr<LUS::File> file) {
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryGenericArrayV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) {
return nullptr;
}
auto arr = std::make_shared<GenericArray>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto type = reader->ReadUInt32();
@@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h"
namespace SF64 {
class ResourceFactoryBinaryGenericArrayV0 : public LUS::ResourceFactoryBinary {
class ResourceFactoryBinaryGenericArrayV0 : public Ship::ResourceFactoryBinary {
public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
};
}; // namespace LUS
+1 -1
View File
@@ -9,7 +9,7 @@ template <typename T> T LoadChild(uint64_t crc) {
if (path == nullptr) {
return nullptr;
}
auto asset = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path);
auto asset = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path);
return asset ? static_cast<T>(asset->GetRawPointer()) : nullptr;
}
}
+2 -2
View File
@@ -3,13 +3,13 @@
#include "spdlog/spdlog.h"
namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryVec3fV0::ReadResource(std::shared_ptr<LUS::File> file) {
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryVec3fV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) {
return nullptr;
}
auto vec = std::make_shared<Vec3fArray>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto vecCount = reader->ReadUInt32();
+2 -2
View File
@@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h"
namespace SF64 {
class ResourceFactoryBinaryVec3fV0 : public LUS::ResourceFactoryBinary {
class ResourceFactoryBinaryVec3fV0 : public Ship::ResourceFactoryBinary {
public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
};
}; // namespace LUS
+2 -2
View File
@@ -3,13 +3,13 @@
#include "spdlog/spdlog.h"
namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryVec3sV0::ReadResource(std::shared_ptr<LUS::File> file) {
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryVec3sV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) {
return nullptr;
}
auto vec = std::make_shared<Vec3sArray>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto vecCount = reader->ReadUInt32();
+2 -2
View File
@@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h"
namespace SF64 {
class ResourceFactoryBinaryVec3sV0 : public LUS::ResourceFactoryBinary {
class ResourceFactoryBinaryVec3sV0 : public Ship::ResourceFactoryBinary {
public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
};
}; // namespace LUS
+2 -2
View File
@@ -21,11 +21,11 @@ struct AnimationData {
/* 0x08 */ JointKey* jointKey;
}; // size = 0xC
class Animation : public LUS::Resource<AnimationData> {
class Animation : public Ship::Resource<AnimationData> {
public:
using Resource::Resource;
Animation() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {}
Animation() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
AnimationData* GetPointer();
size_t GetPointerSize();
+2 -2
View File
@@ -19,11 +19,11 @@ struct ColPolyData {
ColPolyData(Vec3s tri, int16_t unk_06, Vec3s norm, int16_t unk_0E, int32_t dist) : tri(std::move(tri)), unk_06(unk_06), norm(std::move(norm)), unk_0E(unk_0E), dist(dist) {}
}; // size = 0x14
class ColPoly : public LUS::Resource<ColPolyData> {
class ColPoly : public Ship::Resource<ColPolyData> {
public:
using Resource::Resource;
ColPoly() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {}
ColPoly() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
ColPolyData* GetPointer();
size_t GetPointerSize();
+2 -2
View File
@@ -26,11 +26,11 @@ struct EnvSettingsData {
/* 0x40 */ int32_t ambB;
};
class EnvSettings : public LUS::Resource<EnvSettingsData> {
class EnvSettings : public Ship::Resource<EnvSettingsData> {
public:
using Resource::Resource;
EnvSettings() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {}
EnvSettings() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
EnvSettingsData* GetPointer();
size_t GetPointerSize();
+2 -2
View File
@@ -40,11 +40,11 @@ enum class ArrayType {
u8, s8, u16, s16, u32, s32, u64, f32, f64, Vec2f, Vec3f, Vec3s, Vec3i, Vec4f, Vec4s,
};
class GenericArray : public LUS::Resource<uint8_t> {
class GenericArray : public Ship::Resource<uint8_t> {
public:
using Resource::Resource;
GenericArray() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {}
GenericArray() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
uint8_t* GetPointer();
size_t GetPointerSize();
+1 -1
View File
@@ -4,7 +4,7 @@
#include <Resource.h>
namespace SF64 {
class Hitbox : public LUS::Resource<float> {
class Hitbox : public Ship::Resource<float> {
public:
using Resource::Resource;
+2 -2
View File
@@ -23,11 +23,11 @@ struct LimbData {
/* 0x01C */ LimbData* child;
}; // size = 0x20
class Limb : public LUS::Resource<LimbData> {
class Limb : public Ship::Resource<LimbData> {
public:
using Resource::Resource;
Limb() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {}
Limb() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
LimbData* GetPointer();
size_t GetPointerSize();
+2 -2
View File
@@ -10,7 +10,7 @@ typedef struct {
u16* msgPtr;
} MsgLookup;
class Message : public LUS::Resource<void> {
class Message : public Ship::Resource<void> {
public:
using Resource::Resource;
@@ -20,7 +20,7 @@ class Message : public LUS::Resource<void> {
std::vector<uint16_t> mMessage;
};
class MessageLookup : public LUS::Resource<MsgLookup> {
class MessageLookup : public Ship::Resource<MsgLookup> {
public:
using Resource::Resource;
+2 -2
View File
@@ -16,11 +16,11 @@ struct ObjectInitData {
/* 0x10 */ int16_t id;
}; // size = 0x14
class ObjectInit : public LUS::Resource<ObjectInitData> {
class ObjectInit : public Ship::Resource<ObjectInitData> {
public:
using Resource::Resource;
ObjectInit() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {}
ObjectInit() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
ObjectInitData* GetPointer();
size_t GetPointerSize();
+2 -2
View File
@@ -4,7 +4,7 @@
#include <Resource.h>
namespace SF64 {
class Script : public LUS::Resource<uint16_t*> {
class Script : public Ship::Resource<uint16_t*> {
public:
using Resource::Resource;
@@ -14,7 +14,7 @@ class Script : public LUS::Resource<uint16_t*> {
std::vector<uint16_t*> mScripts;
};
class ScriptCMDs : public LUS::Resource<uint16_t> {
class ScriptCMDs : public Ship::Resource<uint16_t> {
public:
using Resource::Resource;
+2 -2
View File
@@ -5,11 +5,11 @@
#include <Resource.h>
namespace SF64 {
class Skeleton : public LUS::Resource<LimbData*> {
class Skeleton : public Ship::Resource<LimbData*> {
public:
using Resource::Resource;
Skeleton() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {}
Skeleton() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
LimbData** GetPointer();
size_t GetPointerSize();
+2 -2
View File
@@ -11,11 +11,11 @@ struct Vec3fData {
Vec3fData(float x, float y, float z) : x(x), y(y), z(z) {}
};
class Vec3fArray : public LUS::Resource<Vec3fData> {
class Vec3fArray : public Ship::Resource<Vec3fData> {
public:
using Resource::Resource;
Vec3fArray() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {}
Vec3fArray() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
Vec3fData* GetPointer();
size_t GetPointerSize();
+2 -2
View File
@@ -11,11 +11,11 @@ struct Vec3sData {
Vec3sData(int16_t x, int16_t y, int16_t z) : x(x), y(y), z(z) {}
};
class Vec3sArray : public LUS::Resource<Vec3sData> {
class Vec3sArray : public Ship::Resource<Vec3sData> {
public:
using Resource::Resource;
Vec3sArray() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {}
Vec3sArray() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
Vec3sData* GetPointer();
size_t GetPointerSize();
+54 -54
View File
@@ -3,11 +3,11 @@
#include "ResolutionEditor.h"
#include <spdlog/spdlog.h>
#include <ImGui/imgui.h>
#include <imgui.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include "libultraship/src/Context.h"
#include <ImGui/imgui_internal.h>
#include <imgui_internal.h>
#include <libultraship/libultraship.h>
#include <Fast3D/gfx_pc.h>
#include "port/Engine.h"
@@ -18,14 +18,14 @@ extern "C" {
namespace GameUI {
std::shared_ptr<GameMenuBar> mGameMenuBar;
std::shared_ptr<LUS::GuiWindow> mConsoleWindow;
std::shared_ptr<LUS::GuiWindow> mStatsWindow;
std::shared_ptr<LUS::GuiWindow> mInputEditorWindow;
std::shared_ptr<LUS::GuiWindow> mGfxDebuggerWindow;
std::shared_ptr<Ship::GuiWindow> mConsoleWindow;
std::shared_ptr<Ship::GuiWindow> mStatsWindow;
std::shared_ptr<Ship::GuiWindow> mInputEditorWindow;
std::shared_ptr<Ship::GuiWindow> mGfxDebuggerWindow;
std::shared_ptr<AdvancedResolutionSettings::AdvancedResolutionSettingsWindow> mAdvancedResolutionSettingsWindow;
void SetupGuiElements() {
auto gui = LUS::Context::GetInstance()->GetWindow()->GetGui();
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
auto& style = ImGui::GetStyle();
style.FramePadding = ImVec2(4.0f, 6.0f);
@@ -112,28 +112,28 @@ void DrawSettingsMenu(){
// audio_set_player_volume(SEQ_PLAYER_ENV, CVarGetFloat("gEnvironmentVolume", 1.0f));
// }
//
// static std::unordered_map<LUS::AudioBackend, const char*> audioBackendNames = {
// { LUS::AudioBackend::WASAPI, "Windows Audio Session API" },
// { LUS::AudioBackend::PULSE, "PulseAudio" },
// { LUS::AudioBackend::SDL, "SDL" },
// static std::unordered_map<Ship::AudioBackend, const char*> audioBackendNames = {
// { Ship::AudioBackend::WASAPI, "Windows Audio Session API" },
// { Ship::AudioBackend::PULSE, "PulseAudio" },
// { Ship::AudioBackend::SDL, "SDL" },
// };
//
// ImGui::Text("Audio API (Needs reload)");
// auto currentAudioBackend = LUS::Context::GetInstance()->GetAudio()->GetAudioBackend();
// auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetAudioBackend();
//
// if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
// if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
// UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f);
// }
// if (ImGui::BeginCombo("##AApi", audioBackendNames[currentAudioBackend])) {
// for (uint8_t i = 0; i < LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) {
// auto backend = LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i];
// for (uint8_t i = 0; i < Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) {
// auto backend = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i];
// if (ImGui::Selectable(audioBackendNames[backend], backend == currentAudioBackend)) {
// LUS::Context::GetInstance()->GetAudio()->SetAudioBackend(backend);
// Ship::Context::GetInstance()->GetAudio()->SetAudioBackend(backend);
// }
// }
// ImGui::EndCombo();
// }
// if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
// if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
// UIWidgets::ReEnableComponent("");
// }
//
@@ -175,23 +175,23 @@ void DrawSettingsMenu(){
UIWidgets::Spacer(0);
// Previously was running every frame, and nothing was setting it? Maybe a bad copy/paste?
// LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1));
// Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1));
// UIWidgets::Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but effective form of anti-aliasing");
#ifndef __WIIU__
if (UIWidgets::CVarSliderInt("MSAA: %d", "gMSAAValue", 1, 8, 1, {
.tooltip = "Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel"
})) {
LUS::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1));
Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1));
}
#endif
{ // FPS Slider
const int minFps = 30;
static int maxFps;
if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) {
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) {
maxFps = 360;
} else {
maxFps = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
}
int currentFps = 0;
#ifdef __WIIU__
@@ -253,15 +253,15 @@ void DrawSettingsMenu(){
currentFps = 60;
}
CVarSetInteger("gInterpolationFPS", currentFps);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
#else
bool matchingRefreshRate =
CVarGetInteger("gMatchRefreshRate", 0) && LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() != LUS::WindowBackend::DX11;
CVarGetInteger("gMatchRefreshRate", 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::DX11;
UIWidgets::CVarSliderInt((currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", "gInterpolationFPS", minFps, maxFps, 1, {
.disabled = matchingRefreshRate
});
#endif
if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) {
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) {
UIWidgets::Tooltip(
"Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely "
"visual and does not impact game logic, execution of glitches etc.\n\n"
@@ -275,13 +275,13 @@ void DrawSettingsMenu(){
}
} // END FPS Slider
if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) {
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) {
UIWidgets::Spacer(0);
if (ImGui::Button("Match Refresh Rate")) {
int hz = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
if (hz >= 30 && hz <= 360) {
CVarSetInteger("gInterpolationFPS", hz);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
}
}
} else {
@@ -290,7 +290,7 @@ void DrawSettingsMenu(){
UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate");
if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) {
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) {
UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS",
"##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false);
UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time.");
@@ -299,51 +299,51 @@ void DrawSettingsMenu(){
UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f);
static std::unordered_map<LUS::WindowBackend, const char*> windowBackendNames = {
{ LUS::WindowBackend::DX11, "DirectX" },
{ LUS::WindowBackend::SDL_OPENGL, "OpenGL"},
{ LUS::WindowBackend::SDL_METAL, "Metal" },
{ LUS::WindowBackend::GX2, "GX2"}
static std::unordered_map<Ship::WindowBackend, const char*> windowBackendNames = {
{ Ship::WindowBackend::DX11, "DirectX" },
{ Ship::WindowBackend::SDL_OPENGL, "OpenGL"},
{ Ship::WindowBackend::SDL_METAL, "Metal" },
{ Ship::WindowBackend::GX2, "GX2"}
};
ImGui::Text("Renderer API (Needs reload)");
LUS::WindowBackend runningWindowBackend = LUS::Context::GetInstance()->GetWindow()->GetWindowBackend();
LUS::WindowBackend configWindowBackend;
int configWindowBackendId = LUS::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1);
if (configWindowBackendId != -1 && configWindowBackendId < static_cast<int>(LUS::WindowBackend::BACKEND_COUNT)) {
configWindowBackend = static_cast<LUS::WindowBackend>(configWindowBackendId);
Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend();
Ship::WindowBackend configWindowBackend;
int configWindowBackendId = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1);
if (configWindowBackendId != -1 && configWindowBackendId < static_cast<int>(Ship::WindowBackend::BACKEND_COUNT)) {
configWindowBackend = static_cast<Ship::WindowBackend>(configWindowBackendId);
} else {
configWindowBackend = runningWindowBackend;
}
if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) {
if (Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) {
UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f);
}
if (ImGui::BeginCombo("##RApi", windowBackendNames[configWindowBackend])) {
for (size_t i = 0; i < LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size(); i++) {
auto backend = LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i];
for (size_t i = 0; i < Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size(); i++) {
auto backend = Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i];
if (ImGui::Selectable(windowBackendNames[backend], backend == configWindowBackend)) {
LUS::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast<int>(backend));
LUS::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name",
Ship::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast<int>(backend));
Ship::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name",
windowBackendNames[backend]);
LUS::Context::GetInstance()->GetConfig()->Save();
Ship::Context::GetInstance()->GetConfig()->Save();
}
}
ImGui::EndCombo();
}
if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) {
if (Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) {
UIWidgets::ReEnableComponent("");
}
if (LUS::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) {
if (Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) {
UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false);
}
if (LUS::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) {
if (Ship::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) {
UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", "gSdlWindowedFullscreen", true, false);
}
if (LUS::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) {
if (Ship::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) {
UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows", "gEnableMultiViewports", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true);
UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect.");
}
@@ -355,7 +355,7 @@ void DrawSettingsMenu(){
UIWidgets::Spacer(0);
LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings();
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings();
ImGui::EndMenu();
}
@@ -364,11 +364,11 @@ void DrawSettingsMenu(){
void DrawMenuBarIcon() {
static bool gameIconLoaded = false;
if (!gameIconLoaded) {
// LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTexture("Game_Icon", "textures/icons/gIcon.png");
// Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTexture("Game_Icon", "textures/icons/gIcon.png");
gameIconLoaded = false;
}
if (LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon")) {
if (Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon")) {
#ifdef __SWITCH__
ImVec2 iconSize = ImVec2(20.0f, 20.0f);
float posScale = 1.0f;
@@ -380,7 +380,7 @@ void DrawMenuBarIcon() {
float posScale = 1.5f;
#endif
ImGui::SetCursorPos(ImVec2(5, 2.5f) * posScale);
ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), iconSize);
ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), iconSize);
ImGui::SameLine();
ImGui::SetCursorPos(ImVec2(25, 0) * posScale);
}
@@ -400,11 +400,11 @@ void DrawGameMenu() {
#if !defined(__SWITCH__) && !defined(__WIIU__)
if (UIWidgets::MenuItem("Toggle Fullscreen", "F9")) {
LUS::Context::GetInstance()->GetWindow()->ToggleFullscreen();
Ship::Context::GetInstance()->GetWindow()->ToggleFullscreen();
}
if (UIWidgets::MenuItem("Quit")) {
LUS::Context::GetInstance()->GetWindow()->Close();
Ship::Context::GetInstance()->GetWindow()->Close();
}
#endif
ImGui::EndMenu();
+2 -2
View File
@@ -6,9 +6,9 @@ namespace GameUI {
void Destroy();
}
class GameMenuBar : public LUS::GuiMenuBar {
class GameMenuBar : public Ship::GuiMenuBar {
public:
using LUS::GuiMenuBar::GuiMenuBar;
using Ship::GuiMenuBar::GuiMenuBar;
protected:
void DrawElement() override;
void InitElement() override {};
+3 -3
View File
@@ -2,7 +2,7 @@
#include "UIWidgets.h"
#include "libultraship/src/Context.h"
#include <ImGui/imgui.h>
#include <imgui.h>
#include <libultraship/libultraship.h>
#include <graphic/Fast3D/gfx_pc.h>
@@ -40,7 +40,7 @@ namespace AdvancedResolutionSettings {
const int pixelCountPresets[] = { 480, 240, 480, 720, 960, 1200, 1440, 1080, 2160, 480 };
const int default_pixelCount = 0; // Default combo list option
const uint32_t minVerticalPixelCount = 240; // see: LUS::AdvancedResolution()
const uint32_t minVerticalPixelCount = 240; // see: Ship::AdvancedResolution()
const uint32_t maxVerticalPixelCount = 4320;
const unsigned short default_maxIntegerScaleFactor = 6; // Default size of Integer scale factor slider.
@@ -104,7 +104,7 @@ namespace AdvancedResolutionSettings {
(CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) &&
CVarGetInteger("gAdvancedResolution.Enabled", 0)) ||
CVarGetInteger("gLowResMode", 0))) {
LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1));
Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1));
}
UIWidgets::Tooltip("Multiplies your output resolution by the value entered, as a more intensive but effective "
"form of anti-aliasing"); // Description pulled from SohMenuBar.cpp
+2 -2
View File
@@ -2,7 +2,7 @@
#include <libultraship/libultraship.h>
namespace AdvancedResolutionSettings {
class AdvancedResolutionSettingsWindow : public LUS::GuiWindow {
class AdvancedResolutionSettingsWindow : public Ship::GuiWindow {
private:
bool IsDroppingFrames();
@@ -10,7 +10,7 @@ namespace AdvancedResolutionSettings {
bool IsBoolArrayTrue(bool*);
public:
using LUS::GuiWindow::GuiWindow;
using Ship::GuiWindow::GuiWindow;
void InitElement() override;
void DrawElement() override;
+20 -20
View File
@@ -9,8 +9,8 @@
#include "libultraship/src/Context.h"
#include <ImGui/imgui.h>
#include <ImGui/imgui_internal.h>
#include <imgui.h>
#include <imgui_internal.h>
#include <libultraship/libultraship.h>
#include <libultraship/libultra/types.h>
@@ -205,7 +205,7 @@ namespace UIWidgets {
bool val = (bool)CVarGetInteger(cvarName, defaultValue);
if (CustomCheckbox(text, &val, disabled, disabledGraphic)) {
CVarSetInteger(cvarName, val);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
changed = true;
}
@@ -245,7 +245,7 @@ namespace UIWidgets {
CVarSetInteger(cvarName, i);
selected = i;
changed = true;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
}
}
}
@@ -258,7 +258,7 @@ namespace UIWidgets {
if (disabledValue >= 0 && selected != disabledValue) {
CVarSetInteger(cvarName, disabledValue);
changed = true;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
}
}
@@ -347,7 +347,7 @@ namespace UIWidgets {
if (changed) {
CVarSetInteger(cvarName, val);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
}
return changed;
@@ -423,7 +423,7 @@ namespace UIWidgets {
if (changed) {
CVarSetFloat(cvarName, val);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
}
return changed;
@@ -470,7 +470,7 @@ namespace UIWidgets {
int val = CVarGetInteger(cvarName, 0);
if (ImGui::RadioButton(make_invisible.c_str(), id == val)) {
CVarSetInteger(cvarName, id);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
ret = true;
}
ImGui::SameLine();
@@ -497,7 +497,7 @@ namespace UIWidgets {
CVarSetColor(cvarName, colorsRGBA);
CVarSetInteger(Cvar_RBM.c_str(), 0); //On click disable rainbow mode.
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
changed = true;
}
Tooltip("Revert colors to the game's original colors (GameCube version)\nOverwrites previously chosen color");
@@ -673,7 +673,7 @@ namespace UIWidgets {
return dirty;
}
bool WindowButton(const char* label, const char* cvarName, std::shared_ptr<LUS::GuiWindow> windowPtr, const ButtonOptions& options) {
bool WindowButton(const char* label, const char* cvarName, std::shared_ptr<Ship::GuiWindow> windowPtr, const ButtonOptions& options) {
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0));
std::string buttonText = label;
bool dirty = false;
@@ -763,7 +763,7 @@ namespace UIWidgets {
bool value = (bool)CVarGetInteger(cvarName, options.defaultValue);
if (Checkbox(label, &value, options)) {
CVarSetInteger(cvarName, value);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true;
}
return dirty;
@@ -867,7 +867,7 @@ namespace UIWidgets {
uint8_t value = (uint8_t)CVarGetInteger(cvarName, options.defaultIndex);
if (Combobox(label, &value, comboArray, options)) {
CVarSetInteger(cvarName, value);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true;
}
return dirty;
@@ -914,7 +914,7 @@ namespace UIWidgets {
if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) {
*value -= options.step;
if (*value < min) *value = min;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true;
}
ImGui::SameLine(0, 3.0f);
@@ -923,7 +923,7 @@ namespace UIWidgets {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
}
if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_S32, value, &min, &max, options.format, options.flags)) {
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true;
}
if (options.showButtons) {
@@ -932,7 +932,7 @@ namespace UIWidgets {
if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) {
*value += options.step;
if (*value > max) *value = max;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true;
}
}
@@ -953,7 +953,7 @@ namespace UIWidgets {
int32_t value = CVarGetInteger(cvarName, defaultValue);
if (SliderInt(label, &value, min, max, options)) {
CVarSetInteger(cvarName, value);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true;
}
return dirty;
@@ -985,7 +985,7 @@ namespace UIWidgets {
if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) {
*value -= options.step;
if (*value < min) *value = min;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true;
}
ImGui::SameLine(0, 3.0f);
@@ -995,7 +995,7 @@ namespace UIWidgets {
}
if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_Float, &valueToDisplay, &minToDisplay, &maxToDisplay, options.format, options.flags)) {
*value = options.isPercentage ? valueToDisplay / 100.0f : valueToDisplay;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true;
}
if (options.showButtons) {
@@ -1004,7 +1004,7 @@ namespace UIWidgets {
if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) {
*value += options.step;
if (*value > max) *value = max;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true;
}
}
@@ -1025,7 +1025,7 @@ namespace UIWidgets {
float value = CVarGetFloat(cvarName, defaultValue);
if (SliderFloat(label, &value, min, max, options)) {
CVarSetFloat(cvarName, value);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true;
}
return dirty;
+8 -8
View File
@@ -3,9 +3,9 @@
#include <string>
#include <vector>
#include <span>
#include <stdint.h>
#include <cstdint>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <ImGui/imgui.h>
#include <imgui.h>
#include <libultraship/libultraship.h>
namespace UIWidgets {
@@ -25,7 +25,7 @@ namespace UIWidgets {
}
return 1;
}
};
// MARK: - Enums
@@ -65,17 +65,17 @@ namespace UIWidgets {
bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false);
bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false);
bool EnhancementCombobox(const char* cvarName, std::span<const char*, std::dynamic_extent> comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1);
bool LabeledRightAlignedEnhancementCombobox(const char* label, const char* cvarName, std::span<const char*, std::dynamic_extent> comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1);
void PaddedText(const char* text, bool padTop = true, bool padBottom = true);
bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = "");
bool PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "");
bool EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = "");
bool PaddedEnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "");
bool EnhancementRadioButton(const char* text, const char* cvarName, int id);
bool DrawResetColorButton(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha);
@@ -141,7 +141,7 @@ namespace UIWidgets {
void PushStyleButton(const ImVec4& color = Colors::Gray);
void PopStyleButton();
bool Button(const char* label, const ButtonOptions& options = {});
bool WindowButton(const char* label, const char* cvarName, std::shared_ptr<LUS::GuiWindow> windowPtr, const ButtonOptions& options = {});
bool WindowButton(const char* label, const char* cvarName, std::shared_ptr<Ship::GuiWindow> windowPtr, const ButtonOptions& options = {});
struct CheckboxOptions {
const ImVec4 color = Colors::Indigo;
+1 -1
View File
@@ -80,7 +80,7 @@ void move_segment_table_to_dmem(void) {
s32 i;
for (i = 0; i < 16; i++) {
gSPSegment(gDisplayListHead++, i, gSegmentTable[i]);
__gSPSegment(gDisplayListHead++, i, gSegmentTable[i]);
}
}