Class: GamePlay::Menu

Inherits:
BaseCleanUpdate::FrameBalanced show all
Includes:
MenuMixin
Defined in:
scripts/01450 Systems/00100 Menu/00003 GamePlay/00100 Menu.rb

Overview

Main menu UI

Rewritten thanks to Jaizu demand

Constant Summary collapse

ACTION_LIST =

List of action according to the “image_index” to call

%i[open_dex open_party open_bag open_tcard open_option open_save open_quit]
ENTERING_ANIMATION_OFFSET =

Entering - leaving animation offset

150
ENTERING_ANIMATION_DURATION =

Entering - leaving animation duration

15

Constants inherited from BaseCleanUpdate

BaseCleanUpdate::AIU_KEY2METHOD

Constants inherited from Base

Base::DEFAULT_TRANSITION, Base::DEFAULT_TRANSITION_PARAMETER

Constants included from Input

Input::ALIAS_KEYS, Input::AXIS_MAPPING, Input::AXIS_SENSITIVITY, Input::DEAD_ZONE, Input::Keyboard, Input::Keys, Input::NON_TRIGGER_ZONE, Input::REPEAT_COOLDOWN, Input::REPEAT_SPACE

Constants included from DisplayMessage

DisplayMessage::MESSAGE_ERROR, DisplayMessage::MESSAGE_PROCESS_ERROR

Instance Attribute Summary

Attributes included from MenuMixin

#call_skill_process

Attributes inherited from Base

#__last_scene, #__result_process, #running, #viewport

Attributes included from DisplayMessage

#message_window

Instance Method Summary collapse

Methods included from MenuMixin

#execute_skill_process

Methods inherited from BaseCleanUpdate::FrameBalanced

#update

Methods included from Graphics::FPSBalancer::Marker

#frame_balanced?

Methods inherited from BaseCleanUpdate

#automatic_input_update, #update

Methods inherited from Base

#add_disposable, #call_scene, #dispose, #find_parent, #main, #return_to_scene, #snap_to_bitmap, #update, #visible

Methods included from Input

dir4, dir8, get_text, joy_axis_position, press?, register_events, released?, repeat?, swap_states, trigger?

Methods included from DisplayMessage

#can_display_message_be_called?, #close_message_window, #display_message, #display_message_and_wait, #message_class, #message_processing?, #message_visible, #message_visible=

Constructor Details

#initializeMenu

Create a new menu



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'scripts/01450 Systems/00100 Menu/00003 GamePlay/00100 Menu.rb', line 14

def initialize
  super
  init_conditions
  init_indexes
  @call_skill_process = nil
  @index = $game_temp.last_menu_index
  @index = 0 if @index >= @image_indexes.size
  @max_index = @image_indexes.size - 1
  @quiting = false # Flag allowing to really quit
  @entering = true # Flag telling we're entering
  @counter = 0 # Animation counter
  @in_save = false
  @mbf_type = @mef_type = :noen if $scene.is_a?(Scene_Map)
end

Instance Method Details

#create_graphics

Create all the graphics



30
31
32
33
34
35
# File 'scripts/01450 Systems/00100 Menu/00003 GamePlay/00100 Menu.rb', line 30

def create_graphics
  create_viewport
  create_background
  create_buttons
  init_entering
end

#main_end

End of the scene



38
39
40
41
# File 'scripts/01450 Systems/00100 Menu/00003 GamePlay/00100 Menu.rb', line 38

def main_end
  super
  $game_temp.last_menu_index = @index
end

#update_graphics

Update the graphics



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'scripts/01450 Systems/00100 Menu/00003 GamePlay/00100 Menu.rb', line 85

def update_graphics
  # Little trick to allow quitting animation ;)
  unless @running || @quiting
    @quiting = true
    @running = true
    @__last_scene.spriteset.visible = true if @__last_scene.is_a?(Scene_Map)
  end
  # Update each animation
  if @entering
    update_entering_animation
  elsif @quiting
    update_quitting_animation
  else
    @buttons.each(&:update)
  end
end

#update_inputsBoolean

Update the input interaction

Returns:

  • (Boolean)

    if no input was detected



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'scripts/01450 Systems/00100 Menu/00003 GamePlay/00100 Menu.rb', line 45

def update_inputs
  return false if @entering || @quiting
  if index_changed(:@index, :UP, :DOWN, @max_index)
    play_cursor_se
    update_buttons
  elsif Input.trigger?(:A)
    action
  elsif Input.trigger?(:B)
    @running = false
  else
    return true
  end
  return false
end

#update_mouse(moved) ⇒ Boolean

Update the mouse interaction

Parameters:

  • moved (Boolean)

    if the mouse moved

Returns:

  • (Boolean)


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'scripts/01450 Systems/00100 Menu/00003 GamePlay/00100 Menu.rb', line 63

def update_mouse(moved)
  @buttons.each_with_index do |button, index|
    next unless button.simple_mouse_in?
    if moved
      last_index = @index
      @index = index
      if last_index != index
        update_buttons
        play_cursor_se
      end
    elsif Mouse.trigger?(:LEFT)
      @index = index
      update_buttons
      play_decision_se
      action
    end
    return false
  end
  return true
end

#visible=(value)

Overload the visible= to allow save to keep the curren background

Parameters:

  • value (Boolean)


104
105
106
107
108
109
110
# File 'scripts/01450 Systems/00100 Menu/00003 GamePlay/00100 Menu.rb', line 104

def visible=(value)
  if @in_save
    @buttons.each { |button| button.visible = value }
  else
    super(value)
  end
end