Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LttP, Core: Fixes patching LttP on a fresh AP install #2118

Merged
merged 7 commits into from
Aug 25, 2023

Conversation

zig-for
Copy link
Collaborator

@zig-for zig-for commented Aug 21, 2023

What is this fixing or adding?

Archipelago (0.4.2) logging initialized on Windows-10-10.0.19045-SP0 running Python 3.8.10
Patch file was supplied. Creating sfc rom..
Wrote rom file to .\output\AP_07758176404715800194_P1_YourName1.sfc
Uncaught exception
Traceback (most recent call last):
  File ".\SNIClient.py", line 726, in <module>
    asyncio.run(main())
  File "D:\Python38\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "D:\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File ".\SNIClient.py", line 698, in main
    adjustedromfile, adjusted = get_alttp_settings(romfile)
  File "D:\git\Archipelago\worlds\alttp\Client.py", line 593, in get_alttp_settings
    setattr(last_settings, option_name, getattr(base_settings, option_name))
AttributeError: 'dict' object has no attribute 'heartcolor'

Cleans up usage of lttp adjuster settings and hardcoded values that could be different than the manual calls to the adjuster. Also implements --disablemusic properly

How was this tested?

Genned. After the first patch, settings appeared to be kosher. Mucked around with the --(disable)music option a bit

If this makes graphical changes, please attach screenshots.

usage: LttPAdjuster.py [-h] [--baserom BASEROM] [--loglevel [{error,info,warning,debug}]] [--menuspeed [{normal,instant,double,triple,quadruple,half}]] [--quickswap] [--deathlink] [--allowcollect]
                       [--music | --disablemusic] [--triforcehud [{normal,hide_goal,hide_required,hide_both}]] [--enableflashing] [--heartbeep [{double,normal,half,quarter,off}]]
                       [--heartcolor [{red,blue,green,yellow,random}]] [--ow_palettes {default,random,blackout,puke,classic,grayscale,negative,dizzy,sick}]
                       [--shield_palettes {default,random,blackout,puke,classic,grayscale,negative,dizzy,sick}] [--sword_palettes {default,random,blackout,puke,classic,grayscale,negative,dizzy,sick}]
                       [--hud_palettes {default,random,blackout,puke,classic,grayscale,negative,dizzy,sick}] [--uw_palettes {default,random,blackout,puke,classic,grayscale,negative,dizzy,sick}] [--sprite SPRITE]
                       [--oof OOF] [--names NAMES] [--update_sprites]
                       [rom]

positional arguments:
  rom                   Path to an ALttP rom to adjust.
~snip~
  --music, --disablemusic
                        Enables/Disables game music. (default: True)
~snip~

@el-u
Copy link
Collaborator

el-u commented Aug 21, 2023

I was able to patch an ALttP ROM using this branch.
One odd thing was that it brought up a UI claiming "Last used adjuster settings were found", even though "_persistent_storage.yaml" was not present.

@Berserker66
Copy link
Member

Yeah, when getting the adjuster settings it now populates it with the default, so it checking for an empty dict will now always trigger, as the dict is populated and bring up the UI.

@zig-for
Copy link
Collaborator Author

zig-for commented Aug 22, 2023 via email

@Berserker66
Copy link
Member

Restoring the old behaviour would be appropriate - if no custom adjuster settings exist, skip the UI

@zig-for zig-for requested a review from Berserker66 as a code owner August 23, 2023 03:03
@zig-for
Copy link
Collaborator Author

zig-for commented Aug 23, 2023

Ok, I think I fixed things up now:

  • Running LttpAdjuster.py will use the persisted adjustersettings as defaults (this might be new behavior, but is probably wanted)
  • Added sprite_pool and auto_apply to the arguments, so that they get correctly populated with defaults
  • Running the client on a fresh install will ignore the adjuster as no settings are stored
  • Running the client with adjuster settings will overlay those settings on top of the defaults

Edit: this allows removing some getattr :)

@zig-for
Copy link
Collaborator Author

zig-for commented Aug 23, 2023

Possible further improvements:

  • Warning/removal of arguments that don't exist

@zig-for
Copy link
Collaborator Author

zig-for commented Aug 23, 2023

Someone who's a better writer than me should come up with nicer help text. :)

if vars(Utils.get_adjuster_settings_no_defaults(GAME_ALTTP)):
last_settings = Utils.get_adjuster_settings(GAME_ALTTP)

allow_list = {"music", "menuspeed", "heartbeep", "heartcolor", "ow_palettes", "quickswap",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list should really just go away - hardly anyone uses text mode, I would guess - and I'd much rather just hide options we don't want to show, rather than hard code a list of special args.

choice = 'no'
if not hasattr(last_settings, 'auto_apply') or 'ask' in last_settings.auto_apply:
if 'ask' in last_settings.auto_apply:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Giving some side-eye to all this if x in y

from worlds.alttp.Rom import get_base_rom_path
last_settings.rom = romfile
last_settings.baserom = get_base_rom_path()
last_settings.world = None

if hasattr(last_settings, "sprite_pool"):
if last_settings.sprite_pool:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there was maybe a bug here if you had an empty sprite_pool before.

if sprite_pool:
printed_options["sprite_pool"] = sprite_pool

sprite_pool = {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto for removing this special case. Just show the pool as it exists in the yaml

def get_rom_options_frame(parent=None):
adjuster_settings = get_adjuster_settings(GAME_ALTTP)
defaults = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray, no more duplicated default args.

@el-u
Copy link
Collaborator

el-u commented Aug 24, 2023

I was able to patch an ALttP ROM using this branch.
The adjuster settings UI no longer popped up when "_persistent_storage.yaml" was not present, which I think is the correct behavior.
(It did appear when "_persistent_storage.yaml" was present but auto_apply was not set, which also seems like correct behavior.)

@Berserker66 Berserker66 merged commit 41a34b1 into ArchipelagoMW:main Aug 25, 2023
@ThePhar ThePhar changed the title Fixes patching LttP on a fresh AP install LttP: Fixes patching LttP on a fresh AP install Oct 16, 2023
@ThePhar ThePhar added is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. affects: core Issues/PRs that touch core and may need additional validation. labels Oct 16, 2023
@ThePhar ThePhar changed the title LttP: Fixes patching LttP on a fresh AP install LttP, Core: Fixes patching LttP on a fresh AP install Oct 16, 2023
FlySniper pushed a commit to FlySniper/Archipelago that referenced this pull request Nov 14, 2023
Jouramie pushed a commit to Jouramie/Archipelago that referenced this pull request Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: core Issues/PRs that touch core and may need additional validation. is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants