Class: Window_BattleLog

Inherits:
Window_Selectable show all
Defined in:
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)

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

- (Window_BattleLog) initialize


  • Object Initialization




12
13
14
15
16
17
18
19
20
21
# File '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

- (Object) add_text(text)


  • Add Text




106
107
108
109
# File 'Window_BattleLog.rb', line 106

def add_text(text)
  @lines.push(text)
  refresh
end

- (Object) back_color


  • Get Background Color




149
150
151
# File 'Window_BattleLog.rb', line 149

def back_color
  Color.new(0, 0, 0, back_opacity)
end

- (Object) back_one


  • Go Back One Line




92
93
94
95
# File 'Window_BattleLog.rb', line 92

def back_one
  @lines.pop
  refresh
end

- (Object) back_opacity


  • Get Background Opacity




155
156
157
# File 'Window_BattleLog.rb', line 155

def back_opacity
  return 64
end

- (Object) back_rect


  • Get Background Rectangle




143
144
145
# File 'Window_BattleLog.rb', line 143

def back_rect
  Rect.new(0, padding, width, line_number * line_height)
end

- (Object) back_to(line_number)


  • Return to Designated Line




99
100
101
102
# File 'Window_BattleLog.rb', line 99

def back_to(line_number)
  @lines.pop while @lines.size > line_number
  refresh
end

- (Object) clear


  • Clear




78
79
80
81
82
# File 'Window_BattleLog.rb', line 78

def clear
  @num_wait = 0
  @lines.clear
  refresh
end

- (Object) create_back_bitmap


  • Create Background Bitmap




51
52
53
# File 'Window_BattleLog.rb', line 51

def create_back_bitmap
  @back_bitmap = Bitmap.new(width, height)
end

- (Object) create_back_sprite


  • Create Background Sprite




57
58
59
60
61
62
# File '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

- (Object) display_action_results(target, item)


  • Display Action Results




257
258
259
260
261
262
263
264
265
266
267
# File '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

- (Object) display_added_states(target)


  • Display Added State




388
389
390
391
392
393
394
395
396
397
# File 'Window_BattleLog.rb', line 388

def display_added_states(target)
  target.result.added_state_objects.each do |state|
    state_msg = target.actor? ? state.message1 : state.message2
    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

- (Object) display_affected_status(target, item)


  • Display Affected Status




361
362
363
364
365
366
367
368
# File '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

- (Object) display_auto_affected_status(target)


  • Display Automatically Affected Status




372
373
374
375
376
377
# File '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

- (Object) display_buffs(target, buffs, fmt)


  • Display Buff/Debuff (Individual)




419
420
421
422
423
424
# File '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

- (Object) display_changed_buffs(target)


  • Display Buff/Debuff




411
412
413
414
415
# File '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

- (Object) display_changed_states(target)


  • Display Added/Removed State




381
382
383
384
# File 'Window_BattleLog.rb', line 381

def display_changed_states(target)
  display_added_states(target)
  display_removed_states(target)
end

- (Object) display_counter(target, item)


  • Display Counterattack




231
232
233
234
235
236
# File 'Window_BattleLog.rb', line 231

def display_counter(target, item)
  Sound.play_evasion
  add_text(sprintf(Vocab::CounterAttack, target.name))
  wait
  back_one
end

- (Object) display_critical(target, item)


  • Display Critical Hit




280
281
282
283
284
285
286
# File '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

- (Object) display_current_state(subject)


  • Display Current State




208
209
210
211
212
213
# File '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

- (Object) display_damage(target, item)


  • Display Damage




290
291
292
293
294
295
296
297
298
299
300
# File '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

- (Object) display_evasion(target, item)


  • Display Evasion




317
318
319
320
321
322
323
324
325
326
327
# File '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

- (Object) display_failure(target, item)


  • Display Failure




271
272
273
274
275
276
# File '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

- (Object) display_hp_damage(target, item)


  • Display HP Damage




331
332
333
334
335
336
337
338
339
# File '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

- (Object) display_miss(target, item)


  • Display Miss




304
305
306
307
308
309
310
311
312
313
# File '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

- (Object) display_mp_damage(target, item)


  • Display MP Damage




343
344
345
346
347
348
# File '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

- (Object) display_reflection(target, item)


  • Display Reflection




240
241
242
243
244
245
# File 'Window_BattleLog.rb', line 240

def display_reflection(target, item)
  Sound.play_reflection
  add_text(sprintf(Vocab::MagicReflection, target.name))
  wait
  back_one
end

- (Object) display_removed_states(target)


  • Display Removed State




401
402
403
404
405
406
407
# File 'Window_BattleLog.rb', line 401

def display_removed_states(target)
  target.result.removed_state_objects.each do |state|
    next if state.message4.empty?
    replace_text(target.name + state.message4)
    wait
  end
end

- (Object) display_substitute(substitute, target)


  • Display Substitute




249
250
251
252
253
# File 'Window_BattleLog.rb', line 249

def display_substitute(substitute, target)
  add_text(sprintf(Vocab::Substitute, substitute.name, target.name))
  wait
  back_one
end

- (Object) display_tp_damage(target, item)


  • Display TP Damage




352
353
354
355
356
357
# File '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

- (Object) display_use_item(subject, item)


  • Display Skill/Item Use




217
218
219
220
221
222
223
224
225
226
227
# File 'Window_BattleLog.rb', line 217

def display_use_item(subject, item)
  if item.is_a?(RPG::Skill)
    add_text(subject.name + item.message1)
    unless item.message2.empty?
      wait
      add_text(item.message2)
    end
  else
    add_text(sprintf(Vocab::UseItem, subject.name, item.name))
  end
end

- (Object) dispose


  • Free




25
26
27
28
29
# File 'Window_BattleLog.rb', line 25

def dispose
  super
  dispose_back_bitmap
  dispose_back_sprite
end

- (Object) dispose_back_bitmap


  • Free Background Bitmap




66
67
68
# File 'Window_BattleLog.rb', line 66

def dispose_back_bitmap
  @back_bitmap.dispose
end

- (Object) dispose_back_sprite


  • Free Background Sprite




72
73
74
# File 'Window_BattleLog.rb', line 72

def dispose_back_sprite
  @back_sprite.dispose
end

- (Object) draw_background


  • Draw Background




136
137
138
139
# File 'Window_BattleLog.rb', line 136

def draw_background
  @back_bitmap.clear
  @back_bitmap.fill_rect(back_rect, back_color)
end

- (Object) draw_line(line_number)


  • Draw Line




161
162
163
164
165
# File '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

- (Object) last_text


  • Get Text From Last Line




122
123
124
# File 'Window_BattleLog.rb', line 122

def last_text
  @lines[-1]
end

- (Object) line_number


  • Get Number of Data Lines




86
87
88
# File 'Window_BattleLog.rb', line 86

def line_number
  @lines.size
end

- (Object) max_line_number


  • Get Maximum Number of Lines




45
46
47
# File 'Window_BattleLog.rb', line 45

def max_line_number
  return 6
end

- (Object) message_speed


  • Get Message Speed




194
195
196
# File 'Window_BattleLog.rb', line 194

def message_speed
  return 20
end

- (Object) method_wait=(method)


  • Set Wait Method




169
170
171
# File 'Window_BattleLog.rb', line 169

def method_wait=(method)
  @method_wait = method
end

- (Object) method_wait_for_effect=(method)


  • Set Wait Method for Effect Execution




175
176
177
# File 'Window_BattleLog.rb', line 175

def method_wait_for_effect=(method)
  @method_wait_for_effect = method
end

- (Object) refresh


  • Refresh




128
129
130
131
132
# File 'Window_BattleLog.rb', line 128

def refresh
  draw_background
  contents.clear
  @lines.size.times {|i| draw_line(i) }
end

- (Object) replace_text(text)


  • Replace Text

    Replaces the last line with different text.



114
115
116
117
118
# File 'Window_BattleLog.rb', line 114

def replace_text(text)
  @lines.pop
  @lines.push(text)
  refresh
end

- (Object) wait


  • Wait




181
182
183
184
# File 'Window_BattleLog.rb', line 181

def wait
  @num_wait += 1
  @method_wait.call(message_speed) if @method_wait
end

- (Object) wait_and_clear


  • Wait and Clear

    Clear after inputing minimum necessary wait for the message to be read.



201
202
203
204
# File 'Window_BattleLog.rb', line 201

def wait_and_clear
  wait while @num_wait < 2 if line_number > 0
  clear
end

- (Object) wait_for_effect


  • Wait Until Effect Execution Ends




188
189
190
# File 'Window_BattleLog.rb', line 188

def wait_for_effect
  @method_wait_for_effect.call if @method_wait_for_effect
end

- (Object) window_height


  • Get Window Height




39
40
41
# File 'Window_BattleLog.rb', line 39

def window_height
  fitting_height(max_line_number)
end

- (Object) window_width


  • Get Window Width




33
34
35
# File 'Window_BattleLog.rb', line 33

def window_width
  Graphics.width
end