ShipInit and move ValueViewer rendering out of src (#5039)

This commit is contained in:
Archez 2025-02-12 15:52:18 -05:00 committed by GitHub
parent d4b9e8c835
commit 0ce9807df6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 39 additions and 39 deletions

View File

@ -2,11 +2,6 @@
#include <libultraship/libultraship.h>
#ifdef __cplusplus
extern "C"
#endif
void DrawColViewer();
typedef enum {
COLVIEW_DISABLED,
COLVIEW_SOLID,

View File

@ -1,6 +1,7 @@
#include "valueViewer.h"
#include "soh/SohGui/UIWidgets.hpp"
#include "soh/OTRGlobals.h"
#include "soh/ShipInit.hpp"
extern "C" {
#include <z64.h>
@ -14,6 +15,10 @@ void GfxPrint_SetPos(GfxPrint* printer, s32 x, s32 y);
s32 GfxPrint_Printf(GfxPrint* printer, const char* fmt, ...);
}
#define CVAR_NAME CVAR_DEVELOPER_TOOLS("ValueViewerEnablePrinting")
#define CVAR_DEFAULT 0
#define CVAR_VALUE CVarGetInteger(CVAR_NAME, CVAR_DEFAULT)
ImVec4 WHITE = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
std::vector<ValueTableElement> valueTable = {
@ -104,8 +109,40 @@ extern "C" void ValueViewer_Draw(GfxPrint* printer) {
}
}
extern "C" void ValueViewer_SetupDraw() {
OPEN_DISPS(gGameState->gfxCtx);
Gfx* gfx;
Gfx* polyOpa;
GfxPrint printer;
polyOpa = POLY_OPA_DISP;
gfx = Graph_GfxPlusOne(polyOpa);
gSPDisplayList(OVERLAY_DISP++, gfx);
GfxPrint_Init(&printer);
GfxPrint_Open(&printer, gfx);
ValueViewer_Draw(&printer);
gfx = GfxPrint_Close(&printer);
GfxPrint_Destroy(&printer);
gSPEndDisplayList(gfx++);
Graph_BranchDlist(polyOpa, gfx);
POLY_OPA_DISP = gfx;
CLOSE_DISPS(gGameState->gfxCtx);
}
void RegisterValueViewerHooks() {
COND_HOOK(OnGameFrameUpdate, CVAR_VALUE, []() { ValueViewer_SetupDraw(); });
}
RegisterShipInitFunc initFunc(RegisterValueViewerHooks, { CVAR_NAME });
void ValueViewerWindow::DrawElement() {
UIWidgets::PaddedEnhancementCheckbox("Enable Printing", CVAR_DEVELOPER_TOOLS("ValueViewerEnablePrinting"));
UIWidgets::PaddedEnhancementCheckbox("Enable Printing", CVAR_NAME);
ImGui::BeginGroup();
static int selectedElement = -1;

View File

@ -42,12 +42,4 @@ class ValueViewerWindow : public Ship::GuiWindow {
void UpdateElement() override {};
};
extern "C" {
#include <z64.h>
#endif
void ValueViewer_Draw(GfxPrint* printer);
#ifdef __cplusplus
}
#endif

View File

@ -6,8 +6,6 @@
#include <stdio.h>
#include <stdlib.h>
#include "soh/Enhancements/debugger/colViewer.h"
#include "soh/Enhancements/debugger/valueViewer.h"
#include "soh/Enhancements/gameconsole.h"
#include "soh/OTRGlobals.h"
#include "libultraship/bridge.h"
@ -300,28 +298,6 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
OPEN_DISPS(gfxCtx);
if (CVarGetInteger(CVAR_DEVELOPER_TOOLS("ValueViewerEnablePrinting"), 0)) {
Gfx* gfx;
Gfx* polyOpa;
GfxPrint printer;
polyOpa = POLY_OPA_DISP;
gfx = Graph_GfxPlusOne(polyOpa);
gSPDisplayList(OVERLAY_DISP++, gfx);
GfxPrint_Init(&printer);
GfxPrint_Open(&printer, gfx);
ValueViewer_Draw(&printer);
gfx = GfxPrint_Close(&printer);
GfxPrint_Destroy(&printer);
gSPEndDisplayList(gfx++);
Graph_BranchDlist(polyOpa, gfx);
POLY_OPA_DISP = gfx;
}
gDPNoOpString(WORK_DISP++, "WORK_DISP 終了", 0);
gDPNoOpString(POLY_OPA_DISP++, "POLY_OPA_DISP 終了", 0);
gDPNoOpString(POLY_XLU_DISP++, "POLY_XLU_DISP 終了", 0);