Skip to content

Commit

Permalink
Attack on Dragon Keep Standalone Support (#98)
Browse files Browse the repository at this point in the history
* preliminary aodk support

* fixed input eating

whoever wrote this hex edit should be ashamed of themselves
  • Loading branch information
apple1417 committed Nov 11, 2021
1 parent b87773d commit 48973ec
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
16 changes: 13 additions & 3 deletions Mods/ModMenu/MenuManager.py
Expand Up @@ -65,6 +65,9 @@ class _General(ModObjects.SDKMod):
)
Version: str = f"{VERSION_MAJOR}.{VERSION_MINOR}"

SupportedGames: ModObjects.Game = (
ModObjects.Game.BL2 | ModObjects.Game.TPS | ModObjects.Game.AoDK
)
Types: ModObjects.ModTypes = ModObjects.ModTypes.All

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

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

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

inject_now = False
if unrealsdk.GetEngine().GetCurrentWorldInfo().NetMode == 3: # NM_Client
inject_now = params.Caption == "$WillowMenu.WillowScrollingListDataProviderFrontEnd.Disconnect"
else:
inject_now = params.Caption == "$WillowMenu.WillowScrollingListDataProviderFrontEnd.Quit"

if inject_now:
caller.AddListItem(_MODS_EVENT_ID, _MODS_MENU_NAME, False, False)

return True

unrealsdk.RunHook("WillowGame.WillowScrollingList.AddListItem", "ModMenu.MenuManager", AddListItem)
Expand Down
21 changes: 13 additions & 8 deletions Mods/ModMenu/ModObjects.py
Expand Up @@ -5,6 +5,7 @@
import json
import sys
from abc import ABCMeta
from functools import lru_cache
from os import path
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, cast

Expand Down Expand Up @@ -78,17 +79,23 @@ class EnabledSaveType(enum.Enum):
class Game(enum.Flag):
BL2 = enum.auto()
TPS = enum.auto()
AoDK = enum.auto()

@staticmethod
@lru_cache(None)
def GetCurrent() -> Game:
""" Gets the current game. """
lower_exe_names: Dict[str, Game] = {
"borderlands2.exe": Game.BL2,
"borderlandspresequel.exe": Game.TPS,
"tinytina.exe": Game.AoDK,
}

exe = path.basename(sys.executable)
exe_lower = exe.lower()
if exe_lower == "borderlands2.exe":
return Game.BL2
elif exe_lower == "borderlandspresequel.exe":
return Game.TPS
raise RuntimeError(f"Unknown executable name '{exe}'!")
if exe_lower not in lower_exe_names:
raise RuntimeError(f"Unknown executable name '{exe}'!")
return lower_exe_names[exe_lower]


class _ModMeta(ABCMeta):
Expand Down Expand Up @@ -172,7 +179,7 @@ class SDKMod(metaclass=_ModMeta):
Description: str = ""
Version: str = "Unknown Version"

SupportedGames: Game = Game.BL2 | Game.TPS
SupportedGames: Game = Game.BL2 | Game.TPS | Game.AoDK
Types: ModTypes = ModTypes.NONE
Priority: int = ModPriorities.Standard
SaveEnabledState: EnabledSaveType = EnabledSaveType.NotSaved
Expand Down Expand Up @@ -228,7 +235,6 @@ def Enable(self) -> None:
"""
HookManager.RegisterHooks(self)
NetworkManager.RegisterNetworkMethods(self)
pass

def Disable(self) -> None:
"""
Expand All @@ -237,7 +243,6 @@ def Disable(self) -> None:
"""
HookManager.RemoveHooks(self)
NetworkManager.UnregisterNetworkMethods(self)
pass

def SettingsInputPressed(self, action: str) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion Mods/ModMenu/__init__.py
Expand Up @@ -37,7 +37,7 @@

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

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

Expand Down

0 comments on commit 48973ec

Please sign in to comment.