From e6b17bf99085e85d2b4cd4038ea5a3d0200d2103 Mon Sep 17 00:00:00 2001 From: Leischii Date: Sun, 30 Mar 2025 17:05:30 +0200 Subject: [PATCH] add: initial options update and up/down update trigger --- Data/Scripts/016_UI/015_UI_Options.rb | 44 ++++++++++++++++++++------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/Data/Scripts/016_UI/015_UI_Options.rb b/Data/Scripts/016_UI/015_UI_Options.rb index 2bc71202c..a9f5b2c89 100644 --- a/Data/Scripts/016_UI/015_UI_Options.rb +++ b/Data/Scripts/016_UI/015_UI_Options.rb @@ -129,13 +129,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 @@ -212,6 +213,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 @@ -319,23 +321,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