if c == "\007"
[contents.font].each {|i| i.bold = !i.bold }
next
end
if c == "\010"
[contents.font].each {|i| i.italic = !i.italic }
next
end
if c == "\013"
text.sub!(/\[(.*?)\]/, "")
icon = $1.to_s
c = ""
end
if c == "\n"
@cursor_width = [@cursor_width, x].max if y >= $game_temp.choice_start
y += 1
x = face == 0 ? 104 : 0
if y >= $game_temp.choice_start
x += 8
@cursor_width = [@cursor_width, x].max
if face == 0
@cursor_width -= 104
@cursor_x = 112
else @cursor_x = 8 end
end
next
else stxt[y] += contents.text_size(c).width end
if icon != ""
icon_y = (32-24)/2
contents.blt(4+x, 32*y+4, Cache.icon(icon), Rect.new(0,0,24,24))
stxt[y] += 24
x += 24
icon = ""
end
if @outline_text and !@shadow_text
contents.draw_text_outline 4+x, 32*y, 40, 32, c
elsif @shadow_text and !@outline_text
contents.draw_text_shadow 4+x, 32*y, 40, 32, c
else contents.draw_text 4+x, 32*y, 40, 32, c end
x += contents.text_size(c).width
end
for i in 0..3 do stxt[i] += 104 end if face == 0
@back.height = y*32+32
@back.width = stxt.max+40
end
men_pos
if $game_temp.choice_max > 0
@item_max = $game_temp.choice_max
self.active, self.index = true, 0
end
if $game_temp.num_input_variable_id > 0
digits_max = $game_temp.num_input_digits_max
number = $game_variables[$game_temp.num_input_variable_id]
@input_number_window = Window_InputNumber.new digits_max
@back.height += 32
width = [@back.width, @input_number_window.width-16].max
@back.width = width
[@input_number_window].each {|o|
o.number = number
o.y = self.y+$game_temp.num_input_start*32
o.x = face != 0 ? self.x+8 : self.x+8+112 }
end
if face
bitmap = Cache.load_bitmap Path, face_name
fy = @back.height <= 128 ? 0 : (@back.height-128)/2
fx = face == 0 ? 0 : stxt.max+8
@back.width = stxt.max + 136 if face == 1
contents.blt fx, fy, bitmap, Rect.new(0,0,96,96)
@back.height = 128 if @back.height <= 128
men_pos
end
if over_event and $game_map.events != nil
ch = event <= 0 ? $game_player : $game_map.events[event]
fx = [[ch.screen_x-@back.width/2, 4].max,
636-@back.width].min
fy = [[ch.screen_y-(@back.height+48), 4].max,
476-@back.height].min
self.x = @back.x = fx
self.y = @back.y = fy
end
if picture
px = self.x+@back.width
@picture = Sprite.new
@picture.bitmap = Cache.load_bitmap Path, pic_name
@picture.x =
px-@picture.bitmap.width @picture.y =
self.y-@picture.bitmap.height @picture.opacity = 0 if Fade
end
if name_box
@name_box = Name_Box.new self.x, self.y-15, name_text
@name_box.opacity = 0 if Fade
@name_box.back.opacity = $game_system.message_frame == 0 ? 255 : 0
end
end
#---------------------------------------------------------------
# ● Update the cursor, the pause graphic, fade the
# windows and handle the input
#---------------------------------------------------------------
def update
super
@back.update
if @input_number_window != nil
@input_number_window.update
if Input.trigger? C
$game_system.se_play $data_system.decision_se
$game_variables[$game_temp.num_input_variable_id] = @input_number_window.number
$game_map.need_refresh = true
@input_number_window.dispose
@input_number_window = nil
terminate_message
end; return
end
if @contents_showing
@back.pause = true if $game_temp.choice_max == 0
if Input.trigger? B
if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
$game_system.se_play $data_system.cancel_se
$game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
terminate_message
end
end
if Input.trigger? C
if $game_temp.choice_max > 0
$game_system.se_play $data_system.decision_se
$game_temp.choice_proc.call(self.index)
end
terminate_message
end; return
end
if $game_temp.message_text != nil
@contents_showing = true
$game_temp.message_window_showing = true
reset_window; refresh
Graphics.frame_reset
self.visible = true
self.contents_opacity = 0
if @input_number_window != nil
@input_number_window.contents_opacity = 0
end
loop do
Graphics.update
self.contents_opacity += 24
@name_box.opacity += 24 if exists? @name_box and Fade
@picture.opacity += 24 if exists? @picture and Fade
if @input_number_window != nil
@input_number_window.contents_opacity += 24
end
break if self.contents_opacity == 255
end
return
end
if self.visible
loop do
Graphics.update
@back.opacity -= 48
break if @back.opacity == 0
end
self.visible = false
$game_temp.message_window_showing = false
return
end
end
#---------------------------------------------------------------
# ● Get the icon bitmaps and names of each item,
# armor, weapon and skills
# option: item, weapon, armor or skill
# index: the id of the object
#---------------------------------------------------------------
def change_icon option, index
s = case option.downcase
when "i" then $data_items[index]
when "w"then $data_weapons[index]
when "a" then $data_armors[index]
when "s" then $data_skills[index] end
return sprintf("\013[%s]%s", s.icon_name, s.name) unless s.name == nil
end
#---------------------------------------------------------------
# ● Set the variables for outline and shadow text
# w1: outline text true or false
# w2: shadow text true or false
#---------------------------------------------------------------
def disp_text w1=false, w2=false
@outline_text, @shadow_text = w1, w2
end
#---------------------------------------------------------------
# ● Return false if the objects is nil or is disposed
#---------------------------------------------------------------
def exists? object
return false if object.nil? or object.disposed?
return true
end
#---------------------------------------------------------------
# ● Resize the windows and set their positions
#---------------------------------------------------------------
def men_pos
h2 = @back.height/2
self.y = $game_temp.in_battle ? 96 - h2 :
case $game_system.message_position
when 0 then 96 - h2
when 1 then 240-h2
when 2 then 384-h2 end
self.x = 320 - @back.width/2
@back.x, @back.y = self.x, self.y
end
#---------------------------------------------------------------
# ● Change the visibility of the windows and call
# men_pos to resize them
#---------------------------------------------------------------
def reset_window
men_pos
@back.opacity = $game_system.message_frame == 0 ? 255 : 0
@back.back_opacity = 160
end
#---------------------------------------------------------------
# ● Update the cursor rect, if this is needed
#---------------------------------------------------------------
def update_cursor_rect
if @index >= 0
n = $game_temp.choice_start + @index
cursor_rect.set @cursor_x, n*32, @cursor_width, 32
else cursor_rect.empty end
end
#---------------------------------------------------------------
# The name box sprite
#---------------------------------------------------------------
class Name_Box < Sprite
#---------------------------------------------------------------
attr_accessor "back"
#---------------------------------------------------------------
# ● Create the name box text sprite
# x: the x position of the text
# y: the y position of the text
# text: the text chosen to be displayed
#---------------------------------------------------------------
def initialize x, y, text=" "
dumb = Bitmap.new 320, 42
# Ajout Krazplay pour correction, la police doit être la même que plus bas
dumb.font = Font.new("Georgia")
dumb.draw_text(0, 0, 320, 22, text)
# Fin ajout Krazplay
size = dumb.text_size(text).width
dumb.dispose
@back = Window_Base.new x, y, size+12, 32
@back.back_opacity = 255 # Opacité du fond de la name box (max 255)
viewport = Viewport.new x+6, y+5, size, 22
viewport.z = @back.z+10
super viewport
self.bitmap = Bitmap.new size, 22
self.bitmap.font = Font.new("Georgia") # Police d'écriture de la name box
case Message::Default_Text
when 0 then bitmap.draw_text 0, 0, size, 22, text
when 1 then bitmap.draw_text_shadow 0, 0, size, 22, text
when 2 then bitmap.draw_text_outline 0, 0, size, 22, text end
end
#---------------------------------------------------------------
# ● Dispose the text and back
#---------------------------------------------------------------
def dispose
super
@back.dispose
end
#---------------------------------------------------------------
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
# Little modification to get the maps names
#-----------------------------------------------------------------
class Scene_Title
#---------------------------------------------------------------
$map_infos = load_data "Data/MapInfos.rxdata"
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Game_Map
#---------------------------------------------------------------
def name; $map_infos[@map_id].name; end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
# Little modification to fix the cursor width
#-----------------------------------------------------------------
class Window_InputNumber < Window_Base
#---------------------------------------------------------------
def initialize(digits_max)
@digits_max = digits_max
@number = 0
dummy = Bitmap.new 32, 32
@cursor_width = dummy.text_size("0").width+8
dummy.dispose
super 0, 0, @cursor_width*@digits_max+64, 64
self.contents = Bitmap.new width-32, 32
self.z += 9999
self.opacity = @index = 0
refresh
update_cursor_rect
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------