Skip to content

Commit

Permalink
Add Minimap funcs, Annotate unknown Minimap and Cell related vars, do…
Browse files Browse the repository at this point in the history
…cument various vars (#81)

* add function definition for AddCreature

* Add MouthTypes to CommonIDs.h

* Add name for Unk10 in enum CreaturePersonality

* Add definitions to Cursors.h

* Fix typo, remove duplicate of auto_METHOD(cEditor, bool, AddCreature, add comment to funcC0h in cTribe.h

* Add enum of identity colors to cIdentityColorable

* Add several more cursors

* ammend comment

* remove mouthtypes commit

* Add space game cursors

* fix compile error in cursors.h

* remove erroneous comment

* change mIDColorID to use IdentityColors

* Add 2 new dev cheats (devEffectLog & PrintCursor), add support for palette subcategories in part icon capture.

NOTE:  UNTESTED!
For those who can, please compile this and test it ingame before accepting/rejecting PR.

* fix improper effects detour

* document several part unlocking related fields

* add comment to cCollectibleItems::sub_597BC0

* Add cursors, Document string format for CursorManager::Load

* fix typo

* Add Math::GetDistance

* Revert "Add Math::GetDistance"

This reverts commit cc145ad.

* Begin redoing EP1 object system

* Revert "change mIDColorID to use IdentityColors"

This reverts commit 489f3ad.

* Update cIdentityColorable.h

* cTribeHut - Document field_218

* cTribeHut - document field_21C

* Resolve 4/5 PR change requests

* add 'class' to identitycolor enum

* SpawnNpcTribe's 4rd interger arg = foodAmount

* fix typo

* fix typo in LoadBackgroundFiles

* Add message enums to SimulatorMessages.h, organize by stage

* fix typo

* Clarify new simulator messages

* Clarify more messages

* Add messages, change 1 type

* Update SimulatorMessages.h

* Update SimulatorMessages.h

* fix typo

* Document tribe vars

* Document cTribe.mbMembersFlee, add Button funcs, fix documentation comments

* Annotate unknown func

* Resolve PR issues

* Revert cTribeTool temp fix

* fix HandheldItem enum typos

* document tribe vars, rename BakeManager::func4Ch to Bake

* Document EditorNamePanel Initialize()

* rename mbMembersFlee to mbDefeated

* String16 serialization fix

* Update cTribe.h

* re-sort numgraspers next to numfeet in enum

* fix typos, document working OTDB params, reformat func28 in OTDB

* Update SimulatorMessages.h

* remove unnecessary comment

* rename field_80 in cCombatant to mbInvincible

* Document Cell Stage vars

* Add TribeToolData group ID

* Add kCitizenActionWalkTo

* document mPaintID

* add Simulator::GetMinimapWindow(), Add documentation related to minimap

* remove unneeded header

* remove messy comment

* undo dubious var name

* fix GetMinimapWindow crash

* add EditorManipulators enum to CommonIDs

* fix new enum to type as a uint32

* annotate EditorRigblock field_138

* fix typo

* fix typo in EditorRigblockBoolAttributes

* change kEditorRigblockModelCanBeParentless to kEditorRigblockModelCannotBeParentless

* document creature model related vars and flags

* clarify comment

* document int arg in cTribe::SpawnMember

* Add ColorRGB & ColorRGBA Serializers

* rename func78h to GrowUp()

* clarify cCreatureBase::IsHerbivore (also returns if creature is omnivore)

* Swap AbilityMode enum entries, annotate Editor::AddCreature()

* add better description for AnimEditor, Fix icon capture for subcategories and ingame community planners

* change IsHervibore to IsHerbivore (recent enough addition to mod API that i didn't include fallback names)

* stop tracking editable sdkpathconfigs

* gitgnore

* fix remaining 'hervibore' typo

* undo "Hervibore" fix due to crashes

* fix variable annotations

* add default var amount to AddCreature

* annotate var

* Editor::field_14C set to uint32

* change PaletteUIPtr  to Palettes::PaletteUI* in thumbnail capture
  • Loading branch information
Valla-Chan authored Jan 21, 2025
1 parent 17e4815 commit 88ded97
Show file tree
Hide file tree
Showing 31 changed files with 332 additions and 173 deletions.
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@ Release
Projects/*
!Projects/Example Projects/
/SDKtoGhidra/temp.cpp
modapi-generated-docs
modapi-generated-docs
/Projects/Example Projects/EditorPlayModeNoBounds/SdkPathConfig.props
/Projects/Example Projects/ModCreatorKit/SdkPathConfig.props
/Projects/Example Projects/TemplatesExample/SdkPathConfig.props
/Projects/Example Projects/SpaceToolCheat/SdkPathConfig.props
/Projects/Example Projects/GmdlExport/SdkPathConfig.props
/Projects/Example Projects/EditorPlayModeNoBounds/SdkPathConfig.props
/Projects/Example Projects/ModCreatorKit/SdkPathConfig.props
/Projects/Example Projects/SpaceToolCheat/SdkPathConfig.props
/Projects/Example Projects/TemplatesExample/SdkPathConfig.props
/Projects/Example Projects/GmdlExport/SdkPathConfig.props

This file was deleted.

18 changes: 0 additions & 18 deletions Projects/Example Projects/GmdlExport/SdkPathConfig.props

This file was deleted.

6 changes: 5 additions & 1 deletion Projects/Example Projects/ModCreatorKit/AnimEditorMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ bool AnimEditorMode::Initialize(App::IGameModeManager* pManager)
request.shopperID = id("CreatureShopper");
Sporepedia::ShopperRequest::Show(request);
}
else if (line.HasFlag("exit"))
{
GameModeManager.SetActiveMode(kGGEMode);
}
size_t numArgs;
if (auto args = line.GetOptionRange("play", &numArgs, 1, 2))
{
Expand All @@ -93,7 +97,7 @@ bool AnimEditorMode::Initialize(App::IGameModeManager* pManager)

const char* GetDescription(ArgScript::DescriptionMode mode) const override
{
return "Enters into anim editor";
return "Enters into anim editor. Use the flags -add and -remove to add or change creatures, and -exit to leave the mode.";
}
};

Expand Down
18 changes: 0 additions & 18 deletions Projects/Example Projects/ModCreatorKit/SdkPathConfig.props

This file was deleted.

115 changes: 96 additions & 19 deletions Projects/Example Projects/ModCreatorKit/ThumbnailCaptureScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ ThumbnailCaptureScript::~ThumbnailCaptureScript()
{
}

//---------------------------------------------------
// Detours

Palettes::PaletteUI* pLastPalette;

// Editor parts palette loading func, PaletteUI::Load. Used to pull the ingame palettes
member_detour(PaletteUILoad_detour, Palettes::PaletteUI, void(Palettes::PaletteMain*, UTFWin::IWindow*, bool, Palettes::PaletteInfo*)) {
void detoured(Palettes::PaletteMain* pPalette, UTFWin::IWindow* pWindow, bool bool1, Palettes::PaletteInfo* pInfo) {
pLastPalette = this;
original_function(this, pPalette, pWindow, bool1, pInfo);
}
};

void ThumbnailCaptureScript::AttachDetour() {
PaletteUILoad_detour::attach(GetAddress(Palettes::PaletteUI, Load));
}

//---------------------------------------------------


int ThumbnailCaptureScript::GetEventFlags() const {
return UTFWin::kEventRefresh;
}
Expand All @@ -52,7 +72,7 @@ bool ThumbnailCaptureScript::HandleUIMessage(IWindow* pWindow, const Message& me
mpItemViewer = mItemViewers[pWindow];
}
else if (message.IsType(kMsgMouseLeave)) {
// For some reason this might happen in paralel to Render? We don't want them to race
// For some reason this might happen in parallel to Render? We don't want them to race
//mpItemViewer = nullptr;
}
return false;
Expand Down Expand Up @@ -154,54 +174,97 @@ void ThumbnailCaptureScript::CaptureImage() {
device->SetRenderTarget(0, surface);
}


PaletteUIPtr ThumbnailCaptureScript::GetCurrentPalette() const {
// Editor is valid, get the parts palette
if (GetEditor() && GetEditor()->IsActive()) { return GetEditor()->mpPartsPaletteUI; }
// Editor is invalid, try the last loaded palette
else { return pLastPalette; }

}

void ThumbnailCaptureScript::InjectListeners() {

PaletteUIPtr palette = GetCurrentPalette();
if (!palette) { return; }

RemoveListeners();
for (auto catUI : GetEditor()->mpPartsPaletteUI->mCategories) {
auto subCatUIs = catUI->mpSubcategoriesUI;
for (PaletteCategoryUIPtr catUI : palette->mCategories) {
PaletteSubcategoriesUIPtr subCatUIs = catUI->mpSubcategoriesUI;

// subcategories present
if (subCatUIs) {
for (auto subCatUI : subCatUIs->mCategoryUIs) {
for (auto pageUI : catUI->mPageUIs) {
for (auto itemUI : pageUI.page->mStandardItems) {
itemUI->field_18->AddWinProc(this);
mItemViewers[itemUI->field_18.get()] = itemUI->mpViewer.get();
for (PaletteCategoryUIPtr subCatUI : subCatUIs->mCategoryUIs) {
for (auto pageUI : subCatUI->mPageUIs) {
// standard editor/planner
if (pageUI.page->mStandardItems.size() > 0) {
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
itemUI->field_18->AddWinProc(this);
mItemViewers[itemUI->field_18.get()] = itemUI->mpViewer.get();
}
}
// adventure editor
/*
else {
for (eastl::intrusive_ptr<Palettes::IAdvancedItemUI> itemUI : pageUI.page->mAdvancedItems) {
itemUI->mpWindow
mItemViewers[itemUI->field_18.get()] = itemUI->mpViewer.get();
}
}*/

}
}
}
// simple category
else {
for (auto pageUI : catUI->mPageUIs) {
for (auto itemUI : pageUI.page->mStandardItems) {
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
itemUI->field_18->AddWinProc(this);
mItemViewers[itemUI->field_18.get()] = itemUI->mpViewer.get();
}
}
}



}

Renderer.RegisterLayer(this, 40);
}



void ThumbnailCaptureScript::RemoveListeners() {

for (auto catUI : GetEditor()->mpPartsPaletteUI->mCategories) {
PaletteUIPtr palette = GetCurrentPalette();
if (!palette) { return; }

for (auto catUI : palette->mCategories) {
auto subCatUIs = catUI->mpSubcategoriesUI;

// subcategories present
if (subCatUIs) {
for (auto subCatUI : subCatUIs->mCategoryUIs) {
for (auto pageUI : catUI->mPageUIs) {
for (auto itemUI : pageUI.page->mStandardItems) {
if (itemUI && itemUI->field_18) {
for (PaletteCategoryUIPtr subCatUI : subCatUIs->mCategoryUIs) {
for (auto pageUI : subCatUI->mPageUIs) {
// standard editor/planner
if (pageUI.page->mStandardItems.size() > 0) {
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
itemUI->field_18->RemoveWinProc(this);
}
}
/*
// adventure editor
else {
for (StandardItemUIPtr itemUI : pageUI.page->mpPage->mItems) {
itemUI->field_18->RemoveWinProc(this);
}
}
*/
}
}
}
// simple category
else {
for (auto pageUI : catUI->mPageUIs) {
for (auto itemUI : pageUI.page->mStandardItems) {
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
if (itemUI && itemUI->field_18) {
itemUI->field_18->RemoveWinProc(this);
}
Expand All @@ -223,9 +286,23 @@ void ThumbnailCaptureScript::ParseLine(const ArgScript::Line& line) {
return;
}

//auto editor = GetEditor();

if (!Editor.IsActive()) {
App::ConsolePrintF("Must be in editor to use this cheat.");
return;

if (Simulator::GetGameModeID() == kEditorMode) {
App::ConsolePrintF("Must be in editor or a community planner to use this cheat.");
return;
}
// TODO: make this work in the adventure editor.
else if (Simulator::IsTribeGame() || Simulator::IsCivGame() || Simulator::IsSpaceGame()) { // || Simulator::IsScenarioMode()
// found a palette that's been loaded anyway
if (!pLastPalette) {
App::ConsolePrintF("Must be in editor or a community planner to use this cheat.");
}
}

//return;
}
else if (!Editor.IsMode(Mode::BuildMode)) {
App::ConsolePrintF("Must be in editor build mode to use this cheat.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ class ThumbnailCaptureScript
bool HandleMessage(uint32_t messageID, void* pMessage) override;

static void AddCheat();
static void AttachDetour();

private:

void CaptureImage();
Vector3 CalculateOffset(Graphics::Model* model);

PaletteUIPtr GetCurrentPalette() const;
void InjectListeners();
void RemoveListeners();

Expand Down
1 change: 1 addition & 0 deletions Projects/Example Projects/ModCreatorKit/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void AttachDetours()
cEffectsManager_detour::attach(GetAddress(Swarm::cSwarmManager, GetDirectoryAndEffectIndex));
AnimLogCheat::AttachDetour();
UILogCheat::AttachDetour();
ThumbnailCaptureScript::AttachDetour();
}


Expand Down
18 changes: 0 additions & 18 deletions Projects/Example Projects/SpaceToolCheat/SdkPathConfig.props

This file was deleted.

18 changes: 0 additions & 18 deletions Projects/Example Projects/TemplatesExample/SdkPathConfig.props

This file was deleted.

11 changes: 11 additions & 0 deletions Spore ModAPI/SourceCode/Simulator/SimulatorSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <Spore\Simulator\SubSystem\SpacePlayerData.h>
#include <Spore\Simulator\SubSystem\GameViewManager.h>
#include <Spore\Simulator\SubSystem\cStrategy.h>
#include <Spore\UTFWin\IWindowManager.h>
#include <Spore\ModAPI.h>

namespace Simulator
Expand All @@ -49,6 +50,16 @@ namespace Simulator
GameViewManager.PrepareSimulator();
}

UI::Minimap* GetMinimapWindow() {
if (WindowManager.GetMainWindow()) {
UTFWin::IWindow* minimapHolder = WindowManager.GetMainWindow()->FindWindowByID(0x0190722E);
if (minimapHolder) {
return object_cast<UI::Minimap>(minimapHolder->FindWindowByID(0x0));
}
}
return nullptr;
}

/// cStrategy ///

cStrategy::cStrategy()
Expand Down
Loading

0 comments on commit 88ded97

Please sign in to comment.