This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
Its not mine I just translated
code
Code:
#------------------------------------------------------------------------
# MouseOver Version 1.3
# RPG Maker XP
#
# Auteur : Samarium
#
# Créé le 11 Février 2008
#
#
# Fonction : Permet d'afficher une fenêtre contenant un texte sur
# un ou des évènement(s) lors du passage de la souris
# sur ce dernier
#
# Utilisation : Très facile ! Faites un commentaire commençant par [M]
# suivit du texte dans l'/les évènement(s) de votre choix.
# Allez vers la ligne 44 pour changer certaines propriétés.
#
# Site : www.rpgcreative.net
#
# Remarque : Script disponible aussi sous RPG Maker VX
#
#------- Modification ---------
# Modifié le 27/03/08
# - Correction des incompatiblités (Remerciement à Siegfried pour quelques éclairements)
# - Correction d'un bug : Affichage selon le déplacement de l'évènement
# - Correction d'un bug : Affichage lorsqu'il y a un changement de map
#
# Modifié le 13/02/08
# - Position de la fenêtre fixe (sur l'évènement) ou mobile (sur la souris)
# - Possibilité de mettre un son
# - Fonctionnalité de \N[x] et \V[x]
#
# Modifié le 12/02/08
# - Correction d'un bug : Affichage de la fenêtre pour tous les évènements
# - Correction d'un bug : Commentaire sans message commençant par [M]
# - Optimation de la vitesse d'éxécution du script
# - Fusionnement de la modification du script Scene_Map avec ce script
#------------------------------------------------------------------------
#------------------------------------------------- -----------------------
# Version 1.3 mouse
# RPG Maker XP
#
# Author: Samarium
#
# Created on 11 February 2008
#
#
# Function: Displays a window containing a text on
# One or more event(s) while the mouse is over event
#
# Use: Very easy! Make a comment starting with [M]
# Followed by the text in the concerned event(s) of your choice.
# Go to line 44 to change certain properties.
#
# Site: www.rpgcreative.net
#
# Note: Script also available in RPG Maker VX
#
#------- ChangeLog -----------
# Last modified 27/03/08
# - Fixed incompatibility (Thanks to Siegfried for some illumination)
# - Fixed bug: Sort by moving the event
# - Fixed a bug: Display where a map
#
# Last modified 13/02/08
# - Window position fixes (on the event) or mobile (in mice)
# - Ability to save a sound
# - Functionality \ N [x] and \ V [x]
#
# Last modified 12/02/08
# - Fixed a bug: the display window for all events
# - Fixed a bug: comment message starting with [M]
# - Optimation the speed of execution of the script
# - Merger of the modification of the script with this script Scene_Map
#------------------------------------------------- -----------------------
def defaut
$data_system = load_data("Data/System.rxdata")
return $data_system.windowskin_name
end
FONT_SIZE = 16 # Text Size
FONT_FACE = "Arial" # Font Style
WINDOWSKIN = defaut # Windowskin
# Text Color
COLOR_RED = 255
COLOR_BLUE = 255
COLOR_GREEN = 255
OPACITY = 160 # Opacity of Window
SON = false # The name of the sound file used when mouse over. Put "false" (without the quotes) to not put his
FIX = true # "true" (without the quotes) to fix the window on the event and "false" (without the quotes) to make mobile window follows mouse
# ------------------------------------------------
#---------------------------------------------------------------------
# Game_Search_Event
#
# Allow from the outset seek any events with a
# Comment starting with [M] and store in a
# Table (ID of the event and message)
#---------------------------------------------------------------------
class Game_Search_Event
def initialize
# initialisation des variables
@element_event = {}
@map = load_data(sprintf("Data/Map%03d.rxdata", $game_map.map_id))
@nb_event = @map.events.size
@tab_event = @map.events.values # Retourne les valeurs du Hash dans un tableau
main
end
def main
for i in 0..@nb_event - 1
# Prend le contenu de la page de chaques évènements
event = @tab_event[i]
pages = event.pages
for page in event.pages
# Prend la liste et le code de la commande d'évènement
list = page.list
code = cod(list)
# Si le code est celui que l'on veut
if code[0]
event_id = event.id
message = code[1]
# Ajoute dans un Hash, l'ID et le message de l'évènement
@element_event[event_id] = message
end
end
$search_finish = $game_map.map_id
end
end
def element_event_id
return @element_event.keys # Array
end
def element_event_message(event)
return @element_event[event] # String
end
def element_event_size
return @element_event.size # Integer
end
def cod(list)
# initialisation des variables
for index in 0...list.size
parameters = list[index].parameters
# Si la commande est un commentaire et commence par [M]
if list[index].code == 108 and commentaire(parameters[0])
message_text = parameters[0] + "\n"
# Ajoute aux messages les lignes suivantes
for line_count in 1..5
if list[line_count] != nil
if list[index + line_count].code == 408
message_text += text_sub(list[index + line_count].parameters[0]) + "\n"
end
end
end
return true, message_text
end
end
return false, false
end
def commentaire(text)
# Cherche le [M] et l'efface
text.gsub!(/[\[Mm]\]/) { "�1" }
while ((c = text.slice!(/./m)) != nil)
if c == "�1"
text.sub!(/[\[Mm]\]/, "")
text_sub(text)
return true
end
end
return false
end
# Remplace \N[x] par le nom du héros d'ID x et \V[x] par la variable x
def text_sub(text)
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
return text
end
end
#---------------------------------------------------------------------
# Mouse
#
# Reprise du module Mouse créé par Cybersam et édité par Astro_mech
# Calcule et retourne la position X et Y de la souris sur l'écran
#
#---------------------------------------------------------------------
def mouse_global_pos
pos = [0, 0].pack('ll')
if @cursor_pos.call(pos) != 0
return pos.unpack('ll')
else
return nil
end
end
def mouse_pos(catch_anywhere = false)
x, y = screen_to_client(*mouse_global_pos)
width, height = client_size
# if catch_anywhere or (x >= 0 and y >= 0 and x < width and y < height)
return x, y
# else
# return $m.x, $m.y
# end
end
def del
if @oldcursor == nil
return
else
@SetClassLong.call(handel ,-12, @oldcursor)
@oldcursor = nil
end
end
end
$scr2cli = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
$client_rect = Win32API.new('user32', 'GetClientRect', %w(l p), 'i')
$readini = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
$findwindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
def screen_to_client(x, y)
return nil unless x and y
pos = [x, y].pack('ll')
if $scr2cli.call(hwnd, pos) != 0
return pos.unpack('ll')
else
return nil
end
end
def client_size
rect = [0, 0, 0, 0].pack('l4')
$client_rect.call(hwnd, rect)
right, bottom = rect.unpack('l4')[2..3]
return right, bottom
end
#---------------------------------------------------------------------
# Game_Pos_Screen_Event
#
# Calcul la position de l'évènement non par rapport à la carte
# mais selon l'écran.
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# Game_Pos_Screen_Mouse
#
# Retourne les positions de la souris grâce au module Mouse
#---------------------------------------------------------------------
class Game_Pos_Screen_Mouse
def initialize
@pos_x_mouse = @pos_y_mouse = 0
end
def screen_x
return @pos_x_mouse = Mouse.mouse_pos[0]
end
def screen_y
return @pos_y_mouse = Mouse.mouse_pos[1]
end
end
#---------------------------------------------------------------------
# Window_MouseOver
#
# Affichage de la fenêtre MouseOver. Calcule la taille de la feêtre
# selon la taille du texte.
#---------------------------------------------------------------------
ctab = text.scan(/./m)
for i in 0..ctab.size - 1
if ctab[i] == "\n"
# Prend la ligne la plus grande (pour la taille de la fenêtre)
if lign_size > max_size
max_size = lign_size
end
lign_size = x = 0
y += 1
next
end
lign_size += self.contents.text_size(ctab[i]).width
taille_height = self.contents.text_size(ctab[i]).height
# Affichage du texte
self.contents.draw_text(x, taille_height * y, 20, 20, ctab[i])
x += self.contents.text_size(ctab[i]).width
end
# Calcule de la taille de la fenêtre
@height = self.height = taille_height * y + 32
@width = self.width = max_size + 32
# Affichage si la taille du contenu de la Bitmap (- 32px) est égal à la taille de la fenêtre
if self.contents.width == @width - 32 and self.contents.height == @height - 32
self.visible = true
else
self.visible = false
end
end
def width_window
return self.width
end
def height_window
return self.height
end
end
#---------------------------------------------------------------------
# Scene_Map
#
# Reprise du scritp Scene_Map avec des parties rajoutées
# Affiche la fenêtre sur la carte.
#---------------------------------------------------------------------
class Scene_Map
# Définition des alias pour la classe Scene_Map
alias new_main main
alias new_update update
# Cherche les évènements commentés commençant par [M]
if $search_finish != $game_map.map_id # Cette condition permet de chercher seulement une fois les évènements par map
$game_search_event = Game_Search_Event.new
@event_tab = $game_search_event.element_event_id
end
# Positions X et Y de la souris sur l'écran
$game_pos_screen_mouse = Game_Pos_Screen_Mouse.new
# Positions X et Y des évènements sur l'écran
$game_pos_screen_event = Game_Pos_Screen_Event.new
element_event_size = $game_search_event.element_event_size
# Parcours le tableau contenant les évènements à afficher
for i in 0..element_event_size - 1
event = @event_tab[i]
# Calcul la position de l'évènement relative à l'écran
$game_pos_screen_event.calcul_pos_event(event)
# Si la souris est sur l'évènement (carreau de 32*32)
if mouse_x != nil and mouse_y != nil # Evite de tester une position nulle de la souris
if mouse_x <= (event_x + 16) and mouse_x >= (event_x - 16)
if mouse_y <= (event_y) and mouse_y >= (event_y - 32)
if @event_memoire != event and SON != false
$game_system.se_play(SON)
end
# Affiche la fenêtre avec le message de l'évènement et à ses positions
text = $game_search_event.element_event_message(event)
if text.size != 1
@mouseover_window.refresh(text)
end
# Calcul la position X et Y à afficher afin d'éviter que l'écran coupe la fenêtre
width_window = @mouseover_window.width_window
height_window = @mouseover_window.height_window
if FIX
if (width_window + event_x) > 640
@mouseover_window.x = event_x - width_window
else
@mouseover_window.x = event_x
end
if (height_window + event_y) > 480
@mouseover_window.y = event_y - height_window - 16
else
@mouseover_window.y = event_y - 16
end
else
if (width_window + event_x) > 640
@mouseover_window.x = mouse_x - width_window
else
@mouseover_window.x = mouse_x
end
if (height_window + event_y) > 480
@mouseover_window.y = mouse_y - height_window
else
@mouseover_window.y = mouse_y
end
end
# Retient en mérmoire l'ID de l'évènement
# @event_memoire = event
# Si la souris n'est plus sur l'évènement
# elsif @event_memoire == event
# @mouseover_window.visible = false
# @event_memoire = 0
end
# elsif @event_memoire == event
# @mouseover_window.visible = false
# @event_memoire = 0
end
# else
# @mouseover_window.visible = false
end
end
new_update
end
end
Ok here is an edit of it still all credit goes to Samarium
I just changed it so that it updated everything right.
code
Code:
#------------------------------------------------------------------------
# MouseOver Version 1.3
# RPG Maker XP
#
# Auteur : Samarium
#
# Créé le 11 Février 2008
#
#
# Fonction : Permet d'afficher une fenêtre contenant un texte sur
# un ou des évènement(s) lors du passage de la souris
# sur ce dernier
#
# Utilisation : Très facile ! Faites un commentaire commençant par [M]
# suivit du texte dans l'/les évènement(s) de votre choix.
# Allez vers la ligne 44 pour changer certaines propriétés.
#
# Site : www.rpgcreative.net
#
# Remarque : Script disponible aussi sous RPG Maker VX
#
#------- Modification ---------
# Modifié le 27/03/08
# - Correction des incompatiblités (Remerciement à Siegfried pour quelques éclairements)
# - Correction d'un bug : Affichage selon le déplacement de l'évènement
# - Correction d'un bug : Affichage lorsqu'il y a un changement de map
#
# Modifié le 13/02/08
# - Position de la fenêtre fixe (sur l'évènement) ou mobile (sur la souris)
# - Possibilité de mettre un son
# - Fonctionnalité de \N[x] et \V[x]
#
# Modifié le 12/02/08
# - Correction d'un bug : Affichage de la fenêtre pour tous les évènements
# - Correction d'un bug : Commentaire sans message commençant par [M]
# - Optimation de la vitesse d'éxécution du script
# - Fusionnement de la modification du script Scene_Map avec ce script
#------------------------------------------------------------------------
#------------------------------------------------- -----------------------
# Version 1.3 mouse
# RPG Maker XP
#
# Author: Samarium
#
# Created on 11 February 2008
#
#
# Function: Displays a window containing a text on
# One or more event(s) while the mouse is over event
#
# Use: Very easy! Make a comment starting with [M]
# Followed by the text in the concerned event(s) of your choice.
# Go to line 44 to change certain properties.
#
# Site: www.rpgcreative.net
#
# Note: Script also available in RPG Maker VX
#
#------- ChangeLog -----------
# Last modified 27/03/08
# - Fixed incompatibility (Thanks to Siegfried for some illumination)
# - Fixed bug: Sort by moving the event
# - Fixed a bug: Display where a map
#
# Last modified 13/02/08
# - Window position fixes (on the event) or mobile (in mice)
# - Ability to save a sound
# - Functionality \ N [x] and \ V [x]
#
# Last modified 12/02/08
# - Fixed a bug: the display window for all events
# - Fixed a bug: comment message starting with [M]
# - Optimation the speed of execution of the script
# - Merger of the modification of the script with this script Scene_Map
#------------------------------------------------- -----------------------
def defaut
$data_system = load_data("Data/System.rxdata")
return $data_system.windowskin_name
end
FONT_SIZE = 16 # Text Size
FONT_FACE = "Arial" # Font Style
WINDOWSKIN = defaut # Windowskin
# Text Color
COLOR_RED = 255
COLOR_BLUE = 255
COLOR_GREEN = 255
OPACITY = 160 # Opacity of Window
SON = false # The name of the sound file used when mouse over. Put "false" (without the quotes) to not put his
FIX = true # "true" (without the quotes) to fix the window on the event and "false" (without the quotes) to make mobile window follows mouse
# ------------------------------------------------
#---------------------------------------------------------------------
# Game_Search_Event
#
# Allow from the outset seek any events with a
# Comment starting with [M] and store in a
# Table (ID of the event and message)
#---------------------------------------------------------------------
class Game_Search_Event
def initialize
# initialisation des variables
@element_event = {}
@map = load_data(sprintf("Data/Map%03d.rxdata", $game_map.map_id))
@nb_event = @map.events.size
@tab_event = @map.events.values # Retourne les valeurs du Hash dans un tableau
main
end
def main
for i in 0..@nb_event - 1
# Prend le contenu de la page de chaques évènements
event = @tab_event[i]
pages = event.pages
for page in event.pages
# Prend la liste et le code de la commande d'évènement
list = page.list
code = cod(list)
# Si le code est celui que l'on veut
if code[0]
event_id = event.id
message = code[1]
# Ajoute dans un Hash, l'ID et le message de l'évènement
@element_event[event_id] = message
end
end
$search_finish = $game_map.map_id
end
end
def element_event_id
return @element_event.keys # Array
end
def element_event_message(event)
return @element_event[event] # String
end
def element_event_size
return @element_event.size # Integer
end
def cod(list)
# initialisation des variables
for index in 0...list.size
parameters = list[index].parameters
# Si la commande est un commentaire et commence par [M]
if list[index].code == 108 and commentaire(parameters[0])
message_text = parameters[0] + "\n"
# Ajoute aux messages les lignes suivantes
for line_count in 1..5
if list[line_count] != nil
if list[index + line_count].code == 408
message_text += text_sub(list[index + line_count].parameters[0]) + "\n"
end
end
end
return true, message_text
end
end
return false, false
end
def commentaire(text)
# Cherche le [M] et l'efface
text.gsub!(/[\[Mm]\]/) { "1" }
while ((c = text.slice!(/./m)) != nil)
if c == "1"
text.sub!(/[\[Mm]\]/, "")
text_sub(text)
return true
end
end
return false
end
# Remplace \N[x] par le nom du héros d'ID x et \V[x] par la variable x
def text_sub(text)
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
return text
end
end
#---------------------------------------------------------------------
# Mouse
#
# Reprise du module Mouse créé par Cybersam et édité par Astro_mech
# Calcule et retourne la position X et Y de la souris sur l'écran
#
#---------------------------------------------------------------------
def mouse_global_pos
pos = [0, 0].pack('ll')
if @cursor_pos.call(pos) != 0
return pos.unpack('ll')
else
return nil
end
end
def mouse_pos(catch_anywhere = false)
x, y = screen_to_client(*mouse_global_pos)
width, height = client_size
# if catch_anywhere or (x >= 0 and y >= 0 and x < width and y < height)
return x, y
# else
# return $m.x, $m.y
# end
end
def del
if @oldcursor == nil
return
else
@SetClassLong.call(handel ,-12, @oldcursor)
@oldcursor = nil
end
end
end
$scr2cli = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
$client_rect = Win32API.new('user32', 'GetClientRect', %w(l p), 'i')
$readini = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
$findwindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
def screen_to_client(x, y)
return nil unless x and y
pos = [x, y].pack('ll')
if $scr2cli.call(hwnd, pos) != 0
return pos.unpack('ll')
else
return nil
end
end
def client_size
rect = [0, 0, 0, 0].pack('l4')
$client_rect.call(hwnd, rect)
right, bottom = rect.unpack('l4')[2..3]
return right, bottom
end
#---------------------------------------------------------------------
# Game_Pos_Screen_Event
#
# Calcul la position de l'évènement non par rapport à la carte
# mais selon l'écran.
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# Game_Pos_Screen_Mouse
#
# Retourne les positions de la souris grâce au module Mouse
#---------------------------------------------------------------------
class Game_Pos_Screen_Mouse
def initialize
@pos_x_mouse = @pos_y_mouse = 0
end
def screen_x
return @pos_x_mouse = Mouse.mouse_pos[0]
end
def screen_y
return @pos_y_mouse = Mouse.mouse_pos[1]
end
end
#---------------------------------------------------------------------
# Window_MouseOver
#
# Affichage de la fenêtre MouseOver. Calcule la taille de la feêtre
# selon la taille du texte.
#---------------------------------------------------------------------
ctab = text.scan(/./m)
for i in 0..ctab.size - 1
if ctab[i] == "\n"
# Prend la ligne la plus grande (pour la taille de la fenêtre)
if lign_size > max_size
max_size = lign_size
end
lign_size = x = 0
y += 1
next
end
lign_size += self.contents.text_size(ctab[i]).width
taille_height = self.contents.text_size(ctab[i]).height
# Affichage du texte
self.contents.draw_text(x, taille_height * y, 20, 20, ctab[i])
x += self.contents.text_size(ctab[i]).width
end
# Calcule de la taille de la fenêtre
@height = self.height = taille_height * y + 32
@width = self.width = max_size + 32
# Affichage si la taille du contenu de la Bitmap (- 32px) est égal à la taille de la fenêtre
if self.contents.width == @width - 32 and self.contents.height == @height - 32
self.visible = true
else
self.visible = false
end
end
def width_window
return self.width
end
def height_window
return self.height
end
end
#---------------------------------------------------------------------
# Scene_Map
#
# Reprise du scritp Scene_Map avec des parties rajoutées
# Affiche la fenêtre sur la carte.
#---------------------------------------------------------------------
class Scene_Map
# Définition des alias pour la classe Scene_Map
alias new_main main
alias new_update update
# Cherche les évènements commentés commençant par [M]
if $search_finish != $game_map.map_id # Cette condition permet de chercher seulement une fois les évènements par map
$game_search_event = Game_Search_Event.new
@event_tab = $game_search_event.element_event_id
end
$search_finish = 0
@event_memoire = 0
$game_search_event = Game_Search_Event.new
@event_tab = $game_search_event.element_event_id
# Positions X et Y de la souris sur l'écran
$game_pos_screen_mouse = Game_Pos_Screen_Mouse.new
# Positions X et Y des évènements sur l'écran
$game_pos_screen_event = Game_Pos_Screen_Event.new
element_event_size = $game_search_event.element_event_size
# Parcours le tableau contenant les évènements à afficher
for i in 0..element_event_size - 1
event = @event_tab[i]
# Calcul la position de l'évènement relative à l'écran
$game_pos_screen_event.calcul_pos_event(event)
# Si la souris est sur l'évènement (carreau de 32*32)
if mouse_x != nil and mouse_y != nil # Evite de tester une position nulle de la souris
if mouse_x <= (event_x + 16) and mouse_x >= (event_x - 16)
if mouse_y <= (event_y) and mouse_y >= (event_y - 32)
if @event_memoire != event and SON != false
$game_system.se_play(SON)
end
# Affiche la fenêtre avec le message de l'évènement et à ses positions
text = $game_search_event.element_event_message(event)
if text.size != 1
@mouseover_window.refresh(text)
end
# Calcul la position X et Y à afficher afin d'éviter que l'écran coupe la fenêtre
width_window = @mouseover_window.width_window
height_window = @mouseover_window.height_window
if FIX
if (width_window + event_x) > 640
@mouseover_window.x = event_x - width_window
else
@mouseover_window.x = event_x
end
if (height_window + event_y) > 480
@mouseover_window.y = event_y - height_window - 16
else
@mouseover_window.y = event_y - 16
end
else
if (width_window + event_x) > 640
@mouseover_window.x = mouse_x - width_window
else
@mouseover_window.x = mouse_x
end
if (height_window + event_y) > 480
@mouseover_window.y = mouse_y - height_window
else
@mouseover_window.y = mouse_y
end
end
# Retient en mérmoire l'ID de l'évènement
# @event_memoire = event
# Si la souris n'est plus sur l'évènement
# elsif @event_memoire == event
# @mouseover_window.visible = false
# @event_memoire = 0
end
# elsif @event_memoire == event
# @mouseover_window.visible = false
# @event_memoire = 0
end
# else
# @mouseover_window.visible = false
end
end