Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Scene_Map < Scene_Base
- # Switch for opening/closing the gold window
- VARIABLE_DISPLAY_SWITCH = 15
- VARIABLE_ID = 42
- VARIABLE_ICON_INDEX = 20
- VARIABLE_X = 424
- VARIABLE_Y = 48
- VARIABLE_WIDTH = 120
- VARIABLE_HEIGHT = 48
- VARIABLE_ICON_OFFSET = 48
- VARIABLE_TEXT_OFFSET = 50
- ##
- # Aliases
- #
- alias_method :zeriab_variable_create_all_windows, :create_all_windows
- def create_all_windows
- zeriab_variable_create_all_windows
- create_variable_display
- end
- alias_method :zeriab_variable_update_scene, :update_scene
- def update_scene
- zeriab_variable_update_scene
- update_variable_display
- end
- ##
- # Creation
- #
- def create_variable_display
- @variable_display = Window_VariableDisplay.new(
- VARIABLE_ID,
- VARIABLE_ICON_INDEX,
- VARIABLE_X,
- VARIABLE_Y,
- VARIABLE_WIDTH,
- VARIABLE_HEIGHT)
- @variable_display.icon_offset = VARIABLE_ICON_OFFSET
- @variable_display.text_offset = VARIABLE_TEXT_OFFSET
- @variable_display.openness = 0
- @show_variable_display = $game_switches[VARIABLE_DISPLAY_SWITCH]
- @variable_display.open if @show_variable_display
- end
- ##
- # Update open state
- #
- def update_variable_display
- if @show_variable_display != $game_switches[VARIABLE_DISPLAY_SWITCH]
- @show_variable_display = $game_switches[VARIABLE_DISPLAY_SWITCH]
- if @show_variable_display
- @variable_display.open
- else
- @variable_display.close
- end
- @variable_display.update
- end
- end
- end
- ##
- # Variable display with icon
- #
- class Window_VariableDisplay < Window_Base
- attr_reader :variable_id
- attr_reader :icon_index
- attr_accessor :icon_offset
- attr_accessor :text_offset
- def value; $game_variables[@variable_id]; end
- ##
- # Init
- #
- def initialize(variable_id, icon_index, x, y, width, height)
- #super(0, 0, window_width, fitting_height(1))
- super(x, y, width, height)
- @variable_id = variable_id
- @icon_index = icon_index
- self.icon_offset = 48
- self.text_offset = 50
- refresh
- end
- ##
- # Refresh
- #
- def refresh
- contents.clear
- draw_icon(icon_index, width - icon_offset, 0)
- draw_text(0, 0, width - text_offset, line_height, value, 2)
- end
- ##
- # Update
- #
- def update
- super
- @old_value ||= value
- if @old_value != value
- @old_value = value
- refresh
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement