Fix compile (#199)

* Fixes made so far

* Fixes up until linking

* Moved GetInterpreter() to a single function under the Engine.h

* Updated shader files included with assets, added exception for Linux for including SDL2_net

* Removed osSetTime stub(for now)

* Adjustments to get it to compile + run

* Decoupled GetInterpreter() from the GameEngine Class, corrected a invalid include in SpaghettiGui.cpp

---------

Co-authored-by: sitton76 <58642183+sitton76@users.noreply.github.com>
This commit is contained in:
MegaMech
2025-05-15 15:25:18 -06:00
committed by GitHub
parent e7415ec072
commit 7cc9894aa1
14 changed files with 52 additions and 73 deletions
+1
View File
@@ -30,6 +30,7 @@ namespace Editor {
Editor::Editor() {
}
std::vector<Mtx> EditorMatrix;
void Editor::Load() {
printf("Editor: Loading Editor...\n");
eObjectPicker.Load();
+2 -2
View File
@@ -28,7 +28,7 @@ bool IsInGameScreen() {
Ship::Coords mouse = wnd->GetMousePos();
// Define viewport boundaries
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport;
int left = gfx_current_game_window_viewport.width;
int right = left + OTRGetGameRenderWidth();
int top = gfx_current_game_window_viewport.height;
@@ -43,7 +43,7 @@ FVector ScreenRayTrace() {
Camera* camera = &cameras[0];
Ship::Coords mouse = wnd->GetMousePos();
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport;
mouse.x -= gfx_current_game_window_viewport.width;
mouse.y -= gfx_current_game_window_viewport.height;
// Get screen dimensions
+11 -19
View File
@@ -49,14 +49,11 @@ float gInterpolationStep = 0.0f;
#include "audio/GameAudio.h"
}
std::weak_ptr<Fast::Interpreter> GameEngine::mInterpreter;
std::shared_ptr<Fast::Interpreter> GameEngine::GetInterpreter() {
auto intP = mInterpreter.lock();
if (!intP) {
assert(false && "Lost reference to Fast::Interpreter");
}
return intP;
Fast::Interpreter* GetInterpreter() {
return static_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow())
->GetInterpreterWeak()
.lock()
.get();
}
GameEngine* GameEngine::Instance;
@@ -543,7 +540,7 @@ extern "C" void GameEngine_UnloadSequence(const uint8_t seqId) {
}
extern "C" float GameEngine_GetAspectRatio() {
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
auto gfx_current_dimensions = GetInterpreter()->mCurDimensions;
return gfx_current_dimensions.aspect_ratio;
}
@@ -617,8 +614,7 @@ extern "C" void Timer_SetValue(int32_t* address, int32_t value) {
// }
extern "C" float OTRGetAspectRatio() {
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
return gfx_current_dimensions.aspect_ratio;
return GetInterpreter()->mCurDimensions.aspect_ratio;
}
extern "C" float OTRGetDimensionFromLeftEdge(float v) {
@@ -661,22 +657,18 @@ extern "C" uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center) {
// Gets the width of the current render target area
extern "C" uint32_t OTRGetGameRenderWidth() {
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
return gfx_current_dimensions.width;
return GetInterpreter()->mCurDimensions.width;
}
// Gets the height of the current render target area
extern "C" uint32_t OTRGetGameRenderHeight() {
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
return gfx_current_dimensions.height;
return GetInterpreter()->mCurDimensions.height;
}
extern "C" uint32_t OTRGetGameViewportWidth() {
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
return gfx_current_game_window_viewport.width;
return GetInterpreter()->mGameWindowViewport.width;
}
extern "C" uint32_t OTRGetGameViewportHeight() {
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
return gfx_current_game_window_viewport.height;
return GetInterpreter()->mGameWindowViewport.height;
}
+3 -3
View File
@@ -25,6 +25,8 @@
#define NUM_AUDIO_CHANNELS 2
#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2)
Fast::Interpreter* GetInterpreter();
struct CtlEntry;
struct AudioBankSample;
struct AudioSequenceData;
@@ -46,9 +48,6 @@ class GameEngine {
ImFont* fontMonoLarger;
ImFont* fontMonoLargest;
static std::weak_ptr<Fast::Interpreter> mInterpreter;
static std::shared_ptr<Fast::Interpreter> GetInterpreter();
std::unordered_map<std::string, uint8_t> bankMapTable;
GameEngine();
static bool GenAssetFile();
@@ -82,6 +81,7 @@ class GameEngine {
private:
ImFont* CreateFontWithSize(float size, std::string fontPath = "");
};
#endif
#ifdef __cplusplus
+1 -1
View File
@@ -27,7 +27,7 @@
#endif
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
#include <graphic/Fast3D/gfx_direct3d11.h>
#include <graphic/Fast3D/backends/gfx_direct3d11.h>
#include <imgui_impl_dx11.h>
#include <imgui_impl_win32.h>
+4 -4
View File
@@ -50,10 +50,10 @@ void SetupGuiElements() {
mPortMenu = std::make_shared<PortMenu>("gOpenMenu", "Port Menu");
gui->SetMenu(mPortMenu);
mMultiplayerWindow = gui->GetGuiWindow("Multiplayer");
if (mMultiplayerWindow == nullptr) {
SPDLOG_ERROR("Could not find multiplayer window");
}
//mMultiplayerWindow = gui->GetGuiWindow("Multiplayer");
//if (mMultiplayerWindow == nullptr) {
// SPDLOG_ERROR("Could not find multiplayer window");
//}
mStatsWindow = gui->GetGuiWindow("Stats");
if (mStatsWindow == nullptr) {
+6 -6
View File
@@ -96,12 +96,12 @@ void RegisterResolutionWidgets() {
// Resolution visualiser
mPortMenu->AddWidget(path, "Viewport dimensions: {} x {}", WIDGET_TEXT).PreFunc([](WidgetInfo& info) {
auto captured_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
auto captured_window_viewport = GetInterpreter()->mGameWindowViewport;
info.name = fmt::format("Viewport dimensions: {} x {}", captured_window_viewport.width,
captured_window_viewport.height);
});
mPortMenu->AddWidget(path, "Internal resolution: {} x {}", WIDGET_TEXT).PreFunc([](WidgetInfo& info) {
auto captured_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
auto captured_current_dimensions = GetInterpreter()->mCurDimensions;
info.name =
fmt::format("Internal resolution: {} x {}", captured_current_dimensions.width, captured_current_dimensions.height);
});
@@ -174,8 +174,8 @@ void RegisterResolutionWidgets() {
}
} else if (showHorizontalResField) { // Show calculated aspect ratio
if (item_aspectRatio) {
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport;
auto gfx_current_dimensions = GetInterpreter()->mCurDimensions;
ImGui::Dummy({ 0, 2 });
const float resolvedAspectRatio = (float)gfx_current_dimensions.width / gfx_current_dimensions.height;
ImGui::Text("Aspect ratio: %.2f:1", resolvedAspectRatio);
@@ -502,8 +502,8 @@ void UpdateResolutionVars() {
short integerScale_maximumBounds = 1; // can change when window is resized
// This is mostly just for UX purposes, as Fit Automatically logic is part of LUS.
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport;
auto gfx_current_dimensions = GetInterpreter()->mCurDimensions;
if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) >
((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) {
// Scale to window height
-5
View File
@@ -96,11 +96,6 @@ s32 osPfsAllocateFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name
return PFS_NO_ERROR;
}
#ifndef __SWITCH__
void osSetTime(OSTime time) {
}
#endif
s32 osPfsIsPlug(OSMesgQueue* queue, u8* pattern) {
}