Author Topic: Warped Movement for Window Selectable  (Read 2086 times)

Offline Zeriab

  • Ethereal Devastator
  • ****
  • Posts: 350
  • LV: 65
  • Mighty Scripter
    • View Profile
    • Zeriab's Junk
Warped Movement for Window Selectable
« on: January 08, 2008, 01:47:08 PM »
Hey all
I was a bit bored and fiddled around with the movement of Window_Items. I found the way I represent here better. I decided to make it broader and have created a solution intended for subclasses of Window_Selectable
I will provide two versions. One if you want to only apply this on certain windows and not others. Another that just changes the functionality of Window_Selectable.

Here is the mix-in version for changing specific classes:
Code: [Select]
#==============================================================================
# ** Warped Movement mix-in for subclasses of Window Selectable
#------------------------------------------------------------------------------
# Zeriab
# Version 1.0
# 2007-08-22 (Year-Month-Day)
#------------------------------------------------------------------------------
# * Description :
#
#   This is a mix-in module for windows subclassing designed to 'enhance' the
#   arrow-key movement system used to select the item by creating warping.
#   That is, if you are at the bottom and press down you will go up to the top
#   in the next column. Like-wise for down, left and right.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place the script anywhere above Main.
#   To give a subclass of Window_Selectable let it include the module
#
#   If you for example wanted to apply the module to Window_Item you should
#   write this code: (Must be below the original Window_Item
# ------------------------------------------
#   class Window_Item < Window_Selectable
#     include Window_Selectable_Type_2
#   end
# ------------------------------------------
#
#   Here is a version for Window_Skill. You get the idea.
# ------------------------------------------
#   class Window_Skill < Window_Selectable
#     include Window_Selectable_Type_2
#   end
# ------------------------------------------
#
#   Note: Don't include this module in Window_Selectable ~
#         May cause issues with Windows where the update method is used
#==============================================================================

#==============================================================================
# ** module Window_Selectable_Warped
#==============================================================================
module Window_Selectable_Warped
  #----------------------------------------------------------------------------
  # * Frame Update
  #----------------------------------------------------------------------------
  def update
    last_index = @index
    super
    if last_index == @index && active && @item_max > 1
      if Input.repeat?(Input::DOWN)
        # Move cursor down
        $game_system.se_play($data_system.cursor_se)
        @index = (@index % @column_max + 1) % @column_max
      end
      # If the up directional button was pressed
      if Input.repeat?(Input::UP)
        # Move cursor up
        $game_system.se_play($data_system.cursor_se)
      @index = (@index % @column_max + 1)
      @index = -@index % @item_max + @item_max % @column_max
      @index -= @column_max  if @index >= @item_max
      end
      # If the right directional button was pressed
      if Input.repeat?(Input::RIGHT)
        # Move cursor right
        $game_system.se_play($data_system.cursor_se)
        @index = (@index + 1) % @item_max
      end
      # If the left directional button was pressed
      if Input.repeat?(Input::LEFT)
        # Move cursor left
        $game_system.se_play($data_system.cursor_se)
        @index = (@index - 1) % @item_max
      end
    end
  end
end

Next we have the change for all Window_Selectable subclasses. This also requires less work.
Code: [Select]
#==============================================================================
# ** Warped Movement for Window Selectable
#------------------------------------------------------------------------------
# Zeriab
# Version 1.0
# 2007-08-22 (Year-Month-Day)
#------------------------------------------------------------------------------
# * Description :
#
#   This script is designed to 'enhance' the arrow-key movement system of
#   Window_Selectable used to select the item by allowing warping.
#   That is, if you are at the bottom and press down you will go up to the top
#   in the next column. Like-wise for down, left and right.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place the script below Window_Selectable and above Main.
#
#   Note: May cause issue with scripts that are depent on the index not
#         changing under certain circumstances
#==============================================================================

#==============================================================================
# ** Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
  alias zeriab_warped_update update
  #----------------------------------------------------------------------------
  # * Frame Update
  #----------------------------------------------------------------------------
  def update
    last_index = @index
    # original update method is called
    zeriab_warped_update
    if last_index == @index && active && @item_max > 1
      if Input.repeat?(Input::DOWN)
        # Move cursor down
        $game_system.se_play($data_system.cursor_se)
        @index = (@index % @column_max + 1) % @column_max
      end
      # If the up directional button was pressed
      if Input.repeat?(Input::UP)
        # Move cursor up
        $game_system.se_play($data_system.cursor_se)
      @index = (@index % @column_max + 1)
      @index = -@index % @item_max + @item_max % @column_max
      @index -= @column_max  if @index >= @item_max
      end
      # If the right directional button was pressed
      if Input.repeat?(Input::RIGHT)
        # Move cursor right
        $game_system.se_play($data_system.cursor_se)
        @index = (@index + 1) % @item_max
      end
      # If the left directional button was pressed
      if Input.repeat?(Input::LEFT)
        # Move cursor left
        $game_system.se_play($data_system.cursor_se)
        @index = (@index - 1) % @item_max
      end
    end
  end
end
Instructions are in the script headers. Enjoy ~

 - Zeriab
« Last Edit: December 05, 2010, 12:21:26 PM by Blizzard »

Offline Fantasist

  • Lexima Warrior
  • *******
  • Posts: 2223
  • LV: 146
  • Gender: Male
    • View Profile
    • Blog
Re: Warped Movement for Window Selectable
« Reply #1 on: January 08, 2008, 04:07:21 PM »
Ideal mod, I hate the way it stops when it reachec the end/beginning.
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)

The best of freeware reviews: Gizmo's Freeware Reviews



Offline Zeriab

  • Ethereal Devastator
  • ****
  • Posts: 350
  • LV: 65
  • Mighty Scripter
    • View Profile
    • Zeriab's Junk
Re: Warped Movement for Window Selectable
« Reply #2 on: January 11, 2008, 02:50:51 AM »
It hate it as well. Exactly why I wrote this mod ^^