Bonjour, ayant réussi à faire ce que je voulais, et pensant qu'il pourrait être utile à d'autres, je partage ce bout de script que j'ai piqué du ring menu et adapté pour tous les menus.
Il permet d'afficher dans le menu le nom de la map dans lequel est le joueur.
Voici ce que cela donne:
Pour obtenir ceci, il vous suffit tout d'abord de créer un nouveau script et d'y introduire ceci:
Code:
#==============================================================================
# ** Window_Location
#------------------------------------------------------------------------------
# This class shows the current map name.
#==============================================================================
class Window_Location < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 160, (WLH*2) + 32)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
$maps = load_data("Data/MapInfos.rvdata")
@map_id = $game_map.map_id
@currmap = $maps[@map_id].name
self.contents.font.color = system_color
self.contents.draw_text(0, -4, 128, 32, "Location :")
self.contents.font.color = normal_color
self.contents.draw_text(0, -4+WLH, 128, 32, @currmap, 1)
end
end
Si vous souhaitez que le nom apparaisse dans le menu, allez dans le script Scene_Menu et modifiez le par celui qui suit (vous pouvez ne pas vouloir l'afficher dans le menu et juste dans les messages):
Code:
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs the menu screen processing.
#==============================================================================
class Scene_Menu < Scene_Base
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor\'s initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
create_menu_background
create_command_window
@location_window = Window_Location.new(0, 280)
@gold_window = Window_Gold.new(0, 360)
@status_window = Window_MenuStatus.new(160, 0)
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@command_window.dispose
@location_window.dispose
@gold_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_menu_background
@command_window.update
@location_window.update
@gold_window.update
@status_window.update
if @command_window.active
update_command_selection
elsif @status_window.active
update_actor_selection
end
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
s1 = Vocab::item
s2 = Vocab::skill
s3 = Vocab::equip
s4 = Vocab::status
s5 = Vocab::save
s6 = Vocab::game_end
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
@command_window.index = @menu_index
if $game_party.members.size == 0 # If number of party members is 0
@command_window.draw_item(0, false) # Disable item
@command_window.draw_item(1, false) # Disable skill
@command_window.draw_item(2, false) # Disable equipment
@command_window.draw_item(3, false) # Disable status
end
if $game_system.save_disabled # If save is forbidden
@command_window.draw_item(4, false) # Disable save
end
end
#--------------------------------------------------------------------------
# * Update Command Selection
#--------------------------------------------------------------------------
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
if $game_party.members.size == 0 and @command_window.index < 4
Sound.play_buzzer
return
elsif $game_system.save_disabled and @command_window.index == 4
Sound.play_buzzer
return
end
Sound.play_decision
case @command_window.index
when 0 # Item
$scene = Scene_Item.new
when 1,2,3 # Skill, equipment, status
start_actor_selection
when 4 # Save
$scene = Scene_File.new(true, false, false)
when 5 # End Game
$scene = Scene_End.new
end
end
end
#--------------------------------------------------------------------------
# * Start Actor Selection
#--------------------------------------------------------------------------
def start_actor_selection
@command_window.active = false
@status_window.active = true
if $game_party.last_actor_index < @status_window.item_max
@status_window.index = $game_party.last_actor_index
else
@status_window.index = 0
end
end
#--------------------------------------------------------------------------
# * End Actor Selection
#--------------------------------------------------------------------------
def end_actor_selection
@command_window.active = true
@status_window.active = false
@status_window.index = -1
end
#--------------------------------------------------------------------------
# * Update Actor Selection
#--------------------------------------------------------------------------
def update_actor_selection
if Input.trigger?(Input::B)
Sound.play_cancel
end_actor_selection
elsif Input.trigger?(Input::C)
$game_party.last_actor_index = @status_window.index
Sound.play_decision
case @command_window.index
when 1 # skill
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
$scene = Scene_Status.new(@status_window.index)
end
end
end
end
J'ai réussi à faire en sorte que l'on puisse également l'insérer dans les messages, cela ressemble à ça:
Pour que cela soit possible, il vous suffit d\'écrire dans le message \M (
Attention: il est important de mettre le M en majuscule!) et bien sûr de modifier un petit script ^^ Allez dans le script Window_Message et remplacez le script par celui qui suit:
Code:
#==============================================================================
# ** Window_Message
#------------------------------------------------------------------------------
# This message window is used to display text.
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
MAX_LINE = 4 # Maximum number of lines
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 288, 544, 128)
self.z = 200
self.active = false
self.index = -1
self.openness = 0
@opening = false # WIndow opening flag
@closing = false # Window closing flag
@text = nil # Remaining text to be displayed
@contents_x = 0 # X coordinate for drawing next character
@contents_y = 0 # Y coordinate for drawing next character
@line_count = 0 # Line count drawn up until now
@wait_count = 0 # Wait count
@background = 0 # Background type
@position = 2 # Display position
@show_fast = false # Fast forward flag
@line_show_fast = false # Fast forward by line flag
@pause_skip = false # Input standby omission flag
create_gold_window
create_location_window
create_number_input_window
create_back_sprite
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
dispose_gold_window
dispose_location_window
dispose_number_input_window
dispose_back_sprite
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_gold_window
update_location_window
update_number_input_window
update_back_sprite
update_show_fast
unless @opening or @closing # Window is not opening or closing
if @wait_count > 0 # Waiting within text
@wait_count -= 1
elsif self.pause # Waiting for text advancement
input_pause
elsif self.active # Inputting choice
input_choice
elsif @number_input_window.visible # Inputting number
input_number
elsif @text != nil # More text exists
update_message # Update message
elsif continue? # If continuing
start_message # Start message
open # Open window
$game_message.visible = true
else # If not continuing
close # Close window
$game_message.visible = @closing
end
end
end
#--------------------------------------------------------------------------
# * Create Gold Window
#--------------------------------------------------------------------------
def create_gold_window
@gold_window = Window_Gold.new(384, 0)
@gold_window.openness = 0
end
#--------------------------------------------------------------------------
# * Create Location Window
#--------------------------------------------------------------------------
def create_location_window
@location_window = Window_Location.new(384, 208)
@location_window.openness = 0
end
#--------------------------------------------------------------------------
# * Create Number Input Window
#--------------------------------------------------------------------------
def create_number_input_window
@number_input_window = Window_NumberInput.new
@number_input_window.visible = false
end
#--------------------------------------------------------------------------
# * Create Background Sprite
#--------------------------------------------------------------------------
def create_back_sprite
@back_sprite = Sprite.new
@back_sprite.bitmap = Cache.system("MessageBack")
@back_sprite.visible = (@background == 1)
@back_sprite.z = 190
end
#--------------------------------------------------------------------------
# * Dispose of Gold Window
#--------------------------------------------------------------------------
def dispose_gold_window
@gold_window.dispose
end
#--------------------------------------------------------------------------
# * Dispose of Location Window
#--------------------------------------------------------------------------
def dispose_location_window
@location_window.dispose
end
#--------------------------------------------------------------------------
# * Dispose of Number Input Window
#--------------------------------------------------------------------------
def dispose_number_input_window
@number_input_window.dispose
end
#--------------------------------------------------------------------------
# * Dispose of Background Sprite
#--------------------------------------------------------------------------
def dispose_back_sprite
@back_sprite.dispose
end
#--------------------------------------------------------------------------
# * Update Gold Window
#--------------------------------------------------------------------------
def update_gold_window
@gold_window.update
end
#--------------------------------------------------------------------------
# * Update Location Window
#--------------------------------------------------------------------------
def update_location_window
@location_window.update
end
#--------------------------------------------------------------------------
# * Update Number Input Window
#--------------------------------------------------------------------------
def update_number_input_window
@number_input_window.update
end
#--------------------------------------------------------------------------
# * Update Background Sprite
#--------------------------------------------------------------------------
def update_back_sprite
@back_sprite.visible = (@background == 1)
@back_sprite.y = y - 16
@back_sprite.opacity = openness
@back_sprite.update
end
#--------------------------------------------------------------------------
# * Update Fast Forward Flag
#--------------------------------------------------------------------------
def update_show_fast
if self.pause or self.openness < 255
@show_fast = false
elsif Input.trigger?(Input::C) and @wait_count < 2
@show_fast = true
elsif not Input.press?(Input::C)
@show_fast = false
end
if @show_fast and @wait_count > 0
@wait_count -= 1
end
end
#--------------------------------------------------------------------------
# * Determine if the Next Message Should be Displayed Continuously
#--------------------------------------------------------------------------
def continue?
return true if $game_message.num_input_variable_id > 0
return false if $game_message.texts.empty?
if self.openness > 0 and not $game_temp.in_battle
return false if @background != $game_message.background
return false if @position != $game_message.position
end
return true
end
#--------------------------------------------------------------------------
# * Start Message
#--------------------------------------------------------------------------
def start_message
@text = ""
for i in 0...$game_message.texts.size
@text += " " if i >= $game_message.choice_start
@text += $game_message.texts[i].clone + "\x00"
end
@item_max = $game_message.choice_max
convert_special_characters
reset_window
new_page
end
#--------------------------------------------------------------------------
# * New Page
#--------------------------------------------------------------------------
def new_page
contents.clear
if $game_message.face_name.empty?
@contents_x = 0
else
name = $game_message.face_name
index = $game_message.face_index
draw_face(name, index, 0, 0)
@contents_x = 112
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
contents.font.color = text_color(0)
end
#--------------------------------------------------------------------------
# * New Line
#--------------------------------------------------------------------------
def new_line
if $game_message.face_name.empty?
@contents_x = 0
else
@contents_x = 112
end
@contents_y += WLH
@line_count += 1
@line_show_fast = false
end
#--------------------------------------------------------------------------
# * Convert Special Characters
#--------------------------------------------------------------------------
def convert_special_characters
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
@text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
@text.gsub!(/\\G/) { "\x02" }
@text.gsub!(/\\\./) { "\x03" }
@text.gsub!(/\\\|/) { "\x04" }
@text.gsub!(/\\!/) { "\x05" }
@text.gsub!(/\\>/) { "\x06" }
@text.gsub!(/\\</) { "\x07" }
@text.gsub!(/\\\^/) { "\x08" }
@text.gsub!(/\\M/) { "\x09" }
@text.gsub!(/\\\\/) { "\\" }
end
#--------------------------------------------------------------------------
# * Set Window Background and Position
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # Normal window
self.opacity = 255
else # Dim Background and Make it Transparent
self.opacity = 0
end
case @position
when 0 # Top
self.y = 0
@gold_window.y = 360
when 1 # Middle
self.y = 144
@gold_window.y = 0
when 2 # Bottom
self.y = 288
@gold_window.y = 0
end
end
#--------------------------------------------------------------------------
# * End Message
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
@gold_window.close
@location_window.close
@number_input_window.active = false
@number_input_window.visible = false
$game_message.main_proc.call if $game_message.main_proc != nil
$game_message.clear
end
#--------------------------------------------------------------------------
# * Update Message
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(/./m) # Get next text character
case c
when nil # There is no text that must be drawn
finish_message # Finish update
break
when "\x00" # New line
new_line
if @line_count >= MAX_LINE # If line count is maximum
unless @text.empty? # If there is more
self.pause = true # Insert number input
break
end
end
when "\x01" # \C[n] (text character color change)
@text.sub!(/\[([0-9]+)\]/, "")
contents.font.color = text_color($1.to_i)
next
when "\x02" # \G (gold display)
@gold_window.refresh
@gold_window.open
when "\x03" # \. (wait 1/4 second)
@wait_count = 15
break
when "\x04" # \| (wait 1 second)
@wait_count = 60
break
when "\x05" # \! (Wait for input)
self.pause = true
break
when "\x06" # \> (Fast display ON)
@line_show_fast = true
when "\x07" # \< (Fast display OFF)
@line_show_fast = false
when "\x08" # \^ (No wait for input)
@pause_skip = true
when "\x09" # \M (map display)
@location_window.refresh
@location_window.open
else # Normal text character
contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# * End Message Update
#--------------------------------------------------------------------------
def finish_message
if $game_message.choice_max > 0
start_choice
elsif $game_message.num_input_variable_id > 0
start_number_input
elsif @pause_skip
terminate_message
else
self.pause = true
end
@wait_count = 10
@text = nil
end
#--------------------------------------------------------------------------
# * Start Choices
#--------------------------------------------------------------------------
def start_choice
self.active = true
self.index = 0
end
#--------------------------------------------------------------------------
# * Start Number Input
#--------------------------------------------------------------------------
def start_number_input
digits_max = $game_message.num_input_digits_max
number = $game_variables[$game_message.num_input_variable_id]
@number_input_window.digits_max = digits_max
@number_input_window.number = number
if $game_message.face_name.empty?
@number_input_window.x = x
else
@number_input_window.x = x + 112
end
@number_input_window.y = y + @contents_y
@number_input_window.active = true
@number_input_window.visible = true
@number_input_window.update
end
#--------------------------------------------------------------------------
# * Update cursor
#--------------------------------------------------------------------------
def update_cursor
if @index >= 0
x = $game_message.face_name.empty? ? 0 : 112
y = ($game_message.choice_start + @index) * WLH
self.cursor_rect.set(x, y, contents.width - x, WLH)
else
self.cursor_rect.empty
end
end
#--------------------------------------------------------------------------
# * Text Advancement Input
#--------------------------------------------------------------------------
def input_pause
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
self.pause = false
if @text != nil and not @text.empty?
new_page if @line_count >= MAX_LINE
else
terminate_message
end
end
end
#--------------------------------------------------------------------------
# * Choice Input
#--------------------------------------------------------------------------
def input_choice
if Input.trigger?(Input::B)
if $game_message.choice_cancel_type > 0
Sound.play_cancel
$game_message.choice_proc.call($game_message.choice_cancel_type - 1)
terminate_message
end
elsif Input.trigger?(Input::C)
Sound.play_decision
$game_message.choice_proc.call(self.index)
terminate_message
end
end
#--------------------------------------------------------------------------
# * Number Input Processing
#--------------------------------------------------------------------------
def input_number
if Input.trigger?(Input::C)
Sound.play_decision
$game_variables[$game_message.num_input_variable_id] =
@number_input_window.number
$game_map.need_refresh = true
terminate_message
end
end
end
J'en profite pour dire que vous pouvez le changer un peu (pas beaucoup, faut pas rêver

) sur plusieurs points.
Dans Window_Location:
Code:
self.contents.draw_text(0, -4, 128, 32, "Location :")
Il vous suffit de modifier "Location :" par le mot que vous voulez et il sera remplacer lors de l'affichage de la fenêtre
Dans Scene_Menu, dans la partie
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
Code:
@location_window = Window_Location.new(0, 280)
@gold_window = Window_Gold.new(0, 360)
La première ligne c'est la position de Window_Location dans le menu, vous pouvez le déplacer à votre guise.
Pas vraiment de rapport, mais juste pour signaler que vous pouvez aussi le faire avec Window_Gold dans la deuxième ligne.
dans Window_Message, vous pouvez également modifier
Code:
#--------------------------------------------------------------------------
# * Create Location Window
#--------------------------------------------------------------------------
def create_location_window
@location_window = Window_Location.new(384, 208)
@location_window.openness = 0
end
C'est la position de la fenêtre lors d'un message en sachant que (x=horizontal, y=vertical)
C'est tout pour l'instant, mais il y a une petite chose que je n'ai pas encore réglée qui devrait se faire assez facilement ^^