Skip to content

Commit 1661afa

Browse files
authored
Valla another fixes and features PR (#87)
1 parent 69c020a commit 1661afa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+364
-102
lines changed

Projects/Example Projects/ModCreatorKit/AnimEditorMode.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ bool AnimEditorMode::Initialize(App::IGameModeManager* pManager)
6464
GameModeManager.SetActiveMode(MODE_ID);
6565
}
6666
else {
67+
if (auto args = line.GetOption("help", 1))
68+
{
69+
App::ConsolePrintF("Params: -add, -remove, -play [hash], -default, -help, -exit");
70+
}
6771
if (auto args = line.GetOption("remove", 1))
6872
{
6973
int index = mpFormatParser->ParseInt(args[0]);
@@ -75,7 +79,7 @@ bool AnimEditorMode::Initialize(App::IGameModeManager* pManager)
7579
request.shopperID = id("CreatureShopper");
7680
Sporepedia::ShopperRequest::Show(request);
7781
}
78-
else if (line.HasFlag("exit"))
82+
else if (line.HasFlag("exit") || line.HasFlag("quit"))
7983
{
8084
GameModeManager.SetActiveMode(kGGEMode);
8185
}

Projects/Example Projects/ModCreatorKit/Cheats.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
#include "AddressCheat.h"
2424
#include "AnimLogCheat.h"
2525
#include "EffectLogCheat.h"
26+
#include "SFXLogCheat.h"
2627
#include "PackageCheat.h"
2728
#include "PrintCursorCheat.h"
2829
#include "UILogCheat.h"
2930
#include "UIInspectCheat.h"
31+
#include "PlaySoundCheat.h"
3032

3133
#include <Spore\App\ICheatManager.h>
3234
#include <Spore\Editors\BakeManager.h>
@@ -49,11 +51,13 @@ void AddCheats()
4951
{
5052
CheatManager.AddCheat("devContext", new ContextCheat());
5153
CheatManager.AddCheat("devAnimLog", new AnimLogCheat());
54+
CheatManager.AddCheat("devSFXLog", new SFXLogCheat());
5255
CheatManager.AddCheat("devEffectLog", new EffectLogCheat());
5356
CheatManager.AddCheat("devPackage", new PackageCheat());
5457
CheatManager.AddCheat("devLogUI", new UILogCheat());
5558
CheatManager.AddCheat("devInspectUI", new UIInspectCheat());
5659
CheatManager.AddCheat("devPrintCursor", new PrintCursorCheat());
60+
CheatManager.AddCheat("devPlaySound", new PlaySoundCheat());
5761

5862
AddressCheat::AddCheat(Address(ModAPI::ChooseAddress(0x1498444, 0x1493E5C)), "devRaid");
5963
AddressCheat::AddCheat(Address(ModAPI::ChooseAddress(0x149845C, 0x1493E74)), "devSpace");

Projects/Example Projects/ModCreatorKit/ModCreatorKit.vcxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,18 @@
126126
<SubType>
127127
</SubType>
128128
</ClInclude>
129+
<ClInclude Include="PlaySoundCheat.h">
130+
<SubType>
131+
</SubType>
132+
</ClInclude>
129133
<ClInclude Include="PrintCursorCheat.h">
130134
<SubType>
131135
</SubType>
132136
</ClInclude>
137+
<ClInclude Include="SFXLogCheat.h">
138+
<SubType>
139+
</SubType>
140+
</ClInclude>
133141
<ClInclude Include="stdafx.h" />
134142
<ClInclude Include="targetver.h" />
135143
<ClInclude Include="ThumbnailCaptureScript.h" />
@@ -174,10 +182,18 @@
174182
<SubType>
175183
</SubType>
176184
</ClCompile>
185+
<ClCompile Include="PlaySoundCheat.cpp">
186+
<SubType>
187+
</SubType>
188+
</ClCompile>
177189
<ClCompile Include="PrintCursorCheat.cpp">
178190
<SubType>
179191
</SubType>
180192
</ClCompile>
193+
<ClCompile Include="SFXLogCheat.cpp">
194+
<SubType>
195+
</SubType>
196+
</ClCompile>
181197
<ClCompile Include="stdafx.cpp">
182198
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
183199
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>

Projects/Example Projects/ModCreatorKit/ModCreatorKit.vcxproj.filters

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@
9494
<ClInclude Include="EffectLogCheat.h">
9595
<Filter>ModCreatorKit\Cheats</Filter>
9696
</ClInclude>
97+
<ClInclude Include="SFXLogCheat.h">
98+
<Filter>ModCreatorKit\Cheats</Filter>
99+
</ClInclude>
100+
<ClInclude Include="PlaySoundCheat.h">
101+
<Filter>ModCreatorKit\Cheats</Filter>
102+
</ClInclude>
97103
</ItemGroup>
98104
<ItemGroup>
99105
<ClCompile Include="DetouredDBPF.cpp">
@@ -165,6 +171,12 @@
165171
<ClCompile Include="EffectLogCheat.cpp">
166172
<Filter>ModCreatorKit\Cheats</Filter>
167173
</ClCompile>
174+
<ClCompile Include="SFXLogCheat.cpp">
175+
<Filter>ModCreatorKit\Cheats</Filter>
176+
</ClCompile>
177+
<ClCompile Include="PlaySoundCheat.cpp">
178+
<Filter>ModCreatorKit\Cheats</Filter>
179+
</ClCompile>
168180
</ItemGroup>
169181
<ItemGroup>
170182
<None Include="SdkPathConfig.props" />
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include "stdafx.h"
2+
#include "PlaySoundCheat.h"
3+
4+
PlaySoundCheat::PlaySoundCheat()
5+
{
6+
}
7+
8+
9+
PlaySoundCheat::~PlaySoundCheat()
10+
{
11+
}
12+
13+
14+
void PlaySoundCheat::ParseLine(const ArgScript::Line& line)
15+
{
16+
mParameter = line.GetArguments(1)[0];
17+
if (string16(mParameter).find(u"0x") == 0) {
18+
Audio::PlayAudio(mpFormatParser->ParseUInt(mParameter));
19+
}
20+
21+
Audio::PlayAudio(id(mParameter));
22+
}
23+
24+
const char* PlaySoundCheat::GetDescription(ArgScript::DescriptionMode mode) const
25+
{
26+
return "Plays an SNR sound file by name or hash.";
27+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
3+
#include <Spore\BasicIncludes.h>
4+
5+
class PlaySoundCheat
6+
: public ArgScript::ICommand
7+
{
8+
public:
9+
PlaySoundCheat();
10+
~PlaySoundCheat();
11+
12+
// Called when the cheat is invoked
13+
void ParseLine(const ArgScript::Line& line) override;
14+
15+
// Returns a string containing the description. If mode != DescriptionMode::Basic, return a more elaborated description
16+
const char* GetDescription(ArgScript::DescriptionMode mode) const override;
17+
private:
18+
const char* mParameter;
19+
};
20+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "stdafx.h"
2+
#include "SFXLogCheat.h"
3+
4+
5+
bool SFXLogCheat::IsEnabled = false;
6+
7+
// Detour the audio playing func
8+
static_detour(PlayAudio_detour, void(uint32_t, Audio::AudioTrack)) {
9+
void detoured(uint32_t soundID, Audio::AudioTrack track) {
10+
original_function(soundID, track);
11+
if (SFXLogCheat::IsEnabled && soundID != 0)
12+
{
13+
App::ConsolePrintF("devSFXLog: playing Audio ID: 0x%x", soundID);
14+
}
15+
}
16+
};
17+
18+
void SFXLogCheat::AttachDetour() {
19+
PlayAudio_detour::attach(GetAddress(Audio, PlayAudio));
20+
}
21+
22+
void SFXLogCheat::ParseLine(const ArgScript::Line& line)
23+
{
24+
auto args = line.GetArguments(1);
25+
SFXLogCheat::IsEnabled = mpFormatParser->ParseBool(args[0]);
26+
}
27+
28+
const char* SFXLogCheat::GetDescription(ArgScript::DescriptionMode mode) const
29+
{
30+
return "Usage: sfxLog on/off. If enabled, every time a UI sound effect is played it will print its ID. Does not include creature voices or world sounds.";
31+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include <Spore\BasicIncludes.h>
4+
5+
class SFXLogCheat
6+
: public ArgScript::ICommand
7+
{
8+
public:
9+
void ParseLine(const ArgScript::Line& line) override;
10+
const char* GetDescription(ArgScript::DescriptionMode mode) const override;
11+
12+
static bool IsEnabled;
13+
14+
static void AttachDetour();
15+
};
16+

Projects/Example Projects/ModCreatorKit/ThumbnailCaptureScript.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ThumbnailCaptureScript::ThumbnailCaptureScript()
3434
, mItemViewers()
3535
, mpItemViewer(nullptr)
3636
, mFolderPath()
37-
, mIsEnabled(false)
37+
, mbIsEnabled(false)
3838
{
3939
}
4040

@@ -199,16 +199,20 @@ void ThumbnailCaptureScript::InjectListeners() {
199199
// standard editor/planner
200200
if (pageUI.page->mStandardItems.size() > 0) {
201201
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
202-
itemUI->field_18->AddWinProc(this);
203-
mItemViewers[itemUI->field_18.get()] = itemUI->mpViewer.get();
202+
itemUI->mpWindow->AddWinProc(this);
203+
mItemViewers[itemUI->mpWindow.get()] = itemUI->mpViewer.get();
204204
}
205205
}
206206
// adventure editor
207207
/*
208208
else {
209-
for (eastl::intrusive_ptr<Palettes::IAdvancedItemUI> itemUI : pageUI.page->mAdvancedItems) {
210-
itemUI->mpWindow
211-
mItemViewers[itemUI->field_18.get()] = itemUI->mpViewer.get();
209+
for (IAdvancedItemUIPtr itemUI : pageUI.page->mAdvancedItems) {
210+
auto item = object_cast<Palettes::DefaultItemFrameUI>(itemUI.get());
211+
if (item && item->mpWindow) {
212+
item->mpWindow->AddWinProc(this);
213+
mItemViewers[item->mpWindow.get()] = itemUI->mpViewer.get();
214+
}
215+
212216
}
213217
}*/
214218

@@ -218,9 +222,11 @@ void ThumbnailCaptureScript::InjectListeners() {
218222
// simple category
219223
else {
220224
for (auto pageUI : catUI->mPageUIs) {
221-
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
222-
itemUI->field_18->AddWinProc(this);
223-
mItemViewers[itemUI->field_18.get()] = itemUI->mpViewer.get();
225+
if (pageUI.page->mStandardItems.size() > 0) {
226+
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
227+
itemUI->mpWindow->AddWinProc(this);
228+
mItemViewers[itemUI->mpWindow.get()] = itemUI->mpViewer.get();
229+
}
224230
}
225231
}
226232
}
@@ -247,14 +253,14 @@ void ThumbnailCaptureScript::RemoveListeners() {
247253
// standard editor/planner
248254
if (pageUI.page->mStandardItems.size() > 0) {
249255
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
250-
itemUI->field_18->RemoveWinProc(this);
256+
itemUI->mpWindow->RemoveWinProc(this);
251257
}
252258
}
253259
/*
254260
// adventure editor
255261
else {
256262
for (StandardItemUIPtr itemUI : pageUI.page->mpPage->mItems) {
257-
itemUI->field_18->RemoveWinProc(this);
263+
itemUI->mpWindow->RemoveWinProc(this);
258264
}
259265
}
260266
*/
@@ -265,8 +271,8 @@ void ThumbnailCaptureScript::RemoveListeners() {
265271
else {
266272
for (auto pageUI : catUI->mPageUIs) {
267273
for (StandardItemUIPtr itemUI : pageUI.page->mStandardItems) {
268-
if (itemUI && itemUI->field_18) {
269-
itemUI->field_18->RemoveWinProc(this);
274+
if (itemUI && itemUI->mpWindow) {
275+
itemUI->mpWindow->RemoveWinProc(this);
270276
}
271277
}
272278
}
@@ -279,10 +285,10 @@ void ThumbnailCaptureScript::RemoveListeners() {
279285
}
280286

281287
void ThumbnailCaptureScript::ParseLine(const ArgScript::Line& line) {
282-
if (mIsEnabled) {
288+
if (mbIsEnabled) {
283289
RemoveListeners();
284290
App::ConsolePrintF("Icon capture disabled.");
285-
mIsEnabled = false;
291+
mbIsEnabled = false;
286292
return;
287293
}
288294

@@ -327,7 +333,7 @@ void ThumbnailCaptureScript::ParseLine(const ArgScript::Line& line) {
327333
InjectListeners();
328334

329335
App::ConsolePrintF("Icon capture enabled: hover a palette item and wait until it starts rotating to generate the icon.");
330-
mIsEnabled = true;
336+
mbIsEnabled = true;
331337
}
332338

333339
const char* ThumbnailCaptureScript::GetDescription(ArgScript::DescriptionMode mode) const {

Projects/Example Projects/ModCreatorKit/ThumbnailCaptureScript.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ class ThumbnailCaptureScript
7373
ColorRGB mOldColor;
7474
ColorRGB mIdentityColor;
7575
string16 mFolderPath;
76-
bool mIsEnabled;
76+
bool mbIsEnabled;
7777
};
7878

0 commit comments

Comments
 (0)