Krótki opis:
Fajny skrypt pozwalający utworzyć wiadomości które będą wyświetlane po najechaniu myszką na zdarzenie. Obsługa jest bardzo prosta więc dema nie potrzeba.
Autor:
Samarium
Tłumaczenie:
Etam (tłumaczenie częściowe - czyli to co potrzeba)
Kompatybilność:
RPG Maker VX
Skrypt:
Spoiler:
Kod:
#------------------------------------------------------------------------
# MouseOver Version 1.3
# RPG Maker VX
#
# Autor : Samarium
#
# Tłumaczenie : Etam
#
# Utworzony 12 Luty 2008
#
# Przetłumaczony 23 Lipiec 2012
#
# Funkcje : Pozwala wyświetlić okno z tekstem
#
# Zastosowanie: Bardzo proste! Dodaj komentarz zaczynający się od [M]
# a następnie wpisz tekst który ma być wyświetlony
# Idź do linii 26, aby zmienić niektóre właściwości.
#
#------------------------------------------------------------------------
FONT_SIZE = 16 # Rozmiar tekstu
FONT_FACE = "Arial" # Czcionka tekstu
WINDOWSKIN = defaut # Umieść "default" (bez cudzysłowiu), aby wyświetlić domyślny (systemowy) Windowskin.
# Ustaw kolor RGB tekstu. Ustaw na 0 dla wszystkich czarny i 255 dla białego
COLOR_RED = 255
COLOR_BLUE = 255
COLOR_GREEN = 255
OPACITY = 160 # Opacité de la fenêtre
SON = false # Le nom du fichier son. Mettez "false" (sans les guillemets) pour ne pas mettre de son
FIX = true # "true" pour fixer la fenêtre sur l'évènement et "false" pour la rendre mobile : fenêtre suit la souris
# ------------------------------------------------
#---------------------------------------------------------------------
# Game_Search_Event
#
# Permet, dès le départ, chercher tout les évènements ayant un
# commentaire commençant par [M] et de les enregistrer dans un
# tableau (ID de l'évènement et message)
#---------------------------------------------------------------------
class Game_Search_Event
def initialize
# initialisation des variables
@element_event = {}
@map = load_data(sprintf("Data/Map%03d.rvdata", $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]\]/) { "\001" }
while ((c = text.slice!(/./m)) != nil)
if c == "\001"
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.
#---------------------------------------------------------------------
def calcul_pos_event(event_id = 1)
# Prend la position de l'évènement
event = $game_map.events[event_id]
pos_x_event = event.x
pos_y_event = event.y
# Calcule la position relative à l'écran
@x = pos_x_event % @map.width
@y = pos_y_event % @map.height
@real_x = @x * 256
@real_y = @y * 256
end
#---------------------------------------------------------------------
# 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_start start
alias new_update update
alias new_terminate terminate
alias new_fadein fadein
def terminate
@mouseover_window.dispose
new_terminate
end
def fadein(duration)
@mouseover_window.visible = false
new_fadein(duration)
end
def update
@mouseover_window.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
# Obliczenie pozycji x i y
width_window = @mouseover_window.width_window
height_window = @mouseover_window.height_window
if FIX
if (width_window + event_x) > 544
@mouseover_window.x = event_x - width_window
else
@mouseover_window.x = event_x
end
if (height_window + event_y) > 416
@mouseover_window.y = event_y - height_window - 16
else
@mouseover_window.y = event_y - 16
end
else
if (width_window + event_x) > 544
@mouseover_window.x = mouse_x - width_window
else
@mouseover_window.x = mouse_x
end
if (height_window + event_y) > 416
@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
Screeny:
Spoiler:
Dodatkowe informacje:
Aby stworzyć okienko z wiadomością tworzymy w zdarzeniu komentarz o treści :
"[M]wiadomość którą chcemy zobaczyć" (ale bez cudzysłowiu )
Dzięki. Mam nadzieję że tłumaczenie wystarczy. Można go użyć zamiast skryptu "Nazwy zdarzeń na mapach", a wtedy nie będzie to kolidowało z cieniami zdarzeń.
Problem pewnie leży w tym że możliwe że masz polskiego ,,mejkera''. Jeśli tak to wklej ten skrypt do angielskiego rpg makera vx, albo jak powidział Etam spróbuj na nowym projekcie
Skoro ma inne skrypty w swoim projekcie to znaczy że dobrze skopiował i ten
Pozatym zawsze można zmienić wcześniejsze skrypty na takie same tylko od innego autora, a efekt niemalże ten sam a gra wtedy może zadziała prawdiłowo
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum