From 17a2d9b97a154587d8b46b562eec881b4f0aa0ea Mon Sep 17 00:00:00 2001 From: infinitefusion Date: Sun, 16 Jul 2023 09:31:00 -0400 Subject: [PATCH] Makes it possible to jump up and down 1 colomn lists with the left and right arrows --- .../005_SpriteWindow_text.rb | 138 +++++++++++------- 1 file changed, 82 insertions(+), 56 deletions(-) diff --git a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb index 2b6737227..e0262910a 100644 --- a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb +++ b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb @@ -848,63 +848,89 @@ class SpriteWindow_Selectable < SpriteWindow_Base super if self.active && @item_max > 0 && @index >= 0 && !@ignore_input if Input.repeat?(Input::UP) - if @index >= @column_max || - (Input.trigger?(Input::UP) && (@item_max % @column_max)==0) - oldindex = @index - @index = (@index - @column_max + @item_max) % @item_max - if @index!=oldindex - pbPlayCursorSE() - update_cursor_rect - end - end + scroll_up() elsif Input.repeat?(Input::DOWN) - if @index < @item_max - @column_max || - (Input.trigger?(Input::DOWN) && (@item_max % @column_max)==0) - oldindex = @index - @index = (@index + @column_max) % @item_max - if @index!=oldindex - pbPlayCursorSE() - update_cursor_rect - end - end - elsif Input.repeat?(Input::LEFT) - if @column_max >= 2 && @index > 0 - oldindex = @index - @index -= 1 - if @index!=oldindex - pbPlayCursorSE() - update_cursor_rect - end - end - elsif Input.repeat?(Input::RIGHT) - if @column_max >= 2 && @index < @item_max - 1 - oldindex = @index - @index += 1 - if @index!=oldindex - pbPlayCursorSE() - update_cursor_rect - end - end - elsif Input.repeat?(Input::JUMPUP) - if @index > 0 - oldindex = @index - @index = [self.index-self.page_item_max, 0].max - if @index!=oldindex - pbPlayCursorSE() - self.top_row -= self.page_row_max - update_cursor_rect - end - end - elsif Input.repeat?(Input::JUMPDOWN) - if @index < @item_max-1 - oldindex = @index - @index = [self.index+self.page_item_max, @item_max-1].min - if @index!=oldindex - pbPlayCursorSE() - self.top_row += self.page_row_max - update_cursor_rect - end - end + scroll_down() + elsif Input.repeat?(Input::LEFT) && @column_max > 1 + scroll_left() + elsif Input.repeat?(Input::RIGHT) && @column_max > 1 + scroll_right() + elsif Input.repeat?(Input::JUMPUP) || Input.repeat?(Input::LEFT) + jump_up() + elsif Input.repeat?(Input::JUMPDOWN) || Input.repeat?(Input::RIGHT) + jump_down() + end + end + end + + def scroll_up() + if @index >= @column_max || + (Input.trigger?(Input::UP) && (@item_max % @column_max)==0) + oldindex = @index + @index = (@index - @column_max + @item_max) % @item_max + if @index!=oldindex + pbPlayCursorSE() + update_cursor_rect + end + end + end + + def scroll_down() + if @index < @item_max - @column_max || + (Input.trigger?(Input::DOWN) && (@item_max % @column_max)==0) + oldindex = @index + @index = (@index + @column_max) % @item_max + if @index!=oldindex + pbPlayCursorSE() + update_cursor_rect + end + end + end + + def scroll_left() + if @column_max >= 2 && @index < @item_max - 1 + oldindex = @index + @index += 1 + if @index!=oldindex + pbPlayCursorSE() + update_cursor_rect + end + end + end + + def scroll_right() + if @column_max >= 2 && @index > 0 + oldindex = @index + @index -= 1 + if @index!=oldindex + pbPlayCursorSE() + update_cursor_rect + end + end + end + + + def jump_up() + if @index > 0 + oldindex = @index + @index = [self.index-self.page_item_max, 0].max + if @index!=oldindex + pbPlayCursorSE() + self.top_row -= self.page_row_max + update_cursor_rect + end + end + end + + + def jump_down() + if @index < @item_max-1 + oldindex = @index + @index = [self.index+self.page_item_max, @item_max-1].min + if @index!=oldindex + pbPlayCursorSE() + self.top_row += self.page_row_max + update_cursor_rect end end end