run clang format (#448)

* add linux clang format script

* first shot at powershell

* whoops

* webrequest is slow, try webclient

* just get the one file

* simplify and maybe make it work?

* whoops again

* try a different suggestion

* why is it always windows

* again

* try again

* bit of path stuff

* chmod +x

* add action to check

* fix workflow name

* run clang format
This commit is contained in:
briaguya
2024-05-22 09:05:05 -05:00
committed by Garrett Cox
parent 0a2d89924b
commit 6da0031295
300 changed files with 4601 additions and 4421 deletions
+70 -70
View File
@@ -23,87 +23,87 @@
bool ShouldClearTextureCacheAtEndOfFrame = false;
namespace BenGui {
// MARK: - Delegates
// MARK: - Delegates
std::shared_ptr<BenMenuBar> mBenMenuBar;
std::shared_ptr<BenMenuBar> mBenMenuBar;
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<Ship::GuiWindow> mConsoleWindow;
std::shared_ptr<Ship::GuiWindow> mStatsWindow;
std::shared_ptr<Ship::GuiWindow> mInputEditorWindow;
std::shared_ptr<Ship::GuiWindow> mGfxDebuggerWindow;
std::shared_ptr<SaveEditorWindow> mSaveEditorWindow;
std::shared_ptr<HudEditorWindow> mHudEditorWindow;
std::shared_ptr<ActorViewerWindow> mActorViewerWindow;
std::shared_ptr<CollisionViewerWindow> mCollisionViewerWindow;
std::shared_ptr<EventLogWindow> mEventLogWindow;
std::shared_ptr<SaveEditorWindow> mSaveEditorWindow;
std::shared_ptr<HudEditorWindow> mHudEditorWindow;
std::shared_ptr<ActorViewerWindow> mActorViewerWindow;
std::shared_ptr<CollisionViewerWindow> mCollisionViewerWindow;
std::shared_ptr<EventLogWindow> mEventLogWindow;
void SetupGuiElements() {
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
void SetupGuiElements() {
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
auto& style = ImGui::GetStyle();
style.FramePadding = ImVec2(4.0f, 6.0f);
style.ItemSpacing = ImVec2(8.0f, 6.0f);
style.Colors[ImGuiCol_MenuBarBg] = UIWidgets::Colors::DarkGray;
auto& style = ImGui::GetStyle();
style.FramePadding = ImVec2(4.0f, 6.0f);
style.ItemSpacing = ImVec2(8.0f, 6.0f);
style.Colors[ImGuiCol_MenuBarBg] = UIWidgets::Colors::DarkGray;
mBenMenuBar = std::make_shared<BenMenuBar>("gOpenMenuBar", CVarGetInteger("gOpenMenuBar", 0));
gui->SetMenuBar(std::reinterpret_pointer_cast<Ship::GuiMenuBar>(mBenMenuBar));
mBenMenuBar = std::make_shared<BenMenuBar>("gOpenMenuBar", CVarGetInteger("gOpenMenuBar", 0));
gui->SetMenuBar(std::reinterpret_pointer_cast<Ship::GuiMenuBar>(mBenMenuBar));
if (gui->GetMenuBar() && !gui->GetMenuBar()->IsVisible()) {
if (gui->GetMenuBar() && !gui->GetMenuBar()->IsVisible()) {
#if defined(__SWITCH__) || defined(__WIIU__)
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Press - to access enhancements menu");
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Press - to access enhancements menu");
#else
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Press F1 to access enhancements menu");
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Press F1 to access enhancements menu");
#endif
}
mStatsWindow = gui->GetGuiWindow("Stats");
if (mStatsWindow == nullptr) {
SPDLOG_ERROR("Could not find stats window");
}
mConsoleWindow = gui->GetGuiWindow("Console");
if (mConsoleWindow == nullptr) {
SPDLOG_ERROR("Could not find console window");
}
mInputEditorWindow = gui->GetGuiWindow("Input Editor");
if (mInputEditorWindow == nullptr) {
SPDLOG_ERROR("Could not find input editor window");
}
mGfxDebuggerWindow = gui->GetGuiWindow("GfxDebuggerWindow");
if (mGfxDebuggerWindow == nullptr) {
SPDLOG_ERROR("Could not find input GfxDebuggerWindow");
}
mSaveEditorWindow = std::make_shared<SaveEditorWindow>("gWindows.SaveEditor", "Save Editor");
gui->AddGuiWindow(mSaveEditorWindow);
mHudEditorWindow = std::make_shared<HudEditorWindow>("gWindows.HudEditor", "Hud Editor");
gui->AddGuiWindow(mHudEditorWindow);
mActorViewerWindow = std::make_shared<ActorViewerWindow>("gWindows.ActorViewer", "Actor Viewer");
gui->AddGuiWindow(mActorViewerWindow);
mCollisionViewerWindow = std::make_shared<CollisionViewerWindow>("gWindows.CollisionViewer", "Collision Viewer");
gui->AddGuiWindow(mCollisionViewerWindow);
mEventLogWindow = std::make_shared<EventLogWindow>("gWindows.EventLog", "Event Log");
gui->AddGuiWindow(mEventLogWindow);
}
void Destroy() {
mBenMenuBar = nullptr;
mStatsWindow = nullptr;
mConsoleWindow = nullptr;
mInputEditorWindow = nullptr;
mGfxDebuggerWindow = nullptr;
mCollisionViewerWindow = nullptr;
mEventLogWindow = nullptr;
mSaveEditorWindow = nullptr;
mHudEditorWindow = nullptr;
mActorViewerWindow = nullptr;
mStatsWindow = gui->GetGuiWindow("Stats");
if (mStatsWindow == nullptr) {
SPDLOG_ERROR("Could not find stats window");
}
mConsoleWindow = gui->GetGuiWindow("Console");
if (mConsoleWindow == nullptr) {
SPDLOG_ERROR("Could not find console window");
}
mInputEditorWindow = gui->GetGuiWindow("Input Editor");
if (mInputEditorWindow == nullptr) {
SPDLOG_ERROR("Could not find input editor window");
}
mGfxDebuggerWindow = gui->GetGuiWindow("GfxDebuggerWindow");
if (mGfxDebuggerWindow == nullptr) {
SPDLOG_ERROR("Could not find input GfxDebuggerWindow");
}
mSaveEditorWindow = std::make_shared<SaveEditorWindow>("gWindows.SaveEditor", "Save Editor");
gui->AddGuiWindow(mSaveEditorWindow);
mHudEditorWindow = std::make_shared<HudEditorWindow>("gWindows.HudEditor", "Hud Editor");
gui->AddGuiWindow(mHudEditorWindow);
mActorViewerWindow = std::make_shared<ActorViewerWindow>("gWindows.ActorViewer", "Actor Viewer");
gui->AddGuiWindow(mActorViewerWindow);
mCollisionViewerWindow = std::make_shared<CollisionViewerWindow>("gWindows.CollisionViewer", "Collision Viewer");
gui->AddGuiWindow(mCollisionViewerWindow);
mEventLogWindow = std::make_shared<EventLogWindow>("gWindows.EventLog", "Event Log");
gui->AddGuiWindow(mEventLogWindow);
}
void Destroy() {
mBenMenuBar = nullptr;
mStatsWindow = nullptr;
mConsoleWindow = nullptr;
mInputEditorWindow = nullptr;
mGfxDebuggerWindow = nullptr;
mCollisionViewerWindow = nullptr;
mEventLogWindow = nullptr;
mSaveEditorWindow = nullptr;
mHudEditorWindow = nullptr;
mActorViewerWindow = nullptr;
}
} // namespace BenGui
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -12,10 +12,11 @@ namespace BenGui {
class BenMenuBar : public Ship::GuiMenuBar {
public:
using Ship::GuiMenuBar::GuiMenuBar;
protected:
void DrawElement() override;
void InitElement() override {};
void UpdateElement() override {};
void InitElement() override{};
void UpdateElement() override{};
};
} // namespace BenGui
+79 -61
View File
@@ -8,24 +8,25 @@ extern "C" int16_t OTRGetRectDimensionFromRightEdge(float v);
HudEditorElementID hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE;
HudEditorElement hudEditorElements[HUD_EDITOR_ELEMENT_MAX] = {
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_B, "B Button", "B", 167, 17, 100, 255, 120, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_LEFT, "C-Left Button", "CLeft", 227, 18, 255, 240, 0, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_DOWN, "C-Down Button", "CDown", 249, 34, 255, 240, 0, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_RIGHT, "C-Right Button", "CRight", 271, 18, 255, 240, 0, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_A, "A Button", "A", 191, 18, 100, 200, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_UP, "C-Up Button", "CUp", 254, 16, 255, 240, 0, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_D_PAD, "D-Pad", "DPad", 271, 55, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_MINIMAP, "Minimap", "Minimap", 295, 220, 0, 255, 255, 160),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_START, "Start Button", "Start", 136, 17, 255, 130, 60, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_CLOCK, "Three Day Clock", "Clock", 160, 206, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_HEARTS, "Hearts", "Hearts", 30, 26, 255, 70, 50, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_MAGIC_METER, "Magic", "Magic", 18, 34, 0, 200, 0, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_TIMERS, "Timers", "Timers", 26, 46, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_TIMERS_MOON_CRASH, "Timer - Skull Kid", "SkullKidTimer", 115, 200, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_MINIGAME_COUNTER, "Minigames", "Minigames", 20, 67, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_RUPEE_COUNTER, "Rupees", "Rupees", 26, 206, 200, 255, 100, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_KEY_COUNTER, "Keys", "Keys", 26, 190, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER, "Skulltulas", "Skulltulas", 26, 190, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_B, "B Button", "B", 167, 17, 100, 255, 120, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_LEFT, "C-Left Button", "CLeft", 227, 18, 255, 240, 0, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_DOWN, "C-Down Button", "CDown", 249, 34, 255, 240, 0, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_RIGHT, "C-Right Button", "CRight", 271, 18, 255, 240, 0, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_A, "A Button", "A", 191, 18, 100, 200, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_UP, "C-Up Button", "CUp", 254, 16, 255, 240, 0, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_D_PAD, "D-Pad", "DPad", 271, 55, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_MINIMAP, "Minimap", "Minimap", 295, 220, 0, 255, 255, 160),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_START, "Start Button", "Start", 136, 17, 255, 130, 60, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_CLOCK, "Three Day Clock", "Clock", 160, 206, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_HEARTS, "Hearts", "Hearts", 30, 26, 255, 70, 50, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_MAGIC_METER, "Magic", "Magic", 18, 34, 0, 200, 0, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_TIMERS, "Timers", "Timers", 26, 46, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_TIMERS_MOON_CRASH, "Timer - Skull Kid", "SkullKidTimer", 115, 200, 255, 255,
255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_MINIGAME_COUNTER, "Minigames", "Minigames", 20, 67, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_RUPEE_COUNTER, "Rupees", "Rupees", 26, 206, 200, 255, 100, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_KEY_COUNTER, "Keys", "Keys", 26, 190, 255, 255, 255, 255),
HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER, "Skulltulas", "Skulltulas", 26, 190, 255, 255, 255, 255),
};
extern "C" bool HudEditor_ShouldOverrideDraw() {
@@ -140,11 +141,7 @@ extern "C" void HudEditor_ModifyDrawValues(s16* rectLeft, s16* rectTop, s16* rec
}
const char* modeNames[] = {
"Vanilla (4:3)",
"Hidden",
"Movable (Align Center)",
"Movable (Align Left)",
"Movable (Align Right)",
"Vanilla (4:3)", "Hidden", "Movable (Align Center)", "Movable (Align Left)", "Movable (Align Right)",
};
const char* presetNames[] = {
@@ -162,7 +159,7 @@ enum Presets {
};
void HudEditorWindow::DrawElement() {
ImGui::SetNextWindowSize(ImVec2(480,600), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize(ImVec2(480, 600), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Hud Editor", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) {
ImGui::End();
return;
@@ -187,23 +184,39 @@ void HudEditorWindow::DrawElement() {
}
case HudEditor::Presets::WIDESCREEN: {
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_B].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_LEFT].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_DOWN].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_RIGHT].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_LEFT].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_DOWN].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_RIGHT].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_A].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_UP].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_D_PAD].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_MINIMAP].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_START].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_CLOCK].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_43);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_HEARTS].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_MAGIC_METER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_TIMERS].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_TIMERS_MOON_CRASH].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_43);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_MINIGAME_COUNTER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_RUPEE_COUNTER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_KEY_COUNTER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_UP].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_D_PAD].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_MINIMAP].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_START].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_CLOCK].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_43);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_HEARTS].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_MAGIC_METER].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_TIMERS].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_TIMERS_MOON_CRASH].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_43);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_MINIGAME_COUNTER].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_RUPEE_COUNTER].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_KEY_COUNTER].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER].modeCvar,
HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT);
break;
}
}
@@ -213,39 +226,44 @@ void HudEditorWindow::DrawElement() {
for (int i = HUD_EDITOR_ELEMENT_B; i < HUD_EDITOR_ELEMENT_MAX; i++) {
ImGui::PushID(hudEditorElements[i].name);
ImGui::SeparatorText(hudEditorElements[i].name);
float color[3] = { (float)hudEditorElements[i].defaultR / 255, (float)hudEditorElements[i].defaultG / 255, (float)hudEditorElements[i].defaultB / 255 };
// BENTODO: This color picker currently doesn't do anything other than serve as a visual indicator. Eventually it will be used to set the color of the element.
float color[3] = { (float)hudEditorElements[i].defaultR / 255, (float)hudEditorElements[i].defaultG / 255,
(float)hudEditorElements[i].defaultB / 255 };
// BENTODO: This color picker currently doesn't do anything other than serve as a visual indicator. Eventually
// it will be used to set the color of the element.
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::ColorEdit3("Color", color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::PopItemFlag();
ImGui::SameLine();
if (UIWidgets::CVarCombobox("Mode", hudEditorElements[i].modeCvar, modeNames, {
.labelPosition = UIWidgets::LabelPosition::None
})) {
if (UIWidgets::CVarCombobox("Mode", hudEditorElements[i].modeCvar, modeNames,
{ .labelPosition = UIWidgets::LabelPosition::None })) {
CVarClear(hudEditorElements[i].xCvar);
CVarClear(hudEditorElements[i].yCvar);
CVarClear(hudEditorElements[i].scaleCvar);
}
if (CVarGetInteger(hudEditorElements[i].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) >= HUD_EDITOR_ELEMENT_MODE_MOVABLE_43) {
if (CVarGetInteger(hudEditorElements[i].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) >=
HUD_EDITOR_ELEMENT_MODE_MOVABLE_43) {
if (ImGui::BeginTable("##table", 3, ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_NoBordersInBody)) {
ImGui::TableNextColumn();
UIWidgets::CVarSliderInt("X", hudEditorElements[i].xCvar, -10, 330, hudEditorElements[i].defaultX, {
.showButtons = false,
.format = "X: %d",
.labelPosition = UIWidgets::LabelPosition::None,
});
UIWidgets::CVarSliderInt("X", hudEditorElements[i].xCvar, -10, 330, hudEditorElements[i].defaultX,
{
.showButtons = false,
.format = "X: %d",
.labelPosition = UIWidgets::LabelPosition::None,
});
ImGui::TableNextColumn();
UIWidgets::CVarSliderInt("Y", hudEditorElements[i].yCvar, -10, 250, hudEditorElements[i].defaultY, {
.showButtons = false,
.format = "Y: %d",
.labelPosition = UIWidgets::LabelPosition::None,
});
UIWidgets::CVarSliderInt("Y", hudEditorElements[i].yCvar, -10, 250, hudEditorElements[i].defaultY,
{
.showButtons = false,
.format = "Y: %d",
.labelPosition = UIWidgets::LabelPosition::None,
});
ImGui::TableNextColumn();
UIWidgets::CVarSliderFloat("Scale", hudEditorElements[i].scaleCvar, 0.25f, 4.0f, 1.0f, {
.showButtons = false,
.format = "Scale: %.2f",
.labelPosition = UIWidgets::LabelPosition::None,
});
UIWidgets::CVarSliderFloat("Scale", hudEditorElements[i].scaleCvar, 0.25f, 4.0f, 1.0f,
{
.showButtons = false,
.format = "Scale: %.2f",
.labelPosition = UIWidgets::LabelPosition::None,
});
ImGui::EndTable();
}
}
+12 -13
View File
@@ -8,12 +8,12 @@
#include <unordered_map>
class HudEditorWindow : public Ship::GuiWindow {
public:
using GuiWindow::GuiWindow;
public:
using GuiWindow::GuiWindow;
void InitElement() override {};
void DrawElement() override;
void UpdateElement() override {};
void InitElement() override{};
void DrawElement() override;
void UpdateElement() override{};
};
extern "C" {
@@ -62,7 +62,8 @@ void HudEditor_ModifyRectSizeValues(s16* rectWidth, s16* rectHeight);
void HudEditor_ModifyTextureStepValues(s16* dsdx, s16* dtdy);
void HudEditor_ModifyMatrixValues(f32* transX, f32* transY);
void HudEditor_ModifyKaleidoEquipAnimValues(s16* ulx, s16* uly, s16* shrinkRate);
void HudEditor_ModifyDrawValuesFromBase(s16 baseX, s16 baseY, s16* rectLeft, s16* rectTop, s16* rectWidth, s16* rectHeight, s16* dsdx, s16* dtdy);
void HudEditor_ModifyDrawValuesFromBase(s16 baseX, s16 baseY, s16* rectLeft, s16* rectTop, s16* rectWidth,
s16* rectHeight, s16* dsdx, s16* dtdy);
void HudEditor_ModifyDrawValues(s16* rectLeft, s16* rectTop, s16* rectWidth, s16* rectHeight, s16* dsdx, s16* dtdy);
typedef struct {
@@ -81,13 +82,11 @@ typedef struct {
const char* modeCvar;
} HudEditorElement;
#define HUD_EDITOR_ELEMENT(id, name, cvar, defaultX, defaultY, defaultR, defaultG, defaultB, defaultA) \
{ \
id, name, defaultX, defaultY, defaultR, defaultG, defaultB, defaultA, \
"gHudEditor." cvar ".Position.X", "gHudEditor." cvar ".Position.Y", \
"gHudEditor." cvar ".Scale", \
"gHudEditor." cvar ".Color.Value", \
"gHudEditor." cvar ".Mode" \
#define HUD_EDITOR_ELEMENT(id, name, cvar, defaultX, defaultY, defaultR, defaultG, defaultB, defaultA) \
{ \
id, name, defaultX, defaultY, defaultR, defaultG, defaultB, defaultA, "gHudEditor." cvar ".Position.X", \
"gHudEditor." cvar ".Position.Y", "gHudEditor." cvar ".Scale", "gHudEditor." cvar ".Color.Value", \
"gHudEditor." cvar ".Mode" \
}
extern HudEditorElementID hudEditorActiveElement;
File diff suppressed because it is too large Load Diff
+69 -66
View File
@@ -106,7 +106,6 @@ Color_RGB8 kokiriColor = { 0x1E, 0x69, 0x1B };
Color_RGB8 goronColor = { 0x64, 0x14, 0x00 };
Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 };
OTRGlobals::OTRGlobals() {
std::vector<std::string> archiveFiles;
std::string mmPath = Ship::Context::LocateFileAcrossAppDirs("mm.zip", appShortName);
@@ -141,13 +140,15 @@ OTRGlobals::OTRGlobals() {
OOT_PAL_11, OOT_NTSC_JP_GC_CE, OOT_NTSC_JP_GC, OOT_NTSC_US_GC,
OOT_PAL_GC, OOT_PAL_GC_DBG1, OOT_PAL_GC_DBG2 };
// tell LUS to reserve 3 SoH specific threads (Game, Audio, Save)
context = Ship::Context::CreateInstance("2 Ship 2 Harkinian", appShortName, "2ship2harkinian.json", archiveFiles, {}, 3);
context =
Ship::Context::CreateInstance("2 Ship 2 Harkinian", appShortName, "2ship2harkinian.json", archiveFiles, {}, 3);
// Override LUS defaults
Ship::Context::GetInstance()->GetLogger()->set_level((spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", 1));
Ship::Context::GetInstance()->GetLogger()->set_level(
(spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", 1));
Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v");
//context = Ship::Context::CreateUninitializedInstance("Ship of Harkinian", appShortName, "shipofharkinian.json");
// context = Ship::Context::CreateUninitializedInstance("Ship of Harkinian", appShortName, "shipofharkinian.json");
auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay();
overlay->LoadFont("Press Start 2P", "fonts/PressStart2P-Regular.ttf", 12.0f);
@@ -180,9 +181,9 @@ OTRGlobals::OTRGlobals() {
static_cast<uint32_t>(SOH::ResourceType::SOH_PlayerAnimation), 0);
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinarySceneV0>(), RESOURCE_FORMAT_BINARY,
"Room", static_cast<uint32_t>(SOH::ResourceType::SOH_Room), 0);
loader
->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryCollisionHeaderV0>(), RESOURCE_FORMAT_BINARY,
"CollisionHeader", static_cast<uint32_t>(SOH::ResourceType::SOH_CollisionHeader), 0);
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryCollisionHeaderV0>(),
RESOURCE_FORMAT_BINARY, "CollisionHeader",
static_cast<uint32_t>(SOH::ResourceType::SOH_CollisionHeader), 0);
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinarySkeletonV0>(), RESOURCE_FORMAT_BINARY,
"Skeleton", static_cast<uint32_t>(SOH::ResourceType::SOH_Skeleton), 0);
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinarySkeletonLimbV0>(),
@@ -200,7 +201,8 @@ OTRGlobals::OTRGlobals() {
RESOURCE_FORMAT_BINARY, "AudioSoundFont",
static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSoundFont), 2);
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryAudioSequenceV2>(),
RESOURCE_FORMAT_BINARY, "AudioSequence", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSequence), 2);
RESOURCE_FORMAT_BINARY, "AudioSequence",
static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSequence), 2);
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryBackgroundV0>(), RESOURCE_FORMAT_BINARY,
"Background", static_cast<uint32_t>(SOH::ResourceType::SOH_Background), 0);
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryTextureAnimationV0>(),
@@ -212,23 +214,23 @@ OTRGlobals::OTRGlobals() {
"KeyFrameSkel", static_cast<uint32_t>(SOH::ResourceType::TSH_CKeyFrameSkel), 0);
context->GetControlDeck()->SetSinglePlayerMappingMode(true);
//gSaveStateMgr = std::make_shared<SaveStateMgr>();
//gRandomizer = std::make_shared<Randomizer>();
// gSaveStateMgr = std::make_shared<SaveStateMgr>();
// gRandomizer = std::make_shared<Randomizer>();
hasMasterQuest = hasOriginal = false;
// Move the camera strings from read only memory onto the heap (writable memory)
// This is in OTRGlobals right now because this is a place that will only ever be run once at the beginning of
// startup. We should probably find some code in db_camera that does initialization and only run once, and then
// dealloc on deinitialization.
//cameraStrings = (char**)malloc(sizeof(constCameraStrings));
//for (int32_t i = 0; i < sizeof(constCameraStrings) / sizeof(char*); i++) {
// cameraStrings = (char**)malloc(sizeof(constCameraStrings));
// for (int32_t i = 0; i < sizeof(constCameraStrings) / sizeof(char*); i++) {
// // OTRTODO: never deallocated...
// auto dup = strdup(constCameraStrings[i]);
// cameraStrings[i] = dup;
//}
auto versions = context->GetResourceManager()->GetArchiveManager()->GetGameVersions();
#if 0
#if 0
for (uint32_t version : versions) {
if (!ValidHashes.contains(version)) {
#if defined(__SWITCH__)
@@ -266,7 +268,7 @@ OTRGlobals::OTRGlobals() {
break;
}
}
#endif
#endif
}
OTRGlobals::~OTRGlobals() {
@@ -317,7 +319,6 @@ static struct {
bool processing;
} audio;
void OTRAudio_Thread() {
while (audio.running) {
{
@@ -331,21 +332,21 @@ void OTRAudio_Thread() {
}
}
std::unique_lock<std::mutex> Lock(audio.mutex);
//AudioMgr_ThreadEntry(&gAudioMgr);
// 528 and 544 relate to 60 fps at 32 kHz 32000/60 = 533.333..
// in an ideal world, one third of the calls should use num_samples=544 and two thirds num_samples=528
//#define SAMPLES_HIGH 560
//#define SAMPLES_LOW 528
// PAL values
//#define SAMPLES_HIGH 656
//#define SAMPLES_LOW 624
// AudioMgr_ThreadEntry(&gAudioMgr);
// 528 and 544 relate to 60 fps at 32 kHz 32000/60 = 533.333..
// in an ideal world, one third of the calls should use num_samples=544 and two thirds num_samples=528
//#define SAMPLES_HIGH 560
//#define SAMPLES_LOW 528
// PAL values
//#define SAMPLES_HIGH 656
//#define SAMPLES_LOW 624
// 44KHZ values
#define SAMPLES_HIGH 752
#define SAMPLES_LOW 720
// 44KHZ values
#define SAMPLES_HIGH 752
#define SAMPLES_LOW 720
#define AUDIO_FRAMES_PER_UPDATE (R_UPDATE_RATE > 0 ? R_UPDATE_RATE : 1 )
#define NUM_AUDIO_CHANNELS 2
#define AUDIO_FRAMES_PER_UPDATE (R_UPDATE_RATE > 0 ? R_UPDATE_RATE : 1)
#define NUM_AUDIO_CHANNELS 2
int samples_left = AudioPlayer_Buffered();
u32 num_audio_samples = samples_left < AudioPlayer_GetDesiredBuffered() ? SAMPLES_HIGH : SAMPLES_LOW;
@@ -353,10 +354,12 @@ void OTRAudio_Thread() {
// 3 is the maximum authentic frame divisor.
s16 audio_buffer[SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 3];
for (int i = 0; i < AUDIO_FRAMES_PER_UPDATE; i++) {
AudioMgr_CreateNextAudioBuffer(audio_buffer + i * (num_audio_samples * NUM_AUDIO_CHANNELS), num_audio_samples);
AudioMgr_CreateNextAudioBuffer(audio_buffer + i * (num_audio_samples * NUM_AUDIO_CHANNELS),
num_audio_samples);
}
AudioPlayer_Play((u8*)audio_buffer, num_audio_samples * (sizeof(int16_t) * NUM_AUDIO_CHANNELS * AUDIO_FRAMES_PER_UPDATE));
AudioPlayer_Play((u8*)audio_buffer,
num_audio_samples * (sizeof(int16_t) * NUM_AUDIO_CHANNELS * AUDIO_FRAMES_PER_UPDATE));
audio.processing = false;
audio.cv_from_thread.notify_one();
@@ -364,8 +367,7 @@ void OTRAudio_Thread() {
}
// C->C++ Bridge
extern "C" void OTRAudio_Init()
{
extern "C" void OTRAudio_Init() {
// Precache all our samples, sequences, etc...
ResourceMgr_LoadDirectory("audio");
@@ -439,9 +441,9 @@ extern "C" void InitOTR() {
DebugConsole_Init();
clearMtx = (uintptr_t)&gMtxClear;
//OTRMessage_Init();
// OTRMessage_Init();
OTRAudio_Init();
//OTRExtScanner();
// OTRExtScanner();
time_t now = time(NULL);
tm* tm_now = localtime(&now);
if (tm_now->tm_mon == 11 && tm_now->tm_mday >= 24 && tm_now->tm_mday <= 25) {
@@ -462,11 +464,10 @@ extern "C" void InitOTR() {
#endif
std::shared_ptr<Ship::Config> conf = OTRGlobals::Instance->context->GetConfig();
}
extern "C" void SaveManager_ThreadPoolWait() {
//SaveManager::Instance->ThreadPoolWait();
// SaveManager::Instance->ThreadPoolWait();
}
extern "C" void DeinitOTR() {
@@ -532,7 +533,7 @@ extern "C" void Graph_StartFrame() {
OTRGlobals::Instance->context->GetWindow()->SetLastScancode(-1);
switch (dwScancode) {
#if 0
#if 0
case KbScancode::LUS_KB_F5: {
if (CVarGetInteger("gSaveStatesEnabled", 0) == 0) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification(
@@ -608,7 +609,7 @@ extern "C" void Graph_StartFrame() {
case KbScancode::LUS_KB_TAB: {
// Toggle HD Assets
CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0));
//ShouldClearTextureCacheAtEndOfFrame = true;
// ShouldClearTextureCacheAtEndOfFrame = true;
break;
}
}
@@ -681,13 +682,13 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
last_update_rate = R_UPDATE_RATE;
{
std::unique_lock<std::mutex> Lock(audio.mutex);
while (audio.processing) {
audio.cv_from_thread.wait(Lock);
}
std::unique_lock<std::mutex> Lock(audio.mutex);
while (audio.processing) {
audio.cv_from_thread.wait(Lock);
}
}
//
//if (ShouldClearTextureCacheAtEndOfFrame) {
// if (ShouldClearTextureCacheAtEndOfFrame) {
// gfx_texture_cache_clear();
// Ship::SkeletonPatcher::UpdateSkeletons();
// ShouldClearTextureCacheAtEndOfFrame = false;
@@ -734,7 +735,8 @@ extern "C" uint32_t ResourceMgr_GetGameVersion(int index) {
}
extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) {
uint32_t version = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
uint32_t version =
Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
switch (version) {
case OOT_NTSC_US_10:
@@ -759,7 +761,8 @@ extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) {
}
extern "C" uint32_t ResourceMgr_GetGameRegion(int index) {
uint32_t version = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
uint32_t version =
Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
switch (version) {
case OOT_NTSC_US_10:
@@ -905,9 +908,9 @@ extern "C" char* ResourceMgr_LoadIfDListByName(const char* filePath) {
return nullptr;
}
//extern "C" Sprite* GetSeedTexture(uint8_t index) {
// return OTRGlobals::Instance->gRandomizer->GetSeedTexture(index);
//}
// extern "C" Sprite* GetSeedTexture(uint8_t index) {
// return OTRGlobals::Instance->gRandomizer->GetSeedTexture(index);
// }
extern "C" char* ResourceMgr_LoadPlayerAnimByName(const char* animPath) {
auto anim = std::static_pointer_cast<SOH::PlayerAnimation>(GetResourceByName(animPath));
@@ -1059,8 +1062,8 @@ extern "C" Vtx* ResourceMgr_LoadVtxByName(char* path) {
}
extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path) {
SequenceData* sequence = (SequenceData*)ResourceGetDataByName(path);
return *sequence;
SequenceData* sequence = (SequenceData*)ResourceGetDataByName(path);
return *sequence;
}
extern "C" KeyFrameSkeleton* ResourceMgr_LoadKeyFrameSkelByName(const char* path) {
return (KeyFrameSkeleton*)ResourceGetDataByName(path);
@@ -1069,7 +1072,7 @@ extern "C" KeyFrameSkeleton* ResourceMgr_LoadKeyFrameSkelByName(const char* path
extern "C" KeyFrameAnimation* ResourceMgr_LoadKeyFrameAnimByName(const char* path) {
return (KeyFrameAnimation*)ResourceGetDataByName(path);
}
//std::map<std::string, SoundFontSample*> cachedCustomSFs;
// std::map<std::string, SoundFontSample*> cachedCustomSFs;
#if 0
extern "C" SoundFontSample* ReadCustomSample(const char* path) {
return nullptr;
@@ -1181,7 +1184,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel
// Therefore we can take this oppurtunity to take note of the Skeleton that is created...
if (skelAnime != nullptr) {
auto stringPath = std::string(path);
//Ship::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime);
// Ship::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime);
}
return skelHeader;
@@ -1233,13 +1236,13 @@ void OTRGlobals::CheckSaveFile(size_t sramSize) const {
saveFile.close();
}
//extern "C" void Ctx_ReadSaveFile(uintptr_t addr, void* dramAddr, size_t size) {
// SaveManager::ReadSaveFile(GetSaveFile(), addr, dramAddr, size);
//}
// extern "C" void Ctx_ReadSaveFile(uintptr_t addr, void* dramAddr, size_t size) {
// SaveManager::ReadSaveFile(GetSaveFile(), addr, dramAddr, size);
// }
//extern "C" void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size) {
// SaveManager::WriteSaveFile(GetSaveFile(), addr, dramAddr, size);
//}
// extern "C" void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size) {
// SaveManager::WriteSaveFile(GetSaveFile(), addr, dramAddr, size);
// }
std::wstring StringToU16(const std::string& s) {
std::vector<unsigned long> result;
@@ -1345,7 +1348,7 @@ extern "C" uint32_t OTRGetCurrentHeight() {
}
Color_RGB8 GetColorForControllerLED() {
#if 0
#if 0
auto brightness = CVarGetFloat("gLedBrightness", 1.0f) / 1.0f;
Color_RGB8 color = { 0, 0, 0 };
if (brightness > 0.0f) {
@@ -1389,7 +1392,7 @@ Color_RGB8 GetColorForControllerLED() {
color.g = color.g * brightness;
color.b = color.b * brightness;
}
#endif
#endif
return { 0, 0, 0 };
}
@@ -1403,12 +1406,12 @@ extern "C" void OTRControllerCallback(uint8_t rumble) {
if (controllerConfigWindow == nullptr) {
controllerConfigWindow = std::dynamic_pointer_cast<Ship::InputEditorWindow>(
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Input Editor"));
// TODO: Add SoH Controller Config window rumble testing to upstream LUS config window
// note: the current implementation may not be desired in LUS, as "true" rumble support
// using osMotor calls is planned: https://github.com/Kenix3/libultraship/issues/9
//
// } else if (controllerConfigWindow->TestingRumble()) {
// return;
// TODO: Add SoH Controller Config window rumble testing to upstream LUS config window
// note: the current implementation may not be desired in LUS, as "true" rumble support
// using osMotor calls is planned: https://github.com/Kenix3/libultraship/issues/9
//
// } else if (controllerConfigWindow->TestingRumble()) {
// return;
}
if (rumble) {
-1
View File
@@ -3,7 +3,6 @@
#pragma once
#define GAME_REGION_NTSC 0
#define GAME_REGION_PAL 1
+33 -44
View File
@@ -16,28 +16,15 @@ typedef enum Method {
HOLD,
} Method;
std::array<const char*, 12> acMapping = {
"Switch",
"Background",
"Player",
"Explosive",
"NPC",
"Enemy",
"Prop",
"Item/Action",
"Misc.",
"Boss",
"Door",
"Chest"
};
std::array<const char*, 12> acMapping = { "Switch", "Background", "Player", "Explosive", "NPC", "Enemy",
"Prop", "Item/Action", "Misc.", "Boss", "Door", "Chest" };
#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName, _humanName) {_enumValue, _humanName},
#define DEFINE_ACTOR_INTERNAL(_name, _enumValue, _allocType, _debugName, _humanName) {_enumValue, _humanName},
#define DEFINE_ACTOR_UNSET(_enumValue) {_enumValue, "Unset"},
#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName, _humanName) { _enumValue, _humanName },
#define DEFINE_ACTOR_INTERNAL(_name, _enumValue, _allocType, _debugName, _humanName) { _enumValue, _humanName },
#define DEFINE_ACTOR_UNSET(_enumValue) { _enumValue, "Unset" },
std::unordered_map<s16, const char*> actorDescriptions = {
#include "tables/actor_table.h"
#include "tables/actor_table.h"
};
#undef DEFINE_ACTOR
@@ -49,7 +36,8 @@ std::string GetActorDescription(u16 actorNum) {
}
std::vector<Actor*> GetCurrentSceneActors() {
if (!gPlayState) return {};
if (!gPlayState)
return {};
std::vector<Actor*> sceneActors;
for (size_t category = ACTORCAT_SWITCH; category < ACTORCAT_MAX; category++) {
@@ -62,7 +50,6 @@ std::vector<Actor*> GetCurrentSceneActors() {
}
}
return sceneActors;
}
static bool needs_reset = false;
@@ -127,8 +114,10 @@ void ActorViewerWindow::DrawElement() {
display = list[i];
newActorId = i;
filler = label;
GameInteractor::Instance->UnregisterGameHookForPtr<GameInteractor::ShouldActorDraw>(preventActorDrawHookId);
GameInteractor::Instance->UnregisterGameHookForPtr<GameInteractor::ShouldActorUpdate>(preventActorUpdateHookId);
GameInteractor::Instance->UnregisterGameHookForPtr<GameInteractor::ShouldActorDraw>(
preventActorDrawHookId);
GameInteractor::Instance->UnregisterGameHookForPtr<GameInteractor::ShouldActorUpdate>(
preventActorUpdateHookId);
preventActorDrawHookId = 0;
preventActorUpdateHookId = 0;
break;
@@ -150,27 +139,29 @@ void ActorViewerWindow::DrawElement() {
ImGui::BeginGroup();
if (preventActorDrawHookId) {
if (ImGui::Button("Continue Drawing", ImVec2(ImGui::GetFontSize() * 10, 0))) {
GameInteractor::Instance->UnregisterGameHookForPtr<GameInteractor::ShouldActorDraw>(preventActorDrawHookId);
GameInteractor::Instance->UnregisterGameHookForPtr<GameInteractor::ShouldActorDraw>(
preventActorDrawHookId);
preventActorDrawHookId = 0;
}
} else {
if (ImGui::Button("Stop Drawing", ImVec2(ImGui::GetFontSize() * 10, 0))) {
preventActorDrawHookId = GameInteractor::Instance->RegisterGameHookForPtr<GameInteractor::ShouldActorDraw>((uintptr_t)display, [](Actor* _, bool* result) {
*result = false;
});
preventActorDrawHookId =
GameInteractor::Instance->RegisterGameHookForPtr<GameInteractor::ShouldActorDraw>(
(uintptr_t)display, [](Actor* _, bool* result) { *result = false; });
}
}
ImGui::SameLine();
if (preventActorUpdateHookId) {
if (ImGui::Button("Continue Updating", ImVec2(ImGui::GetFontSize() * 10, 0))) {
GameInteractor::Instance->UnregisterGameHookForPtr<GameInteractor::ShouldActorUpdate>(preventActorUpdateHookId);
GameInteractor::Instance->UnregisterGameHookForPtr<GameInteractor::ShouldActorUpdate>(
preventActorUpdateHookId);
preventActorUpdateHookId = 0;
}
} else {
if (ImGui::Button("Stop Updating", ImVec2(ImGui::GetFontSize() * 10, 0))) {
preventActorUpdateHookId = GameInteractor::Instance->RegisterGameHookForPtr<GameInteractor::ShouldActorUpdate>((uintptr_t)display, [](Actor* _, bool* result) {
*result = false;
});
preventActorUpdateHookId =
GameInteractor::Instance->RegisterGameHookForPtr<GameInteractor::ShouldActorUpdate>(
(uintptr_t)display, [](Actor* _, bool* result) { *result = false; });
}
}
ImGui::EndGroup();
@@ -228,7 +219,7 @@ void ActorViewerWindow::DrawElement() {
}
}
if (UIWidgets::Button("Fetch: Target", {.tooltip = "Grabs actor with target arrow above it."})) {
if (UIWidgets::Button("Fetch: Target", { .tooltip = "Grabs actor with target arrow above it." })) {
Player* player = GET_PLAYER(gPlayState);
fetch = player->lockOnActor;
if (fetch != nullptr) {
@@ -240,7 +231,7 @@ void ActorViewerWindow::DrawElement() {
display = {};
}
}
if (UIWidgets::Button("Fetch: Held", {.tooltip = "Grabs actor Link is currently holding."})) {
if (UIWidgets::Button("Fetch: Held", { .tooltip = "Grabs actor Link is currently holding." })) {
Player* player = GET_PLAYER(gPlayState);
fetch = player->heldActor;
if (fetch != nullptr) {
@@ -253,13 +244,11 @@ void ActorViewerWindow::DrawElement() {
}
}
if (UIWidgets::Button("Kill", {.color = UIWidgets::Colors::Red}) && display != nullptr &&
if (UIWidgets::Button("Kill", { .color = UIWidgets::Colors::Red }) && display != nullptr &&
display->id != ACTOR_PLAYER) {
Actor_Kill(display);
}
ImGui::TreePop();
}
if (ImGui::TreeNode("New...")) {
@@ -288,7 +277,8 @@ void ActorViewerWindow::DrawElement() {
ImGui::InputScalar("rZ", ImGuiDataType_S16, &newActor.rot.z);
ImGui::EndGroup();
UIWidgets::CVarCheckbox("Remove Obj Dep?", "gObjDep", { .tooltip = "Allows actors to spawn where/when they normally wouldn't."});
UIWidgets::CVarCheckbox("Remove Obj Dep?", "gObjDep",
{ .tooltip = "Allows actors to spawn where/when they normally wouldn't." });
if (UIWidgets::Button("Fetch from Link")) {
Player* player = GET_PLAYER(gPlayState);
@@ -296,16 +286,17 @@ void ActorViewerWindow::DrawElement() {
newActor.rot = player->actor.world.rot;
}
if (UIWidgets::Button("Spawn", {.color = UIWidgets::Colors::Green})) {
if (UIWidgets::Button("Spawn", { .color = UIWidgets::Colors::Green })) {
Actor_Spawn(&gPlayState->actorCtx, gPlayState, newActor.id, newActor.pos.x, newActor.pos.y,
newActor.pos.z, newActor.rot.x, newActor.rot.y, newActor.rot.z, newActor.params);
newActor.pos.z, newActor.rot.x, newActor.rot.y, newActor.rot.z, newActor.params);
}
if (UIWidgets::Button("Spawn as Child", {.color = UIWidgets::Colors::Green})) {
if (UIWidgets::Button("Spawn as Child", { .color = UIWidgets::Colors::Green })) {
Actor* parent = display;
if (parent != nullptr) {
Actor_SpawnAsChild(&gPlayState->actorCtx, parent, gPlayState, newActor.id, newActor.pos.x,
newActor.pos.y, newActor.pos.z, newActor.rot.x, newActor.rot.y, newActor.rot.z, newActor.params);
newActor.pos.y, newActor.pos.z, newActor.rot.x, newActor.rot.y, newActor.rot.z,
newActor.params);
} else {
Audio_PlaySfx(NA_SE_SY_ERROR);
}
@@ -320,10 +311,8 @@ void ActorViewerWindow::DrawElement() {
} else {
ImGui::Text("Playstate needed for actors!");
}
ImGui::End();
ImGui::End();
}
void ActorViewerWindow::InitElement() {
}
+5 -5
View File
@@ -3,10 +3,10 @@
#include <libultraship/libultraship.h>
class ActorViewerWindow : public Ship::GuiWindow {
public:
using GuiWindow::GuiWindow;
public:
using GuiWindow::GuiWindow;
void InitElement() override;
void DrawElement() override;
void UpdateElement() override {};
void InitElement() override;
void DrawElement() override;
void UpdateElement() override{};
};
+11 -13
View File
@@ -25,12 +25,13 @@ void BetterMapSelect_LoadFileSelect(MapSelectState* mapSelectState) {
}
// 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName
#define DEFINE_SCENE(_name, _enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, entranceSceneId, _betterMapSelectIndex, humanName) \
#define DEFINE_SCENE(_name, _enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, \
entranceSceneId, _betterMapSelectIndex, humanName) \
{ humanName, BetterMapSelect_LoadGame, ENTRANCE(entranceSceneId, 0) },
#define DEFINE_SCENE_UNSET(_enumValue)
static SceneSelectEntry sBetterScenes[104] = {
#include "tables/scene_table.h"
#include "tables/scene_table.h"
{ "File Select", BetterMapSelect_LoadFileSelect, 0 },
{ "Title Screen", MapSelect_LoadConsoleLogo, 0 },
};
@@ -39,7 +40,8 @@ static SceneSelectEntry sBetterScenes[104] = {
#undef DEFINE_SCENE_UNSET
// 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName
#define DEFINE_SCENE(_name, _enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, entranceSceneId, betterMapSelectIndex, humanName) \
#define DEFINE_SCENE(_name, _enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, \
entranceSceneId, betterMapSelectIndex, humanName) \
{ humanName, ENTRANCE(entranceSceneId, 0), betterMapSelectIndex },
#define DEFINE_SCENE_UNSET(_enumValue)
@@ -50,7 +52,7 @@ typedef struct {
} BetterMapSelectInfoEntry;
static BetterMapSelectInfoEntry sBetterMapSelectInfo[102] = {
#include "tables/scene_table.h"
#include "tables/scene_table.h"
};
#undef DEFINE_SCENE
@@ -92,11 +94,7 @@ void BetterMapSelect_Update(MapSelectState* mapSelectState) {
}
static const char* betterFormLabels[] = {
"Deity",
"Goron",
"Zora",
"Deku",
"Child",
"Deity", "Goron", "Zora", "Deku", "Child",
};
void BetterMapSelect_PrintMenu(MapSelectState* mapSelectState, GfxPrint* printer) {
@@ -122,7 +120,7 @@ void BetterMapSelect_PrintMenu(MapSelectState* mapSelectState, GfxPrint* printer
} else {
GfxPrint_SetColor(printer, 175, 175, 175, 255);
}
sceneName = sBetterScenes[sceneIndex].name;
GfxPrint_Printf(printer, "%3d %s", sceneIndex, sceneName);
};
@@ -173,11 +171,11 @@ void BetterMapSelect_PrintMenu(MapSelectState* mapSelectState, GfxPrint* printer
GfxPrint_SetColor(printer, 200, 100, 200, 255);
switch (gSaveContext.save.cutsceneIndex) {
case 0:
gSaveContext.save.time = CLOCK_TIME(12, 0);
gSaveContext.save.time = CLOCK_TIME(12, 0);
stageName = "Afternoon";
break;
case 0x8000:
gSaveContext.save.time = CLOCK_TIME(6, 0) + 1;
gSaveContext.save.time = CLOCK_TIME(6, 0) + 1;
stageName = "Morning";
break;
case 0x8800:
@@ -185,7 +183,7 @@ void BetterMapSelect_PrintMenu(MapSelectState* mapSelectState, GfxPrint* printer
stageName = "Night";
break;
case 0xFFF0:
gSaveContext.save.time = CLOCK_TIME(12, 0);
gSaveContext.save.time = CLOCK_TIME(12, 0);
stageName = "0";
break;
case 0xFFF1:
+39 -27
View File
@@ -74,10 +74,14 @@ void CollisionViewerWindow::DrawElement() {
ImGui::SeparatorText("Collision Types");
UIWidgets::CVarCombobox("Scene", "gCollisionViewer.SceneCollisionMode", ColRenderSettingNames, { .color = UIWidgets::Colors::Gray });
UIWidgets::CVarCombobox("BG Actors", "gCollisionViewer.BGActorsCollisionMode", ColRenderSettingNames, { .color = UIWidgets::Colors::Gray });
UIWidgets::CVarCombobox("Col Check", "gCollisionViewer.ColCheckCollisionMode", ColRenderSettingNames, { .color = UIWidgets::Colors::Gray });
UIWidgets::CVarCombobox("Waterbox", "gCollisionViewer.WaterboxCollisionMode", ColRenderSettingNames, { .color = UIWidgets::Colors::Gray });
UIWidgets::CVarCombobox("Scene", "gCollisionViewer.SceneCollisionMode", ColRenderSettingNames,
{ .color = UIWidgets::Colors::Gray });
UIWidgets::CVarCombobox("BG Actors", "gCollisionViewer.BGActorsCollisionMode", ColRenderSettingNames,
{ .color = UIWidgets::Colors::Gray });
UIWidgets::CVarCombobox("Col Check", "gCollisionViewer.ColCheckCollisionMode", ColRenderSettingNames,
{ .color = UIWidgets::Colors::Gray });
UIWidgets::CVarCombobox("Waterbox", "gCollisionViewer.WaterboxCollisionMode", ColRenderSettingNames,
{ .color = UIWidgets::Colors::Gray });
ImGui::SeparatorText("Colors");
@@ -102,8 +106,10 @@ void CollisionViewerWindow::DrawElement() {
UIWidgets::CVarColorPicker("AT", "gCollisionViewer.ATCollisionColor", { 255, 0, 0, 255 });
ImGui::EndTable();
}
UIWidgets::CVarColorPicker("Special Surface (Grass/Sand/Etc)", "gCollisionViewer.SpecialSurfaceColor", { 192, 255, 192, 255 });
UIWidgets::CVarColorPicker("Interactable (Vines/Crawlspace/Etc)", "gCollisionViewer.InteractableColor", { 192, 0, 192, 255 });
UIWidgets::CVarColorPicker("Special Surface (Grass/Sand/Etc)", "gCollisionViewer.SpecialSurfaceColor",
{ 192, 255, 192, 255 });
UIWidgets::CVarColorPicker("Interactable (Vines/Crawlspace/Etc)", "gCollisionViewer.InteractableColor",
{ 192, 0, 192, 255 });
ImGui::EndDisabled();
@@ -201,9 +207,9 @@ void CreateSphereFace(std::vector<std::tuple<size_t, size_t, size_t>>& faces, in
// Create 3 new verticies at the midpoints
Vec3f vs[3] = {
Vec3f{(v0.n.ob[0] + v1.n.ob[0]) / 2.0f, (v0.n.ob[1] + v1.n.ob[1]) / 2.0f, (v0.n.ob[2] + v1.n.ob[2]) / 2.0f},
Vec3f{(v1.n.ob[0] + v2.n.ob[0]) / 2.0f, (v1.n.ob[1] + v2.n.ob[1]) / 2.0f, (v1.n.ob[2] + v2.n.ob[2]) / 2.0f},
Vec3f{(v2.n.ob[0] + v0.n.ob[0]) / 2.0f, (v2.n.ob[1] + v0.n.ob[1]) / 2.0f, (v2.n.ob[2] + v0.n.ob[2]) / 2.0f}
Vec3f{ (v0.n.ob[0] + v1.n.ob[0]) / 2.0f, (v0.n.ob[1] + v1.n.ob[1]) / 2.0f, (v0.n.ob[2] + v1.n.ob[2]) / 2.0f },
Vec3f{ (v1.n.ob[0] + v2.n.ob[0]) / 2.0f, (v1.n.ob[1] + v2.n.ob[1]) / 2.0f, (v1.n.ob[2] + v2.n.ob[2]) / 2.0f },
Vec3f{ (v2.n.ob[0] + v0.n.ob[0]) / 2.0f, (v2.n.ob[1] + v0.n.ob[1]) / 2.0f, (v2.n.ob[2] + v0.n.ob[2]) / 2.0f }
};
// Normalize vertex positions so they are on the sphere
@@ -228,20 +234,20 @@ void CreateSphereData() {
float d = (1.0f + sqrtf(5.0f)) / 2.0f;
// Create the 12 starting verticies, 4 on each rectangle
base.emplace_back(Vec3f({-1, d, 0}));
base.emplace_back(Vec3f({1, d, 0}));
base.emplace_back(Vec3f({-1, -d, 0}));
base.emplace_back(Vec3f({1, -d, 0}));
base.emplace_back(Vec3f({ -1, d, 0 }));
base.emplace_back(Vec3f({ 1, d, 0 }));
base.emplace_back(Vec3f({ -1, -d, 0 }));
base.emplace_back(Vec3f({ 1, -d, 0 }));
base.emplace_back(Vec3f({0, -1, d}));
base.emplace_back(Vec3f({0, 1, d}));
base.emplace_back(Vec3f({0, -1, -d}));
base.emplace_back(Vec3f({0, 1, -d}));
base.emplace_back(Vec3f({ 0, -1, d }));
base.emplace_back(Vec3f({ 0, 1, d }));
base.emplace_back(Vec3f({ 0, -1, -d }));
base.emplace_back(Vec3f({ 0, 1, -d }));
base.emplace_back(Vec3f({d, 0, -1}));
base.emplace_back(Vec3f({d, 0, 1}));
base.emplace_back(Vec3f({-d, 0, -1}));
base.emplace_back(Vec3f({-d, 0, 1}));
base.emplace_back(Vec3f({ d, 0, -1 }));
base.emplace_back(Vec3f({ d, 0, 1 }));
base.emplace_back(Vec3f({ -d, 0, -1 }));
base.emplace_back(Vec3f({ -d, 0, 1 }));
// Normalize verticies so they are on the unit sphere
for (Vec3f& v : base) {
@@ -350,7 +356,8 @@ void DrawDynapoly(std::vector<Gfx>& dl, CollisionHeader* col, int32_t bgId) {
Color_RGBA8 voidCollisionColor = CVarGetColor("gCollisionViewer.VoidCollisionColor", { 255, 0, 0, 255 });
Color_RGBA8 entranceCollisionColor = CVarGetColor("gCollisionViewer.EntranceCollisionColor", { 0, 255, 0, 255 });
Color_RGBA8 slopeCollisionColor = CVarGetColor("gCollisionViewer.SlopeCollisionColor", { 255, 255, 128, 255 });
Color_RGBA8 hookshotCollisionColor = CVarGetColor("gCollisionViewer.HookshotCollisionColor", { 128, 128, 255, 255 });
Color_RGBA8 hookshotCollisionColor =
CVarGetColor("gCollisionViewer.HookshotCollisionColor", { 128, 128, 255, 255 });
Color_RGBA8 specialSurfaceColor = CVarGetColor("gCollisionViewer.SpecialSurfaceColor", { 192, 255, 192, 255 });
Color_RGBA8 interactableColor = CVarGetColor("gCollisionViewer.InteractableColor", { 192, 0, 192, 255 });
uint32_t colorR = sceneCollisionColor.r;
@@ -448,7 +455,8 @@ void DrawDynapoly(std::vector<Gfx>& dl, CollisionHeader* col, int32_t bgId) {
// Draws the scene
void DrawSceneCollision() {
ColRenderSetting showSceneColSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.SceneCollisionMode", (uint32_t)ColRenderSetting::Disabled);
ColRenderSetting showSceneColSetting =
(ColRenderSetting)CVarGetInteger("gCollisionViewer.SceneCollisionMode", (uint32_t)ColRenderSetting::Disabled);
if (showSceneColSetting == ColRenderSetting::Disabled) {
return;
@@ -463,7 +471,8 @@ void DrawSceneCollision() {
// Draws all Bg Actors
void DrawBgActorCollision() {
ColRenderSetting showBgActorSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.BGActorsCollisionMode", (uint32_t)ColRenderSetting::Disabled);
ColRenderSetting showBgActorSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.BGActorsCollisionMode",
(uint32_t)ColRenderSetting::Disabled);
if (showBgActorSetting == ColRenderSetting::Disabled) {
return;
}
@@ -591,7 +600,8 @@ void DrawColCheckCollision() {
Color_RGBA8 oCollisionColor = CVarGetColor("gCollisionViewer.OCollisionColor", { 255, 255, 255, 255 });
Color_RGBA8 aCollisionColor = CVarGetColor("gCollisionViewer.ACollisionColor", { 0, 0, 255, 255 });
Color_RGBA8 aTCollisionColor = CVarGetColor("gCollisionViewer.ATCollisionColor", { 255, 0, 0, 255 });
ColRenderSetting showColCheckSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.ColCheckCollisionMode", (uint32_t)ColRenderSetting::Disabled);
ColRenderSetting showColCheckSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.ColCheckCollisionMode",
(uint32_t)ColRenderSetting::Disabled);
if (showColCheckSetting == ColRenderSetting::Disabled) {
return;
}
@@ -639,7 +649,8 @@ void DrawWaterbox(std::vector<Gfx>& dl, WaterBox* water, float water_max_depth =
// Draws all waterboxes
void DrawWaterboxList() {
Color_RGBA8 waterboxCollisionColor = CVarGetColor("gCollisionViewer.WaterboxCollisionColor", { 0, 0, 255, 255 });
ColRenderSetting showWaterboxSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.WaterboxCollisionMode", (uint32_t)ColRenderSetting::Disabled);
ColRenderSetting showWaterboxSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.WaterboxCollisionMode",
(uint32_t)ColRenderSetting::Disabled);
if (showWaterboxSetting == ColRenderSetting::Disabled) {
return;
}
@@ -648,7 +659,8 @@ void DrawWaterboxList() {
InitGfx(dl, showWaterboxSetting);
dl.push_back(gsSPMatrix(&gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH));
dl.push_back(gsDPSetPrimColor(0, 0, waterboxCollisionColor.r, waterboxCollisionColor.g, waterboxCollisionColor.b, 255));
dl.push_back(
gsDPSetPrimColor(0, 0, waterboxCollisionColor.r, waterboxCollisionColor.g, waterboxCollisionColor.b, 255));
CollisionHeader* col = gPlayState->colCtx.colHeader;
for (int32_t waterboxIndex = 0; waterboxIndex < col->numWaterBoxes; waterboxIndex++) {
+1 -1
View File
@@ -17,7 +17,7 @@ class CollisionViewerWindow : public Ship::GuiWindow {
void InitElement() override;
void DrawElement() override;
void UpdateElement() override {};
void UpdateElement() override{};
};
#endif
+14 -14
View File
@@ -17,11 +17,11 @@ extern "C" {
#define CMD_REGISTER Ship::Context::GetInstance()->GetConsole()->AddCommand
// TODO: Commands should be using the output passed in.
#define ERROR_MESSAGE \
#define ERROR_MESSAGE \
std::reinterpret_pointer_cast<Ship::ConsoleWindow>( \
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \
->SendErrorMessage
#define INFO_MESSAGE \
#define INFO_MESSAGE \
std::reinterpret_pointer_cast<Ship::ConsoleWindow>( \
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \
->SendInfoMessage
@@ -132,7 +132,8 @@ static bool ResetHandler(std::shared_ptr<Ship::Console> Console, std::vector<std
return 0;
}
static bool BHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args, std::string* output) {
static bool BHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args,
std::string* output) {
if (args.size() < 2) {
ERROR_MESSAGE("[2S2H] Unexpected arguments passed");
return 1;
@@ -277,17 +278,16 @@ void DebugConsole_Init(void) {
CMD_REGISTER("bItem", { BHandler, "Set an item to the B button.", { { "Item ID", Ship::ArgumentType::NUMBER } } });
CMD_REGISTER("spawn",
{ ActorSpawnHandler,
"Spawn an actor.",
{ { "actor id", Ship::ArgumentType::NUMBER },
{ "data", Ship::ArgumentType::NUMBER },
{ "x", Ship::ArgumentType::NUMBER, true },
{ "y", Ship::ArgumentType::NUMBER, true },
{ "z", Ship::ArgumentType::NUMBER, true },
{ "rx", Ship::ArgumentType::NUMBER, true },
{ "ry", Ship::ArgumentType::NUMBER, true },
{ "rz", Ship::ArgumentType::NUMBER, true } } });
CMD_REGISTER("spawn", { ActorSpawnHandler,
"Spawn an actor.",
{ { "actor id", Ship::ArgumentType::NUMBER },
{ "data", Ship::ArgumentType::NUMBER },
{ "x", Ship::ArgumentType::NUMBER, true },
{ "y", Ship::ArgumentType::NUMBER, true },
{ "z", Ship::ArgumentType::NUMBER, true },
{ "rx", Ship::ArgumentType::NUMBER, true },
{ "ry", Ship::ArgumentType::NUMBER, true },
{ "rz", Ship::ArgumentType::NUMBER, true } } });
CMD_REGISTER("pos", { SetPosHandler,
"Sets the position of the player.",
+6 -9
View File
@@ -119,9 +119,8 @@ void RegisterPreventActorUpdateHooks() {
}
if (CVarGetInteger("gDeveloperTools.PreventActorUpdate", 0)) {
hookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::ShouldActorUpdate>([](Actor* actor, bool* result) {
*result = false;
});
hookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::ShouldActorUpdate>(
[](Actor* actor, bool* result) { *result = false; });
}
}
@@ -133,9 +132,8 @@ void RegisterPreventActorDrawHooks() {
}
if (CVarGetInteger("gDeveloperTools.PreventActorDraw", 0)) {
hookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::ShouldActorDraw>([](Actor* actor, bool* result) {
*result = false;
});
hookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::ShouldActorDraw>(
[](Actor* actor, bool* result) { *result = false; });
}
}
@@ -147,9 +145,8 @@ void RegisterPreventActorInitHooks() {
}
if (CVarGetInteger("gDeveloperTools.PreventActorInit", 0)) {
hookId = GameInteractor::Instance->RegisterGameHookForFilter<GameInteractor::ShouldActorInit>(GameInteractor::HookFilter::SActorNotPlayer, [](Actor* actor, bool* result) {
*result = false;
});
hookId = GameInteractor::Instance->RegisterGameHookForFilter<GameInteractor::ShouldActorInit>(
GameInteractor::HookFilter::SActorNotPlayer, [](Actor* actor, bool* result) { *result = false; });
}
}
+130 -137
View File
@@ -26,16 +26,8 @@ typedef enum {
} EventLogEntryType;
const char* eventLogEntryTypeNames[] = {
"FlagSet",
"FlagUnset",
"SceneFlagSet",
"SceneFlagUnset",
"ActorInit",
"ActorKill",
"SceneInit",
"RoomInit",
"OpenText",
"ItemGive",
"FlagSet", "FlagUnset", "SceneFlagSet", "SceneFlagUnset", "ActorInit",
"ActorKill", "SceneInit", "RoomInit", "OpenText", "ItemGive",
};
struct EventLogEntry {
@@ -47,29 +39,17 @@ struct EventLogEntry {
std::vector<EventLogEntry> eventLogEntries;
const char* flagTypeNames[] = {
"",
"weekEventReg",
"eventInf",
"scenesVisible",
"owlActivation",
"chest",
"switch",
"clearedRoom",
"collectible",
"unk_14",
"rooms",
"chest *",
"switch *",
"clearedRoom *",
"collectible *",
"", "weekEventReg", "eventInf", "scenesVisible", "owlActivation",
"chest", "switch", "clearedRoom", "collectible", "unk_14",
"rooms", "chest *", "switch *", "clearedRoom *", "collectible *",
};
#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName, _humanName) {_enumValue, _debugName},
#define DEFINE_ACTOR_INTERNAL(_name, _enumValue, _allocType, _debugName, _humanName) {_enumValue, _debugName},
#define DEFINE_ACTOR_UNSET(_enumValue) {_enumValue, "Unset"},
#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName, _humanName) { _enumValue, _debugName },
#define DEFINE_ACTOR_INTERNAL(_name, _enumValue, _allocType, _debugName, _humanName) { _enumValue, _debugName },
#define DEFINE_ACTOR_UNSET(_enumValue) { _enumValue, "Unset" },
std::unordered_map<s16, const char*> actorNames = {
#include "tables/actor_table.h"
#include "tables/actor_table.h"
};
#undef DEFINE_ACTOR
@@ -77,12 +57,13 @@ std::unordered_map<s16, const char*> actorNames = {
#undef DEFINE_ACTOR_UNSET
// 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName
#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, _entranceSceneId, _betterMapSelectIndex, humanName) \
#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, \
_entranceSceneId, _betterMapSelectIndex, humanName) \
{ enumValue, humanName },
#define DEFINE_SCENE_UNSET(_enumValue)
std::unordered_map<s16, const char*> sceneNames = {
#include "tables/scene_table.h"
#include "tables/scene_table.h"
};
#undef DEFINE_SCENE
@@ -140,121 +121,139 @@ void RegisterEventLogHooks() {
return;
}
onFlagSetHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnFlagSet>([](FlagType type, u32 flag) {
if (type == FlagType::FLAG_WEEK_EVENT_REG) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_FLAG_SET,
.meta = fmt::format("WEEKEVENTREG_{:02d}_{:02x}", flag >> 8, flag & 0xFF),
});
} else if (type == FlagType::FLAG_EVENT_INF) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_FLAG_SET,
.meta = fmt::format("EVENTINF_{:02x}", flag),
});
} else {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_FLAG_SET,
.meta = fmt::format("{}({:02d}) {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF),
});
}
TrimEventLog();
});
onFlagUnsetHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnFlagUnset>([](FlagType type, u32 flag) {
if (type == FlagType::FLAG_WEEK_EVENT_REG) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_FLAG_UNSET,
.meta = fmt::format("WEEKEVENTREG_{:02d}_{:02x}", flag >> 8, flag & 0xFF),
});
} else if (type == FlagType::FLAG_EVENT_INF) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_FLAG_UNSET,
.meta = fmt::format("EVENTINF_{:02x}", flag),
});
} else {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_FLAG_UNSET,
.meta = fmt::format("{}({:02d}) {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF),
});
}
TrimEventLog();
});
onSceneFlagSetHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneFlagSet>([](s16 sceneId, FlagType type, u32 flag) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_SCENE_FLAG_SET,
.meta = fmt::format("{}({:02d}) {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF),
onFlagSetHookId =
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnFlagSet>([](FlagType type, u32 flag) {
if (type == FlagType::FLAG_WEEK_EVENT_REG) {
eventLogEntries.insert(eventLogEntries.begin(),
{
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_FLAG_SET,
.meta = fmt::format("WEEKEVENTREG_{:02d}_{:02x}", flag >> 8, flag & 0xFF),
});
} else if (type == FlagType::FLAG_EVENT_INF) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_FLAG_SET,
.meta = fmt::format("EVENTINF_{:02x}", flag),
});
} else {
eventLogEntries.insert(
eventLogEntries.begin(),
{
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_FLAG_SET,
.meta = fmt::format("{}({:02d}) {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF),
});
}
TrimEventLog();
});
TrimEventLog();
});
onSceneFlagUnsetHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneFlagUnset>([](s16 sceneId, FlagType type, u32 flag) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_SCENE_FLAG_UNSET,
.meta = fmt::format("{}[{:02d}] {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF),
onFlagUnsetHookId =
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnFlagUnset>([](FlagType type, u32 flag) {
if (type == FlagType::FLAG_WEEK_EVENT_REG) {
eventLogEntries.insert(eventLogEntries.begin(),
{
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_FLAG_UNSET,
.meta = fmt::format("WEEKEVENTREG_{:02d}_{:02x}", flag >> 8, flag & 0xFF),
});
} else if (type == FlagType::FLAG_EVENT_INF) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_FLAG_UNSET,
.meta = fmt::format("EVENTINF_{:02x}", flag),
});
} else {
eventLogEntries.insert(
eventLogEntries.begin(),
{
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_FLAG_UNSET,
.meta = fmt::format("{}({:02d}) {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF),
});
}
TrimEventLog();
});
onSceneFlagSetHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneFlagSet>(
[](s16 sceneId, FlagType type, u32 flag) {
eventLogEntries.insert(
eventLogEntries.begin(),
{
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_SCENE_FLAG_SET,
.meta = fmt::format("{}({:02d}) {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF),
});
TrimEventLog();
});
onSceneFlagUnsetHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneFlagUnset>(
[](s16 sceneId, FlagType type, u32 flag) {
eventLogEntries.insert(
eventLogEntries.begin(),
{
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_SCENE_FLAG_UNSET,
.meta = fmt::format("{}[{:02d}] {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF),
});
TrimEventLog();
});
TrimEventLog();
});
onActorInitHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnActorInit>([](Actor* actor) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_ACTOR_INIT,
.meta = fmt::format("{} {}", actorNames[actor->id], actor->params),
});
eventLogEntries.insert(eventLogEntries.begin(),
{
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_ACTOR_INIT,
.meta = fmt::format("{} {}", actorNames[actor->id], actor->params),
});
TrimEventLog();
});
onActorKillHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnActorKill>([](Actor* actor) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_ACTOR_KILL,
.meta = fmt::format("{} {}", actorNames[actor->id], actor->params),
});
eventLogEntries.insert(eventLogEntries.begin(),
{
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_ACTOR_KILL,
.meta = fmt::format("{} {}", actorNames[actor->id], actor->params),
});
TrimEventLog();
});
onSceneInitHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneInit>([](s16 sceneId, s8 spawnNum) {
onSceneInitHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneInit>([](s16 sceneId,
s8 spawnNum) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_SCENE_INIT,
.meta = fmt::format("{} {}", sceneNames[sceneId], spawnNum),
});
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_SCENE_INIT,
.meta = fmt::format("{} {}", sceneNames[sceneId], spawnNum),
});
TrimEventLog();
});
onRoomInitHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnRoomInit>([](s16 sceneId, s8 roomId) {
onRoomInitHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnRoomInit>([](s16 sceneId,
s8 roomId) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_ROOM_INIT,
.meta = fmt::format("{} {}", sceneNames[sceneId], roomId),
});
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_ROOM_INIT,
.meta = fmt::format("{} {}", sceneNames[sceneId], roomId),
});
TrimEventLog();
});
onOpenTextHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnOpenText>([](s16 textId) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_OPEN_TEXT,
.meta = fmt::format("0x{:02x}", textId),
});
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_OPEN_TEXT,
.meta = fmt::format("0x{:02x}", textId),
});
TrimEventLog();
});
onItemGiveHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnItemGive>([](u8 item) {
eventLogEntries.insert(eventLogEntries.begin(), {
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_ITEM_GIVE,
.meta = fmt::format("0x{:02x}", item),
});
.timestamp = CurrentTime(),
.type = EVENT_LOG_ENTRY_TYPE_ITEM_GIVE,
.meta = fmt::format("0x{:02x}", item),
});
TrimEventLog();
});
}
@@ -278,31 +277,24 @@ void EventLogWindow::DrawElement() {
if (ImGui::BeginPopup("eventLogFiltersPopup")) {
bool allChecked =
CVarGetInteger("gEventLog.Filter.FlagSet", 1) &&
CVarGetInteger("gEventLog.Filter.FlagUnset", 1) &&
CVarGetInteger("gEventLog.Filter.FlagSet", 1) && CVarGetInteger("gEventLog.Filter.FlagUnset", 1) &&
CVarGetInteger("gEventLog.Filter.SceneFlagSet", 1) &&
CVarGetInteger("gEventLog.Filter.SceneFlagUnset", 1) &&
CVarGetInteger("gEventLog.Filter.ActorInit", 1) &&
CVarGetInteger("gEventLog.Filter.ActorKill", 1) &&
CVarGetInteger("gEventLog.Filter.SceneInit", 1) &&
CVarGetInteger("gEventLog.Filter.RoomInit", 1) &&
CVarGetInteger("gEventLog.Filter.OpenText", 1) &&
CVarGetInteger("gEventLog.Filter.SceneFlagUnset", 1) && CVarGetInteger("gEventLog.Filter.ActorInit", 1) &&
CVarGetInteger("gEventLog.Filter.ActorKill", 1) && CVarGetInteger("gEventLog.Filter.SceneInit", 1) &&
CVarGetInteger("gEventLog.Filter.RoomInit", 1) && CVarGetInteger("gEventLog.Filter.OpenText", 1) &&
CVarGetInteger("gEventLog.Filter.ItemGive", 1);
bool someChecked =
CVarGetInteger("gEventLog.Filter.FlagSet", 1) ||
CVarGetInteger("gEventLog.Filter.FlagUnset", 1) ||
CVarGetInteger("gEventLog.Filter.FlagSet", 1) || CVarGetInteger("gEventLog.Filter.FlagUnset", 1) ||
CVarGetInteger("gEventLog.Filter.SceneFlagSet", 1) ||
CVarGetInteger("gEventLog.Filter.SceneFlagUnset", 1) ||
CVarGetInteger("gEventLog.Filter.ActorInit", 1) ||
CVarGetInteger("gEventLog.Filter.ActorKill", 1) ||
CVarGetInteger("gEventLog.Filter.SceneInit", 1) ||
CVarGetInteger("gEventLog.Filter.RoomInit", 1) ||
CVarGetInteger("gEventLog.Filter.OpenText", 1) ||
CVarGetInteger("gEventLog.Filter.SceneFlagUnset", 1) || CVarGetInteger("gEventLog.Filter.ActorInit", 1) ||
CVarGetInteger("gEventLog.Filter.ActorKill", 1) || CVarGetInteger("gEventLog.Filter.SceneInit", 1) ||
CVarGetInteger("gEventLog.Filter.RoomInit", 1) || CVarGetInteger("gEventLog.Filter.OpenText", 1) ||
CVarGetInteger("gEventLog.Filter.ItemGive", 1);
ImGuiContext* g = ImGui::GetCurrentContext();
ImGuiItemFlags backup_item_flags = g->CurrentItemFlags;
if (!allChecked && someChecked) g->CurrentItemFlags |= ImGuiItemFlags_MixedValue;
if (!allChecked && someChecked)
g->CurrentItemFlags |= ImGuiItemFlags_MixedValue;
if (UIWidgets::Checkbox("All", &allChecked)) {
if (allChecked) {
CVarSetInteger("gEventLog.Filter.FlagSet", 1);
@@ -376,7 +368,8 @@ void EventLogWindow::DrawElement() {
ImGui::TableHeadersRow();
for (int i = 0; i < eventLogEntries.size(); i++) {
if (!CVarGetInteger((std::string("gEventLog.Filter.") + eventLogEntryTypeNames[eventLogEntries[i].type]).c_str(), 1)) {
if (!CVarGetInteger(
(std::string("gEventLog.Filter.") + eventLogEntryTypeNames[eventLogEntries[i].type]).c_str(), 1)) {
continue;
}
+5 -5
View File
@@ -3,10 +3,10 @@
#include <libultraship/libultraship.h>
class EventLogWindow : public Ship::GuiWindow {
public:
using GuiWindow::GuiWindow;
public:
using GuiWindow::GuiWindow;
void InitElement() override;
void DrawElement() override;
void UpdateElement() override {};
void InitElement() override;
void DrawElement() override;
void UpdateElement() override{};
};
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -3,10 +3,10 @@
#include <libultraship/libultraship.h>
class SaveEditorWindow : public Ship::GuiWindow {
public:
using GuiWindow::GuiWindow;
public:
using GuiWindow::GuiWindow;
void InitElement() override;
void DrawElement() override;
void UpdateElement() override {};
void InitElement() override;
void DrawElement() override;
void UpdateElement() override{};
};
+10 -10
View File
@@ -15,19 +15,21 @@ extern SaveContext gSaveContext;
#define CV "gDeveloperTools.WarpPoint."
// 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName
#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, _entranceSceneId, _betterMapSelectIndex, humanName) \
#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, \
_entranceSceneId, _betterMapSelectIndex, humanName) \
{ enumValue, humanName },
#define DEFINE_SCENE_UNSET(_enumValue)
std::unordered_map<s16, const char*> warpPointSceneList = {
#include "tables/scene_table.h"
#include "tables/scene_table.h"
};
#undef DEFINE_SCENE
#undef DEFINE_SCENE_UNSET
void RenderWarpPointSection() {
if (gPlayState == NULL) return;
if (gPlayState == NULL)
return;
if (UIWidgets::Button("Set Warp Point")) {
Player* player = GET_PLAYER(gPlayState);
@@ -58,14 +60,12 @@ void RenderWarpPointSection() {
}
ImGui::SameLine();
if (UIWidgets::Button("Warp", { .size = UIWidgets::Sizes::Inline })) {
Vec3f pos = { CVarGetFloat(CV "X", 0.0f),
CVarGetFloat(CV "Y", 0.0f),
CVarGetFloat(CV "Z", 0.0f) };
Vec3f pos = { CVarGetFloat(CV "X", 0.0f), CVarGetFloat(CV "Y", 0.0f), CVarGetFloat(CV "Z", 0.0f) };
Play_SetRespawnData(&gPlayState->state, RESPAWN_MODE_DOWN,
CVarGetInteger(CV "Entrance", ENTRANCE(SOUTH_CLOCK_TOWN, 0)),
CVarGetInteger(CV "Room", 0), PLAYER_PARAMS(0xFF, PLAYER_INITMODE_D),
&pos, CVarGetFloat(CV "Rotation", 0.0f));
Play_SetRespawnData(&gPlayState->state, RESPAWN_MODE_DOWN,
CVarGetInteger(CV "Entrance", ENTRANCE(SOUTH_CLOCK_TOWN, 0)),
CVarGetInteger(CV "Room", 0), PLAYER_PARAMS(0xFF, PLAYER_INITMODE_D), &pos,
CVarGetFloat(CV "Rotation", 0.0f));
func_80169EFC(&gPlayState->state);
}
}

Some files were not shown because too many files have changed in this diff Show More