RPG Fusion
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.



 
AccueilPortailRechercherDernières imagesS'enregistrerConnexion
-45%
Le deal à ne pas rater :
PC Portable LG Gram 17″ Intel Evo Core i7 32 Go /1 To
1099.99 € 1999.99 €
Voir le deal

 

 Menu sauvegarder sur la carte

Aller en bas 
AuteurMessage
arshes
Jongleur Itinérant
Jongleur Itinérant
arshes


Masculin
Nombre de messages : 81
Age : 29
Date d'inscription : 23/06/2007

Menu sauvegarder sur la carte Empty
MessageSujet: Menu sauvegarder sur la carte   Menu sauvegarder sur la carte EmptyMar 10 Juil 2007, 12:14

Voici un petit script qui devrait servir à certaine personne d'après ce qu'on m'a dis donc je le poste ^^.
Ce script permet d'afficher sur la carte un menu avec sauver charger et quitter actionnable à la sourie.

- Auteur : cybersam

- Screen :

Menu sauvegarder sur la carte Scriptni8


- Installation :

Copier ce code, et collez-le dans un script au dessus de Main :

Code:
#==============================================================================
#
# Mouse Script v1                                      created by: cybersam
#
#==============================================================================
#
# this script is what you think it is...
# this one let you use and see you mouse...
# (of course not realy use since the buttons are handled in the keyboard module)
# but here we dont need to change anything...
# only the variables...
# if you already using the first 2 variables...
# comments are over the lines with the variables so you wont have to go
# through the script if you're not good with this kind of stuff ^-^
#
#==============================================================================
module Mouse
  $RMouse_BUTTON_L = 0x01        # left mouse button
  $RMouse_BUTTON_R = 0x02        # right mouse button
  $RMouse_BUTTON_M = 0x04        # middle mouse button
  $RMouse_BUTTON_4 = 0x05        # 4th mouse button # only tested with win2k with a logitech mouse (MX900)
  $RMouse_BUTTON_5 = 0x06        # 5th mouse button # only tested with win2k with a logitech mouse (MX900)
 
  GetKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
  GetKeyboardState = Win32API.new("user32","GetKeyState",['i'],'i')
 
  module_function
 
  def press?(rkey)
    GetKeyState.call(rkey) & 0x01 == 1  #
  end
 
  def trigger?(rkey, key = 0)
    GetKeyboardState.call(rkey) & 0x01 == key #
  end

  gsm = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')

  @cursor_pos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')

  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)
      # the only ones that needs to be changed... if you already using these to
      # variables...
      # change only the number in these 2 lines...
      # if you change other stuff it might srew up the whole module...
      $mouse_x = x
      $mouse_y = y
      return x, y
    else
      return nil
    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

class MapMenu
  def initialize(x,y)
    @x = x
    @y = y
    @spritesave = Sprite.new
    @spriteload = Sprite.new
    @spritequit = Sprite.new
    @savebmp = RPG::Cache.picture('save1')
    @loadbmp = RPG::Cache.picture('load1')
    @quitbmp = RPG::Cache.picture('quit1')
    @actifsavebmp = RPG::Cache.picture('save2')
    @actifloadbmp = RPG::Cache.picture('load2')
    @actifquitbmp = RPG::Cache.picture('quit2')
    @spritesave.x = @x
    @spriteload.x = @x - 20
    @spritequit.x = @x - 40
    @spritesave.y = @y
    @spriteload.y = @y+@savebmp.height+10
    @spritequit.y = @y+@savebmp.height+@loadbmp.height+20
    @spritesave.z = 200
    @spriteload.z = 200
    @spritequit.z = 200
    @actif = -1
    refresh
  end
 
  def dispose
    @spritesave.dispose
    @spriteload.dispose
    @spritequit.dispose
  end
 
  def refresh
    case @actif
    when 0
      @spritesave.bitmap = @actifsavebmp
      @spriteload.bitmap = @loadbmp
      @spritequit.bitmap = @quitbmp
    when 1
      @spritesave.bitmap = @savebmp
      @spriteload.bitmap = @actifloadbmp
      @spritequit.bitmap = @quitbmp
    when 2
      @spritesave.bitmap = @savebmp
      @spriteload.bitmap = @loadbmp
      @spritequit.bitmap = @actifquitbmp
    when -1
      @spritesave.bitmap = @savebmp
      @spriteload.bitmap = @loadbmp
      @spritequit.bitmap = @quitbmp
    end
  end
 
  def update
    oldactif = @actif
    pos = Mouse.mouse_pos(true)
    press = false
    x = @x
    y = @y
    if pos[0].between?(x,x+@savebmp.width) and
      pos[1].between?(y,y+@savebmp.height)
      @actif = 0
      press = true
    end
    x -= 20
    y += @savebmp.height+10
    if pos[0].between?(x,x+@loadbmp.width) and
      pos[1].between?(y,y+@loadbmp.height)
      @actif = 1
      press = true
    end
    x -= 20
    y += @loadbmp.height+10
    if pos[0].between?(x,x+@quitbmp.width) and
      pos[1].between?(y,y+@quitbmp.height)
      @actif = 2
      press = true
    end
    if press == false
      @actif = -1
    end
    refresh if oldactif != @actif
    command
  end
 
  def command
    if Mouse.press?($RMouse_BUTTON_L)
      case @actif
      when 0
        $game_temp.save_calling = true
      when 1
        $scene = Scene_MapLoad.new
      when 2
        $scene = Scene_MapEnd.new
      end
    end
  end
end

class Scene_Map
  alias mimiman_mapmenu_scenemap_main main
  def main
    @mapMenu = MapMenu.new(550,320)
    mimiman_mapmenu_scenemap_main
    @mapMenu.dispose
  end
  alias mimiman_mapmenu_scenemap_update update
  def update
    @mapMenu.update
    mimiman_mapmenu_scenemap_update
  end
end

#==============================================================================
# ¦ Scene_Load
#------------------------------------------------------------------------------
#  ?????????????????
#==============================================================================

class Scene_MapLoad < Scene_File
  #--------------------------------------------------------------------------
  # ? ?????????
  #--------------------------------------------------------------------------
  def initialize
    # ??????????????????
    $game_temp.last_file_index = 0
    latest_time = Time.at(0)
    for i in 0..3
      filename = make_filename(i)
      if FileTest.exist?(filename)
        file = File.open(filename, "r")
        if file.mtime > latest_time
          latest_time = file.mtime
          $game_temp.last_file_index = i
        end
        file.close
      end
    end
    super("Charger quelle partie?")
  end
  #--------------------------------------------------------------------------
  # ? ??????
  #--------------------------------------------------------------------------
  def on_decision(filename)
    # ????????????
    unless FileTest.exist?(filename)
      # ??? SE ???
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    # ??? SE ???
    $game_system.se_play($data_system.load_se)
    # ???????????
    file = File.open(filename, "rb")
    read_save_data(file)
    file.close
    # BGM?BGS ???
    $game_system.bgm_play($game_system.playing_bgm)
    $game_system.bgs_play($game_system.playing_bgs)
    # ?????? (????????)
    $game_map.update
    # ??????????
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # ? ?????????
  #--------------------------------------------------------------------------
  def on_cancel
    # ????? SE ???
    $game_system.se_play($data_system.cancel_se)
    # ???????????
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # ? ???????????
  #    file : ??????????????? (??????)
  #--------------------------------------------------------------------------
  def read_save_data(file)
    # ?????????????????????????
    characters = Marshal.load(file)
    # ??????????????????????
    Graphics.frame_count = Marshal.load(file)
    # ????????????????
    $game_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    $game_variables    = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_screen        = Marshal.load(file)
    $game_actors        = Marshal.load(file)
    $game_party        = Marshal.load(file)
    $game_troop        = Marshal.load(file)
    $game_map          = Marshal.load(file)
    $game_player        = Marshal.load(file)
    # ???????????????????
    # (?????????????????)
    if $game_system.magic_number != $data_system.magic_number
      # ????????
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
    # ???????????????
    $game_party.refresh
  end
end

#==============================================================================
# ¦ Scene_End
#------------------------------------------------------------------------------
#  ???????????????????
#==============================================================================

class Scene_MapEnd
  #--------------------------------------------------------------------------
  # ? ?????
  #--------------------------------------------------------------------------
  def main
    # ????????????
    s1 = "Écran-Titre"
    s2 = "Quitter"
    s3 = "Annuler"
    @command_window = Window_Command.new(192, [s1, s2, s3])
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 240 - @command_window.height / 2
    # ?????????
    Graphics.transition
    # ??????
    loop do
      # ????????
      Graphics.update
      # ???????
      Input.update
      # ??????
      update
      # ????????????????
      if $scene != self
        break
      end
    end
    # ?????????
    Graphics.freeze
    # ????????
    @command_window.dispose
    # ???????????????
    if $scene.is_a?(Scene_Title)
      # ??????????
      Graphics.transition
      Graphics.freeze
    end
  end
  #--------------------------------------------------------------------------
  # ? ??????
  #--------------------------------------------------------------------------
  def update
    # ????????????
    @command_window.update
    # B ??????????
    if Input.trigger?(Input::B)
      # ????? SE ???
      $game_system.se_play($data_system.cancel_se)
      # ???????????
      $scene = Scene_Map.new
      return
    end
    # C ??????????
    if Input.trigger?(Input::C)
      # ???????????????????
      case @command_window.index
      when 0  # ?????
        command_to_title
      when 1  # ???????
        command_shutdown
      when 2  # ???
        command_cancel
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # ? ???? [?????] ??????
  #--------------------------------------------------------------------------
  def command_to_title
    # ?? SE ???
    $game_system.se_play($data_system.decision_se)
    # BGM?BGS?ME ????????
    Audio.bgm_fade(800)
    Audio.bgs_fade(800)
    Audio.me_fade(800)
    # ???????????
    $scene = Scene_Title.new
  end
  #--------------------------------------------------------------------------
  # ? ???? [???????] ??????
  #--------------------------------------------------------------------------
  def command_shutdown
    # ?? SE ???
    $game_system.se_play($data_system.decision_se)
    # BGM?BGS?ME ????????
    Audio.bgm_fade(800)
    Audio.bgs_fade(800)
    Audio.me_fade(800)
    # ???????
    $scene = nil
  end
  #--------------------------------------------------------------------------
  # ? ???? [???] ??????
  #--------------------------------------------------------------------------
  def command_cancel
    # ?? SE ???
    $game_system.se_play($data_system.decision_se)
    # ???????????
    $scene = Scene_Map.new
  end
end

Vous avez juste à créer 6 images, save1 save2 load1 load2 quit1 et je pense que vous devinez que la dernière est quit2 ^^.

Les *1 sont les images quand la sourie n'est pas dessus et les *2 le contraire, quand la sourie passe sur l'option.

Donc voila, amusez-vous ^^.
Revenir en haut Aller en bas
 
Menu sauvegarder sur la carte
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» Map Monde

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
RPG Fusion :: BANQUE DU CODE :: Antre des Scripts :: Map-
Sauter vers:  
Ne ratez plus aucun deal !
Abonnez-vous pour recevoir par notification une sélection des meilleurs deals chaque jour.
IgnorerAutoriser