Skip to content

Commit a06f24b

Browse files
committed
Minor fixes, cleanup ImGuiConsole, update aurora
1 parent 8a04683 commit a06f24b

File tree

4 files changed

+60
-26
lines changed

4 files changed

+60
-26
lines changed

Runtime/Graphics/CGraphics.cpp

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "Runtime/Graphics/CGX.hpp"
99

1010
#include <zeus/Math.hpp>
11+
#include <dolphin/gx.h>
1112

1213
namespace metaforce {
1314
CGraphics::CProjectionState CGraphics::g_Proj;
@@ -190,12 +191,21 @@ void CGraphics::Render2D(CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::
190191
const auto oldProj = g_Proj;
191192
const auto oldCull = g_cullMode;
192193
const auto oldLights = g_LightActive;
193-
SetOrtho(-g_Viewport.x10_halfWidth, g_Viewport.x10_halfWidth, g_Viewport.x14_halfHeight, -g_Viewport.x14_halfHeight,
194-
-1.f, -10.f);
194+
SetOrtho(-g_Viewport.x8_width / 2, g_Viewport.x8_width / 2, g_Viewport.xc_height / 2, -g_Viewport.xc_height / 2, -1.f,
195+
-10.f);
195196
GXLoadPosMtxImm(&zeus::skIdentityMatrix4f, GX_PNMTX0);
196-
DisableAllLights();
197+
GXVtxDescList desc[] = {
198+
{GX_VA_POS, GX_DIRECT},
199+
{GX_VA_CLR0, GX_DIRECT},
200+
{GX_VA_TEX0, GX_DIRECT},
201+
{GX_VA_NULL, GX_NONE},
202+
};
203+
CGX::SetVtxDescv(desc);
204+
SetTevStates(6);
205+
if (g_LightActive.any()) {
206+
DisableAllLights();
207+
}
197208
SetCullMode(ERglCullMode::None);
198-
tex.Load(GX_TEXMAP0, EClampMode::Repeat);
199209

200210
// float hPad, vPad;
201211
// if (CGraphics::GetViewportAspect() >= 1.78f) {
@@ -211,23 +221,32 @@ void CGraphics::Render2D(CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::
211221
float scaledW = static_cast<float>(w) / 640.f * static_cast<float>(g_Viewport.x8_width);
212222
float scaledH = static_cast<float>(h) / 448.f * static_cast<float>(g_Viewport.xc_height);
213223

214-
float x1 = scaledX - g_Viewport.x10_halfWidth;
215-
float y1 = scaledY - g_Viewport.x14_halfHeight;
224+
float x1 = scaledX - (g_Viewport.x8_width / 2);
225+
float y1 = scaledY - (g_Viewport.xc_height / 2);
216226
float x2 = x1 + scaledW;
217227
float y2 = y1 + scaledH;
218-
StreamBegin(GX_TRIANGLESTRIP);
219-
StreamColor(col);
220-
StreamTexcoord(0.f, 0.f);
221-
StreamVertex(x1, y1, 1.f);
222-
StreamTexcoord(1.f, 0.f);
223-
StreamVertex(x2, y1, 1.f);
224-
StreamTexcoord(0.f, 1.f);
225-
StreamVertex(x1, y2, 1.f);
226-
StreamTexcoord(1.f, 1.f);
227-
StreamVertex(x2, y2, 1.f);
228-
StreamEnd();
229228

230-
SetLightState(g_LightActive);
229+
tex.Load(GX_TEXMAP0, EClampMode::Repeat);
230+
CGX::Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 4);
231+
{
232+
GXPosition3f32(x1, y1, 1.f);
233+
GXColor4f32(col.r(), col.g(), col.b(), col.a());
234+
GXTexCoord2f32(0.f, 0.f);
235+
GXPosition3f32(x2, y1, 1.f);
236+
GXColor4f32(col.r(), col.g(), col.b(), col.a());
237+
GXTexCoord2f32(1.f, 0.f);
238+
GXPosition3f32(x1, y2, 1.f);
239+
GXColor4f32(col.r(), col.g(), col.b(), col.a());
240+
GXTexCoord2f32(0.f, 1.f);
241+
GXPosition3f32(x2, y2, 1.f);
242+
GXColor4f32(col.r(), col.g(), col.b(), col.a());
243+
GXTexCoord2f32(1.f, 1.f);
244+
}
245+
CGX::End();
246+
247+
if (oldLights.any()) {
248+
SetLightState(oldLights);
249+
}
231250
g_Proj = oldProj;
232251
FlushProjection();
233252
SetModelMatrix({});

Runtime/ImGuiConsole.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <zeus/CVector2f.hpp>
2+
#include <ranges>
23
#define IM_VEC2_CLASS_EXTRA \
34
ImVec2(const zeus::CVector2f& v) { \
45
x = v.x(); \
@@ -21,6 +22,7 @@
2122
#include <SDL3/SDL_dialog.h>
2223
#include <SDL3/SDL_error.h>
2324
#include <magic_enum.hpp>
25+
#include <build/linux-default-relwithdebinfo/_deps/imgui-src/imgui_internal.h>
2426
#include <zeus/CEulerAngles.hpp>
2527

2628
namespace ImGui {
@@ -146,7 +148,7 @@ static void Warp(const CAssetId worldId, TAreaId aId) {
146148
}
147149
}
148150

149-
static inline float GetScale() { return ImGui::GetIO().DisplayFramebufferScale.x; }
151+
static inline float GetScale() { return ImGui::GetCurrentContext()->CurrentDpiScale; }
150152

151153
void ImGuiConsole::ShowMenuGame() {
152154
if (g_Main != nullptr) {
@@ -815,13 +817,26 @@ static std::string BytesToString(size_t bytes) {
815817
}
816818

817819
void ImGuiConsole::ShowDebugOverlay() {
818-
if (!m_developer && !m_frameCounter && !m_frameRate && !m_inGameTime && !m_roomTimer) {
819-
return;
820-
}
821-
if (!m_playerInfo && !m_areaInfo && !m_worldInfo && !m_randomStats && !m_resourceStats && !m_pipelineInfo &&
822-
!m_drawCallInfo && !m_bufferInfo) {
820+
const std::array flags{
821+
m_frameCounter && (g_StateManager != nullptr),
822+
m_frameRate,
823+
m_inGameTime && (g_StateManager != nullptr),
824+
m_roomTimer && (g_StateManager != nullptr),
825+
m_playerInfo && (g_StateManager != nullptr) && (g_StateManager->Player() != nullptr),
826+
m_worldInfo && (g_StateManager != nullptr) && m_developer,
827+
m_areaInfo && (g_StateManager != nullptr) && m_developer,
828+
m_layerInfo && (g_StateManager != nullptr) && m_developer,
829+
m_randomStats && m_developer,
830+
m_drawCallInfo && m_developer,
831+
m_bufferInfo && m_developer,
832+
m_pipelineInfo && m_developer,
833+
m_resourceStats && (g_SimplePool != nullptr),
834+
};
835+
836+
if (std::ranges::all_of(flags, [](const bool v) { return !v; })) {
823837
return;
824838
}
839+
825840
ImGuiIO& io = ImGui::GetIO();
826841
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
827842
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;

Runtime/MP1/CSaveGameScreen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ bool CSaveGameScreen::PumpLoad() {
109109
}
110110

111111
x50_loadedFrame = x44_frmeGenericMenu.GetObj();
112-
x50_loadedFrame->SetAspectConstraint(1.78f);
112+
x50_loadedFrame->SetAspectConstraint(1.33f);
113113
x54_textpane_message = static_cast<CGuiTextPane*>(x50_loadedFrame->FindWidget("textpane_message"));
114114
x58_tablegroup_choices = static_cast<CGuiTableGroup*>(x50_loadedFrame->FindWidget("tablegroup_choices"));
115115
x5c_textpane_choice0 = static_cast<CGuiTextPane*>(x50_loadedFrame->FindWidget("textpane_choice0"));

0 commit comments

Comments
 (0)