rgss3_default_scripts 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +9 -0
- data/Rakefile +2 -0
- data/lib/rgss3_default_scripts.rb +109 -0
- data/lib/rgss3_default_scripts/BattleManager.rb +392 -0
- data/lib/rgss3_default_scripts/Cache.rb +134 -0
- data/lib/rgss3_default_scripts/DataManager.rb +267 -0
- data/lib/rgss3_default_scripts/Game_Action.rb +262 -0
- data/lib/rgss3_default_scripts/Game_ActionResult.rb +159 -0
- data/lib/rgss3_default_scripts/Game_Actor.rb +696 -0
- data/lib/rgss3_default_scripts/Game_Actors.rb +22 -0
- data/lib/rgss3_default_scripts/Game_BaseItem.rb +51 -0
- data/lib/rgss3_default_scripts/Game_Battler.rb +824 -0
- data/lib/rgss3_default_scripts/Game_BattlerBase.rb +731 -0
- data/lib/rgss3_default_scripts/Game_Character.rb +396 -0
- data/lib/rgss3_default_scripts/Game_CharacterBase.rb +443 -0
- data/lib/rgss3_default_scripts/Game_CommonEvent.rb +41 -0
- data/lib/rgss3_default_scripts/Game_Enemy.rb +264 -0
- data/lib/rgss3_default_scripts/Game_Event.rb +308 -0
- data/lib/rgss3_default_scripts/Game_Follower.rb +74 -0
- data/lib/rgss3_default_scripts/Game_Followers.rb +112 -0
- data/lib/rgss3_default_scripts/Game_Interpreter.rb +1413 -0
- data/lib/rgss3_default_scripts/Game_Map.rb +704 -0
- data/lib/rgss3_default_scripts/Game_Message.rb +101 -0
- data/lib/rgss3_default_scripts/Game_Party.rb +418 -0
- data/lib/rgss3_default_scripts/Game_Picture.rb +161 -0
- data/lib/rgss3_default_scripts/Game_Pictures.rb +28 -0
- data/lib/rgss3_default_scripts/Game_Player.rb +488 -0
- data/lib/rgss3_default_scripts/Game_Screen.rb +234 -0
- data/lib/rgss3_default_scripts/Game_SelfSwitches.rb +35 -0
- data/lib/rgss3_default_scripts/Game_Switches.rb +35 -0
- data/lib/rgss3_default_scripts/Game_System.rb +122 -0
- data/lib/rgss3_default_scripts/Game_Temp.rb +45 -0
- data/lib/rgss3_default_scripts/Game_Timer.rb +56 -0
- data/lib/rgss3_default_scripts/Game_Troop.rb +205 -0
- data/lib/rgss3_default_scripts/Game_Unit.rb +131 -0
- data/lib/rgss3_default_scripts/Game_Variables.rb +34 -0
- data/lib/rgss3_default_scripts/Game_Vehicle.rb +193 -0
- data/lib/rgss3_default_scripts/SceneManager.rb +94 -0
- data/lib/rgss3_default_scripts/Scene_Base.rb +132 -0
- data/lib/rgss3_default_scripts/Scene_Battle.rb +693 -0
- data/lib/rgss3_default_scripts/Scene_Debug.rb +87 -0
- data/lib/rgss3_default_scripts/Scene_End.rb +61 -0
- data/lib/rgss3_default_scripts/Scene_Equip.rb +144 -0
- data/lib/rgss3_default_scripts/Scene_File.rb +203 -0
- data/lib/rgss3_default_scripts/Scene_Gameover.rb +85 -0
- data/lib/rgss3_default_scripts/Scene_Item.rb +75 -0
- data/lib/rgss3_default_scripts/Scene_ItemBase.rb +147 -0
- data/lib/rgss3_default_scripts/Scene_Load.rb +40 -0
- data/lib/rgss3_default_scripts/Scene_Map.rb +276 -0
- data/lib/rgss3_default_scripts/Scene_Menu.rb +127 -0
- data/lib/rgss3_default_scripts/Scene_MenuBase.rb +63 -0
- data/lib/rgss3_default_scripts/Scene_Name.rb +32 -0
- data/lib/rgss3_default_scripts/Scene_Save.rb +38 -0
- data/lib/rgss3_default_scripts/Scene_Shop.rb +299 -0
- data/lib/rgss3_default_scripts/Scene_Skill.rb +108 -0
- data/lib/rgss3_default_scripts/Scene_Status.rb +25 -0
- data/lib/rgss3_default_scripts/Scene_Title.rb +137 -0
- data/lib/rgss3_default_scripts/Sound.rb +135 -0
- data/lib/rgss3_default_scripts/Sprite_Base.rb +232 -0
- data/lib/rgss3_default_scripts/Sprite_Battler.rb +231 -0
- data/lib/rgss3_default_scripts/Sprite_Character.rb +226 -0
- data/lib/rgss3_default_scripts/Sprite_Picture.rb +82 -0
- data/lib/rgss3_default_scripts/Sprite_Timer.rb +77 -0
- data/lib/rgss3_default_scripts/Spriteset_Battle.rb +389 -0
- data/lib/rgss3_default_scripts/Spriteset_Map.rb +273 -0
- data/lib/rgss3_default_scripts/Spriteset_Weather.rb +184 -0
- data/lib/rgss3_default_scripts/Vocab.rb +145 -0
- data/lib/rgss3_default_scripts/Window_ActorCommand.rb +78 -0
- data/lib/rgss3_default_scripts/Window_Base.rb +571 -0
- data/lib/rgss3_default_scripts/Window_BattleActor.rb +38 -0
- data/lib/rgss3_default_scripts/Window_BattleEnemy.rb +70 -0
- data/lib/rgss3_default_scripts/Window_BattleItem.rb +40 -0
- data/lib/rgss3_default_scripts/Window_BattleLog.rb +425 -0
- data/lib/rgss3_default_scripts/Window_BattleSkill.rb +34 -0
- data/lib/rgss3_default_scripts/Window_BattleStatus.rb +111 -0
- data/lib/rgss3_default_scripts/Window_ChoiceList.rb +88 -0
- data/lib/rgss3_default_scripts/Window_Command.rb +152 -0
- data/lib/rgss3_default_scripts/Window_DebugLeft.rb +104 -0
- data/lib/rgss3_default_scripts/Window_DebugRight.rb +119 -0
- data/lib/rgss3_default_scripts/Window_EquipCommand.rb +36 -0
- data/lib/rgss3_default_scripts/Window_EquipItem.rb +78 -0
- data/lib/rgss3_default_scripts/Window_EquipSlot.rb +111 -0
- data/lib/rgss3_default_scripts/Window_EquipStatus.rb +97 -0
- data/lib/rgss3_default_scripts/Window_GameEnd.rb +38 -0
- data/lib/rgss3_default_scripts/Window_Gold.rb +47 -0
- data/lib/rgss3_default_scripts/Window_Help.rb +43 -0
- data/lib/rgss3_default_scripts/Window_HorzCommand.rb +106 -0
- data/lib/rgss3_default_scripts/Window_ItemCategory.rb +54 -0
- data/lib/rgss3_default_scripts/Window_ItemList.rb +117 -0
- data/lib/rgss3_default_scripts/Window_KeyItem.rb +55 -0
- data/lib/rgss3_default_scripts/Window_MapName.rb +96 -0
- data/lib/rgss3_default_scripts/Window_MenuActor.rb +43 -0
- data/lib/rgss3_default_scripts/Window_MenuCommand.rb +106 -0
- data/lib/rgss3_default_scripts/Window_MenuStatus.rb +85 -0
- data/lib/rgss3_default_scripts/Window_Message.rb +397 -0
- data/lib/rgss3_default_scripts/Window_NameEdit.rb +129 -0
- data/lib/rgss3_default_scripts/Window_NameInput.rb +253 -0
- data/lib/rgss3_default_scripts/Window_NumberInput.rb +148 -0
- data/lib/rgss3_default_scripts/Window_PartyCommand.rb +47 -0
- data/lib/rgss3_default_scripts/Window_SaveFile.rb +69 -0
- data/lib/rgss3_default_scripts/Window_ScrollText.rb +90 -0
- data/lib/rgss3_default_scripts/Window_Selectable.rb +442 -0
- data/lib/rgss3_default_scripts/Window_ShopBuy.rb +115 -0
- data/lib/rgss3_default_scripts/Window_ShopCommand.rb +36 -0
- data/lib/rgss3_default_scripts/Window_ShopNumber.rb +137 -0
- data/lib/rgss3_default_scripts/Window_ShopSell.rb +27 -0
- data/lib/rgss3_default_scripts/Window_ShopStatus.rb +124 -0
- data/lib/rgss3_default_scripts/Window_SkillCommand.rb +76 -0
- data/lib/rgss3_default_scripts/Window_SkillList.rb +121 -0
- data/lib/rgss3_default_scripts/Window_SkillStatus.rb +38 -0
- data/lib/rgss3_default_scripts/Window_Status.rb +125 -0
- data/lib/rgss3_default_scripts/Window_TitleCommand.rb +45 -0
- data/rgss3_default_scripts.gemspec +23 -0
- metadata +186 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#==============================================================================
|
|
2
|
+
# ** Window_PartyCommand
|
|
3
|
+
#------------------------------------------------------------------------------
|
|
4
|
+
# This window is used to select whether to fight or escape on the battle
|
|
5
|
+
# screen.
|
|
6
|
+
#==============================================================================
|
|
7
|
+
|
|
8
|
+
class Window_PartyCommand < Window_Command
|
|
9
|
+
#--------------------------------------------------------------------------
|
|
10
|
+
# * Object Initialization
|
|
11
|
+
#--------------------------------------------------------------------------
|
|
12
|
+
def initialize
|
|
13
|
+
super(0, 0)
|
|
14
|
+
self.openness = 0
|
|
15
|
+
deactivate
|
|
16
|
+
end
|
|
17
|
+
#--------------------------------------------------------------------------
|
|
18
|
+
# * Get Window Width
|
|
19
|
+
#--------------------------------------------------------------------------
|
|
20
|
+
def window_width
|
|
21
|
+
return 128
|
|
22
|
+
end
|
|
23
|
+
#--------------------------------------------------------------------------
|
|
24
|
+
# * Get Number of Lines to Show
|
|
25
|
+
#--------------------------------------------------------------------------
|
|
26
|
+
def visible_line_number
|
|
27
|
+
return 4
|
|
28
|
+
end
|
|
29
|
+
#--------------------------------------------------------------------------
|
|
30
|
+
# * Create Command List
|
|
31
|
+
#--------------------------------------------------------------------------
|
|
32
|
+
def make_command_list
|
|
33
|
+
add_command(Vocab::fight, :fight)
|
|
34
|
+
add_command(Vocab::escape, :escape, BattleManager.can_escape?)
|
|
35
|
+
end
|
|
36
|
+
#--------------------------------------------------------------------------
|
|
37
|
+
# * Setup
|
|
38
|
+
#--------------------------------------------------------------------------
|
|
39
|
+
def setup
|
|
40
|
+
clear_command_list
|
|
41
|
+
make_command_list
|
|
42
|
+
refresh
|
|
43
|
+
select(0)
|
|
44
|
+
activate
|
|
45
|
+
open
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#==============================================================================
|
|
2
|
+
# ** Window_SaveFile
|
|
3
|
+
#------------------------------------------------------------------------------
|
|
4
|
+
# This window displays save files on the save and load screens.
|
|
5
|
+
#==============================================================================
|
|
6
|
+
|
|
7
|
+
class Window_SaveFile < Window_Base
|
|
8
|
+
#--------------------------------------------------------------------------
|
|
9
|
+
# * Public Instance Variables
|
|
10
|
+
#--------------------------------------------------------------------------
|
|
11
|
+
attr_reader :selected # selected
|
|
12
|
+
#--------------------------------------------------------------------------
|
|
13
|
+
# * Object Initialization
|
|
14
|
+
# index : index of save files
|
|
15
|
+
#--------------------------------------------------------------------------
|
|
16
|
+
def initialize(height, index)
|
|
17
|
+
super(0, index * height, Graphics.width, height)
|
|
18
|
+
@file_index = index
|
|
19
|
+
refresh
|
|
20
|
+
@selected = false
|
|
21
|
+
end
|
|
22
|
+
#--------------------------------------------------------------------------
|
|
23
|
+
# * Refresh
|
|
24
|
+
#--------------------------------------------------------------------------
|
|
25
|
+
def refresh
|
|
26
|
+
contents.clear
|
|
27
|
+
change_color(normal_color)
|
|
28
|
+
name = Vocab::File + " #{@file_index + 1}"
|
|
29
|
+
draw_text(4, 0, 200, line_height, name)
|
|
30
|
+
@name_width = text_size(name).width
|
|
31
|
+
draw_party_characters(152, 58)
|
|
32
|
+
draw_playtime(0, contents.height - line_height, contents.width - 4, 2)
|
|
33
|
+
end
|
|
34
|
+
#--------------------------------------------------------------------------
|
|
35
|
+
# * Draw Party Characters
|
|
36
|
+
#--------------------------------------------------------------------------
|
|
37
|
+
def draw_party_characters(x, y)
|
|
38
|
+
header = DataManager.load_header(@file_index)
|
|
39
|
+
return unless header
|
|
40
|
+
header[:characters].each_with_index do |data, i|
|
|
41
|
+
draw_character(data[0], data[1], x + i * 48, y)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
#--------------------------------------------------------------------------
|
|
45
|
+
# * Draw Play Time
|
|
46
|
+
#--------------------------------------------------------------------------
|
|
47
|
+
def draw_playtime(x, y, width, align)
|
|
48
|
+
header = DataManager.load_header(@file_index)
|
|
49
|
+
return unless header
|
|
50
|
+
draw_text(x, y, width, line_height, header[:playtime_s], 2)
|
|
51
|
+
end
|
|
52
|
+
#--------------------------------------------------------------------------
|
|
53
|
+
# * Set Selected
|
|
54
|
+
#--------------------------------------------------------------------------
|
|
55
|
+
def selected=(selected)
|
|
56
|
+
@selected = selected
|
|
57
|
+
update_cursor
|
|
58
|
+
end
|
|
59
|
+
#--------------------------------------------------------------------------
|
|
60
|
+
# * Update Cursor
|
|
61
|
+
#--------------------------------------------------------------------------
|
|
62
|
+
def update_cursor
|
|
63
|
+
if @selected
|
|
64
|
+
cursor_rect.set(0, 0, @name_width + 8, line_height)
|
|
65
|
+
else
|
|
66
|
+
cursor_rect.empty
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#==============================================================================
|
|
2
|
+
# ** Window_ScrollText
|
|
3
|
+
#------------------------------------------------------------------------------
|
|
4
|
+
# This window is for displaying scrolling text. No frame is displayed, but it
|
|
5
|
+
# is handled as a window for convenience.
|
|
6
|
+
#==============================================================================
|
|
7
|
+
|
|
8
|
+
class Window_ScrollText < Window_Base
|
|
9
|
+
#--------------------------------------------------------------------------
|
|
10
|
+
# * Object Initialization
|
|
11
|
+
#--------------------------------------------------------------------------
|
|
12
|
+
def initialize
|
|
13
|
+
super(0, 0, Graphics.width, Graphics.height)
|
|
14
|
+
self.opacity = 0
|
|
15
|
+
self.arrows_visible = false
|
|
16
|
+
hide
|
|
17
|
+
end
|
|
18
|
+
#--------------------------------------------------------------------------
|
|
19
|
+
# * Frame Update
|
|
20
|
+
#--------------------------------------------------------------------------
|
|
21
|
+
def update
|
|
22
|
+
super
|
|
23
|
+
if $game_message.scroll_mode
|
|
24
|
+
update_message if @text
|
|
25
|
+
start_message if !@text && $game_message.has_text?
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
#--------------------------------------------------------------------------
|
|
29
|
+
# * Start Message
|
|
30
|
+
#--------------------------------------------------------------------------
|
|
31
|
+
def start_message
|
|
32
|
+
@text = $game_message.all_text
|
|
33
|
+
refresh
|
|
34
|
+
show
|
|
35
|
+
end
|
|
36
|
+
#--------------------------------------------------------------------------
|
|
37
|
+
# * Refresh
|
|
38
|
+
#--------------------------------------------------------------------------
|
|
39
|
+
def refresh
|
|
40
|
+
reset_font_settings
|
|
41
|
+
update_all_text_height
|
|
42
|
+
create_contents
|
|
43
|
+
draw_text_ex(4, 0, @text)
|
|
44
|
+
self.oy = @scroll_pos = -height
|
|
45
|
+
end
|
|
46
|
+
#--------------------------------------------------------------------------
|
|
47
|
+
# * Update Height Needed to Draw All Text
|
|
48
|
+
#--------------------------------------------------------------------------
|
|
49
|
+
def update_all_text_height
|
|
50
|
+
@all_text_height = 1
|
|
51
|
+
convert_escape_characters(@text).each_line do |line|
|
|
52
|
+
@all_text_height += calc_line_height(line, false)
|
|
53
|
+
end
|
|
54
|
+
reset_font_settings
|
|
55
|
+
end
|
|
56
|
+
#--------------------------------------------------------------------------
|
|
57
|
+
# * Calculate Height of Window Contents
|
|
58
|
+
#--------------------------------------------------------------------------
|
|
59
|
+
def contents_height
|
|
60
|
+
@all_text_height ? @all_text_height : super
|
|
61
|
+
end
|
|
62
|
+
#--------------------------------------------------------------------------
|
|
63
|
+
# * Update Message
|
|
64
|
+
#--------------------------------------------------------------------------
|
|
65
|
+
def update_message
|
|
66
|
+
@scroll_pos += scroll_speed
|
|
67
|
+
self.oy = @scroll_pos
|
|
68
|
+
terminate_message if @scroll_pos >= contents.height
|
|
69
|
+
end
|
|
70
|
+
#--------------------------------------------------------------------------
|
|
71
|
+
# * Get Scroll Speed
|
|
72
|
+
#--------------------------------------------------------------------------
|
|
73
|
+
def scroll_speed
|
|
74
|
+
$game_message.scroll_speed * (show_fast? ? 1.0 : 0.5)
|
|
75
|
+
end
|
|
76
|
+
#--------------------------------------------------------------------------
|
|
77
|
+
# * Determine if Fast Forward
|
|
78
|
+
#--------------------------------------------------------------------------
|
|
79
|
+
def show_fast?
|
|
80
|
+
!$game_message.scroll_no_fast && (Input.press?(:A) || Input.press?(:C))
|
|
81
|
+
end
|
|
82
|
+
#--------------------------------------------------------------------------
|
|
83
|
+
# * End Message
|
|
84
|
+
#--------------------------------------------------------------------------
|
|
85
|
+
def terminate_message
|
|
86
|
+
@text = nil
|
|
87
|
+
$game_message.clear
|
|
88
|
+
hide
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
#==============================================================================
|
|
2
|
+
# ** Window_Selectable
|
|
3
|
+
#------------------------------------------------------------------------------
|
|
4
|
+
# This window class contains cursor movement and scroll functions.
|
|
5
|
+
#==============================================================================
|
|
6
|
+
|
|
7
|
+
class Window_Selectable < Window_Base
|
|
8
|
+
#--------------------------------------------------------------------------
|
|
9
|
+
# * Public Instance Variables
|
|
10
|
+
#--------------------------------------------------------------------------
|
|
11
|
+
attr_reader :index # cursor position
|
|
12
|
+
attr_reader :help_window # help window
|
|
13
|
+
attr_accessor :cursor_fix # fix cursor flag
|
|
14
|
+
attr_accessor :cursor_all # select all cursors flag
|
|
15
|
+
#--------------------------------------------------------------------------
|
|
16
|
+
# * Object Initialization
|
|
17
|
+
#-------------------------------------------------------------------------
|
|
18
|
+
def initialize(x, y, width, height)
|
|
19
|
+
super
|
|
20
|
+
@index = -1
|
|
21
|
+
@handler = {}
|
|
22
|
+
@cursor_fix = false
|
|
23
|
+
@cursor_all = false
|
|
24
|
+
update_padding
|
|
25
|
+
deactivate
|
|
26
|
+
end
|
|
27
|
+
#--------------------------------------------------------------------------
|
|
28
|
+
# * Get Digit Count
|
|
29
|
+
#--------------------------------------------------------------------------
|
|
30
|
+
def col_max
|
|
31
|
+
return 1
|
|
32
|
+
end
|
|
33
|
+
#--------------------------------------------------------------------------
|
|
34
|
+
# * Get Spacing for Items Arranged Side by Side
|
|
35
|
+
#--------------------------------------------------------------------------
|
|
36
|
+
def spacing
|
|
37
|
+
return 32
|
|
38
|
+
end
|
|
39
|
+
#--------------------------------------------------------------------------
|
|
40
|
+
# * Get Number of Items
|
|
41
|
+
#--------------------------------------------------------------------------
|
|
42
|
+
def item_max
|
|
43
|
+
return 0
|
|
44
|
+
end
|
|
45
|
+
#--------------------------------------------------------------------------
|
|
46
|
+
# * Get Item Width
|
|
47
|
+
#--------------------------------------------------------------------------
|
|
48
|
+
def item_width
|
|
49
|
+
(width - standard_padding * 2 + spacing) / col_max - spacing
|
|
50
|
+
end
|
|
51
|
+
#--------------------------------------------------------------------------
|
|
52
|
+
# * Get Item Height
|
|
53
|
+
#--------------------------------------------------------------------------
|
|
54
|
+
def item_height
|
|
55
|
+
line_height
|
|
56
|
+
end
|
|
57
|
+
#--------------------------------------------------------------------------
|
|
58
|
+
# * Get Row Count
|
|
59
|
+
#--------------------------------------------------------------------------
|
|
60
|
+
def row_max
|
|
61
|
+
[(item_max + col_max - 1) / col_max, 1].max
|
|
62
|
+
end
|
|
63
|
+
#--------------------------------------------------------------------------
|
|
64
|
+
# * Calculate Height of Window Contents
|
|
65
|
+
#--------------------------------------------------------------------------
|
|
66
|
+
def contents_height
|
|
67
|
+
[super - super % item_height, row_max * item_height].max
|
|
68
|
+
end
|
|
69
|
+
#--------------------------------------------------------------------------
|
|
70
|
+
# * Update Padding
|
|
71
|
+
#--------------------------------------------------------------------------
|
|
72
|
+
def update_padding
|
|
73
|
+
super
|
|
74
|
+
update_padding_bottom
|
|
75
|
+
end
|
|
76
|
+
#--------------------------------------------------------------------------
|
|
77
|
+
# * Update Bottom Padding
|
|
78
|
+
#--------------------------------------------------------------------------
|
|
79
|
+
def update_padding_bottom
|
|
80
|
+
surplus = (height - standard_padding * 2) % item_height
|
|
81
|
+
self.padding_bottom = padding + surplus
|
|
82
|
+
end
|
|
83
|
+
#--------------------------------------------------------------------------
|
|
84
|
+
# * Set Height
|
|
85
|
+
#--------------------------------------------------------------------------
|
|
86
|
+
def height=(height)
|
|
87
|
+
super
|
|
88
|
+
update_padding
|
|
89
|
+
end
|
|
90
|
+
#--------------------------------------------------------------------------
|
|
91
|
+
# * Change Active State
|
|
92
|
+
#--------------------------------------------------------------------------
|
|
93
|
+
def active=(active)
|
|
94
|
+
super
|
|
95
|
+
update_cursor
|
|
96
|
+
call_update_help
|
|
97
|
+
end
|
|
98
|
+
#--------------------------------------------------------------------------
|
|
99
|
+
# * Set Cursor Position
|
|
100
|
+
#--------------------------------------------------------------------------
|
|
101
|
+
def index=(index)
|
|
102
|
+
@index = index
|
|
103
|
+
update_cursor
|
|
104
|
+
call_update_help
|
|
105
|
+
end
|
|
106
|
+
#--------------------------------------------------------------------------
|
|
107
|
+
# * Select Item
|
|
108
|
+
#--------------------------------------------------------------------------
|
|
109
|
+
def select(index)
|
|
110
|
+
self.index = index if index
|
|
111
|
+
end
|
|
112
|
+
#--------------------------------------------------------------------------
|
|
113
|
+
# * Deselect Item
|
|
114
|
+
#--------------------------------------------------------------------------
|
|
115
|
+
def unselect
|
|
116
|
+
self.index = -1
|
|
117
|
+
end
|
|
118
|
+
#--------------------------------------------------------------------------
|
|
119
|
+
# * Get Current Line
|
|
120
|
+
#--------------------------------------------------------------------------
|
|
121
|
+
def row
|
|
122
|
+
index / col_max
|
|
123
|
+
end
|
|
124
|
+
#--------------------------------------------------------------------------
|
|
125
|
+
# * Get Top Row
|
|
126
|
+
#--------------------------------------------------------------------------
|
|
127
|
+
def top_row
|
|
128
|
+
oy / item_height
|
|
129
|
+
end
|
|
130
|
+
#--------------------------------------------------------------------------
|
|
131
|
+
# * Set Top Row
|
|
132
|
+
#--------------------------------------------------------------------------
|
|
133
|
+
def top_row=(row)
|
|
134
|
+
row = 0 if row < 0
|
|
135
|
+
row = row_max - 1 if row > row_max - 1
|
|
136
|
+
self.oy = row * item_height
|
|
137
|
+
end
|
|
138
|
+
#--------------------------------------------------------------------------
|
|
139
|
+
# * Get Number of Rows Displayable on 1 Page
|
|
140
|
+
#--------------------------------------------------------------------------
|
|
141
|
+
def page_row_max
|
|
142
|
+
(height - padding - padding_bottom) / item_height
|
|
143
|
+
end
|
|
144
|
+
#--------------------------------------------------------------------------
|
|
145
|
+
# * Get Number of Items Displayable on 1 Page
|
|
146
|
+
#--------------------------------------------------------------------------
|
|
147
|
+
def page_item_max
|
|
148
|
+
page_row_max * col_max
|
|
149
|
+
end
|
|
150
|
+
#--------------------------------------------------------------------------
|
|
151
|
+
# * Determine Horizontal Selection
|
|
152
|
+
#--------------------------------------------------------------------------
|
|
153
|
+
def horizontal?
|
|
154
|
+
page_row_max == 1
|
|
155
|
+
end
|
|
156
|
+
#--------------------------------------------------------------------------
|
|
157
|
+
# * Get Bottom Row
|
|
158
|
+
#--------------------------------------------------------------------------
|
|
159
|
+
def bottom_row
|
|
160
|
+
top_row + page_row_max - 1
|
|
161
|
+
end
|
|
162
|
+
#--------------------------------------------------------------------------
|
|
163
|
+
# * Set Bottom Row
|
|
164
|
+
#--------------------------------------------------------------------------
|
|
165
|
+
def bottom_row=(row)
|
|
166
|
+
self.top_row = row - (page_row_max - 1)
|
|
167
|
+
end
|
|
168
|
+
#--------------------------------------------------------------------------
|
|
169
|
+
# * Get Rectangle for Drawing Items
|
|
170
|
+
#--------------------------------------------------------------------------
|
|
171
|
+
def item_rect(index)
|
|
172
|
+
rect = Rect.new
|
|
173
|
+
rect.width = item_width
|
|
174
|
+
rect.height = item_height
|
|
175
|
+
rect.x = index % col_max * (item_width + spacing)
|
|
176
|
+
rect.y = index / col_max * item_height
|
|
177
|
+
rect
|
|
178
|
+
end
|
|
179
|
+
#--------------------------------------------------------------------------
|
|
180
|
+
# * Get Rectangle for Drawing Items (for Text)
|
|
181
|
+
#--------------------------------------------------------------------------
|
|
182
|
+
def item_rect_for_text(index)
|
|
183
|
+
rect = item_rect(index)
|
|
184
|
+
rect.x += 4
|
|
185
|
+
rect.width -= 8
|
|
186
|
+
rect
|
|
187
|
+
end
|
|
188
|
+
#--------------------------------------------------------------------------
|
|
189
|
+
# * Set Help Window
|
|
190
|
+
#--------------------------------------------------------------------------
|
|
191
|
+
def help_window=(help_window)
|
|
192
|
+
@help_window = help_window
|
|
193
|
+
call_update_help
|
|
194
|
+
end
|
|
195
|
+
#--------------------------------------------------------------------------
|
|
196
|
+
# * Set Handler Corresponding to Operation
|
|
197
|
+
# method : Method set as a handler (Method object)
|
|
198
|
+
#--------------------------------------------------------------------------
|
|
199
|
+
def set_handler(symbol, method)
|
|
200
|
+
@handler[symbol] = method
|
|
201
|
+
end
|
|
202
|
+
#--------------------------------------------------------------------------
|
|
203
|
+
# * Check for Handler Existence
|
|
204
|
+
#--------------------------------------------------------------------------
|
|
205
|
+
def handle?(symbol)
|
|
206
|
+
@handler.include?(symbol)
|
|
207
|
+
end
|
|
208
|
+
#--------------------------------------------------------------------------
|
|
209
|
+
# * Call Handler
|
|
210
|
+
#--------------------------------------------------------------------------
|
|
211
|
+
def call_handler(symbol)
|
|
212
|
+
@handler[symbol].call if handle?(symbol)
|
|
213
|
+
end
|
|
214
|
+
#--------------------------------------------------------------------------
|
|
215
|
+
# * Determine if Cursor is Moveable
|
|
216
|
+
#--------------------------------------------------------------------------
|
|
217
|
+
def cursor_movable?
|
|
218
|
+
active && open? && !@cursor_fix && !@cursor_all && item_max > 0
|
|
219
|
+
end
|
|
220
|
+
#--------------------------------------------------------------------------
|
|
221
|
+
# * Move Cursor Down
|
|
222
|
+
#--------------------------------------------------------------------------
|
|
223
|
+
def cursor_down(wrap = false)
|
|
224
|
+
if index < item_max - col_max || (wrap && col_max == 1)
|
|
225
|
+
select((index + col_max) % item_max)
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
#--------------------------------------------------------------------------
|
|
229
|
+
# * Move Cursor Up
|
|
230
|
+
#--------------------------------------------------------------------------
|
|
231
|
+
def cursor_up(wrap = false)
|
|
232
|
+
if index >= col_max || (wrap && col_max == 1)
|
|
233
|
+
select((index - col_max + item_max) % item_max)
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
#--------------------------------------------------------------------------
|
|
237
|
+
# * Move Cursor Right
|
|
238
|
+
#--------------------------------------------------------------------------
|
|
239
|
+
def cursor_right(wrap = false)
|
|
240
|
+
if col_max >= 2 && (index < item_max - 1 || (wrap && horizontal?))
|
|
241
|
+
select((index + 1) % item_max)
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
#--------------------------------------------------------------------------
|
|
245
|
+
# * Move Cursor Left
|
|
246
|
+
#--------------------------------------------------------------------------
|
|
247
|
+
def cursor_left(wrap = false)
|
|
248
|
+
if col_max >= 2 && (index > 0 || (wrap && horizontal?))
|
|
249
|
+
select((index - 1 + item_max) % item_max)
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
#--------------------------------------------------------------------------
|
|
253
|
+
# * Move Cursor One Page Down
|
|
254
|
+
#--------------------------------------------------------------------------
|
|
255
|
+
def cursor_pagedown
|
|
256
|
+
if top_row + page_row_max < row_max
|
|
257
|
+
self.top_row += page_row_max
|
|
258
|
+
select([@index + page_item_max, item_max - 1].min)
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
#--------------------------------------------------------------------------
|
|
262
|
+
# * Move Cursor One Page Up
|
|
263
|
+
#--------------------------------------------------------------------------
|
|
264
|
+
def cursor_pageup
|
|
265
|
+
if top_row > 0
|
|
266
|
+
self.top_row -= page_row_max
|
|
267
|
+
select([@index - page_item_max, 0].max)
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
#--------------------------------------------------------------------------
|
|
271
|
+
# * Frame Update
|
|
272
|
+
#--------------------------------------------------------------------------
|
|
273
|
+
def update
|
|
274
|
+
super
|
|
275
|
+
process_cursor_move
|
|
276
|
+
process_handling
|
|
277
|
+
end
|
|
278
|
+
#--------------------------------------------------------------------------
|
|
279
|
+
# * Cursor Movement Processing
|
|
280
|
+
#--------------------------------------------------------------------------
|
|
281
|
+
def process_cursor_move
|
|
282
|
+
return unless cursor_movable?
|
|
283
|
+
last_index = @index
|
|
284
|
+
cursor_down (Input.trigger?(:DOWN)) if Input.repeat?(:DOWN)
|
|
285
|
+
cursor_up (Input.trigger?(:UP)) if Input.repeat?(:UP)
|
|
286
|
+
cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
|
|
287
|
+
cursor_left (Input.trigger?(:LEFT)) if Input.repeat?(:LEFT)
|
|
288
|
+
cursor_pagedown if !handle?(:pagedown) && Input.trigger?(:R)
|
|
289
|
+
cursor_pageup if !handle?(:pageup) && Input.trigger?(:L)
|
|
290
|
+
Sound.play_cursor if @index != last_index
|
|
291
|
+
end
|
|
292
|
+
#--------------------------------------------------------------------------
|
|
293
|
+
# * Handling Processing for OK and Cancel Etc.
|
|
294
|
+
#--------------------------------------------------------------------------
|
|
295
|
+
def process_handling
|
|
296
|
+
return unless open? && active
|
|
297
|
+
return process_ok if ok_enabled? && Input.trigger?(:C)
|
|
298
|
+
return process_cancel if cancel_enabled? && Input.trigger?(:B)
|
|
299
|
+
return process_pagedown if handle?(:pagedown) && Input.trigger?(:R)
|
|
300
|
+
return process_pageup if handle?(:pageup) && Input.trigger?(:L)
|
|
301
|
+
end
|
|
302
|
+
#--------------------------------------------------------------------------
|
|
303
|
+
# * Get Activation State of OK Processing
|
|
304
|
+
#--------------------------------------------------------------------------
|
|
305
|
+
def ok_enabled?
|
|
306
|
+
handle?(:ok)
|
|
307
|
+
end
|
|
308
|
+
#--------------------------------------------------------------------------
|
|
309
|
+
# * Get Activation State of Cancel Processing
|
|
310
|
+
#--------------------------------------------------------------------------
|
|
311
|
+
def cancel_enabled?
|
|
312
|
+
handle?(:cancel)
|
|
313
|
+
end
|
|
314
|
+
#--------------------------------------------------------------------------
|
|
315
|
+
# * Processing When OK Button Is Pressed
|
|
316
|
+
#--------------------------------------------------------------------------
|
|
317
|
+
def process_ok
|
|
318
|
+
if current_item_enabled?
|
|
319
|
+
Sound.play_ok
|
|
320
|
+
Input.update
|
|
321
|
+
deactivate
|
|
322
|
+
call_ok_handler
|
|
323
|
+
else
|
|
324
|
+
Sound.play_buzzer
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
#--------------------------------------------------------------------------
|
|
328
|
+
# * Call OK Handler
|
|
329
|
+
#--------------------------------------------------------------------------
|
|
330
|
+
def call_ok_handler
|
|
331
|
+
call_handler(:ok)
|
|
332
|
+
end
|
|
333
|
+
#--------------------------------------------------------------------------
|
|
334
|
+
# * Processing When Cancel Button Is Pressed
|
|
335
|
+
#--------------------------------------------------------------------------
|
|
336
|
+
def process_cancel
|
|
337
|
+
Sound.play_cancel
|
|
338
|
+
Input.update
|
|
339
|
+
deactivate
|
|
340
|
+
call_cancel_handler
|
|
341
|
+
end
|
|
342
|
+
#--------------------------------------------------------------------------
|
|
343
|
+
# * Call Cancel Handler
|
|
344
|
+
#--------------------------------------------------------------------------
|
|
345
|
+
def call_cancel_handler
|
|
346
|
+
call_handler(:cancel)
|
|
347
|
+
end
|
|
348
|
+
#--------------------------------------------------------------------------
|
|
349
|
+
# * Processing When L Button (Page Up) Is Pressed
|
|
350
|
+
#--------------------------------------------------------------------------
|
|
351
|
+
def process_pageup
|
|
352
|
+
Sound.play_cursor
|
|
353
|
+
Input.update
|
|
354
|
+
deactivate
|
|
355
|
+
call_handler(:pageup)
|
|
356
|
+
end
|
|
357
|
+
#--------------------------------------------------------------------------
|
|
358
|
+
# * Processing When R Button (Page Down) Is Pressed
|
|
359
|
+
#--------------------------------------------------------------------------
|
|
360
|
+
def process_pagedown
|
|
361
|
+
Sound.play_cursor
|
|
362
|
+
Input.update
|
|
363
|
+
deactivate
|
|
364
|
+
call_handler(:pagedown)
|
|
365
|
+
end
|
|
366
|
+
#--------------------------------------------------------------------------
|
|
367
|
+
# * Update Cursor
|
|
368
|
+
#--------------------------------------------------------------------------
|
|
369
|
+
def update_cursor
|
|
370
|
+
if @cursor_all
|
|
371
|
+
cursor_rect.set(0, 0, contents.width, row_max * item_height)
|
|
372
|
+
self.top_row = 0
|
|
373
|
+
elsif @index < 0
|
|
374
|
+
cursor_rect.empty
|
|
375
|
+
else
|
|
376
|
+
ensure_cursor_visible
|
|
377
|
+
cursor_rect.set(item_rect(@index))
|
|
378
|
+
end
|
|
379
|
+
end
|
|
380
|
+
#--------------------------------------------------------------------------
|
|
381
|
+
# * Scroll Cursor to Position Within Screen
|
|
382
|
+
#--------------------------------------------------------------------------
|
|
383
|
+
def ensure_cursor_visible
|
|
384
|
+
self.top_row = row if row < top_row
|
|
385
|
+
self.bottom_row = row if row > bottom_row
|
|
386
|
+
end
|
|
387
|
+
#--------------------------------------------------------------------------
|
|
388
|
+
# * Call Help Window Update Method
|
|
389
|
+
#--------------------------------------------------------------------------
|
|
390
|
+
def call_update_help
|
|
391
|
+
update_help if active && @help_window
|
|
392
|
+
end
|
|
393
|
+
#--------------------------------------------------------------------------
|
|
394
|
+
# * Update Help Window
|
|
395
|
+
#--------------------------------------------------------------------------
|
|
396
|
+
def update_help
|
|
397
|
+
@help_window.clear
|
|
398
|
+
end
|
|
399
|
+
#--------------------------------------------------------------------------
|
|
400
|
+
# * Get Activation State of Selection Item
|
|
401
|
+
#--------------------------------------------------------------------------
|
|
402
|
+
def current_item_enabled?
|
|
403
|
+
return true
|
|
404
|
+
end
|
|
405
|
+
#--------------------------------------------------------------------------
|
|
406
|
+
# * Draw All Items
|
|
407
|
+
#--------------------------------------------------------------------------
|
|
408
|
+
def draw_all_items
|
|
409
|
+
item_max.times {|i| draw_item(i) }
|
|
410
|
+
end
|
|
411
|
+
#--------------------------------------------------------------------------
|
|
412
|
+
# * Draw Item
|
|
413
|
+
#--------------------------------------------------------------------------
|
|
414
|
+
def draw_item(index)
|
|
415
|
+
end
|
|
416
|
+
#--------------------------------------------------------------------------
|
|
417
|
+
# * Erase Item
|
|
418
|
+
#--------------------------------------------------------------------------
|
|
419
|
+
def clear_item(index)
|
|
420
|
+
contents.clear_rect(item_rect(index))
|
|
421
|
+
end
|
|
422
|
+
#--------------------------------------------------------------------------
|
|
423
|
+
# * Redraw Item
|
|
424
|
+
#--------------------------------------------------------------------------
|
|
425
|
+
def redraw_item(index)
|
|
426
|
+
clear_item(index) if index >= 0
|
|
427
|
+
draw_item(index) if index >= 0
|
|
428
|
+
end
|
|
429
|
+
#--------------------------------------------------------------------------
|
|
430
|
+
# * Redraw Selection Item
|
|
431
|
+
#--------------------------------------------------------------------------
|
|
432
|
+
def redraw_current_item
|
|
433
|
+
redraw_item(@index)
|
|
434
|
+
end
|
|
435
|
+
#--------------------------------------------------------------------------
|
|
436
|
+
# * Refresh
|
|
437
|
+
#--------------------------------------------------------------------------
|
|
438
|
+
def refresh
|
|
439
|
+
contents.clear
|
|
440
|
+
draw_all_items
|
|
441
|
+
end
|
|
442
|
+
end
|