Merge pull request #136 from Leischii/options-description-fix

Options UI: Fix descriptions not updating correctly
This commit is contained in:
infinitefusion
2025-04-08 21:08:24 -04:00
committed by GitHub

View File

@@ -131,13 +131,14 @@ end
#===============================================================================
#
#===============================================================================
class NumberOption
class NumberOption < Option
include PropertyMixin
attr_reader :name
attr_reader :optstart
attr_reader :optend
def initialize(name, optstart, optend, getProc, setProc)
def initialize(name, optstart, optend, getProc, setProc, description="")
super(description)
@name = name
@optstart = optstart
@optend = optend
@@ -214,6 +215,7 @@ class Window_PokemonOption < Window_DrawableCommand
@mustUpdateDescription = false
@selected_position = 0
@allow_arrows_jump = false
@is_first_update = true
for i in 0...@options.length
@optvalues[i] = 0
end
@@ -321,23 +323,43 @@ class Window_PokemonOption < Window_DrawableCommand
oldindex = self.index
@mustUpdateOptions = false
super
dorefresh = (self.index != oldindex)
if @is_first_update
# Needed for displaying the description of the initially selected option correctly
@selected_position = self[self.index]
@mustUpdateOptions = true
@mustUpdateDescription = true
@is_first_update = false
refresh
return
end
if self.active && self.index < @options.length
if Input.repeat?(Input::LEFT)
self[self.index] = @options[self.index].prev(self[self.index])
dorefresh =
@selected_position = self[self.index]
@mustUpdateOptions = true
@mustUpdateDescription = true
elsif Input.repeat?(Input::RIGHT)
self[self.index] = @options[self.index].next(self[self.index])
dorefresh = true
@selected_position = self[self.index]
@mustUpdateOptions = true
@mustUpdateDescription = true
refresh if self[self.index]
return
end
if Input.repeat?(Input::RIGHT)
self[self.index] = @options[self.index].next(self[self.index])
@selected_position = self[self.index]
@mustUpdateOptions = true
@mustUpdateDescription = true
refresh
return
end
if Input.repeat?(Input::UP) || Input.repeat?(Input::DOWN)
@selected_position = self[self.index]
@mustUpdateOptions = true
@mustUpdateDescription = true
refresh
return
end
end
refresh if dorefresh
refresh if (self.index != oldindex)
end
end