Skip to content

Commit 80c49b4

Browse files
authored
Extra Small Files (#74)
1 parent 903db4c commit 80c49b4

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

Mods/ModMenu/ModObjects.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from __future__ import annotations
22

3-
import unrealsdk
43
import copy
54
import enum
5+
import sys
66
from abc import ABCMeta
7+
from os import path
78
from typing import Any, Dict, List, Optional, Sequence, Tuple
89

910
from . import KeybindManager
@@ -71,7 +72,13 @@ class Game(enum.Flag):
7172
@staticmethod
7273
def GetCurrent() -> Game:
7374
""" Gets the current game. """
74-
return Game.BL2 if unrealsdk.GetEngine().GetEngineVersion() == 8639 else Game.TPS
75+
exe = path.basename(sys.executable)
76+
exe_lower = exe.lower()
77+
if exe_lower == "borderlands2.exe":
78+
return Game.BL2
79+
elif exe_lower == "borderlandspresequel.exe":
80+
return Game.TPS
81+
raise RuntimeError(f"Unknown executable name '{exe}'!")
7582

7683

7784
class _ModMeta(ABCMeta):

Mods/ModMenu/SettingsManager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def LoadModSettings(mod: ModObjects.SDKMod) -> None:
9696
try:
9797
with open(GetSettingsFilePath(mod)) as file:
9898
settings = json.load(file)
99-
except FileNotFoundError:
99+
except (FileNotFoundError, json.JSONDecodeError):
100100
return
101101

102102
def load_options_dict(options: Sequence[Options.Base], settings: Dict[str, Any]) -> None:
@@ -129,7 +129,7 @@ def load_options_dict(options: Sequence[Options.Base], settings: Dict[str, Any])
129129
elif isinstance(option, Options.Nested):
130130
load_options_dict(option.Children, value)
131131

132-
load_options_dict(mod.Options, settings.get(_KEYBINDS_CATEGORY_NAME, {}))
132+
load_options_dict(mod.Options, settings.get(_OPTIONS_CATEGORY_NAME, {}))
133133

134134
saved_keybinds = settings.get(_KEYBINDS_CATEGORY_NAME, {})
135135
for input in mod.Keybinds:

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 = 0
7+
VERSION_MINOR = 1
88

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

0 commit comments

Comments
 (0)