Skip to content

Commit e0f1461

Browse files
authored
Merge pull request #7 from apple1417/master
change the functions the keybinds implementation should overwrite
2 parents bd45c9d + 96aa6fe commit e0f1461

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

Readme.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ game specific things:
1111
- A mod menu. Consider using [console_mod_menu](https://github.com/bl-sdk/console_mod_menu/)
1212
while developing, though you likely want to create a gui version for users.
1313

14-
- A keybind implementation, which overwrites `KeybindType.enable` and `KeybindType.disable`, and
15-
sets up some hooks to run the callbacks as appropriate.
14+
- A keybind implementation, which overwrites `KeybindType._enable` and `KeybindType._disable` (and
15+
possibly `KeybindType._rebind`), and sets up some hooks to run the callbacks as appropriate.
1616

1717
- An initialization script. This should import this and the keybind implementation, then find and
18-
import all mods, and finally call `mods_base.mod_list.register_base_mod `
18+
import all mods, and finally call `mods_base.mod_list.register_base_mod`
1919

2020
# Changelog
2121

22+
### v1.7 (Upcoming)
23+
- Changed the functions the keybind implementation should overwrite from `KeybindType.enable` to
24+
`KeybindType._enable` (+ same for disable). These functions don't need to set `is_enabled`.
25+
2226
### v1.6
2327
- Changed default type of `HookType` generic type hint to any, so that by default pre and post hooks
2428
can be combined under the same type. As an example, previously if you passed an explicit hook list

__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .dot_sdkmod import open_in_mod_dir
99

1010
# Need to define a few things first to avoid circular imports
11-
__version_info__: tuple[int, int] = (1, 6)
11+
__version_info__: tuple[int, int] = (1, 7)
1212
__version__: str = f"{__version_info__[0]}.{__version_info__[1]}"
1313
__author__: str = "bl-sdk"
1414

keybinds.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,26 @@ def __setattr__(self, name: str, value: Any) -> None:
9696

9797
super().__setattr__(name, value)
9898

99+
def enable(self) -> None:
100+
"""Enables this keybind."""
101+
self._enable()
102+
self.is_enabled = True
103+
104+
def disable(self) -> None:
105+
"""Disables this keybind."""
106+
self._disable()
107+
self.is_enabled = False
108+
99109
# These three functions should get replaced by the keybind implementation
100110
# The initialization script should make sure to load it before any mods, to make sure they don't
101111
# end up with references to these functions
102-
# If writing a new implementation, make sure to still set `is_enabled` correctly
103-
def enable(self) -> None:
112+
def _enable(self) -> None:
104113
"""Enables this keybind."""
105114
logging.error("No keybind implementation loaded, unable to enable binds")
106-
self.is_enabled = True
107115

108-
def disable(self) -> None:
116+
def _disable(self) -> None:
109117
"""Disables this keybind."""
110118
logging.error("No keybind implementation loaded, unable to disable binds")
111-
self.is_enabled = False
112119

113120
def _rebind(self, new_key: str | None) -> None:
114121
"""

0 commit comments

Comments
 (0)