Skip to content

Commit

Permalink
#23 - space tool icon override precedence fix (#24)
Browse files Browse the repository at this point in the history
Possible fix to social palette precedence in Space Tool Icon overrider.

Co-authored-by: LenP-dev <49527545+LenP-dev@users.noreply.github.com>
Co-authored-by: Eric Mor <emd4600@gmail.com>
  • Loading branch information
3 people authored Aug 18, 2021
1 parent 0cc223c commit 1d803f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
################################################################################
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

Expand All @@ -10,4 +10,4 @@
Debug
Release
Projects/*
!Projects/Example Projects/
!Projects/Example Projects/
15 changes: 9 additions & 6 deletions Spore ModAPI/SourceCode/DLL/SpaceToolIconOverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,20 @@ void InjectIconWindows(UTFWin::IWindow* window)
}
}

member_detour(LoadSpaceGameUI_detour, UI::SpaceGameUI, void()) {
void detoured() {
original_function(this);
InjectIconWindows(this->mInventoryItemIcons->FindWindowByID(0xC19CCD88)); // First icon from spui. Should be the fastest to access.
// Icons should be destroyed with window hierarchy when they are no longer needed.
member_detour(LoadIconSpui_detour, UTFWin::UILayout, bool(const ResourceKey&, bool, uint32_t)) {
bool detoured(const ResourceKey & resourceKey, bool unkBool, uint32_t params) {
bool result = original_function(this, resourceKey, unkBool, params);
if (resourceKey.instanceID == 0x46fed9c8) { // SPU holding all space icons.
InjectIconWindows(this->FindWindowByID(0xC19CCD88)); // First icon from spui. Should be the fastest to access.
}

return result;
}
};

long SpaceToolIconOverride::AttachDetour() {
long result = 0;
result |= LoadSpaceGameUI_detour::attach(GetAddress(UI::SpaceGameUI, Load));
result |= LoadIconSpui_detour::attach(GetAddress(UTFWin::UILayout, Load));
return result;
}

Expand Down

0 comments on commit 1d803f7

Please sign in to comment.