Class: GamePlay::Language_Choice

Inherits:
BaseCleanUpdate::FrameBalanced show all
Defined in:
scripts/01450 Systems/00106 Save Load/00003 GamePlay/00300 Language_Choice.rb

Overview

Scene responsive of displaying the language choice when creating a new game

Constant Summary collapse

ANIME_CHANGE =

If the change of index is animated

true
ANIME_FRAMES =

Number of frame for index change

6

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 inherited from Base

#__last_scene, #__result_process, #running, #viewport

Attributes included from DisplayMessage

#message_window

Instance Method Summary collapse

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, #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

#initializeLanguage_Choice

Initialize the scene



10
11
12
13
14
15
16
# File 'scripts/01450 Systems/00106 Save Load/00003 GamePlay/00300 Language_Choice.rb', line 10

def initialize
  super()
  @running = true
  @lang_list = Configs.language.choosable_language_code
  @index = @lang_list.find_index(Configs.language.default_language_code)
  @counter = 0
end

Instance Method Details

#create_graphics

Create the graphics



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'scripts/01450 Systems/00106 Save Load/00003 GamePlay/00300 Language_Choice.rb', line 19

def create_graphics
  create_viewport
  @stack = UI::SpriteStack.new(@viewport)
  @frame = @stack.add_sprite(0, 0, 'language/frame')

  @flag_left = @stack.add_sprite(-76, 85, nil)
  @flag_left.opacity = 192

  @flag_center = @stack.add_sprite(91, 81, nil)
  @flag_center.opacity = 255

  @flag_right = @stack.add_sprite(258, 85, nil)
  @flag_right.opacity = 192
  @flag_right.zoom = @flag_left.zoom = 0.9

  # @type [SpriteSheet]
  @cursor = @stack.add_sprite(91 - 4, 81 - 4, 'language/cursors', 1, 2, type: SpriteSheet)

  @base_ui = UI::GenericBase.new(@viewport, hide_background_and_button: true)

  update_index
end

#update_graphics

Update the graphics



43
44
45
46
47
48
49
50
51
52
53
# File 'scripts/01450 Systems/00106 Save Load/00003 GamePlay/00300 Language_Choice.rb', line 43

def update_graphics
  @base_ui.update_background_animation
  @counter += 1
  if @counter >= 60
    @counter = 0
  elsif @counter >= 30
    @cursor.sy = 0
  else
    @cursor.sy = 1
  end
end

#update_inputs

Update the inputs



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'scripts/01450 Systems/00106 Save Load/00003 GamePlay/00300 Language_Choice.rb', line 56

def update_inputs
  if Input.repeat?(:LEFT)
    @index = @index != 0 ? @index - 1 : @lang_list.size - 1
    move(false) if ANIME_CHANGE
    update_index
  elsif Input.repeat?(:RIGHT)
    @index = @index != @lang_list.size - 1 ? @index + 1 : 0
    move(true) if ANIME_CHANGE
    update_index
  end

  if Input.trigger?(:A)
    @running = false
    Configs.language.default_language_code = @lang_list[@index]
  end
end