Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
- # Icon Window Choice
- # Version 1.10
- # Author: LiTTleDRAgo
- #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
- #
- # Cara Pakainya
- # Ketik di script call
- #
- # IconChoice([ICON 1, ICON 2, dsb], cancel? , x, y)
- #
- # ARRAY = semua icon choice yg dipakai
- # cancel? = bisa dicancel atau ngga, default true, ga dipake juga gpp
- # kalau seandainya dicancel nanti value variablenya jadi 0
- # x, y = posisi dari window, ga dipake juga gpp
- #
- # Misal
- #
- # IconChoice([23,43,46], true, 100, 300)
- #
- # atau seperti ini pun jadi
- #
- # IconChoice([23,43,46])
- #
- # Nanti valuenya bakalan masuk ke variable yg disetting di bawah
- #
- #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
- module LiTTleDRAgo
- # ID dari variable yang akan dipakai sebagai pilihan
- ICON_CHOICE_VAR = 15
- end
- #==============================================================================
- # ** Game_Interpreter
- #------------------------------------------------------------------------------
- # An interpreter for executing event commands. This class is used within the
- # Game_Map, Game_Troop, and Game_Event classes.
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :message_waiting
- #--------------------------------------------------------------------------
- # * IconChoice
- #--------------------------------------------------------------------------
- def IconChoice(choices, cancel = true, x = nil, y = nil)
- return unless $scene.is_a?(Scene_Map)
- $game_map.interpreter.message_waiting = true
- $game_message.choice_cancel_type = cancel
- w = [Graphics.width,Graphics.height,(choices.size+1)*(24+7)]
- $scene.iconchoice_window = Window_IconCommand.new(w[2], choices)
- $scene.iconchoice_window.x = x ? x : (w[0]-$scene.iconchoice_window.width)/2
- $scene.iconchoice_window.y = y ? y : (w[1]-$scene.iconchoice_window.height)/2
- end
- end
- #==============================================================================
- # ** Window_IconCommand
- #------------------------------------------------------------------------------
- # This window deals with general command choices.
- #==============================================================================
- class Window_IconCommand < Window_Selectable
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :commands # command
- #--------------------------------------------------------------------------
- # * Object Initialization
- # width : window width
- # commands : command string array
- # column_max : digit count (if 2 or more, horizontal selection)
- # row_max : row count (0: match command count)
- # spacing : blank space when items are arrange horizontally
- #--------------------------------------------------------------------------
- def initialize(width, commands, column_max = 1, row_max = 0, spacing = 4)
- column_max,row_max = commands.size, 1
- super(0, 0, width, row_max * WLH + 32, spacing)
- @commands, @item_max, @column_max = commands, commands.size, column_max
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- (0...@item_max).each {|index|
- rect = item_rect(index)
- rect.x,rect.width = rect.x + 4, rect.width - 8
- self.contents.clear_rect(rect)
- draw_icon(@commands[index], (24+7)*index, rect.y)}
- end
- end
- #==============================================================================
- # ** Scene_Map
- #------------------------------------------------------------------------------
- # This class performs the map screen processing.
- #==============================================================================
- class Scene_Map
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :iconchoice_window
- #--------------------------------------------------------------------------
- # * Alias Listing
- #--------------------------------------------------------------------------
- alias drg126_main main
- alias drg126_upd update
- def main
- drg126_main
- @iconchoice_window.dispose if @iconchoice_window
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- if @iconchoice_window && @iconchoice_window.active
- @iconchoice_window.update
- if Input.trigger?(Input::B)
- return Sound.play_buzzer unless $game_message.choice_cancel_type
- Sound.play_cancel
- $game_variables[LiTTleDRAgo::ICON_CHOICE_VAR] = 0
- icon_terminate = true
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- $game_variables[LiTTleDRAgo::ICON_CHOICE_VAR] = @iconchoice_window.index+1
- icon_terminate = true
- end
- if icon_terminate
- $game_map.interpreter.message_waiting = false
- @iconchoice_window.dispose
- @iconchoice_window = nil
- end
- end
- drg126_upd
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement