Skip to content

Commit

Permalink
- Add cScenarioEditModeDisplayStrategy class, with method Load()
Browse files Browse the repository at this point in the history
- Add PngEncoder class, with method EncodePNG()
- Fix CreateTradingObject(), which has been moved to SpaceTrading
- Add LayerSequence class
  • Loading branch information
emd4600 committed Nov 3, 2024
1 parent a715461 commit 78d9778
Show file tree
Hide file tree
Showing 20 changed files with 200 additions and 14 deletions.
4 changes: 4 additions & 0 deletions Spore ModAPI/SourceCode/App/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ namespace App
Args(const eastl::string16& path, eastl::hash_set<eastl::string16>& dstSkippedPaths, int& dstCount),
Args(path, dstSkippedPaths, dstCount));

auto_METHOD(PngEncoder, bool, EncodePNG,
Args(IO::IStream* stream, int mode),
Args(stream, mode));


auto_STATIC_METHOD_(cIDGenerator, cIDGenerator*, Get);

Expand Down
5 changes: 5 additions & 0 deletions Spore ModAPI/SourceCode/DLL/AddressesApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ namespace App
DefineAddress(ImportDirectoryPNGs, SelectAddress(0x5FC900, 0x5FCA80));
}

namespace Addresses(PngEncoder)
{
DefineAddress(EncodePNG, SelectAddress(0x68E660, 0x68e190));
}

namespace Addresses(cLocaleManager)
{
DefineAddress(Get, SelectAddress(0x67DF60, 0x67DE00));
Expand Down
6 changes: 6 additions & 0 deletions Spore ModAPI/SourceCode/DLL/AddressesSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <Spore\Simulator\cCreatureCitizen.h>
#include <Spore\Simulator\cCreatureBase.h>
#include <Spore\Simulator\cCropCirclesToolStrategy.h>
#include <Spore\Simulator\cScenarioEditModeDisplayStrategy.h>
#include <Spore\Simulator\cDeepSpaceProjectileToolStrategy.h>
#include <Spore\Simulator\cDefaultAoETool.h>
#include <Spore\Simulator\cDefaultBeamTool.h>
Expand Down Expand Up @@ -1055,6 +1056,11 @@ namespace Simulator
DefineAddress(GetRareHasBeenFound, SelectAddress(0x103BC30, 0x103AC50));
DefineAddress(SetRareAsFound, SelectAddress(0x1040820, 0x103FBB0));
DefineAddress(GenerateNPCStore, SelectAddress(0x103F560, 0x103E8F0));
DefineAddress(CreateTradingObject, SelectAddress(0x103B470, 0x103A490));
}

namespace Addresses(cScenarioEditModeDisplayStrategy) {
DefineAddress(Load, SelectAddress(0xED6000, 0xED5C70));
}

namespace Addresses(cGamePersistenceManager)
Expand Down
15 changes: 15 additions & 0 deletions Spore ModAPI/SourceCode/Graphics/Rendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <Spore\Graphics\GlobalState.h>
#include <Spore\Graphics\ActiveState.h>
#include <Spore\Graphics\cFrustumCull.h>
#include <Spore\Graphics\LayerSequence.h>

namespace Graphics
{
Expand Down Expand Up @@ -196,5 +197,19 @@ namespace Graphics
return *(D3DPRESENT_PARAMETERS*)(GetAddress(ActiveState, sPresentParams));
}
}


int LayerSequence::AddRef() {
return RefCountTemplate::AddRef();
}
int LayerSequence::Release() {
return RefCountTemplate::Release();
}
LayerSequence::~LayerSequence() {}
void LayerSequence::DrawLayer(int flags, int layerIndex, App::cViewer** viewers, RenderStatistics& statistics) {
for (auto& layer : mLayers) {
layer.layer->DrawLayer(layer.flags, layer.layerIndex, viewers, statistics);
}
}
}
#endif
4 changes: 4 additions & 0 deletions Spore ModAPI/SourceCode/Simulator/SimulatorMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
#include <Spore\Simulator\cCollectableItems.h>
#include <Spore\Simulator\cPlanetaryArtifact.h>
#include <Spore\Simulator\cNpcTribeController.h>
#include <Spore\Simulator\cScenarioEditModeDisplayStrategy.h>

namespace Simulator
{
auto_METHOD_(cScenarioEditModeDisplayStrategy, bool, Load);


void cHerd::SetEnabled(bool enabled)
{
mbEnabled = enabled;
Expand Down
4 changes: 4 additions & 0 deletions Spore ModAPI/SourceCode/Simulator/SimulatorSpaceGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,9 @@ namespace Simulator
auto_METHOD_VOID(cSpaceTrading, GenerateNPCStore,
Args(cPlanetRecord* planetRecord, LocalizedString& dstSpiceText),
Args(planetRecord, dstSpiceText));

auto_METHOD_VOID(cSpaceTrading, CreateTradingObject,
Args(cSpaceInventoryItemPtr& dst, const ResourceKey& itemID, int itemCount, float itemCost),
Args(dst, itemID, itemCount, itemCost));
}
#endif
4 changes: 0 additions & 4 deletions Spore ModAPI/SourceCode/Simulator/SpaceInventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ namespace Simulator
auto_STATIC_METHOD_VOID(cSpaceInventoryItem, CreateMultiDeliveryObject,
Args(cSpaceInventoryItemPtr& dst, const ResourceKey& itemID, uint32_t instanceID),
Args(dst, itemID, instanceID));

auto_STATIC_METHOD_VOID(cSpaceInventoryItem, CreateTradingObject,
Args(cSpaceInventoryItemPtr& dst, const ResourceKey& itemID, int itemCount, float itemCost),
Args(dst, itemID, itemCount, itemCost));
}

#endif
3 changes: 3 additions & 0 deletions Spore ModAPI/Spore ModAPI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,11 @@
<ClInclude Include="Spore\App\IDGenerator.h" />
<ClInclude Include="Spore\App\JobManager.h" />
<ClInclude Include="Spore\App\Thumbnail_cImportExport.h" />
<ClInclude Include="Spore\Graphics\LayerSequence.h" />
<ClInclude Include="Spore\Resource\FakeRecord.h" />
<ClInclude Include="Spore\Simulator\cBaseSimulatorInputStrategy.h" />
<ClInclude Include="Spore\Simulator\cObstacle.h" />
<ClInclude Include="Spore\Simulator\cScenarioEditModeDisplayStrategy.h" />
<ClInclude Include="Spore\Simulator\cTribeInputStrategy.h" />
<ClInclude Include="Spore\Simulator\cNpcTribeController.h" />
<ClInclude Include="Spore\Simulator\cTribeToolData.h" />
Expand Down Expand Up @@ -866,6 +868,7 @@
<ClInclude Include="Spore\UTFWin\CascadeEffect.h" />
<ClInclude Include="Spore\UTFWin\ComboBoxDrawable.h" />
<ClInclude Include="Spore\UTFWin\Constants.h" />
<ClInclude Include="Spore\UTFWin\cSPUIBehaviorEventBase.h" />
<ClInclude Include="Spore\UTFWin\cSPUIMessageBox.h" />
<ClInclude Include="Spore\UTFWin\CursorManager.h" />
<ClInclude Include="Spore\UTFWin\Cursors.h" />
Expand Down
9 changes: 9 additions & 0 deletions Spore ModAPI/Spore ModAPI.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,15 @@
<ClInclude Include="Spore\Simulator\cNpcTribeController.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Spore\Graphics\LayerSequence.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Spore\Simulator\cScenarioEditModeDisplayStrategy.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Spore\UTFWin\cSPUIBehaviorEventBase.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SourceCode\Allocator.cpp">
Expand Down
3 changes: 2 additions & 1 deletion Spore ModAPI/Spore/App/ScenarioMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <Spore\Simulator\cScenarioData.h>
#include <Spore\Simulator\cScenarioPlayMode.h>
#include <Spore\Simulator\cScenarioTerraformMode.h>
#include <Spore\Simulator\cScenarioEditModeDisplayStrategy.h>
#include <Spore\App\IGameMode.h>
#include <Spore\App\IMessageListener.h>
#include <Spore\App\MessageListenerData.h>
Expand Down Expand Up @@ -65,7 +66,7 @@ namespace App

public:
/* 10h */ int mpEditModeInputStrategy; // cScenarioEditModeInputStrategy
/* 14h */ int mpEditModeDisplayStrategy; // cScenarioEditModeDisplayStrategy
/* 14h */ cScenarioEditModeDisplayStrategyPtr mpEditModeDisplayStrategy;
/* 18h */ cScenarioTerraformModePtr mpTerraformMode;
/* 1Ch */ int mpScenarioUI; // Simulator::ScenarioModeUI ?
/* 20h */ GameInput mInput;
Expand Down
36 changes: 35 additions & 1 deletion Spore ModAPI/Spore/App/Thumbnail_cImportExport.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,35 @@

namespace App
{
struct PngEncoder {

bool EncodePNG(IO::IStream* outputStream, int mode);

/* 00h */ eastl::vector<int> field_0;
/* 14h */ int field_14;
/* 18h */ int field_18;
/* 1Ch */ int field_1C; // not initialized
/* 20h */ bool field_20;
/* 24h */ int field_24;
/* 28h */ int field_28; // -1
/* 2Ch */ int field_2C; // -1
/* 30h */ int field_30;
/* 34h */ int field_34;
/* 38h */ int field_38;
/* 3Ch */ int field_3C;
/* 40h */ int field_40;
/* 44h */ int field_44;
/* 48h */ int field_48;
/* 4Ch */ int field_4C; // 8
/* 50h */ int field_50;
/* 54h */ bool field_54; // not initialized
/* 55h */ bool field_55;
/* 56h */ bool field_56;
/* 58h */ eastl::vector<int8_t> mData;
/* 6Ch */ int field_6C;
};
ASSERT_SIZE(PngEncoder, 0x70);

struct ThumbnailDecodedMetadata
{
ThumbnailDecodedMetadata() = default;
Expand Down Expand Up @@ -112,7 +141,7 @@ namespace App
/* 44h */ uint32_t mMachineId; // not initialized
/* 48h */ eastl::hash_map<int, int> field_48;
/* 68h */ eastl::hash_map<int, int> field_68;
/* 88h */ char padding_88[0xF8 - 0x88];
/* 88h */ PngEncoder mPngEncoder;
/* F8h */ int field_F8;
/* FCh */ int field_FC;
/* 100h */ int field_100;
Expand All @@ -139,4 +168,9 @@ namespace App
DeclareAddress(SaveFilePaths); // 0x5F89C0 0x5F8B60
DeclareAddress(ImportDirectoryPNGs); // 0x5FC900 0x5FCA80
}

namespace Addresses(PngEncoder)
{
DeclareAddress(EncodePNG); // 0x68E660 0x68e190
}
}
4 changes: 3 additions & 1 deletion Spore ModAPI/Spore/CommonIDs.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ namespace GroupIDs
ShaderFragments = 0x40212002,
Shaders = 0x40212004,

Scripts1 = 0x24A4F5A
Scripts1 = 0x24A4F5A,

SharedDialogs = 0x490F6945
};
}
1 change: 1 addition & 0 deletions Spore ModAPI/Spore/Graphics/IRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <Spore\Internal.h>
#include <Spore\Graphics\ILayer.h>
#include <Spore\Graphics\LambdaLayer.h>
#include <Spore\Graphics\LayerSequence.h>
#include <Spore\App\cJob.h>


Expand Down
36 changes: 36 additions & 0 deletions Spore ModAPI/Spore/Graphics/LayerSequence.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

#include <Spore\Graphics\ILayer.h>
#include <Spore\Object.h>
#include <EASTL\intrusive_ptr.h>
#include <EASTL\vector.h>

#define LayerSequencePtr eastl::intrusive_ptr<Graphics::LayerSequence>

namespace Graphics
{
class LayerSequence
: public ILayer
, public RefCountTemplate
{
public:
virtual int AddRef() override;
virtual int Release() override;
virtual ~LayerSequence();
virtual void DrawLayer(int flags, int layerIndex, App::cViewer** viewers, RenderStatistics& statistics) override;

inline void AddLayer(ILayer* layer, int index, int flags) {
mLayers.push_back({layer, index, flags});
}

public:
struct SequenceLayer {
ILayerPtr layer;
int layerIndex;
int flags;
};

eastl::vector<SequenceLayer> mLayers;
};
ASSERT_SIZE(LayerSequence, 0x20);
}
1 change: 1 addition & 0 deletions Spore ModAPI/Spore/Simulator/SubSystem/PlanetModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ namespace Simulator
DeclareAddress(GetGravity);
DeclareAddress(GetHeightAt);
DeclareAddress(GetOrientation);
DeclareAddress(GetRadius); // 0xB7DD80 TODO
}
}
8 changes: 8 additions & 0 deletions Spore ModAPI/Spore/Simulator/SubSystem/SpaceTrading.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ namespace Simulator
/// @param[out] dstSpiceText
void GenerateNPCStore(cPlanetRecord* planetRecord, LocalizedString& dstSpiceText);

/// Creates a trading object, which is an inventory item from GroupIDs::SpaceTrading_.
/// @param[out] dst Pointer where the new object will be written.
/// @param itemID Key to the item configuration in GroupIDs::SpaceTrading_
/// @param itemCount Number of items to create
/// @param itemCost Cost of the object
void CreateTradingObject(cSpaceInventoryItemPtr& dst, const ResourceKey& itemID, int itemCount, float itemCost);

public:
struct RareGroup {
/* 00h */ uint32_t mGroupID;
Expand Down Expand Up @@ -126,5 +133,6 @@ namespace Simulator
DeclareAddress(GetRareHasBeenFound); // 0x103BC30 0x103AC50
DeclareAddress(SetRareAsFound); // 0x1040820 0x103FBB0
DeclareAddress(GenerateNPCStore); // 0x103F560 0x103E8F0
DeclareAddress(CreateTradingObject); // 0x103B470 0x103A490
}
}
61 changes: 61 additions & 0 deletions Spore ModAPI/Spore/Simulator/cScenarioEditModeDisplayStrategy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#pragma once

#include <Spore\App\IMessageListener.h>
#include <Spore\App\MessageListenerData.h>
#include <Spore\UTFWin\UILayout.h>
#include <Spore\UTFWin\IWinProc.h>
#include <Spore\UTFWin\cSPUIMessageBox.h>

#define cScenarioEditModeDisplayStrategyPtr eastl::intrusive_ptr<Simulator::cScenarioEditModeDisplayStrategy>

namespace Simulator
{
class cScenarioEditModeDisplayStrategy
/* 00h */ : public DefaultRefCounted
/* 08h */ , public UTFWin::IWinProc
/* 0Ch */ , public UTFWin::MessageBoxCallback
/* 10h */ , public App::IMessageListener
{
public:
static const uint32_t TYPE = 0x7103861;

bool Load();

public:
/* 14h */ DefaultRefCountedPtr field_14;
/* 18h */ DefaultRefCountedPtr mEditModeScriptUI; // cScenarioEditModeScriptUIPtr
/* 1Ch */ int field_1C; // -1
/* 20h */ int field_20; // -1
/// 0x396F69F5.spui
/* 24h */ UILayoutPtr mMainUILayout;
/* 28h */ DefaultRefCountedPtr field_28;
/* 2Ch */ ObjectPtr mNamePanelUI;
/* 30h */ ObjectPtr mWorldComplexityMeter; // cScenarioComplexityMeterPtr
/* 34h */ ObjectPtr mTerraformComplexityMeter; // cScenarioComplexityMeterPtr
/* 38h */ ObjectPtr mTutorialsChecklistUI; // cScenarioTutorialsChecklistUIPtr
/* 3Ch */ ObjectPtr mTutorialsChecklistUI2; // cScenarioTutorialsChecklistUIPtr
/* 40h */ ObjectPtr mPosseUI; // UI::PossePtr
/* 44h */ ObjectPtr mSPUIGlobalOptions; // cSPUIGlobalOptionsPtr
/* 48h */ int field_48;
/* 4Ch */ int field_4C;
/* 50h */ int field_50;
/* 54h */ int field_54;
/* 58h */ int field_58;
/* 5Ch */ int field_5C;
/* 60h */ int field_60;
/* 64h */ int field_64;
/* 68h */ int field_68;
/* 6Ch */ int field_6C;
/* 70h */ App::MessageListenerData mMessageListenerData;
/* 84h */ int field_84;
/* 88h */ int field_88;
/* 8Ch */ int field_8C;
/* 90h */ int field_90;
/* 94h */ int field_94;
};
ASSERT_SIZE(cScenarioEditModeDisplayStrategy, 0x98);

namespace Addresses(cScenarioEditModeDisplayStrategy) {
DeclareAddress(Load); // 0xED6000 0xED5C70
}
}
7 changes: 0 additions & 7 deletions Spore ModAPI/Spore/Simulator/cSpaceInventoryItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,6 @@ namespace Simulator
/// @param instanceIDcddc
static void CreateMultiDeliveryObject(cSpaceInventoryItemPtr& dst, const ResourceKey& itemID, uint32_t instanceID);

/// Creates a trading object, which is an inventory item from GroupIDs::SpaceTrading_.
/// @param[out] dst Pointer where the new object will be written.
/// @param itemID Key to the item configuration in GroupIDs::SpaceTrading_
/// @param itemCount Number of items to create
/// @param itemCost Cost of the object
static void CreateTradingObject(cSpaceInventoryItemPtr& dst, const ResourceKey& itemID, int itemCount, float itemCost);

public:
/* 10h */ size_t mItemCount; // 1
/* 14h */ SpaceInventoryItemType mItemType; // 2
Expand Down
1 change: 1 addition & 0 deletions Spore ModAPI/Spore/UTFWin/SporeStdDrawable.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace UTFWin
{
public:
static const uint32_t TYPE = 0x53EB526;
static const int NUM_STATES = 8;

SporeStdDrawable();
virtual ~SporeStdDrawable();
Expand Down
2 changes: 2 additions & 0 deletions Spore ModAPI/Spore/UserInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include <Spore\UTFWin\WindowIterators.h>
#include <Spore\UTFWin\CursorManager.h>
#include <Spore\UTFWin\SporeTooltipWinProc.h>
#include <Spore\UTFWin\cSPUIMessageBox.h>
#include <Spore\UTFWin\SporeStdDrawable.h>
#include <Spore\UI\cSPAssetView.h>
#include <Spore\UI\SpaceGameUI.h>
#include <Spore\UI\GlobalUI.h>
Expand Down

0 comments on commit 78d9778

Please sign in to comment.