Class: Window_BattleLog
- Inherits:
-
Window_Selectable
- Object
- Window
- Window_Base
- Window_Selectable
- Window_BattleLog
- Defined in:
- lib/rgss3_default_scripts/Window_BattleLog.rb
Overview
** Window_BattleLog
This window is for displaying battle progress. No frame is displayed, but it
is handled as a window for convenience.
Instance Attribute Summary
Attributes inherited from Window_Selectable
#cursor_all, #cursor_fix, #help_window, #index
Instance Method Summary collapse
-
#add_text(text) ⇒ Object
————————————————————————– * Add Text ————————————————————————–.
-
#back_color ⇒ Object
————————————————————————– * Get Background Color ————————————————————————–.
-
#back_one ⇒ Object
————————————————————————– * Go Back One Line ————————————————————————–.
-
#back_opacity ⇒ Object
————————————————————————– * Get Background Opacity ————————————————————————–.
-
#back_rect ⇒ Object
————————————————————————– * Get Background Rectangle ————————————————————————–.
-
#back_to(line_number) ⇒ Object
————————————————————————– * Return to Designated Line ————————————————————————–.
-
#clear ⇒ Object
————————————————————————– * Clear ————————————————————————–.
-
#create_back_bitmap ⇒ Object
————————————————————————– * Create Background Bitmap ————————————————————————–.
-
#create_back_sprite ⇒ Object
————————————————————————– * Create Background Sprite ————————————————————————–.
-
#display_action_results(target, item) ⇒ Object
————————————————————————– * Display Action Results ————————————————————————–.
-
#display_added_states(target) ⇒ Object
————————————————————————– * Display Added State ————————————————————————–.
-
#display_affected_status(target, item) ⇒ Object
————————————————————————– * Display Affected Status ————————————————————————–.
-
#display_auto_affected_status(target) ⇒ Object
————————————————————————– * Display Automatically Affected Status ————————————————————————–.
-
#display_buffs(target, buffs, fmt) ⇒ Object
————————————————————————– * Display Buff/Debuff (Individual) ————————————————————————–.
-
#display_changed_buffs(target) ⇒ Object
————————————————————————– * Display Buff/Debuff ————————————————————————–.
-
#display_changed_states(target) ⇒ Object
————————————————————————– * Display Added/Removed State ————————————————————————–.
-
#display_counter(target, item) ⇒ Object
————————————————————————– * Display Counterattack ————————————————————————–.
-
#display_critical(target, item) ⇒ Object
————————————————————————– * Display Critical Hit ————————————————————————–.
-
#display_current_state(subject) ⇒ Object
————————————————————————– * Display Current State ————————————————————————–.
-
#display_damage(target, item) ⇒ Object
————————————————————————– * Display Damage ————————————————————————–.
-
#display_evasion(target, item) ⇒ Object
————————————————————————– * Display Evasion ————————————————————————–.
-
#display_failure(target, item) ⇒ Object
————————————————————————– * Display Failure ————————————————————————–.
-
#display_hp_damage(target, item) ⇒ Object
————————————————————————– * Display HP Damage ————————————————————————–.
-
#display_miss(target, item) ⇒ Object
————————————————————————– * Display Miss ————————————————————————–.
-
#display_mp_damage(target, item) ⇒ Object
————————————————————————– * Display MP Damage ————————————————————————–.
-
#display_reflection(target, item) ⇒ Object
————————————————————————– * Display Reflection ————————————————————————–.
-
#display_removed_states(target) ⇒ Object
————————————————————————– * Display Removed State ————————————————————————–.
-
#display_substitute(substitute, target) ⇒ Object
————————————————————————– * Display Substitute ————————————————————————–.
-
#display_tp_damage(target, item) ⇒ Object
————————————————————————– * Display TP Damage ————————————————————————–.
-
#display_use_item(subject, item) ⇒ Object
————————————————————————– * Display Skill/Item Use ————————————————————————–.
-
#dispose ⇒ Object
————————————————————————– * Free ————————————————————————–.
-
#dispose_back_bitmap ⇒ Object
————————————————————————– * Free Background Bitmap ————————————————————————–.
-
#dispose_back_sprite ⇒ Object
————————————————————————– * Free Background Sprite ————————————————————————–.
-
#draw_background ⇒ Object
————————————————————————– * Draw Background ————————————————————————–.
-
#draw_line(line_number) ⇒ Object
————————————————————————– * Draw Line ————————————————————————–.
-
#initialize ⇒ Window_BattleLog
constructor
————————————————————————– * Object Initialization ————————————————————————–.
-
#last_text ⇒ Object
————————————————————————– * Get Text From Last Line ————————————————————————–.
-
#line_number ⇒ Object
————————————————————————– * Get Number of Data Lines ————————————————————————–.
-
#max_line_number ⇒ Object
————————————————————————– * Get Maximum Number of Lines ————————————————————————–.
-
#message_speed ⇒ Object
————————————————————————– * Get Message Speed ————————————————————————–.
-
#method_wait=(method) ⇒ Object
————————————————————————– * Set Wait Method ————————————————————————–.
-
#method_wait_for_effect=(method) ⇒ Object
————————————————————————– * Set Wait Method for Effect Execution ————————————————————————–.
-
#refresh ⇒ Object
————————————————————————– * Refresh ————————————————————————–.
-
#replace_text(text) ⇒ Object
————————————————————————– * Replace Text Replaces the last line with different text.
-
#wait ⇒ Object
————————————————————————– * Wait ————————————————————————–.
-
#wait_and_clear ⇒ Object
————————————————————————– * Wait and Clear Clear after inputing minimum necessary wait for the message to be read.
-
#wait_for_effect ⇒ Object
————————————————————————– * Wait Until Effect Execution Ends ————————————————————————–.
-
#window_height ⇒ Object
————————————————————————– * Get Window Height ————————————————————————–.
-
#window_width ⇒ Object
————————————————————————– * Get Window Width ————————————————————————–.
Methods inherited from Window_Selectable
#active=, #bottom_row, #bottom_row=, #call_cancel_handler, #call_handler, #call_ok_handler, #call_update_help, #cancel_enabled?, #clear_item, #col_max, #contents_height, #current_item_enabled?, #cursor_down, #cursor_left, #cursor_movable?, #cursor_pagedown, #cursor_pageup, #cursor_right, #cursor_up, #draw_all_items, #draw_item, #ensure_cursor_visible, #handle?, #height=, #horizontal?, #item_height, #item_max, #item_rect, #item_rect_for_text, #item_width, #ok_enabled?, #page_item_max, #page_row_max, #process_cancel, #process_cursor_move, #process_handling, #process_ok, #process_pagedown, #process_pageup, #redraw_current_item, #redraw_item, #row, #row_max, #select, #set_handler, #spacing, #top_row, #top_row=, #unselect, #update, #update_cursor, #update_help, #update_padding, #update_padding_bottom
Methods inherited from Window_Base
#activate, #actor_name, #calc_line_height, #change_color, #close, #contents_height, #contents_width, #convert_escape_characters, #create_contents, #crisis_color, #deactivate, #draw_actor_class, #draw_actor_face, #draw_actor_graphic, #draw_actor_hp, #draw_actor_icons, #draw_actor_level, #draw_actor_mp, #draw_actor_name, #draw_actor_nickname, #draw_actor_param, #draw_actor_simple_status, #draw_actor_tp, #draw_character, #draw_currency_value, #draw_current_and_max_values, #draw_face, #draw_gauge, #draw_icon, #draw_item_name, #draw_text, #draw_text_ex, #fitting_height, #gauge_back_color, #hide, #hp_color, #hp_gauge_color1, #hp_gauge_color2, #knockout_color, #line_height, #make_font_bigger, #make_font_smaller, #mp_color, #mp_cost_color, #mp_gauge_color1, #mp_gauge_color2, #normal_color, #obtain_escape_code, #obtain_escape_param, #open, #param_change_color, #party_member_name, #pending_color, #power_down_color, #power_up_color, #process_character, #process_draw_icon, #process_escape_character, #process_new_line, #process_new_page, #process_normal_character, #reset_font_settings, #show, #standard_padding, #system_color, #text_color, #text_size, #tp_color, #tp_cost_color, #tp_gauge_color1, #tp_gauge_color2, #translucent_alpha, #update, #update_close, #update_open, #update_padding, #update_tone
Constructor Details
#initialize ⇒ Window_BattleLog
-
Object Initialization
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 12 def initialize super(0, 0, window_width, window_height) self.z = 200 self.opacity = 0 @lines = [] @num_wait = 0 create_back_bitmap create_back_sprite refresh end |
Instance Method Details
#add_text(text) ⇒ Object
-
Add Text
106 107 108 109 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 106 def add_text(text) @lines.push(text) refresh end |
#back_color ⇒ Object
-
Get Background Color
149 150 151 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 149 def back_color Color.new(0, 0, 0, back_opacity) end |
#back_one ⇒ Object
-
Go Back One Line
92 93 94 95 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 92 def back_one @lines.pop refresh end |
#back_opacity ⇒ Object
-
Get Background Opacity
155 156 157 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 155 def back_opacity return 64 end |
#back_rect ⇒ Object
-
Get Background Rectangle
143 144 145 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 143 def back_rect Rect.new(0, padding, width, line_number * line_height) end |
#back_to(line_number) ⇒ Object
-
Return to Designated Line
99 100 101 102 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 99 def back_to(line_number) @lines.pop while @lines.size > line_number refresh end |
#clear ⇒ Object
-
Clear
78 79 80 81 82 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 78 def clear @num_wait = 0 @lines.clear refresh end |
#create_back_bitmap ⇒ Object
-
Create Background Bitmap
51 52 53 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 51 def create_back_bitmap @back_bitmap = Bitmap.new(width, height) end |
#create_back_sprite ⇒ Object
-
Create Background Sprite
57 58 59 60 61 62 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 57 def create_back_sprite @back_sprite = Sprite.new @back_sprite.bitmap = @back_bitmap @back_sprite.y = y @back_sprite.z = z - 1 end |
#display_action_results(target, item) ⇒ Object
-
Display Action Results
257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 257 def display_action_results(target, item) if target.result.used last_line_number = line_number display_critical(target, item) display_damage(target, item) display_affected_status(target, item) display_failure(target, item) wait if line_number > last_line_number back_to(last_line_number) end end |
#display_added_states(target) ⇒ Object
-
Display Added State
388 389 390 391 392 393 394 395 396 397 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 388 def display_added_states(target) target.result.added_state_objects.each do |state| state_msg = target.actor? ? state. : state. target.perform_collapse_effect if state.id == target.death_state_id next if state_msg.empty? replace_text(target.name + state_msg) wait wait_for_effect end end |
#display_affected_status(target, item) ⇒ Object
-
Display Affected Status
361 362 363 364 365 366 367 368 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 361 def display_affected_status(target, item) if target.result.status_affected? add_text("") if line_number < max_line_number display_changed_states(target) display_changed_buffs(target) back_one if last_text.empty? end end |
#display_auto_affected_status(target) ⇒ Object
-
Display Automatically Affected Status
372 373 374 375 376 377 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 372 def display_auto_affected_status(target) if target.result.status_affected? display_affected_status(target, nil) wait if line_number > 0 end end |
#display_buffs(target, buffs, fmt) ⇒ Object
-
Display Buff/Debuff (Individual)
419 420 421 422 423 424 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 419 def display_buffs(target, buffs, fmt) buffs.each do |param_id| replace_text(sprintf(fmt, target.name, Vocab::param(param_id))) wait end end |
#display_changed_buffs(target) ⇒ Object
-
Display Buff/Debuff
411 412 413 414 415 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 411 def display_changed_buffs(target) display_buffs(target, target.result.added_buffs, Vocab::BuffAdd) display_buffs(target, target.result.added_debuffs, Vocab::DebuffAdd) display_buffs(target, target.result.removed_buffs, Vocab::BuffRemove) end |
#display_changed_states(target) ⇒ Object
-
Display Added/Removed State
381 382 383 384 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 381 def display_changed_states(target) display_added_states(target) display_removed_states(target) end |
#display_counter(target, item) ⇒ Object
-
Display Counterattack
231 232 233 234 235 236 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 231 def display_counter(target, item) Sound.play_evasion add_text(sprintf(Vocab::CounterAttack, target.name)) wait back_one end |
#display_critical(target, item) ⇒ Object
-
Display Critical Hit
280 281 282 283 284 285 286 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 280 def display_critical(target, item) if target.result.critical text = target.actor? ? Vocab::CriticalToActor : Vocab::CriticalToEnemy add_text(text) wait end end |
#display_current_state(subject) ⇒ Object
-
Display Current State
208 209 210 211 212 213 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 208 def display_current_state(subject) unless subject.most_important_state_text.empty? add_text(subject.name + subject.most_important_state_text) wait end end |
#display_damage(target, item) ⇒ Object
-
Display Damage
290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 290 def display_damage(target, item) if target.result.missed display_miss(target, item) elsif target.result.evaded display_evasion(target, item) else display_hp_damage(target, item) display_mp_damage(target, item) display_tp_damage(target, item) end end |
#display_evasion(target, item) ⇒ Object
-
Display Evasion
317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 317 def display_evasion(target, item) if !item || item.physical? fmt = Vocab::Evasion Sound.play_evasion else fmt = Vocab::MagicEvasion Sound.play_magic_evasion end add_text(sprintf(fmt, target.name)) wait end |
#display_failure(target, item) ⇒ Object
-
Display Failure
271 272 273 274 275 276 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 271 def display_failure(target, item) if target.result.hit? && !target.result.success add_text(sprintf(Vocab::ActionFailure, target.name)) wait end end |
#display_hp_damage(target, item) ⇒ Object
-
Display HP Damage
331 332 333 334 335 336 337 338 339 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 331 def display_hp_damage(target, item) return if target.result.hp_damage == 0 && item && !item.damage.to_hp? if target.result.hp_damage > 0 && target.result.hp_drain == 0 target.perform_damage_effect end Sound.play_recovery if target.result.hp_damage < 0 add_text(target.result.hp_damage_text) wait end |
#display_miss(target, item) ⇒ Object
-
Display Miss
304 305 306 307 308 309 310 311 312 313 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 304 def display_miss(target, item) if !item || item.physical? fmt = target.actor? ? Vocab::ActorNoHit : Vocab::EnemyNoHit Sound.play_miss else fmt = Vocab::ActionFailure end add_text(sprintf(fmt, target.name)) wait end |
#display_mp_damage(target, item) ⇒ Object
-
Display MP Damage
343 344 345 346 347 348 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 343 def display_mp_damage(target, item) return if target.dead? || target.result.mp_damage == 0 Sound.play_recovery if target.result.mp_damage < 0 add_text(target.result.mp_damage_text) wait end |
#display_reflection(target, item) ⇒ Object
-
Display Reflection
240 241 242 243 244 245 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 240 def display_reflection(target, item) Sound.play_reflection add_text(sprintf(Vocab::MagicReflection, target.name)) wait back_one end |
#display_removed_states(target) ⇒ Object
-
Display Removed State
401 402 403 404 405 406 407 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 401 def display_removed_states(target) target.result.removed_state_objects.each do |state| next if state..empty? replace_text(target.name + state.) wait end end |
#display_substitute(substitute, target) ⇒ Object
-
Display Substitute
249 250 251 252 253 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 249 def display_substitute(substitute, target) add_text(sprintf(Vocab::Substitute, substitute.name, target.name)) wait back_one end |
#display_tp_damage(target, item) ⇒ Object
-
Display TP Damage
352 353 354 355 356 357 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 352 def display_tp_damage(target, item) return if target.dead? || target.result.tp_damage == 0 Sound.play_recovery if target.result.tp_damage < 0 add_text(target.result.tp_damage_text) wait end |
#display_use_item(subject, item) ⇒ Object
-
Display Skill/Item Use
217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 217 def display_use_item(subject, item) if item.is_a?(RPG::Skill) add_text(subject.name + item.) unless item..empty? wait add_text(item.) end else add_text(sprintf(Vocab::UseItem, subject.name, item.name)) end end |
#dispose ⇒ Object
-
Free
25 26 27 28 29 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 25 def dispose super dispose_back_bitmap dispose_back_sprite end |
#dispose_back_bitmap ⇒ Object
-
Free Background Bitmap
66 67 68 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 66 def dispose_back_bitmap @back_bitmap.dispose end |
#dispose_back_sprite ⇒ Object
-
Free Background Sprite
72 73 74 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 72 def dispose_back_sprite @back_sprite.dispose end |
#draw_background ⇒ Object
-
Draw Background
136 137 138 139 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 136 def draw_background @back_bitmap.clear @back_bitmap.fill_rect(back_rect, back_color) end |
#draw_line(line_number) ⇒ Object
-
Draw Line
161 162 163 164 165 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 161 def draw_line(line_number) rect = item_rect_for_text(line_number) contents.clear_rect(rect) draw_text_ex(rect.x, rect.y, @lines[line_number]) end |
#last_text ⇒ Object
-
Get Text From Last Line
122 123 124 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 122 def last_text @lines[-1] end |
#line_number ⇒ Object
-
Get Number of Data Lines
86 87 88 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 86 def line_number @lines.size end |
#max_line_number ⇒ Object
-
Get Maximum Number of Lines
45 46 47 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 45 def max_line_number return 6 end |
#message_speed ⇒ Object
-
Get Message Speed
194 195 196 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 194 def return 20 end |
#method_wait=(method) ⇒ Object
-
Set Wait Method
169 170 171 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 169 def method_wait=(method) @method_wait = method end |
#method_wait_for_effect=(method) ⇒ Object
-
Set Wait Method for Effect Execution
175 176 177 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 175 def method_wait_for_effect=(method) @method_wait_for_effect = method end |
#refresh ⇒ Object
-
Refresh
128 129 130 131 132 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 128 def refresh draw_background contents.clear @lines.size.times {|i| draw_line(i) } end |
#replace_text(text) ⇒ Object
-
Replace Text
Replaces the last line with different text.
114 115 116 117 118 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 114 def replace_text(text) @lines.pop @lines.push(text) refresh end |
#wait ⇒ Object
-
Wait
181 182 183 184 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 181 def wait @num_wait += 1 @method_wait.call() if @method_wait end |
#wait_and_clear ⇒ Object
-
Wait and Clear
Clear after inputing minimum necessary wait for the message to be read.
201 202 203 204 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 201 def wait_and_clear wait while @num_wait < 2 if line_number > 0 clear end |
#wait_for_effect ⇒ Object
-
Wait Until Effect Execution Ends
188 189 190 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 188 def wait_for_effect @method_wait_for_effect.call if @method_wait_for_effect end |
#window_height ⇒ Object
-
Get Window Height
39 40 41 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 39 def window_height fitting_height(max_line_number) end |
#window_width ⇒ Object
-
Get Window Width
33 34 35 |
# File 'lib/rgss3_default_scripts/Window_BattleLog.rb', line 33 def window_width Graphics.width end |