From f62f882a851385002a8f9aeb95fc439567d3c4dc Mon Sep 17 00:00:00 2001 From: Cruor Date: Fri, 20 Aug 2021 14:56:12 +0200 Subject: [PATCH] Added Everest Custom Height Display Trigger. Fixed Core Mode and Dreaming state in chapter checkpoint settings not saving. Fixed custom tilesets not loading when loading a file from backup. --- lang/en_gb.lang | 9 +++++++++ src/backups.jl | 4 +--- src/helpers/form_helper.jl | 15 +++++++++++++-- src/triggers/activate_dream_blocks.jl | 2 +- src/triggers/everest_custom_height_display.jl | 12 ++++++++++++ src/windows/file_dialog_window.jl | 7 ++++--- 6 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 src/triggers/everest_custom_height_display.jl diff --git a/lang/en_gb.lang b/lang/en_gb.lang index ff21e3d..2f9b8b7 100644 --- a/lang/en_gb.lang +++ b/lang/en_gb.lang @@ -562,6 +562,15 @@ placements.triggers.everest/activateDreamBlocksTrigger.tooltips.fastAnimation=Wh placements.triggers.everest/customBirdTutorialTrigger.tooltips.birdId=Which bird the trigger should affect. placements.triggers.everest/customBirdTutorialTrigger.tooltips.showTutorial=If ticked, the targeted bird will show its speech bubble. If unchecked, the bird will fly away. +# Custom Height Display (Everest) +placements.triggers.everest/CustomHeightDisplayTrigger.tooltips.vanilla=Whether this trigger should use the vanilla height display. The vanilla one only uses the target attribute. +placements.triggers.everest/CustomHeightDisplayTrigger.tooltips.target=The new meter count. +placements.triggers.everest/CustomHeightDisplayTrigger.tooltips.from=The previous meter count. +placements.triggers.everest/CustomHeightDisplayTrigger.tooltips.progressAudio=Whether the trigger should increment audio progress. +placements.triggers.everest/CustomHeightDisplayTrigger.tooltips.displayOnTransition=Whether the trigger should wait for a room transition to occur before displaying the counter. +placements.triggers.everest/CustomHeightDisplayTrigger.tooltips.text=The text of the counter. The meter count specified in target is substituted in for {x}.\nExample: "Currently at {x} meters". + + # -- Effects -- placements.effects.tentacles.names.sides=Sides diff --git a/src/backups.jl b/src/backups.jl index 411e2c5..8869824 100644 --- a/src/backups.jl +++ b/src/backups.jl @@ -89,9 +89,7 @@ function openBackupDialog() latestBackupFilename = getBackupFilename(side) # The latest filename may also be in another folder, make sure we get the right folder - Ahorn.showFileOpenDialog(MenuItem(), dirname(joinpath(backupFolder, latestBackupFilename))) - Ahorn.loadedState.filename = latestFilename - Ahorn.persistence["files_lastfile"] = latestFilename + Ahorn.showFileOpenDialog(MenuItem(), dirname(joinpath(backupFolder, latestBackupFilename)), latestFilename) end end diff --git a/src/helpers/form_helper.jl b/src/helpers/form_helper.jl index e25403c..c58ba6d 100644 --- a/src/helpers/form_helper.jl +++ b/src/helpers/form_helper.jl @@ -212,7 +212,7 @@ mutable struct DictionaryChoiceOption <: Option end Base.size(option::DictionaryChoiceOption) = (2, 1) -getValue(option::DictionaryChoiceOption) = typeof(option.value) === String ? Ahorn.convertString(option.as, option.value) : option.value +getValue(option::DictionaryChoiceOption) = option.value setValue!(option::DictionaryChoiceOption, value::Any) = Ahorn.setComboIndex!(option.combobox, collect(values(option.options)), value, allowCustom=false) getGroup(option::DictionaryChoiceOption) = 1 setGtkProperty!(option::DictionaryChoiceOption, field::Symbol, value::Any) = set_gtk_property!(option.combobox, field, value) @@ -224,7 +224,18 @@ function addToGrid!(grid::Gtk.GtkGrid, option::DictionaryChoiceOption, col::Inte @guarded signal_connect(option.combobox, "changed") do args... text = Gtk.bytestring(GAccessor.active_text(option.combobox)) - option.value = get(option.options, text, text) + + if haskey(option.options, text) + option.value = get(option.options, text, text) + + else + try + option.value = Ahorn.convertString(option.as, text) + + catch + option.value = first(option.options)[2] + end + end end end diff --git a/src/triggers/activate_dream_blocks.jl b/src/triggers/activate_dream_blocks.jl index b8fb5b5..b4c183b 100644 --- a/src/triggers/activate_dream_blocks.jl +++ b/src/triggers/activate_dream_blocks.jl @@ -4,7 +4,7 @@ using ..Ahorn, Maple const placements = Ahorn.PlacementDict( "Activate Space Jams (Everest)" => Ahorn.EntityPlacement( - Maple.ActivateDreamBlocks, + Maple.ActivateDreamBlocksTrigger, "rectangle" ) ) diff --git a/src/triggers/everest_custom_height_display.jl b/src/triggers/everest_custom_height_display.jl new file mode 100644 index 0000000..840bc59 --- /dev/null +++ b/src/triggers/everest_custom_height_display.jl @@ -0,0 +1,12 @@ +module EverestCustomHeightDisplay + +using ..Ahorn, Maple + +const placements = Ahorn.PlacementDict( + "Custom Height Display (Everest)" => Ahorn.EntityPlacement( + Maple.CustomHeightDisplayTrigger, + "rectangle" + ) +) + +end \ No newline at end of file diff --git a/src/windows/file_dialog_window.jl b/src/windows/file_dialog_window.jl index ee93721..b4ba089 100644 --- a/src/windows/file_dialog_window.jl +++ b/src/windows/file_dialog_window.jl @@ -8,7 +8,7 @@ function lastMapDir() return targetDir end -function showFileOpenDialog(leaf::Ahorn.MenuItemsTypes=MenuItem(), folder::String=lastMapDir()) +function showFileOpenDialog(leaf::Ahorn.MenuItemsTypes=MenuItem(), folder::String=lastMapDir(), overrideFilename::Union{String, Nothing}=nothing) @Ahorn.catchall begin filename = openDialog("Select map binary", window, ["*.bin"], folder=folder) @@ -23,7 +23,8 @@ function showFileOpenDialog(leaf::Ahorn.MenuItemsTypes=MenuItem(), folder::Strin deleteDrawableRoomCache(loadedState.map) end - loadedState.filename = filename + # Allow backups to "fake" where a file is actually stored + loadedState.filename = something(overrideFilename, filename) loadedState.side = loadSide(filename) loadedState.map = loadedState.side.map loadedState.lastSavedHash = hash(loadedState.side) @@ -32,7 +33,7 @@ function showFileOpenDialog(leaf::Ahorn.MenuItemsTypes=MenuItem(), folder::Strin persistence["files_lastroom"] = loadedState.roomName persistence["files_lastfile"] = loadedState.filename - + packageName = loadedState.map.package EntityIds.updateValidIds(loadedState.map)