Skip to content

Commit

Permalink
Post PR cleanup and adding features from GD repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Amethyst-szs committed Aug 25, 2023
1 parent 9650fef commit 755ed5b
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/program/devgui/DevGuiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void DevGuiManager::createElements()
createWindow<WindowInfo>(infoWindowName, true);
createWindow<WindowActorBrowse>(actorBrowseWindowName, false);
createWindow<WindowFPS>(fpsWindowName, true);
createWindow<WindowTAS>(tasWindowName, true);
createWindow<WindowTAS>(tasWindowName, false);

WindowGroup* memoryGroup = createWindowGroup("Memory Tools", 2);
createWindow<WindowLoadLog>(loadLogWindowName, false, memoryGroup);
Expand Down
3 changes: 2 additions & 1 deletion src/program/devgui/settings/DevGuiSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ DevGuiSettings::DevGuiSettings(DevGuiManager* parent)
registerNewSetting(false, true, "Clear Wall Jump Limits");
registerNewSetting(false, true, "Button Motion Roll");
registerNewSetting(false, true, "Moon Refresh");
registerNewSetting(false, true, "Disable Kingdom Moon Lock");
registerNewSetting(false, true, "Always Manually Skip Cutscenes");
registerNewSetting(false, true, "Always Allow Checkpoints");
registerNewSetting(true, true, "Autosave");
registerNewSetting(true, true, "Display HUD");
registerNewSetting(true, true, "Play Music");
registerNewSetting(false, true, "Always Manually Skip Cutscenes");

Logger::log(" Created %i settings\n", mSettings.size());
}
Expand Down
12 changes: 12 additions & 0 deletions src/program/devgui/settings/SettingsHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ HOOK_DEFINE_TRAMPOLINE(GreyShineRefreshHook) {
}
};

HOOK_DEFINE_TRAMPOLINE(DisableMoonLockHook) {
static int Callback(GameDataHolder *thisPtr, bool *isCrashList, int worldID) {
int lockSize = Orig(thisPtr, isCrashList, worldID);

if (DevGuiManager::instance()->getSettings()->getStateByName("Disable Kingdom Moon Lock"))
return 0;

return lockSize;
}
};

HOOK_DEFINE_TRAMPOLINE(ButtonMotionRollHook) {
static bool Callback(void* thisPtr) {
if (DevGuiManager::instance()->getSettings()->getStateByName("Button Motion Roll"))
Expand All @@ -158,6 +169,7 @@ void exlSetupSettingsHooks()
SaveHook::InstallAtSymbol("_ZNK10StageScene12isEnableSaveEv");
CheckpointWarpHook::InstallAtSymbol("_ZNK9MapLayout22isEnableCheckpointWarpEv");
GreyShineRefreshHook::InstallAtSymbol("_ZN16GameDataFunction10isGotShineE22GameDataHolderAccessorPK9ShineInfo");
DisableMoonLockHook::InstallAtSymbol("_ZNK14GameDataHolder18findUnlockShineNumEPbi");
ButtonMotionRollHook::InstallAtSymbol("_ZNK23PlayerJudgeStartRolling21isTriggerRestartSwingEv");
NoDamageHook::InstallAtSymbol("_ZN16GameDataFunction12damagePlayerE20GameDataHolderWriter");
exlSetupDemoHooks();
Expand Down
2 changes: 1 addition & 1 deletion src/program/ghost/GhostManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GhostManager : public al::NerveExecutor {
s64 mEntryCount;
nn::fs::DirectoryEntry* mEntries = nullptr;
bool* mActiveReplays = nullptr;
int mMaxGhostNum = 8;
int mMaxGhostNum = 1;
sead::PtrArray<Ghost> ghosts;
al::Scene* mScene = nullptr;
PlayerActorHakoniwa* mPlayer = nullptr;
Expand Down
19 changes: 18 additions & 1 deletion src/program/primitives/PrimitiveQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,19 @@ class PrimitiveQueue {

void pushLine(sead::Vector3f point1, sead::Vector3f point2, sead::Color4f col)
{
auto* entry = new (mHeap) PrimitiveTypeLine(point1, point2, col);
auto* entry = new (mHeap) PrimitiveTypeLine(point1, point2, col, 0.f, 0.f);
mRenderQueue.pushBack((PrimitiveTypeBase*)entry);
}

void pushLine(sead::Vector3f point1, sead::Vector3f point2, sead::Color4f col, float size)
{
auto* entry = new (mHeap) PrimitiveTypeLine(point1, point2, col, size, size);
mRenderQueue.pushBack((PrimitiveTypeBase*)entry);
}

void pushLine(sead::Vector3f point1, sead::Vector3f point2, sead::Color4f col, float size1, float size2)
{
auto* entry = new (mHeap) PrimitiveTypeLine(point1, point2, col, size1, size2);
mRenderQueue.pushBack((PrimitiveTypeBase*)entry);
}

Expand All @@ -40,6 +52,11 @@ class PrimitiveQueue {
mRenderQueue.pushBack((PrimitiveTypeBase*)entry);
}

void pushBox(sead::Vector3f pos, float size, sead::Color4f frame, sead::Color4f fill)
{
auto* entry = new (mHeap) PrimitiveTypeBox(pos, {size, size, size}, frame, fill);
mRenderQueue.pushBack((PrimitiveTypeBase*)entry);
}
void pushArea(const char* gName, sead::Color4f frame, sead::Color4f fill)
{
auto* entry = new (mHeap) PrimitiveTypeArea(gName, frame, fill);
Expand Down
22 changes: 22 additions & 0 deletions src/program/primitives/PrimitiveTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ void PrimitiveTypeLine::render()
{
sead::PrimitiveRenderer* renderer = sead::PrimitiveRenderer::instance();
renderer->drawLine(mPoints[0], mPoints[1], mColor);

if(mPointsSize[0] > 0.f)
renderer->drawSphere4x8(mPoints[0], mPointsSize[0], mColor - sead::Color4f(0.f, 0.f, 0.f, 0.25f));
if(mPointsSize[1] > 0.f)
renderer->drawSphere4x8(mPoints[1], mPointsSize[1], mColor - sead::Color4f(0.f, 0.f, 0.f, 0.25f));
}

void PrimitiveTypeAxis::render()
Expand All @@ -22,6 +27,23 @@ void PrimitiveTypeAxis::render()
renderer->drawAxis(mTranslation, mSize);
}

void PrimitiveTypeBox::render()
{
sead::PrimitiveRenderer* renderer = sead::PrimitiveRenderer::instance();

sead::Matrix34f mtx = sead::Matrix34f::ident;
mtx.setTranslation(mPos);

renderer->setModelMatrix(mtx);

sead::PrimitiveDrawer::CubeArg shapeAreaSolid(sead::Vector3f::zero, mSize, mFillColor);
sead::PrimitiveDrawer::CubeArg shapeAreaWire(sead::Vector3f::zero, mSize, mFrameColor);
renderer->drawCube(shapeAreaSolid);
renderer->drawWireCube(shapeAreaWire);

renderer->setModelMatrix(sead::Matrix34f::ident);
}

void PrimitiveTypeArea::render()
{
sead::PrimitiveRenderer* renderer = sead::PrimitiveRenderer::instance();
Expand Down
25 changes: 24 additions & 1 deletion src/program/primitives/PrimitiveTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,19 @@ class PrimitiveTypePoint : public PrimitiveTypeBase {

class PrimitiveTypeLine : public PrimitiveTypeBase {
public:
PrimitiveTypeLine(sead::Vector3f point1, sead::Vector3f point2, sead::Color4f col)
PrimitiveTypeLine(sead::Vector3f point1, sead::Vector3f point2, sead::Color4f col, float pointSize1, float pointSize2)
: PrimitiveTypeBase(PrimitiveTypes::PRIM_LINE)
{
mPoints[0] = point1;
mPoints[1] = point2;
mPointsSize[0] = pointSize1;
mPointsSize[1] = pointSize2;
mColor = col;
}
~PrimitiveTypeLine() override {}

sead::Vector3f mPoints[2];
float mPointsSize[2];
sead::Color4f mColor;

void render() override;
Expand All @@ -85,6 +88,26 @@ class PrimitiveTypeAxis : public PrimitiveTypeBase {
void render() override;
};

class PrimitiveTypeBox : public PrimitiveTypeBase {
public:
PrimitiveTypeBox(sead::Vector3f pos, sead::Vector3f size, sead::Color4f frame, sead::Color4f fill)
: PrimitiveTypeBase(PrimitiveTypes::PRIM_AREA)
{
mPos = pos;
mSize = size;
mFrameColor = frame;
mFillColor = fill;
}
~PrimitiveTypeBox() override {}

sead::Vector3f mPos;
sead::Vector3f mSize;
sead::Color4f mFrameColor;
sead::Color4f mFillColor;

void render() override;
};

class PrimitiveTypeArea : public PrimitiveTypeBase {
public:
PrimitiveTypeArea(const char* gName, sead::Color4f frame, sead::Color4f fill)
Expand Down

0 comments on commit 755ed5b

Please sign in to comment.