Skip to content

Commit 48973ec

Browse files
authored
Attack on Dragon Keep Standalone Support (#98)
* preliminary aodk support * fixed input eating whoever wrote this hex edit should be ashamed of themselves
1 parent b87773d commit 48973ec

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

Mods/ModMenu/MenuManager.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class _General(ModObjects.SDKMod):
6565
)
6666
Version: str = f"{VERSION_MAJOR}.{VERSION_MINOR}"
6767

68+
SupportedGames: ModObjects.Game = (
69+
ModObjects.Game.BL2 | ModObjects.Game.TPS | ModObjects.Game.AoDK
70+
)
6871
Types: ModObjects.ModTypes = ModObjects.ModTypes.All
6972

7073
Status: str = ""
@@ -75,7 +78,7 @@ class _General(ModObjects.SDKMod):
7578

7679
def SettingsInputPressed(self, action: str) -> None:
7780
if action == "Help":
78-
webbrowser.open("http://borderlandsmodding.com/sdk-mods/")
81+
webbrowser.open("http://bl-sdk.github.io/")
7982
elif action == "Open Mods Folder":
8083
os.startfile(os.path.join(os.path.dirname(sys.executable), "Mods"))
8184

@@ -157,10 +160,17 @@ def AddListItem(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params
157160
Using it cause it simplifies the code to replace the caption.
158161
"""
159162
if params.Caption == "$WillowMenu.WillowScrollingListDataProviderFrontEnd.DLC":
160-
unrealsdk.DoInjectedCallNext()
161-
caller.AddListItem(_MODS_EVENT_ID, _MODS_MENU_NAME, False, False)
162163
return False
163164

165+
inject_now = False
166+
if unrealsdk.GetEngine().GetCurrentWorldInfo().NetMode == 3: # NM_Client
167+
inject_now = params.Caption == "$WillowMenu.WillowScrollingListDataProviderFrontEnd.Disconnect"
168+
else:
169+
inject_now = params.Caption == "$WillowMenu.WillowScrollingListDataProviderFrontEnd.Quit"
170+
171+
if inject_now:
172+
caller.AddListItem(_MODS_EVENT_ID, _MODS_MENU_NAME, False, False)
173+
164174
return True
165175

166176
unrealsdk.RunHook("WillowGame.WillowScrollingList.AddListItem", "ModMenu.MenuManager", AddListItem)

Mods/ModMenu/ModObjects.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import json
66
import sys
77
from abc import ABCMeta
8+
from functools import lru_cache
89
from os import path
910
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, cast
1011

@@ -78,17 +79,23 @@ class EnabledSaveType(enum.Enum):
7879
class Game(enum.Flag):
7980
BL2 = enum.auto()
8081
TPS = enum.auto()
82+
AoDK = enum.auto()
8183

8284
@staticmethod
85+
@lru_cache(None)
8386
def GetCurrent() -> Game:
8487
""" Gets the current game. """
88+
lower_exe_names: Dict[str, Game] = {
89+
"borderlands2.exe": Game.BL2,
90+
"borderlandspresequel.exe": Game.TPS,
91+
"tinytina.exe": Game.AoDK,
92+
}
93+
8594
exe = path.basename(sys.executable)
8695
exe_lower = exe.lower()
87-
if exe_lower == "borderlands2.exe":
88-
return Game.BL2
89-
elif exe_lower == "borderlandspresequel.exe":
90-
return Game.TPS
91-
raise RuntimeError(f"Unknown executable name '{exe}'!")
96+
if exe_lower not in lower_exe_names:
97+
raise RuntimeError(f"Unknown executable name '{exe}'!")
98+
return lower_exe_names[exe_lower]
9299

93100

94101
class _ModMeta(ABCMeta):
@@ -172,7 +179,7 @@ class SDKMod(metaclass=_ModMeta):
172179
Description: str = ""
173180
Version: str = "Unknown Version"
174181

175-
SupportedGames: Game = Game.BL2 | Game.TPS
182+
SupportedGames: Game = Game.BL2 | Game.TPS | Game.AoDK
176183
Types: ModTypes = ModTypes.NONE
177184
Priority: int = ModPriorities.Standard
178185
SaveEnabledState: EnabledSaveType = EnabledSaveType.NotSaved
@@ -228,7 +235,6 @@ def Enable(self) -> None:
228235
"""
229236
HookManager.RegisterHooks(self)
230237
NetworkManager.RegisterNetworkMethods(self)
231-
pass
232238

233239
def Disable(self) -> None:
234240
"""
@@ -237,7 +243,6 @@ def Disable(self) -> None:
237243
"""
238244
HookManager.RemoveHooks(self)
239245
NetworkManager.UnregisterNetworkMethods(self)
240-
pass
241246

242247
def SettingsInputPressed(self, action: str) -> None:
243248
"""

Mods/ModMenu/__init__.py

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

3838
# Need to define these up here so that they're accessable when importing the other files
3939
VERSION_MAJOR = 2
40-
VERSION_MINOR = 4
40+
VERSION_MINOR = 5
4141

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

0 commit comments

Comments
 (0)