Skip to content

Commit 1f9f92b

Browse files
authored
More minor stealth fixes (#75)
* more small fixes fix mods being added to menu twice when offline fix hidden options being unusable * make skill rando bl2 only * bump version number
1 parent 80c49b4 commit 1f9f92b

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

Mods/ModMenu/MenuManager.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def AddListItem(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params
155155
Using it cause it simplifies the code to replace the caption.
156156
"""
157157
if params.Caption == "$WillowMenu.WillowScrollingListDataProviderFrontEnd.DLC":
158+
unrealsdk.DoInjectedCallNext()
158159
caller.AddListItem(_MODS_EVENT_ID, _MODS_MENU_NAME, False, False)
159160
return False
160161

@@ -169,6 +170,30 @@ def AddListItem(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params
169170
return False
170171

171172

173+
def _RefreshDLC(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool:
174+
"""
175+
This function is called to refresh the DLC menu. We're mostly interested in it because Gearbox
176+
has amazing code, and calls `OnDownloadableContentListRead` twice if you're offline.
177+
178+
This happens right at the end of the function, so it's easiest to just recreate it.
179+
180+
We can ignore the filter stuff, `OnDownloadableContentListRead` overwrites it right after, and
181+
we can also remove the small meaningless loading message that some people get hung up on.
182+
"""
183+
if caller.bDelegateFired:
184+
caller.ShowMarketplaceElements(False)
185+
caller.SetShoppingTooltips(False, False, False, False, True)
186+
caller.SetContentData()
187+
caller.bDelegateFired = False
188+
189+
# Here's the issue: earlier they setup a delegate for this call, but when it fails they
190+
# also manually call the delgate again - we just don't
191+
caller.WPCOwner.OnlineSub.ContentInterface.ObjectPointer.ReadDownloadableContentList(
192+
caller.WPCOwner.GetMyControllerId()
193+
)
194+
return False
195+
196+
172197
def _OnDownloadableContentListRead(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool:
173198
""" This function is called to fill in the dlc menu, we overwrite it with our mods instead. """
174199
global _current_mod_list
@@ -189,7 +214,7 @@ def _OnDownloadableContentListRead(caller: unrealsdk.UObject, function: unrealsd
189214

190215
for idx, mod in enumerate(_current_mod_list):
191216
# This is weird and crashes if you don't have the second arg, but also crashes most the time
192-
# when you try to access something on it
217+
# when you try to access something on it - seems like a garbage pointer
193218
item, _ = caller.CreateMarketplaceItem()
194219

195220
item.SetString(caller.Prop_offeringId, str(idx), translation_context)
@@ -248,7 +273,7 @@ def update_item() -> None:
248273
# were, but we have to call this to actually update the visuals
249274
# This also resets filters, and for some reason none of the filter functions want to work
250275
# right now either :/
251-
caller.RefreshDLC()
276+
_RefreshDLC(caller, None, None)
252277

253278
if key == "Q":
254279
if event == KeybindManager.InputEvent.Released:
@@ -386,6 +411,7 @@ def _FrontEndUpdateTooltips(caller: unrealsdk.UObject, function: unrealsdk.UFunc
386411

387412

388413
unrealsdk.RunHook("WillowGame.WillowScrollingListDataProviderFrontEnd.Populate", "ModMenu.MenuManager", _FrontEndPopulate)
414+
unrealsdk.RunHook("WillowGame.MarketplaceGFxMovie.RefreshDLC", "ModMenu.MenuManager", _RefreshDLC)
389415
unrealsdk.RunHook("WillowGame.MarketplaceGFxMovie.OnDownloadableContentListRead", "ModMenu.MenuManager", _OnDownloadableContentListRead)
390416
unrealsdk.RunHook("WillowGame.MarketplaceGFxMovie.ShopInputKey", "ModMenu.MenuManager", _ShopInputKey)
391417
unrealsdk.RunHook("WillowGame.MarketplaceGFxMovie.extOnOfferingChanged", "ModMenu.MenuManager", _extOnOfferingChanged)

Mods/ModMenu/Options.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from typing import Any, Optional, Sequence, Tuple
33

44
from . import DeprecationHelper as dh
5-
from . import SettingsManager
65

76

87
class Base(ABC):
@@ -71,8 +70,6 @@ class Hidden(Value):
7170
StartingValue: The default value of the option.
7271
IsHidden: If the option is hidden from the options menu. This is forced to True.
7372
"""
74-
_current_value: Any
75-
7673
def __init__(
7774
self,
7875
Caption: str,
@@ -108,15 +105,6 @@ def IsHidden(self) -> bool: # type: ignore
108105
def IsHidden(self, val: bool) -> None:
109106
pass
110107

111-
@property
112-
def CurrentValue(self) -> Any:
113-
return self._current_value
114-
115-
@CurrentValue.setter
116-
def CurrentValue(self, val: Any) -> None:
117-
self._current_value = val
118-
SettingsManager.SaveAllModSettings()
119-
120108

121109
class Slider(Value):
122110
"""

Mods/ModMenu/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# Need to define these up here so that they're accessable when importing the other files
66
VERSION_MAJOR = 2
7-
VERSION_MINOR = 1
7+
VERSION_MINOR = 2
88

99
unrealsdk.Log(f"[ModMenu] Version: {VERSION_MAJOR}.{VERSION_MINOR}")
1010

Mods/SkillRandomizer/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@
66
import os
77

88
from ..ModManager import BL2MOD, RegisterMod
9+
from Mods.ModMenu import Game
910

1011
class CrossSkillRandomizer(BL2MOD):
12+
Name = "Cross Class Skill Randomizer ({})"
1113
Description = "Randomize all the skills!"
14+
15+
SupportedGames = Game.BL2
1216

1317
LocalModDir = os.path.dirname(os.path.realpath(__file__))
1418

1519
def __init__(self, seed=None):
1620
self.Seed = seed
1721
if seed:
18-
self.Name = "Cross Class Skill Randomizer ({})".format(self.Seed)
22+
self.Name = self.Name.format(self.Seed)
1923
else:
20-
self.Name = "Cross Class Skill Randomizer (New Seed)"
24+
self.Name = self.Name.format("New Seed")
2125

2226
def RecordSeed(self):
2327
with open(self.LocalModDir + "\\log.json", "r+") as f:

0 commit comments

Comments
 (0)