RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Position Choice Window

0 Members and 1 Guest are viewing this topic.

*
Rep: +0/-0Level 39
RMRK Junior
Position Choice Window
Hello. I needed to move the choice list window around the screen. I could not find a script which would allow me to do that, so I made one.

Code
Spoiler for:
Code: [Select]
################################################################################
#                           Position Choice Window                             #
################################################################################
# For RPG Maker VXace                                                  1/29/2014
#                                                                      By Lament
#===============================================================================
# Full control over the choice list window position.
#===============================================================================
#UPDATES:
# 2/1/2014  - Setting an axis to nil gives its default position.
#           - Added codes for attaching to the text window.
#           - Added editable region for attaching choice window to the message
#             window using resized game windows via Yanfly's Core Engine.
#           - Mispelled strings no longer crash. The choice window will default.
#2/2/2014   - Fixed mistake which disallowed number coordinates.
#2/10/2014  - Cleaned up the comments and instructions. Added functionality over
#             the z axis. Changed resized resolution options so that they are
#             now available to everyone who has resized their Graphics. By
#             default choice list windows are now attached to the top left of
#             message windows instead of the screen, and choice list windows
#             are located above both message windows and scenes along z.
#
#INSTRUCTIONS:
#   
#   1. Paste the script under 'Materials' and above 'Main Process.'
#
#   2. Past the following into the event command 'script':
#
#       Lam_Choice_Window_Position.new(<X AXIS>, <Y AXIS>, <Z AXIS>)       
#
#   3. Replace the angled brackets and their contents with the desired location
#of the choice window's bottom left corner using any number which will be
#indexed to your RPG MAKER VXace resolution. By default, it is 544 x 416. For
#example (0, 0) will create the choice window in the bottom left corner.
#
#   * After pasting the code, all subsequent choice windows will spawn in that
#location until it is disabled, either by setting one of the AXIS values to nil,
#or by just leaving them out altogether.
#
#POSITION CODES:
#
#   Some positions, such as the exact middle of the screen, will change
#depending on the size of the choice window, so I have created case sensitive
#codes that can used for conveniently positioning the choice window. They are:
#              [x-axis]                   [y-axis]
#               "left"                     "top"
#              "middle"                   "middle"
#               "right"                   "bottom"
#            "left_window"              "top_window"
#            "right_window"            "bottom_window"
#   Just use any of the x-axis strings, quotes included(!), in place of <X_AXIS>
#and likewise for the y-axis. Z-axis by number only, default above scene base.
#===============================================================================
class Window_ChoiceList < Window_Command 
  alias lam_choice_reposition_update_placement         update_placement
  def update_placement()
    x_offset = (Graphics.width - 544) / 2 unless Graphics.width < 544
    x_offset = 0 if x_offset.nil?
    unless $lam_choice_x_axis == nil && $lam_choice_y_axis == nil && $lam_choice_y_axis == nil
      self.width  = [max_choice_width + 24, 96].max + padding  * 2
      self.width  = [width, Graphics.width].min
      self.height = fitting_height($game_message.choices.size)

#determine x-axis
      case $lam_choice_x_axis
      when "left"
            self.x = 0
      when "middle"
            self.x = (Graphics.width / 2) - (width / 2)
      when "right"
            self.x = Graphics.width - width
      when "left_window"
            self.x = x_offset     
      when "right_window"
            self.x = Graphics.width - x_offset
      else
        if $lam_choice_x_axis.is_a?(Float) || $lam_choice_x_axis.is_a?(Integer)
              self.x = $lam_choice_x_axis
        else
              self.x = Graphics.width - width - x_offset     
        end
      end
         
#determine y-axis
      case $lam_choice_y_axis
      when "top"
            self.y = 0
      when "middle"
            self.y = (Graphics.height / 2) - (height / 2)
      when "bottom"
            self.y = Graphics.height - height
      when "top_window"
            self.y = @message_window.y - height
      when "bottom_window"
            self.y =  @message_window.y + @message_window.height
      else  #determine to default or use coordinates for position.
        if $lam_choice_y_axis.is_a?(Float) || $lam_choice_y_axis.is_a?(Integer)
              self.y = Graphics.height - self.height - $lam_choice_y_axis
        else
           lam_choice_reposition_default_y
        end
      end
     
#determine z-axis
      if $lam_choice_z_axis.is_a?(Integer) || $lam_choice_z_axis.is_a?(Float)
        self.z = $lam_choice_z_axis
      else
        self.z = 210
      end
   
#none specified / default position
    else 
      lam_choice_reposition_update_placement
      self.x -= x_offset #default x position for new resolutions
      self.z  = 210      #choice windows now take priority over scenes
    end
  end
 
#method which determines default y-axis 
  def lam_choice_reposition_default_y
    if @message_window.y >= Graphics.height / 2
        self.y = @message_window.y - height
    else
        self.y = @message_window.y + @message_window.height
    end
  end
end
#===============================================================================
# Lam_Choice_Window_Position
#===============================================================================
class Lam_Choice_Window_Position
  def initialize(lam_choice_x_axis = nil, lam_choice_y_axis = nil, lam_choice_z_axis = nil)
    $lam_choice_x_axis = lam_choice_x_axis
    $lam_choice_y_axis = lam_choice_y_axis
    $lam_choice_x_axis = lam_choice_x_axis
  end
end
Images
Spoiler for:

edit 2.1.2014: Added a few codes. Also, added an option for YEA core users whom have changed the default resolution. When enabled, the choice window will align with the text window.
edit 2.3.2014: In game found a problem from last edit, fixed it and cleaned up a bit.
edit 2.10.2014 More changes. If anyone knows a way around using global variables, please suggest/implement.
« Last Edit: February 11, 2014, 01:39:44 AM by Lament »