Skip to content

Commit

Permalink
Added a property post inits.
Browse files Browse the repository at this point in the history
You can now perform post inits on property files(similar to how key parent works), to apply a set of properties to a file.
Fixed transform and bbox overrides not getting replaced.
Renamed project to Universal Property Enhancer(UPE)
  • Loading branch information
Zarklord committed Feb 20, 2020
1 parent 22eb646 commit 359d618
Show file tree
Hide file tree
Showing 16 changed files with 205 additions and 63 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ bld/
[Oo]bj/

# Intermidate Building Things
UniversalPropertyReplacement/[Dd]ebug/
UniversalPropertyReplacement/[Rr]elease/
UniversalPropertyEnhancer/[Dd]ebug/
UniversalPropertyEnhancer/[Rr]elease/

# Visual Studio 2015 cache/options directory
.vs/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29728.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UniversalPropertyReplacement", "UniversalPropertyReplacement\UniversalPropertyReplacement.vcxproj", "{07FC5B61-B575-4207-B464-AFAE6AF3FC19}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UniversalPropertyEnhancer", "UniversalPropertyEnhancer\UniversalPropertyEnhancer.vcxproj", "{07FC5B61-B575-4207-B464-AFAE6AF3FC19}"
ProjectSection(ProjectDependencies) = postProject
{F057451A-1413-4D68-AF56-1BF529933420} = {F057451A-1413-4D68-AF56-1BF529933420}
EndProjectSection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
========================================================================
DYNAMIC LINK LIBRARY : UniversalPropertyReplacement Project Overview
DYNAMIC LINK LIBRARY : UniversalPropertyEnhancer Project Overview
========================================================================

AppWizard has created this UniversalPropertyReplacement DLL for you.
AppWizard has created this UniversalPropertyEnhancer DLL for you.

This file contains a summary of what you will find in each of the files that
make up your UniversalPropertyReplacement application.
make up your UniversalPropertyEnhancer application.


UniversalPropertyReplacement.vcxproj
UniversalPropertyEnhancer.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.

UniversalPropertyReplacement.vcxproj.filters
UniversalPropertyEnhancer.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
Expand All @@ -26,7 +26,7 @@ Other standard files:

StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named UniversalPropertyReplacement.pch and a precompiled types file named StdAfx.obj.
named UniversalPropertyEnhancer.pch and a precompiled types file named StdAfx.obj.

/////////////////////////////////////////////////////////////////////////////
Other notes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{07FC5B61-B575-4207-B464-AFAE6AF3FC19}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>UniversalPropertyReplacement</RootNamespace>
<RootNamespace>UniversalPropertyEnhancer</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>UniversalPropertyEnhancer</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down Expand Up @@ -100,6 +101,7 @@
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="UniversalPropertyPostInit.h" />
<ClInclude Include="UniversalPropertyReplacement.h" />
<ClInclude Include="VerificationCheat.h" />
</ItemGroup>
Expand All @@ -116,6 +118,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="UniversalPropertyPostInit.cpp" />
<ClCompile Include="UniversalPropertyReplacement.cpp" />
<ClCompile Include="VerificationCheat.cpp" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="UniversalPropertyReplacement">
<UniqueIdentifier>{3880d018-2395-4502-abfe-4b83e0817aab}</UniqueIdentifier>
</Filter>
<Filter Include="Internal">
<UniqueIdentifier>{d62ad12d-69d8-4933-8342-03043c9adc22}</UniqueIdentifier>
</Filter>
<Filter Include="UniversalPropertyEnhancer">
<UniqueIdentifier>{3880d018-2395-4502-abfe-4b83e0817aab}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="targetver.h">
Expand All @@ -20,24 +20,30 @@
<Filter>Internal</Filter>
</ClInclude>
<ClInclude Include="UniversalPropertyReplacement.h">
<Filter>UniversalPropertyReplacement</Filter>
<Filter>UniversalPropertyEnhancer</Filter>
</ClInclude>
<ClInclude Include="VerificationCheat.h">
<Filter>UniversalPropertyReplacement</Filter>
<Filter>UniversalPropertyEnhancer</Filter>
</ClInclude>
<ClInclude Include="UniversalPropertyPostInit.h">
<Filter>UniversalPropertyEnhancer</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<Filter>UniversalPropertyReplacement</Filter>
<Filter>UniversalPropertyEnhancer</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Internal</Filter>
</ClCompile>
<ClCompile Include="UniversalPropertyReplacement.cpp">
<Filter>UniversalPropertyReplacement</Filter>
<Filter>UniversalPropertyEnhancer</Filter>
</ClCompile>
<ClCompile Include="VerificationCheat.cpp">
<Filter>UniversalPropertyReplacement</Filter>
<Filter>UniversalPropertyEnhancer</Filter>
</ClCompile>
<ClCompile Include="UniversalPropertyPostInit.cpp">
<Filter>UniversalPropertyEnhancer</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
Expand Down
77 changes: 77 additions & 0 deletions UniversalPropertyEnhancer/UniversalPropertyPostInit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/****************************************************************************
* Copyright (C) 2020 Zarklord
*
* This file is part of UniversalPropertyEnhancer.
*
* UniversalPropertyEnhancer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with UniversalPropertyEnhancer. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

#include "stdafx.h"
#include "UniversalPropertyPostInit.h"

namespace UniversalPropertyPostInit {
long AttachDetours() {
long result = 0;
result |= GetPropertyList__detour::attach(GetAddress(App::cPropManager, GetPropertyList));

return result;
}
bool Inititalize() {
uint32_t groupID = id("prop_postinits");
eastl::vector<uint32_t> instanceList {};
PropManager.GetAllListIDs(groupID, instanceList);
for (eastl_size_t i = 0; i < instanceList.size(); i++) {
PropertyListPtr propList;
PropManager.GetPropertyList(instanceList[i], groupID, propList);

size_t stringCount = 0;
eastl::string8* stringList = nullptr;
App::Property::GetArrayString8(propList.get(), id("postinitList"), stringCount, stringList);

for (size_t j = 0; j < stringCount; j++) {
ResourceKey postinit {};
ResourceKey source {};

//as much as GetArrayString8 says it gives a string8 array it doesn't, this took alot of debugging to get this right, the strings are seperated every 0x8 bytes as pointers to the strings.
ArgScript::Line PropLine = ArgScript::Line(*(char**)(static_cast<char*>(static_cast<void*>(stringList)) + (0x8 * j)));
if (PropLine.GetArgumentsCount() != 2) continue;

if (!App::Property::GetKey(propList.get(), id(PropLine.GetArgumentAt(0)), postinit)) continue;
if (!App::Property::GetKey(propList.get(), id(PropLine.GetArgumentAt(1)), source)) continue;

postinits.emplace_back(eastl::pair<ResourceKey, ResourceKey>{postinit, source});
}
}
return true;
}
}

using namespace UniversalPropertyPostInit;

template<typename FN, typename T>
void ApplyPostInits(FN* original_function, T* ClassPtr, uint32_t instanceID, uint32_t groupID, PropertyListPtr& pDst) {
for (auto i : postinits) {
if (i.first.groupID == groupID && i.first.instanceID == instanceID) {
PropertyListPtr postProp;
if (!original_function(ClassPtr, i.second.instanceID, i.second.groupID, postProp)) continue;
pDst->AddAllPropertiesFrom(postProp.get());
}
}
}

bool UniversalPropertyPostInit::GetPropertyList__detour::DETOUR(uint32_t instanceID, uint32_t groupID, PropertyListPtr& pDst) {
if (!original_function(this, instanceID, groupID, pDst)) return false;
ApplyPostInits(original_function, this, instanceID, groupID, pDst);
return true;
}
31 changes: 31 additions & 0 deletions UniversalPropertyEnhancer/UniversalPropertyPostInit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/****************************************************************************
* Copyright (C) 2020 Zarklord
*
* This file is part of UniversalPropertyEnhancer.
*
* UniversalPropertyEnhancer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with UniversalPropertyEnhancer. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

#pragma once
#include <Spore/BasicIncludes.h>
#include <Spore/App/cPropManager.h>

namespace UniversalPropertyPostInit {
bool Inititalize();
long AttachDetours();

static eastl::vector<eastl::pair<ResourceKey, ResourceKey>> postinits {};

virtual_detour(GetPropertyList__detour, App::cPropManager, App::IPropManager, bool(uint32_t instanceID, uint32_t groupID, PropertyListPtr& pDst)) {};
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/****************************************************************************
* Copyright (C) 2018, 2020 Zarklord
*
* This file is part of UniversalPropertyReplacement.
* This file is part of UniversalPropertyEnhancer.
*
* UniversalPropertyReplacement is free software: you can redistribute it and/or modify
* UniversalPropertyEnhancer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
Expand All @@ -14,12 +14,11 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with UniversalPropertyReplacement. If not, see <http://www.gnu.org/licenses/>.
* along with UniversalPropertyEnhancer. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

#include "stdafx.h"
#include "UniversalPropertyReplacement.h"
#include "VerificationCheat.h"

namespace UniversalPropertyReplacement {
long AttachDetours() {
Expand All @@ -31,7 +30,6 @@ namespace UniversalPropertyReplacement {
return result;
}
bool Inititalize() {
CheatManager.AddCheat("VerifyUPR", new VerificationCheat());
uint32_t groupID = id("prop_overrides");
eastl::vector<uint32_t> instanceList{};
PropManager.GetAllListIDs(groupID, instanceList);
Expand Down Expand Up @@ -126,18 +124,17 @@ namespace UniversalPropertyReplacement {
if (!result) continue;
colorRGBAValueMapOverride[replaceHash] = value;
} else if (typeString == "transform") {
/*ManualBreakpoint();
Transform value;
Transform* value;
result = propList->GetProperty(id(valueString.c_str()), out);
if (!result) continue;
value = *(out->GetValueTransform());
transformValueMapOverride[replaceHash] = value;*/
value = out->GetValueTransform();
transformValueMapArrayOverride[replaceHash] = eastl::pair<Transform*, uint32_t> {value, 1};
} else if (typeString == "bbox") {
/*BoundingBox value;
BoundingBox* value;
result = propList->GetProperty(id(valueString.c_str()), out);
if (!result) continue;
value = *(out->GetValueBBox());
bBoxValueMapOverride[replaceHash] = value;*/
value = out->GetValueBBox();
bBoxValueMapArrayOverride[replaceHash] = eastl::pair<BoundingBox*, uint32_t> {value, 1};
} else if (typeString == "bools") {
bool* value;
result = propList->GetProperty(id(valueString.c_str()), out);
Expand Down Expand Up @@ -360,12 +357,13 @@ void ApplyValueMapProperty(App::Property*& prop, uint32_t propertyID) {
case App::PropertyType::ColorRGBA: {
return ApplyTemplateValueMapProperty(prop, propertyID, colorRGBAValueMapOverride);
}
/* unreachable properties
case App::PropertyType::Transform: {
return ApplyTemplateValueMapProperty(prop, propertyID, transformValueMapOverride);
}
case App::PropertyType::BBox: {
return ApplyTemplateValueMapProperty(prop, propertyID, bBoxValueMapOverride);
}
}*/
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/****************************************************************************
* Copyright (C) 2018, 2020 Zarklord
*
* This file is part of UniversalPropertyReplacement.
* This file is part of UniversalPropertyEnhancer.
*
* UniversalPropertyReplacement is free software: you can redistribute it and/or modify
* UniversalPropertyEnhancer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
Expand All @@ -14,7 +14,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with UniversalPropertyReplacement. If not, see <http://www.gnu.org/licenses/>.
* along with UniversalPropertyEnhancer. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

#pragma once
Expand Down Expand Up @@ -63,10 +63,8 @@ namespace UniversalPropertyReplacement {
static eastl::map<uint32_t, ColorRGBA> colorRGBAValueMapOverride {};
static eastl::map<uint32_t, eastl::pair<ColorRGBA*, uint32_t>> colorRGBAValueMapArrayOverride {};

static eastl::map<uint32_t, Transform> transformValueMapOverride {};
static eastl::map<uint32_t, eastl::pair<Transform*, uint32_t>> transformValueMapArrayOverride {};

static eastl::map<uint32_t, BoundingBox> bBoxValueMapOverride {};
static eastl::map<uint32_t, eastl::pair<BoundingBox*, uint32_t>> bBoxValueMapArrayOverride {};

member_detour(GetPropertyAlt__detour, App::PropertyList, bool(uint32_t propertyID, App::Property*& result)) {};
Expand Down
Loading

0 comments on commit 359d618

Please sign in to comment.