Skip to content

Commit 88ded97

Browse files
authored
Add Minimap funcs, Annotate unknown Minimap and Cell related vars, document 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
1 parent 17e4815 commit 88ded97

31 files changed

Lines changed: 332 additions & 173 deletions

.gitignore

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,14 @@ Release
1313
Projects/*
1414
!Projects/Example Projects/
1515
/SDKtoGhidra/temp.cpp
16-
modapi-generated-docs
16+
modapi-generated-docs
17+
/Projects/Example Projects/EditorPlayModeNoBounds/SdkPathConfig.props
18+
/Projects/Example Projects/ModCreatorKit/SdkPathConfig.props
19+
/Projects/Example Projects/TemplatesExample/SdkPathConfig.props
20+
/Projects/Example Projects/SpaceToolCheat/SdkPathConfig.props
21+
/Projects/Example Projects/GmdlExport/SdkPathConfig.props
22+
/Projects/Example Projects/EditorPlayModeNoBounds/SdkPathConfig.props
23+
/Projects/Example Projects/ModCreatorKit/SdkPathConfig.props
24+
/Projects/Example Projects/SpaceToolCheat/SdkPathConfig.props
25+
/Projects/Example Projects/TemplatesExample/SdkPathConfig.props
26+
/Projects/Example Projects/GmdlExport/SdkPathConfig.props

Projects/Example Projects/EditorPlayModeNoBounds/SdkPathConfig.props

Lines changed: 0 additions & 18 deletions
This file was deleted.

Projects/Example Projects/GmdlExport/SdkPathConfig.props

Lines changed: 0 additions & 18 deletions
This file was deleted.

Projects/Example Projects/ModCreatorKit/AnimEditorMode.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ bool AnimEditorMode::Initialize(App::IGameModeManager* pManager)
7575
request.shopperID = id("CreatureShopper");
7676
Sporepedia::ShopperRequest::Show(request);
7777
}
78+
else if (line.HasFlag("exit"))
79+
{
80+
GameModeManager.SetActiveMode(kGGEMode);
81+
}
7882
size_t numArgs;
7983
if (auto args = line.GetOptionRange("play", &numArgs, 1, 2))
8084
{
@@ -93,7 +97,7 @@ bool AnimEditorMode::Initialize(App::IGameModeManager* pManager)
9397

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

Projects/Example Projects/ModCreatorKit/SdkPathConfig.props

Lines changed: 0 additions & 18 deletions
This file was deleted.

Projects/Example Projects/ModCreatorKit/ThumbnailCaptureScript.cpp

Lines changed: 96 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ ThumbnailCaptureScript::~ThumbnailCaptureScript()
4343
{
4444
}
4545

46+
//---------------------------------------------------
47+
// Detours
48+
49+
Palettes::PaletteUI* pLastPalette;
50+
51+
// Editor parts palette loading func, PaletteUI::Load. Used to pull the ingame palettes
52+
member_detour(PaletteUILoad_detour, Palettes::PaletteUI, void(Palettes::PaletteMain*, UTFWin::IWindow*, bool, Palettes::PaletteInfo*)) {
53+
void detoured(Palettes::PaletteMain* pPalette, UTFWin::IWindow* pWindow, bool bool1, Palettes::PaletteInfo* pInfo) {
54+
pLastPalette = this;
55+
original_function(this, pPalette, pWindow, bool1, pInfo);
56+
}
57+
};
58+
59+
void ThumbnailCaptureScript::AttachDetour() {
60+
PaletteUILoad_detour::attach(GetAddress(Palettes::PaletteUI, Load));
61+
}
62+
63+
//---------------------------------------------------
64+
65+
4666
int ThumbnailCaptureScript::GetEventFlags() const {
4767
return UTFWin::kEventRefresh;
4868
}
@@ -52,7 +72,7 @@ bool ThumbnailCaptureScript::HandleUIMessage(IWindow* pWindow, const Message& me
5272
mpItemViewer = mItemViewers[pWindow];
5373
}
5474
else if (message.IsType(kMsgMouseLeave)) {
55-
// For some reason this might happen in paralel to Render? We don't want them to race
75+
// For some reason this might happen in parallel to Render? We don't want them to race
5676
//mpItemViewer = nullptr;
5777
}
5878
return false;
@@ -154,54 +174,97 @@ void ThumbnailCaptureScript::CaptureImage() {
154174
device->SetRenderTarget(0, surface);
155175
}
156176

177+
178+
PaletteUIPtr ThumbnailCaptureScript::GetCurrentPalette() const {
179+
// Editor is valid, get the parts palette
180+
if (GetEditor() && GetEditor()->IsActive()) { return GetEditor()->mpPartsPaletteUI; }
181+
// Editor is invalid, try the last loaded palette
182+
else { return pLastPalette; }
183+
184+
}
185+
157186
void ThumbnailCaptureScript::InjectListeners() {
187+
188+
PaletteUIPtr palette = GetCurrentPalette();
189+
if (!palette) { return; }
190+
158191
RemoveListeners();
159-
for (auto catUI : GetEditor()->mpPartsPaletteUI->mCategories) {
160-
auto subCatUIs = catUI->mpSubcategoriesUI;
192+
for (PaletteCategoryUIPtr catUI : palette->mCategories) {
193+
PaletteSubcategoriesUIPtr subCatUIs = catUI->mpSubcategoriesUI;
194+
195+
// subcategories present
161196
if (subCatUIs) {
162-
for (auto subCatUI : subCatUIs->mCategoryUIs) {
163-
for (auto pageUI : catUI->mPageUIs) {
164-
for (auto itemUI : pageUI.page->mStandardItems) {
165-
itemUI->field_18->AddWinProc(this);
166-
mItemViewers[itemUI->field_18.get()] = itemUI->mpViewer.get();
197+
for (PaletteCategoryUIPtr subCatUI : subCatUIs->mCategoryUIs) {
198+
for (auto pageUI : subCatUI->mPageUIs) {
199+
// standard editor/planner
200+
if (pageUI.page->mStandardItems.size() > 0) {
201+
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
202+
itemUI->field_18->AddWinProc(this);
203+
mItemViewers[itemUI->field_18.get()] = itemUI->mpViewer.get();
204+
}
167205
}
206+
// adventure editor
207+
/*
208+
else {
209+
for (eastl::intrusive_ptr<Palettes::IAdvancedItemUI> itemUI : pageUI.page->mAdvancedItems) {
210+
itemUI->mpWindow
211+
mItemViewers[itemUI->field_18.get()] = itemUI->mpViewer.get();
212+
}
213+
}*/
214+
168215
}
169216
}
170217
}
218+
// simple category
171219
else {
172220
for (auto pageUI : catUI->mPageUIs) {
173-
for (auto itemUI : pageUI.page->mStandardItems) {
221+
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
174222
itemUI->field_18->AddWinProc(this);
175223
mItemViewers[itemUI->field_18.get()] = itemUI->mpViewer.get();
176224
}
177225
}
178226
}
179227

180-
181-
182228
}
183229

184230
Renderer.RegisterLayer(this, 40);
185231
}
186232

233+
234+
187235
void ThumbnailCaptureScript::RemoveListeners() {
188236

189-
for (auto catUI : GetEditor()->mpPartsPaletteUI->mCategories) {
237+
PaletteUIPtr palette = GetCurrentPalette();
238+
if (!palette) { return; }
239+
240+
for (auto catUI : palette->mCategories) {
190241
auto subCatUIs = catUI->mpSubcategoriesUI;
242+
243+
// subcategories present
191244
if (subCatUIs) {
192-
for (auto subCatUI : subCatUIs->mCategoryUIs) {
193-
for (auto pageUI : catUI->mPageUIs) {
194-
for (auto itemUI : pageUI.page->mStandardItems) {
195-
if (itemUI && itemUI->field_18) {
245+
for (PaletteCategoryUIPtr subCatUI : subCatUIs->mCategoryUIs) {
246+
for (auto pageUI : subCatUI->mPageUIs) {
247+
// standard editor/planner
248+
if (pageUI.page->mStandardItems.size() > 0) {
249+
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
196250
itemUI->field_18->RemoveWinProc(this);
197251
}
198252
}
253+
/*
254+
// adventure editor
255+
else {
256+
for (StandardItemUIPtr itemUI : pageUI.page->mpPage->mItems) {
257+
itemUI->field_18->RemoveWinProc(this);
258+
}
259+
}
260+
*/
199261
}
200262
}
201263
}
264+
// simple category
202265
else {
203266
for (auto pageUI : catUI->mPageUIs) {
204-
for (auto itemUI : pageUI.page->mStandardItems) {
267+
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
205268
if (itemUI && itemUI->field_18) {
206269
itemUI->field_18->RemoveWinProc(this);
207270
}
@@ -223,9 +286,23 @@ void ThumbnailCaptureScript::ParseLine(const ArgScript::Line& line) {
223286
return;
224287
}
225288

289+
//auto editor = GetEditor();
290+
226291
if (!Editor.IsActive()) {
227-
App::ConsolePrintF("Must be in editor to use this cheat.");
228-
return;
292+
293+
if (Simulator::GetGameModeID() == kEditorMode) {
294+
App::ConsolePrintF("Must be in editor or a community planner to use this cheat.");
295+
return;
296+
}
297+
// TODO: make this work in the adventure editor.
298+
else if (Simulator::IsTribeGame() || Simulator::IsCivGame() || Simulator::IsSpaceGame()) { // || Simulator::IsScenarioMode()
299+
// found a palette that's been loaded anyway
300+
if (!pLastPalette) {
301+
App::ConsolePrintF("Must be in editor or a community planner to use this cheat.");
302+
}
303+
}
304+
305+
//return;
229306
}
230307
else if (!Editor.IsMode(Mode::BuildMode)) {
231308
App::ConsolePrintF("Must be in editor build mode to use this cheat.");

Projects/Example Projects/ModCreatorKit/ThumbnailCaptureScript.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ class ThumbnailCaptureScript
5353
bool HandleMessage(uint32_t messageID, void* pMessage) override;
5454

5555
static void AddCheat();
56+
static void AttachDetour();
5657

5758
private:
5859

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

63+
PaletteUIPtr GetCurrentPalette() const;
6264
void InjectListeners();
6365
void RemoveListeners();
6466

Projects/Example Projects/ModCreatorKit/dllmain.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void AttachDetours()
109109
cEffectsManager_detour::attach(GetAddress(Swarm::cSwarmManager, GetDirectoryAndEffectIndex));
110110
AnimLogCheat::AttachDetour();
111111
UILogCheat::AttachDetour();
112+
ThumbnailCaptureScript::AttachDetour();
112113
}
113114

114115

Projects/Example Projects/SpaceToolCheat/SdkPathConfig.props

Lines changed: 0 additions & 18 deletions
This file was deleted.

Projects/Example Projects/TemplatesExample/SdkPathConfig.props

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)