Adds toggle for displaying generated entries or not + fixes issue when cleaning json strings

This commit is contained in:
infinitefusion
2024-12-23 23:52:04 -05:00
parent d2e5dfb8cd
commit 950c942b20
21 changed files with 41 additions and 14 deletions

View File

@@ -119,11 +119,11 @@ def downloadAllowed?()
end
def clean_json_string(str)
return str if $PokemonSystem.on_mobile
#echoln str
#return str if $PokemonSystem.on_mobile
# Remove non-UTF-8 characters and unexpected control characters
#cleaned_str = str.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
cleaned_str = str
cleaned_str = str.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
# Remove literal \n, \r, \t, etc.
cleaned_str = cleaned_str.gsub(/\\n|\\r|\\t/, '')
@@ -137,6 +137,7 @@ def clean_json_string(str)
cleaned_str = cleaned_str.gsub(/\\u([\da-fA-F]{4})/) { |match|
[$1.to_i(16)].pack("U")
}
echoln cleaned_str
return cleaned_str
end

View File

@@ -323,7 +323,7 @@ class PokemonPokedexInfo_Scene
# species_data.pokedex_entry, base, shadow)
#
#
#$PokemonSystem.use_generated_dex_entries=true if $PokemonSystem.use_generated_dex_entries ==nil
drawEntryText(overlay, species_data)
# Draw the footprint
@@ -362,7 +362,8 @@ class PokemonPokedexInfo_Scene
pbDrawImagePositions(overlay, imagepos)
end
def drawEntryText(overlay, species_data)
def drawEntryText(overlay, species_data)
baseColor = Color.new(88, 88, 80)
shadow = Color.new(168, 184, 184)
shadowCustom = Color.new(160, 200, 150)
@@ -374,12 +375,17 @@ class PokemonPokedexInfo_Scene
entryText = customEntry
shadowColor = shadowCustom
else
aiEntry = getAIDexEntry(species_data.species, species_data.name)
if aiEntry
entryText = aiEntry
shadowColor = shadowAI
if $PokemonSystem.use_generated_dex_entries
aiEntry = getAIDexEntry(species_data.species, species_data.name)
if aiEntry
entryText = aiEntry
shadowColor = shadowAI
else
entryText = species_data.pokedex_entry
shadowColor = shadow
end
else
entryText = species_data.pokedex_entry
entryText = "No custom Pokédex entry available for this Pokémon. Placeholder entries can be enabled in the game's options."
shadowColor = shadow
end
end

View File

@@ -22,6 +22,7 @@ class PokemonSystem
attr_accessor :max_nb_sprites_download
attr_accessor :on_mobile
attr_accessor :type_icons
attr_accessor :use_generated_dex_entries
def initialize
@textspeed = 1 # Text speed (0=slow, 1=normal, 2=fast)
@@ -43,6 +44,7 @@ class PokemonSystem
@max_nb_sprites_download = 5
@on_mobile = false
@type_icons = true
@use_generated_dex_entries = true
end
end

View File

@@ -111,6 +111,19 @@ class PokemonGameOption_Scene < PokemonOption_Scene
"Automatically download missing custom sprites and Pokédex entries from the internet"
)
generated_entries_option_selected=$PokemonSystem.use_generated_dex_entries ? 1 : 0
options << EnumOption.new(_INTL("Autogen dex entries"), [_INTL("Off"), _INTL("On")],
proc { generated_entries_option_selected },
proc { |value|
$PokemonSystem.use_generated_dex_entries = value == 1
},
[
"Fusions without a custom Pokédex entry display nothing.",
"Fusions without a custom Pokédex entry display an auto-generated placeholder."
]
)
if $game_switches && ($game_switches[SWITCH_NEW_GAME_PLUS] || $game_switches[SWITCH_BEAT_THE_LEAGUE]) #beat the league
options <<
EnumOption.new(_INTL("Battle type"), [_INTL("1v1"), _INTL("2v2"), _INTL("3v3")],
@@ -177,6 +190,8 @@ class PokemonGameOption_Scene < PokemonOption_Scene
"Display the enemy Pokémon type in battles."
)
end
options << EnumOption.new(_INTL("Screen Size"), [_INTL("S"), _INTL("M"), _INTL("L"), _INTL("XL"), _INTL("Full")],
proc { [$PokemonSystem.screensize, 4].min },