Skip to content

Commit

Permalink
Merge pull request #372 from randovania/item-icons
Browse files Browse the repository at this point in the history
Add mapping for pickups and map icons
  • Loading branch information
ThanatosGit authored Jun 13, 2024
2 parents b9d618f + e759872 commit d6ee8cf
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/open_samus_returns_rando/files/custom/sprites_texturehud.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
Game.ImportLibrary("gui/scripts/sprites_texturehud_original.lua")

GUI.AddSpriteSheetItem("item_powerup", "gui/textures/texturehud.bctex", {
TextureWidth = "512",
TextureHeight = "256",
UPixelOffset = "144",
VPixelOffset = "24",
UPixelScale = "8",
VPixelScale = "8",
AngleOffset = "0"
})
GUI.AddSpriteSheetItem("item_offworld", "gui/textures/texturehud.bctex", {
TextureWidth = "512",
TextureHeight = "256",
UPixelOffset = "104",
VPixelOffset = "40",
UPixelScale = "8",
VPixelScale = "8",
AngleOffset = "0"
})
GUI.AddSpriteSheetItem("item_adn", "gui/textures/texturehud.bctex", {
TextureWidth = "512",
TextureHeight = "256",
UPixelOffset = "112",
VPixelOffset = "40",
UPixelScale = "8",
VPixelScale = "8",
AngleOffset = "0"
})
GUI.AddSpriteSheetItem("dooriceleft", "gui/textures/texturehud.bctex", {
TextureWidth = "512",
TextureHeight = "256",
Expand Down
Binary file not shown.
45 changes: 44 additions & 1 deletion src/open_samus_returns_rando/pickups/pickup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from enum import Enum

from construct import Container, ListContainer
from mercury_engine_data_structures.formats import Bmsad, Lua
from mercury_engine_data_structures.formats import Bmsad, Bmsmsd, Lua
from open_samus_returns_rando.constants import get_package_name
from open_samus_returns_rando.files import templates_path
from open_samus_returns_rando.logger import LOG
Expand Down Expand Up @@ -288,13 +288,56 @@ def patch(self, editor: PatcherEditor) -> None:

script_class.ensure_files(editor)

self.patch_minimap(editor, scenario_name, actor_name)

# Dependencies
for level_pkg in pkgs_for_level:
for model_name in model_names:
model_data = get_data(model_name)
for dep in model_data.dependencies:
editor.ensure_present(get_package_name(level_pkg, dep), dep)


def patch_minimap(self, editor: PatcherEditor, scenario_name: str, actor_name: str) -> None:
if scenario_name != "s110_surfaceb":
scenario_minimap = editor.get_file(f"gui/minimaps/c10_samus/{scenario_name}.bmsmsd", Bmsmsd)
else:
scenario_minimap = editor.get_file("gui/minimaps/c10_samus/s000_surface.bmsmsd", Bmsmsd)
tiles = scenario_minimap.raw["tiles"]

# find item tile
tile_for_item = [
x for x in tiles if len(x.icons) and next((y for y in x.icons if actor_name in y.actor_name), 0)
]

if len(tile_for_item) == 1:
pickup_tile_icon = next((y for y in tile_for_item[0].icons if "item" in y.icon), None)

if not pickup_tile_icon:
raise ValueError("No icon found")

pickup_model = self.pickup["model"][0]

# Tanks and offworld items just use the icon with the same name as the pickup_model
# Powerups and Nothing items use a "custom" itemsphere so they update on the map
if "itemsphere" in pickup_model or "powerup" in pickup_model:
pickup_model = "item_powerup"
# DNA uses a custom icon
elif "adn" in pickup_model:
pickup_model = "item_adn"

# change the icons to their new item type
pickup_tile_icon.icon = pickup_model

# Special cases
# Custom blockx are no longer attached to the pickup, so make all hidden pickups consistent and generic
if pickup_tile_icon.icon_priority == "HIDDEN_ITEM" or (
# The Queen pickup is always visible on the map without fighing it, so make it generic
scenario_name == "s100_area10" and actor_name == "LE_Baby_Hatchling"
):
pickup_tile_icon.icon = "itemenabled"


def get_scenario(self) -> str:
return self.pickup["pickup_actor"]["scenario"]

Expand Down

0 comments on commit d6ee8cf

Please sign in to comment.