Ogłoszenie 

Uwaga! To forum jest w trybie offline.
Wszelką pomoc uzyskasz pod adresem
forum.ultimateam.pl


Administracja Forum


Poprzedni temat «» Następny temat
MouseOver
Autor Wiadomość
Etam 




Preferowany:
RPG Maker VX

Dołączył: 23 Lip 2012
Posty: 44
  Wysłany: Pon 23 Lip, 2012 19:37
MouseOver
~ MouseOver ~


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.
#
#------------------------------------------------------------------------
 
def defaut
  return "Window"
end
 
# ------------------ Konfiguracja -------------------
 
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
#
#---------------------------------------------------------------------
 
module Mouse
  gsm = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
 
  @cursor_pos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  module_function
 
  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 hwnd
  game_name = "\0" * 256
  $readini.call('Game','Title','',game_name,255,".\\Game.ini")
  game_name.delete!("\0")
  return $findwindow.call('RGSS Player',game_name)
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&#232;nement non par rapport &#224; la carte
# mais selon l'écran.
#---------------------------------------------------------------------
 
class Game_Pos_Screen_Event
 
  def initialize
    # Initialisation
    @x = @y = @real_x = @real_y = 0
    @map = load_data(sprintf("Data/Map%03d.rvdata", $game_map.map_id))
  end
   
  def calcul_pos_event(event_id = 1)
    # Prend la position de l'év&#232;nement
    event = $game_map.events[event_id]
    pos_x_event = event.x
    pos_y_event = event.y
   
    # Calcule la position relative &#224; l'écran
    @x = pos_x_event % @map.width
    @y = pos_y_event % @map.height
    @real_x = @x * 256
    @real_y = @y * 256
  end
           
 def screen_x
    return ($game_map.adjust_x(@real_x) + 8007) / 8 - 1000 + 16
  end
 
   def screen_y
    return ($game_map.adjust_y(@real_y) + 8007) / 8 - 1000 + 32
  end
 
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&#234;tre MouseOver. Calcule la taille de la fe&#234;tre
# selon la taille du texte.
#---------------------------------------------------------------------
 
 
class Window_MouseOver < Window_Base
 
  def initialize
    super(0, 0, 64, 64)
    @height = @width = 64
  end
 
   def refresh(text)
     # initialisation
    x = y = lign_size = max_size = 0
 
    self.contents = Bitmap.new(@width - 32, @height - 32)
 
    self.contents.font.name = FONT_FACE
    self.contents.font.size = FONT_SIZE
    self.windowskin = Cache.system(WINDOWSKIN)
    self.contents.font.color = Color.new(COLOR_RED,COLOR_BLUE, COLOR_GREEN, 255)
    self.opacity = OPACITY
     
   self.contents.clear
   
     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&#234;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&#234;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 &#224; la taille de la fen&#234;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&#234;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 start
 
     $search_finish = 0
   
      @map = load_data(sprintf("Data/Map%03d.rvdata", $game_map.map_id))
      @mouseover_window = Window_MouseOver.new
      @mouseover_window.visible = false
      @event_memoire = 0
     
      new_start
    end
   
  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&#232;nements commentés commençant par [M]
  if $search_finish != $game_map.map_id # Cette condition permet de chercher seulement une fois les év&#232;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
   
   mouse_x = $game_pos_screen_mouse.screen_x
   mouse_y = $game_pos_screen_mouse.screen_y
   
   # Positions X et Y des év&#232;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&#232;nements &#224; afficher
    for i in 0..element_event_size - 1
       
    event = @event_tab[i]
   
    # Calcul la position de l'év&#232;nement relative &#224; l'écran
    $game_pos_screen_event.calcul_pos_event(event)
   
     event_x = $game_pos_screen_event.screen_x
     event_y = $game_pos_screen_event.screen_y
   
    # Si la souris est sur l'év&#232;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&#234;tre avec le message de l'év&#232;nement et &#224; 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&#232;nement
          @event_memoire = event
       
      # Si la souris n'est plus sur l'év&#232;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 )
 
 
Loki 




Preferowany:
RPG Maker VX

Pomógł: 12 razy
Dołączył: 25 Kwi 2012
Posty: 162
Wysłany: Pon 23 Lip, 2012 21:03
To sie nazywa skrypt :-D Szczególnie w grze online by sie świetnie nadał, napewno użyje ;-)
 
 
Etam 




Preferowany:
RPG Maker VX

Dołączył: 23 Lip 2012
Posty: 44
Wysłany: Wto 24 Lip, 2012 10:48
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ń. :mrgreen:
 
 
master miller 




Preferowany:
RPG Maker VX

Pomógł: 6 razy
Dołączył: 29 Sty 2012
Posty: 107
Wysłany: Wto 24 Lip, 2012 16:21
Taki skrypt w połączeniu z użyciem myszki do poruszania bohaterem dałby ciekawy efekt, na pewno lepszy niż oldschoolowe poruszanie strzałkami :D
________________________
<----- Kliknij
 
 
pw1602 



Preferowany:
RPG Maker VX

Pomógł: 11 razy
Dołączył: 09 Paź 2011
Posty: 119
Wysłany: Sro 25 Lip, 2012 00:52
A mi wyskakuje oto taki błąd:
Spoiler:

________________________



 
 
Etam 




Preferowany:
RPG Maker VX

Dołączył: 23 Lip 2012
Posty: 44
Wysłany: Sro 25 Lip, 2012 08:06
pw1602 - Ja nie pisałem tego skryptu więc za bardzo ci nie pomogę. :D Spróbuj na nowym projekcie a jak nie to napisz jakich innych skryptów używasz.
 
 
Loki 




Preferowany:
RPG Maker VX

Pomógł: 12 razy
Dołączył: 25 Kwi 2012
Posty: 162
Wysłany: Sro 25 Lip, 2012 08:47
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 :-)
 
 
Etam 




Preferowany:
RPG Maker VX

Dołączył: 23 Lip 2012
Posty: 44
Wysłany: Sro 25 Lip, 2012 09:02
To akurat nie jest błąd. Ja też używam polskiego RPG Makera i mi działa. Trzeba poczekać na kogoś kto będzie wiedział na czym polega ten błąd.
 
 
Loki 




Preferowany:
RPG Maker VX

Pomógł: 12 razy
Dołączył: 25 Kwi 2012
Posty: 162
Wysłany: Sro 25 Lip, 2012 09:05
Czyli zostaje jeszcze wkleić skrypt na czysty projekt bo innego wytłumaczenia niemam :-)
 
 
Etam 




Preferowany:
RPG Maker VX

Dołączył: 23 Lip 2012
Posty: 44
Wysłany: Sro 25 Lip, 2012 09:21
Niech zapisze tu skrypty jakich używa.
A może nie skopiował dobrze skryptu ???
 
 
Loki 




Preferowany:
RPG Maker VX

Pomógł: 12 razy
Dołączył: 25 Kwi 2012
Posty: 162
Wysłany: Sro 25 Lip, 2012 10:30
Skoro ma inne skrypty w swoim projekcie to znaczy że dobrze skopiował i ten :-P
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 :-D
 
 
Etam 




Preferowany:
RPG Maker VX

Dołączył: 23 Lip 2012
Posty: 44
Wysłany: Sro 25 Lip, 2012 11:36
Dobra. Tylko poczekajmy może na to co on napisze. :mrgreen:
 
 
pw1602 



Preferowany:
RPG Maker VX

Pomógł: 11 razy
Dołączył: 09 Paź 2011
Posty: 119
Wysłany: Sro 25 Lip, 2012 14:10
Dobra wszystko działa :) Źle go skopiowałem, bo na czystym też wyskakiwał błąd, ale jeszcze raz wkleiłem go ze strony to wszystko działa.
________________________



 
 
Wyświetl posty z ostatnich:   
Odpowiedz do tematu
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
Dodaj temat do Ulubionych
Wersja do druku

Skocz do:  

Powered by phpBB modified by Przemo © 2003 phpBB Group | Template Klam by Ayene