Module: PFM::Message::State

Includes:
Parser
Included in:
UI::Message::Layout, UI::Message::Window
Defined in:
scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb

Overview

Module responsive of helping the message window with states

In order to have everything working properly, the class including this module needs to define:

  • message_width : Returns an integer telling the width of the message window we want to process (can use @properties)

  • width_computer : Returns [PFM::Message::WidthComputer] object helping to compute the width of the words/texts

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Parser

#convert_text_to_properties, #make_instructions, register_marker

Instance Attribute Details

#auto_skipBoolean

If the message doesn't wait the player to hit A to terminate

Returns:

  • (Boolean)


16
17
18
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 16

def auto_skip
  @auto_skip
end

#current_instruction (readonly)

Returns the value of attribute current_instruction.



25
26
27
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 25

def current_instruction
  @current_instruction
end

#instructions (readonly)

Returns the value of attribute instructions.



28
29
30
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 28

def instructions
  @instructions
end

#last_textString? (readonly)

The last unprocessed text the window has shown

Returns:



22
23
24
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 22

def last_text
  @last_text
end

#properties (readonly)

Returns the value of attribute properties.



31
32
33
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 31

def properties
  @properties
end

#stay_visibleBoolean

If the window message doesn't fade out

Returns:

  • (Boolean)


19
20
21
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 19

def stay_visible
  @stay_visible
end

Instance Method Details

#at_end_of_line?Boolean

Test if we're at the end of the line

Returns:

  • (Boolean)


74
75
76
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 74

def at_end_of_line?
  return @current_instruction == Instructions::NewLine
end

#done_drawing_message?Boolean

Test if we're done drawing the message

Returns:

  • (Boolean)


80
81
82
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 80

def done_drawing_message?
  return (@instructions&.done_processing? || !@instructions) && !current_instruction
end

#initialize

Initialize the states



34
35
36
37
38
39
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 34

def initialize(...)
  @auto_skip = false
  @stay_visible = false
  @last_text = nil
  super(...) # Forward any arguments to original super ;)
end

#load_next_instruction

Load the next instruction



68
69
70
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 68

def load_next_instruction
  @current_instruction = @instructions.get
end

#need_to_show_choice?Boolean

Tell if the message window need to show a choice

Returns:

  • (Boolean)


92
93
94
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 92

def need_to_show_choice?
  return $game_temp.choice_max > 0
end

#need_to_show_message?Boolean

Tell if the message window need to show a message

Returns:

  • (Boolean)


43
44
45
46
47
48
49
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 43

def need_to_show_message?
  # If the window is showing a message and not done drawing it, no need to show the new message
  return false if showing_message? && @instructions

  # The message text needs to be String object in order to show a new message
  return $game_temp.message_text.is_a?(String)
end

#need_to_show_number_input?Boolean

Tell if the message window need to show a number input

Returns:

  • (Boolean)


98
99
100
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 98

def need_to_show_number_input?
  return $game_temp.num_input_digits_max > 0
end

#need_to_wait_user_input?Boolean

Tell if the message window need to wait for user input

Returns:

  • (Boolean)


53
54
55
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 53

def need_to_wait_user_input?
  return showing_message? && done_drawing_message? && !$game_temp.message_text.nil?
end

#parse_and_show_new_message

Parse the new message and set the window into showing message state



58
59
60
61
62
63
64
65
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 58

def parse_and_show_new_message
  @last_text = $game_temp.message_text
  @properties = convert_text_to_properties($game_temp.message_text)
  @instructions = make_instructions(@properties, message_width, width_computer)
  @instructions.start_processing
  @current_instruction = nil
  $game_temp.message_window_showing = true
end

#showing_message?Boolean

Tell if the message window is showing a message

Returns:

  • (Boolean)


86
87
88
# File 'scripts/01450 Systems/00004 Message/00001 Logic/00090 State.rb', line 86

def showing_message?
  return $game_temp.message_window_showing
end