Skip to content

Commit

Permalink
cleanup/prep for release
Browse files Browse the repository at this point in the history
  • Loading branch information
apple1417 committed Feb 2, 2025
1 parent 86edfaa commit d65ee6f
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 17 deletions.
10 changes: 9 additions & 1 deletion .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ extend-ignore-re = [
# Ignore markdown links to github commits/trees
"\\[[0-9a-fA-F]+?\\]\\(https://github.com/.+?/.+?/(commit|tree)/.+?\\)",
# Ignore this specific hook string, which gearbox typo'd
"\"WillowGame\\.WillowPlayerController:CanAcessOakUpsell\""
"\"WillowGame\\.WillowPlayerController:CanAcessOakUpsell\"",
# Ignore the `EInventorySortType` enum prefix
"IST_EquippedThenMajorTypeThenRarityThenSubtype",
"IST_MajorTypeThenSubtypeThenRarity",
"IST_MajorTypeThenRarityThenSubtype",
"IST_Manufacturer",
"IST_ClassRequirementThenRarity",
"IST_Value",
"IST_MAX",
]

[default.extend-identifiers]
Expand Down
4 changes: 4 additions & 0 deletions vendor_edit/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Changelog

### Vendor Edit v1
Initial Release.
4 changes: 1 addition & 3 deletions vendor_edit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
from . import bugfix, editor, hooks
from .editor import open_editor_menu
from .item_codes import get_item_code, spawn_item_from_code
from .spawner import open_spawner_menu

__version__: str
__version_info__: tuple[int, ...]

__all__: tuple[str, ...] = (
"get_item_code",
"mod",
"open_editor_menu",
"open_spawner_menu",
"spawn_item_from_code",
)

Expand Down
4 changes: 2 additions & 2 deletions vendor_edit/bugfix.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from mods_base import hook
from mods_base import HookType, hook
from unrealsdk.hooks import Block
from unrealsdk.unreal import BoundFunction, UObject, WrappedStruct

Expand Down Expand Up @@ -53,4 +53,4 @@ def end_finish_compare_iotd(*_: Any) -> None:
block_switch_to_panels.disable()


hooks = [on_finish_compare_iotd, end_finish_compare_iotd]
hooks: tuple[HookType, ...] = (on_finish_compare_iotd, end_finish_compare_iotd)
10 changes: 7 additions & 3 deletions vendor_edit/dummy_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def _get_cash_manufacturer() -> InventoryBalanceDefinition:
return inner


SPAWN_FROM_BAL_DEF = unrealsdk.find_class(
"ItemPool",
).ClassDefaultObject.SpawnBalancedInventoryFromInventoryBalanceDefinition


@dataclass(frozen=True)
class DummyItemMixin:
display_name: str
Expand Down Expand Up @@ -121,9 +126,7 @@ def spawn(self, owner: WillowPawn) -> WillowInventory:
Args:
owner: The pawn to set as the item's owner.
"""
_, spawned = unrealsdk.find_class(
"ItemPool",
).ClassDefaultObject.SpawnBalancedInventoryFromInventoryBalanceDefinition(
_, spawned = SPAWN_FROM_BAL_DEF(
InvBalanceDefinition=self.bal_def,
Quantity=1,
GameStage=1,
Expand Down Expand Up @@ -191,6 +194,7 @@ def from_balance(cls, bal: InventoryBalanceDefinition) -> DummyItem:
The relevant enum value.
"""
for entry in cls:
# Since we lazily construct objects, we don't want to compare against entry.bal_def
if entry.obj_name.lower() == bal.Name.lower():
return entry
raise ValueError(f"Couldn't find dummy item for balance: {bal}")
Expand Down
4 changes: 2 additions & 2 deletions vendor_edit/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class EBackButtonScreen(UnrealEnum):

reopen_inv_option = BoolOption(
"Reopen Inventory After Editing",
True,
False,
description="If to re-open your inventory after you finish editing an item.",
)

Expand Down Expand Up @@ -101,4 +101,4 @@ def on_purchase(purchased: WillowInventory) -> None:
)


options: list[BaseOption] = [reopen_inv_option]
options: tuple[BaseOption, ...] = (reopen_inv_option,)
2 changes: 1 addition & 1 deletion vendor_edit/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def handle_menu_input(
return None


# If we immediately opening the edit menu, closing it compeltely loses focus and you lose all
# If we immediately opening the edit menu, closing it completely loses focus and you lose all
# control. Instead we just cache this item for a split second, until after the `OnClose` call.
_item_to_edit: WillowInventory | None = None

Expand Down
2 changes: 1 addition & 1 deletion vendor_edit/item_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_item_code(inv: WillowInventory) -> str:
Gets the save-editor compatible item code for the given item.
Args:
inv: The inventory item to get the code fo.
inv: The inventory item to get the code of.
Returns:
The item code.
"""
Expand Down
15 changes: 15 additions & 0 deletions vendor_edit/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[project]
name = "vendor_edit"
version = "2"
authors = [{ name = "apple1417" }]
description = """\
Lets you edit your gear using the familiar vendor menus.
"""

[project.urls]
Changelog = "https://github.com/apple1417/willow2-sdk-mods/blob/master/vendor_edit/Readme.md"

[tool.sdkmod]
name = "Vendor Edit"
license = {name = "GPL3", url = "https://choosealicense.com/licenses/gpl-3.0/" }
download = "https://github.com/apple1417/willow2-sdk-mods/releases/download/nightly/vendor_edit.sdkmod"
8 changes: 4 additions & 4 deletions vendor_edit/replacement_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def create_replacements_for_slot(self, slot: DummyItem) -> Sequence[WillowInvent
new_def = copy(def_data)
setattr(new_def, slot_names.def_data, part)

# Keep game stage synced - this is general good practice, and we explictly want it when
# Keep game stage synced - this is general good practice, and we explicitly want it when
# editing level
new_def.GameStage = new_def.ManufacturerGradeIndex

Expand All @@ -188,7 +188,7 @@ def create_replacements_for_slot(self, slot: DummyItem) -> Sequence[WillowInvent
@abstractmethod
def get_basic_slots(cls) -> Mapping[DummyItem, BaseReplacementList.SlotNames]:
"""
Gets a dict mapping a category dummy item to the basic slots from the item's defintion data.
Gets a dict mapping a category dummy item to the item definition data's basic part slots.
Returns:
The basic slots dict.
Expand All @@ -198,10 +198,10 @@ def get_basic_slots(cls) -> Mapping[DummyItem, BaseReplacementList.SlotNames]:
@abstractmethod
def init_basic_slots(self, inv: WillowInventory) -> None:
"""
Initalizes the fields on this object which depend on the basic slots.
Initializes the fields on this object which depend on the basic slots.
Args:
inv: The inventory item to initalize based off of.
inv: The inventory item to initialize based off of.
"""
raise NotImplementedError

Expand Down

0 comments on commit d65ee6f

Please sign in to comment.