View difference between Paste ID: UFeTdMUm and ng1uVaih
SHOW: | | - or go back to the newest paste.
1
###-----------------------------------------------------------------------------
2-
#  Skill Display script v1.0
2+
#  Skill Display v1.2
3
#  Created by Neon Black
4-
#  V1.1 - 1.28.2012 - Small updates
4+
#  V1.2 - 2.11.2014 - More small updates
5
#  V1.1 - 1.28.2013 - Small updates
6-
#  Created for both commercial and non-commercial use as long as credit is
6+
7-
#  given to Neon Black.
7+
#  For both commercial and non-commercial use as long as credit is given to
8
#  Neon Black and any additional authors.  Licensed under Creative Commons
9
#  CC BY 4.0 - http://creativecommons.org/licenses/by/4.0/
10
###-----------------------------------------------------------------------------
11
12-
  ## These three constants can be changed from nil to a string value ("Counter"
12+
13-
  ## with the quotes for example) to display a message when counter, reflection,
13+
14-
  ## or substitution occurs.
14+
  #  These three constants can be changed from nil to a string value ("Counter"
15
  #  with the quotes for example) to display a message when counter, reflection,
16
  #  or substitution occurs.
17
  ##------
18
  COUNTER = nil
19
  REFLECT = nil
20
  SUB = nil
21-
  ## These twho constants are used to determined the X and Y offsets of the
21+
22-
  ## window.  Increase these values to move them down or right and decrease
22+
23-
  ## them to move the window up and left.
23+
  #  These twho constants are used to determined the X and Y offsets of the
24
  #  window.  Increase these values to move them down or right and decrease
25
  #  them to move the window up and left.
26
  ##------
27
  
28
  X_OFFSET = 0
29
  Y_OFFSET = 48
30-
  ## Allows a picture to be used instead of the default black background.  If
30+
31-
  ## you do not want to use a picture, just set this to nil.  The picture goes
31+
32-
  ## in the Graphics/Pictures folder.
32+
  #  Allows a picture to be used instead of the default black background.  If
33
  #  you do not want to use a picture, just set this to nil.  The picture goes
34
  #  in the Graphics/Pictures folder.
35
  ##------
36
  
37
  BACK_COLOR = Color.new(0, 0, 0, 64)
38
  BACK_PIC = nil
39
  
40
  ##------
41
  #  The time taken for each turn measured in frames.
42
  ##------
43
  ACTION_SPEED = 20
44
    
45
##-----------------------------------------------------------------------------
46
#  The following lines are the actual core code of the script.  While you are
47
#  certainly invited to look, modifying it may result in undesirable results.
48
#  Modify at your own risk!
49
##-----------------------------------------------------------------------------
50
  
51
52
  ## Adds a new array to store skill names.
53
  alias cp_init initialize
54
  def initialize
55
    @pop_wind = []
56
    cp_init
57
    @back_sprite.x = self.x = X_OFFSET
58
    @back_sprite.y = self.y = Y_OFFSET
59
    create_background_picture
60
  end
61
  
62
  def create_background_picture
63
    @back_pic_sprite = Sprite.new
64
    return unless BACK_PIC
65
    @back_pic_sprite.bitmap = Cache.picture(BACK_PIC)
66
    @back_pic_sprite.ox = @back_pic_sprite.width / 2
67
    @back_pic_sprite.oy = @back_pic_sprite.height / 2
68
    @back_pic_sprite.x = width / 2 + x
69
    @back_pic_sprite.y = height / 2 + y
70
    @back_pic_sprite.visible = false
71
  end
72
  
73
  ## Change the log window to 1 line max.
74
  def max_line_number
75
    return 1
76
  end
77
  
78
  alias cp_window_clear clear
79
  def clear
80
    @pop_wind.clear
81
    cp_window_clear
82
  end
83
  
84
  ## Overwrites the refresh to change what is drawn.
85
  def refresh
86
    draw_background unless BACK_PIC
87
    contents.clear
88
    @back_pic_sprite.visible = false if @back_pic_sprite
89
    return if @pop_wind.empty?
90
    @back_pic_sprite.visible = true
91
    if @pop_wind[-1].is_a?(String)
92
      draw_text(0, 0, contents.width, line_height, @pop_wind[-1], 1)
93
    elsif @pop_wind[-1].is_a?(Array)
94
      xpos = contents.width - (contents.text_size(@pop_wind[-1][1]).width + 24)
95
      xpos /= 2
96
      draw_icon(@pop_wind[-1][0], xpos, 0)
97
      change_color(normal_color)
98
      draw_text(xpos + 24, 0, contents.width, line_height, @pop_wind[-1][1])
99
    else
100
      xpos = contents.width - (contents.text_size(@pop_wind[-1].name).width + 24)
101
      xpos /= 2
102
      draw_item_name(@pop_wind[-1], xpos, 0)
103
    end
104
  end
105
  
106
  ## Draws the display box in a different size.
107
  def draw_background
108
    @back_bitmap.clear
109
    @back_bitmap.fill_rect(back_rect, back_color)
110
    rect1 = Rect.new(back_rect.x - 64, back_rect.y, 64, back_rect.height)
111
    rect2 = Rect.new(back_rect.x + back_rect.width, back_rect.y, 64,
112
                     back_rect.height)
113
    @back_bitmap.gradient_fill_rect(rect1, no_colour, back_color)
114
    @back_bitmap.gradient_fill_rect(rect2, back_color, no_colour)
115
  end
116
  
117
  def back_rect
118-
    Color.new(0, 0, 0, 0)
118+
119
      i = width
120
    elsif @pop_wind[-1].is_a?(Array)
121
      n = @pop_wind[-1][1]
122
      i = contents.text_size(n).width
123
      i += 24
124
    else
125
      n = @pop_wind[-1].is_a?(String) ? @pop_wind[-1] : @pop_wind[-1].name
126
      i = contents.text_size(n).width
127
      i += 24 unless @pop_wind[-1].is_a?(String)
128
    end
129
    Rect.new((width - i) / 2, padding, i, (@pop_wind.empty? ? 0 : 1) * line_height)
130
  end
131
  
132
  def back_color
133
    BACK_COLOR
134
  end
135
  
136
  def no_colour
137
    color = back_color.clone
138
    color.alpha = 0
139
    color
140
  end
141
    
142
  def add_pop_line(item = nil)
143
    @pop_wind.push(item) unless item.nil? || item == ""
144
    @pop_wind.pop if !item.is_a?(String) && item.name == ""
145
    refresh
146
  end
147
    
148
  def add_pop_array(icon = 0, text = "")
149
    @pop_wind.push([icon, text]) unless text.empty?
150
    refresh
151
  end
152
  
153
  ## Grabs the names of skills rather than the usage lines.  
154-
end
154+
155
    add_pop_line(item)
156
  end
157
  
158
  def display_counter(target, item)
159
    return unless COUNTER
160
    add_pop_line(COUNTER)
161
    wait
162
  end
163
  
164
  def display_reflection(target, item)
165
    return unless REFLECT
166
    add_pop_line(REFLECT)
167
    wait
168
  end
169
  
170
  def display_substitute(substitute, target)
171
    return unless SUB
172
    add_pop_line(SUB)
173
    wait
174
  end
175
  
176
  def message_speed
177
    return ACTION_SPEED
178
  end
179
end
180
181
182
##-----------------------------------------------------------------------------
183
#  End of script.
184
##-----------------------------------------------------------------------------