Project1

标题: 新手想请教如何更改立绘和物品栏的排版和图片 [打印本页]

作者: wangxiaojiav6    时间: 2016-10-24 18:12
标题: 新手想请教如何更改立绘和物品栏的排版和图片
本帖最后由 wangxiaojiav6 于 2016-10-25 11:37 编辑

新手刚入坑,研究了两天va,但脚本一直不是很明白……(代码苦手……)
想做出立绘在对话框前面的效果,找到了一个可以实现的脚本,但是出现了字体离立绘太远的问题……大概离了8个字左右的距离。立绘图片是贴边剪裁的,想到是不是脚本中字体位置设置的问题但不知道哪里才是修改的代码……
还有想将默认的物品栏的排版和图片换成自己的素材……这几天找了不少一直没找到,求大神们指教QWQ…………谢谢


下面是找的脚本
#encoding:utf-8
#==============================================================================
# ■ 半身像对话框 by LBQ
#------------------------------------------------------------------------------
#  一个简单的半身像对话框罢了= =
#------------------------------------------------------------------------------
# ■ 用法一览
#     1:如何将半身像应用到游戏中?
#       ——如果想要把一个脸图替换成半身像,则需要找到这个脸图的编号,比如说拉尔
#           夫,就是Actor1的编号0,之后去在Graphics/Busts这个文件夹里面拷贝一个
#           叫做Actor1_0的图像,这个图像会被当做半身像替换原有图像。
#==============================================================================
# 2013.8.25 => 修复存档不能Bug (感谢小刀
#==============================================================================
$imported ||= {}
$imported[:LBQ_Bust]=true

module LBQ
  module Bust
    FOLDER="Busts"
    SUB1=[/【/,    "\\{\\c[6]-- "]
    SUB2=[/】/,    " --\\c[0]\\}"]

    TEXT_FOR_NEXT="[next]"
    TEXT_FOR_END ="[end]"

    INDENT=255 #半身像的缩进
  end
end

module Cache
  def self.busts(filename)
    load_bitmap("Graphics/#{LBQ::Bust::FOLDER}/", filename)
  end
end



class Sprite_Bust < Sprite_Base
  attr_accessor   :bust_graphics
  attr_accessor   :status

  def initialize(vp=nil)
    super(vp)
    @bust_graphics=nil
    @status=:nothing
  end

  def slide_in
    @status=:sliding_in
  end

  def slide_out
    @status=:sliding_out
    if $game_temp.do_not_slide_out
      @status=:slided_out
      set_pos
    end
  end




  def set_pos(slide_in=true)
    self.x=0 - self.bitmap.width
    self.y=Graphics.height-self.bitmap.height

    self.x=0 unless slide_in
  end


  def set_graphics(bust_graphics)
    self.bitmap=Cache.busts(bust_graphics)
  end



  def update
    super
    case @status
    when :nothing
      # Do Nothing
    when :sliding_in
      #Slide In
      self.x+=12
      if self.x>=0
        self.x=0
        @status=:slided_in
      end

    when :sliding_out
      self.x-=12
      if self.x<= -self.bitmap.width
        self.x= -self.bitmap.width
        @status=:slided_out
      end
      #Slide Out
    when :slided_in
      #Slided in
    when :slided_out
      #Sliede out
    end

  end


end



class Game_Temp
  attr_accessor   :bust_name
  attr_accessor   :bust
  attr_accessor   :have_bust
  attr_accessor   :do_not_slide_out

  alias lbq_bust_shot_game_message_init initialize
  def initialize
    lbq_bust_shot_game_message_init
    @bust_name=""
    @bust=nil
    @have_bust=false
    @do_not_slide_out=false
  end




end

class Game_Message
   #--------------------------------------------------------------------------
  # ● 添加内容
  #--------------------------------------------------------------------------
  def add(text)
    new_text=text.gsub(LBQ::Bust::SUB1[0],LBQ::Bust::SUB1[1])
    new_text2=new_text.gsub(LBQ::Bust::SUB2[0],LBQ::Bust::SUB2[1])
    if new_text2.include? LBQ::Bust::TEXT_FOR_NEXT
      new_text2.delete!(LBQ::Bust::TEXT_FOR_NEXT)
      $game_temp.do_not_slide_out=true
    end

    if new_text2.include? LBQ::Bust::TEXT_FOR_END
      new_text2.delete!(LBQ::Bust::TEXT_FOR_END)
      $game_temp.do_not_slide_out=false
    end
    @texts.push(new_text2)
  end
end


class Game_Interpreter
  alias lbq_bust_shot_command_101 command_101
  #--------------------------------------------------------------------------
  # ● 显示文字
  #--------------------------------------------------------------------------
  def command_101
    $game_temp.bust=nil
      unless @params[0].empty?
        if File.exist?("Graphics/#{LBQ::Bust::FOLDER}/#{@params[0]}_#{@params[1]}.png")
          $game_temp.have_bust=true
        else
          $game_temp.have_bust=false
          $game_temp.bust_name=""
        end
      end

    unless @params[3] == 2
      $game_temp.have_bust=false
    end

    if $game_temp.have_bust
      $game_temp.bust_name="#{@params[0]}_#{@params[1]}"
      $game_temp.bust=nil
      $game_temp.bust=Sprite_Bust.new
      $game_temp.bust.set_graphics($game_temp.bust_name)
      $game_temp.bust.z=888
      unless $game_temp.do_not_slide_out
        $game_temp.bust.set_pos
        $game_temp.bust.slide_in
      else
        $game_temp.bust.set_pos(false)
        $game_temp.bust.slide_in
      end
    end

    lbq_bust_shot_command_101
    if $game_temp.have_bust
        $game_temp.bust.slide_out
        Fiber.yield until $game_temp.bust.status==:slided_out
    end
    $game_temp.have_bust=false
    $game_temp.bust_name=""

  end


  alias lbq_bust_int_update update
  def update
    lbq_bust_int_update
    $game_temp.bust.update unless $game_temp.bust.nil?
  end

end


class Window_Message
  #--------------------------------------------------------------------------
  # ● 获取换行位置
  #--------------------------------------------------------------------------
  def new_line_x
    # 如果有头像
    unless $game_message.face_name.empty?
      value=112
      value=LBQ::Bust::INDENT unless $game_temp.bust_name.empty?
    # 木有
    else
      value=0
    end
    return value
  end
end


#~ class Window_Message
  #--------------------------------------------------------------------------
  # ● 翻页处理
  #--------------------------------------------------------------------------
#~   def new_page(text, pos)
#~     contents.clear
#~     draw_face($game_message.face_name, $game_message.face_index, 0, 0) if $game_temp.bust_name.empty?
#~     reset_font_settings
#~     pos[:x] = new_line_x
#~     pos[:y] = 0
#~     pos[:new_x] = new_line_x
#~     pos[:height] = calc_line_height(text)
#~     clear_flags
#~   end
#~ end

只看得懂z控制文字在最远,以便在最上面显示……在哪里修改xy就不太明白了……在不显示立绘的情况下,怎么让文字的位置回复到最左边呢?求教QAQ,谢谢

物品栏是想做出这种感觉的,不太懂怎么修改……


作者: RaidenInfinity    时间: 2016-10-25 12:06
你的第一个问题的解决方法主要是在这一段

RUBY 代码复制
  1. class Window_Message
  2.   #--------------------------------------------------------------------------
  3.   # ● 获取换行位置
  4.   #--------------------------------------------------------------------------
  5.   def new_line_x
  6.     # 如果有头像
  7.     unless $game_message.face_name.empty?
  8.       value=112
  9.       value=LBQ::Bust::INDENT unless $game_temp.bust_name.empty?
  10.     # 木有
  11.     else
  12.       value=0
  13.     end
  14.     return value
  15.   end
  16. end


因为并未提供工程,所以我只能凭着脚本作猜测。new_line_x这个方法,决定文字显示的X值。如果在事件指令中没有指定脸图,那么X值会是0。“在不显示立绘的情况下,怎么让文字的位置回复到最左边” 的这个问题,我不觉得有问题,这个得实际看到工程测试了才能理解。那么下列的这两行:

RUBY 代码复制
  1. value=112
  2. value=LBQ::Bust::INDENT unless $game_temp.bust_name.empty?


这个脚本呢,如果有提供立绘,那就使用 LBQ::Bust::INDENT 这个常量来决定X值,否则使用112(普通脸图)。
“字体离立绘太远”的这个问题,解决的方法有两种,一是更改常量:
RUBY 代码复制
  1. $imported ||= {}
  2. $imported[:LBQ_Bust]=true
  3.  
  4. module LBQ
  5.   module Bust
  6.     FOLDER="Busts"
  7.     SUB1=[/【/,    "\\{\\c[6]-- "]
  8.     SUB2=[/】/,    " --\\c[0]\\}"]
  9.  
  10.     TEXT_FOR_NEXT="[next]"
  11.     TEXT_FOR_END ="[end]"
  12.  
  13.     INDENT=255 #半身像的缩进 <----把255改成你觉得合适的X值 … 然后我要吐槽下LBQ大佬啊你为啥等号前后不加空格
  14.   end
  15. end


二就是舍弃常量,直接定义数值:
RUBY 代码复制
  1. value = 200 unless $game_temp.bust_name.empty? #把200改成你觉得合适的X值


至于第二个问题,“将默认的物品栏的排版和图片换成自己的素材”,没有详细的资讯(排版成怎么样?什么素材?之类的)大概是帮不了。
不过如果需要的话,可以使用论坛的私信功能联系我,可能可以帮上忙,定制所需的脚本。
作者: wangxiaojiav6    时间: 2016-10-25 13:09
RaidenInfinity 发表于 2016-10-25 12:06
你的第一个问题的解决方法主要是在这一段

非常感谢这么细致的回复,按照你的方法已经解决了。QWQ,谢谢你。
排版的话是希望能做出上面那个图的感觉,还在看论坛的教程,想看看能不能根据更改背景图片和窗口位置实现。(很喜欢深海囚人的菜单栏……)
再次感谢你的帮助QWQ,谢谢大神~~


作者: 魔法丶小肉包    时间: 2016-10-25 23:30
根据楼主给出的菜单要求↓
效果图:


脚本↓
RUBY 代码复制
  1. module MFXRB
  2.   ITEM = "ITEM"
  3.   SKILL= "MAGIC"
  4.   EQUIP= "EQI"
  5.   SAVE = "SAVE"
  6.   GEND = "SHUT DOWN"
  7.   SAVETEXT="CONTINUE"
  8.   FILE = "DATA"
  9.   FH   = "☆"
  10.   FHF  = "△"
  11. end
  12. module DataManager
  13.   def self.make_save_header
  14.     header = {}
  15.     header[:characters] = $game_party.characters_for_savefile
  16.     header[:playtime_s] = $game_system.playtime_s
  17.     header[:map] = $game_map.display_name
  18.     header[:lv] = $game_party.leader.level
  19.     header[:hp] = $game_party.leader.hp
  20.     header[:face] = $game_party.face_for_savefile
  21.     header
  22.   end
  23. end
  24. class Game_Party < Game_Unit
  25.   def face_for_savefile
  26.     battle_members.collect do |actor|
  27.       [actor.face_name, actor.face_index]
  28.     end
  29.   end
  30. end
  31. class Scene_Menu < Scene_MenuBase
  32.   def create_command_window
  33.     @command_window = Window_MenuCommand.new
  34.     @command_window.set_handler(:item,      method(:command_item))
  35.     @command_window.set_handler(:skill,     method(:command_personal))
  36.     @command_window.set_handler(:equip,     method(:command_personal))
  37.     @command_window.set_handler(:save,      method(:command_save))
  38.     @command_window.set_handler(:game_end,  method(:command_game_end))
  39.     @command_window.set_handler(:cancel,    method(:return_scene))
  40.   end
  41. end
  42. class Window_MenuCommand < Window_Command
  43.   def make_command_list
  44.     add_main_commands
  45.     add_original_commands
  46.     add_save_command
  47.     add_game_end_command
  48.   end
  49.   def add_main_commands
  50.     add_command(MFXRB::FH+MFXRB::ITEM,   :item,   main_commands_enabled)
  51.     add_command(MFXRB::FH+MFXRB::SKILL,  :skill,  main_commands_enabled)
  52.     add_command(MFXRB::FH+MFXRB::EQUIP,  :equip,  main_commands_enabled)
  53.   end
  54.   def add_save_command
  55.     add_command(MFXRB::FH+MFXRB::SAVE, :save, save_enabled)
  56.   end
  57.   def add_game_end_command
  58.     add_command(MFXRB::FH+MFXRB::GEND, :game_end)
  59.   end
  60. end
  61. class Window_MenuStatus < Window_Selectable
  62.   def draw_item(index)
  63.     actor = $game_party.members[index]
  64.     enabled = $game_party.battle_members.include?(actor)
  65.     rect = item_rect(index)
  66.     draw_item_background(index)
  67.     draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
  68.     draw_actor_name(actor, rect.x + 100, rect.y + 1)
  69.     draw_actor_class(actor, rect.x + 250, rect.y + 1)
  70.     draw_actor_level(actor, rect.x + 100, rect.y + line_height)
  71.     d_a_zt(actor,rect.x + 180, rect.y + line_height)
  72.     d_ah(actor, rect.x + 240, rect.y + line_height)
  73.     d_aexp(actor, rect.x + 100, rect.y + line_height*2)
  74.     d_am(actor, rect.x + 240, rect.y + line_height*2)
  75.   end
  76. end
  77. class Window_Base < Window
  78.   def d_a_zt(actor,x,y,width=100)
  79.       draw_text_ex(x,y,if actor.dead?;"死亡";else "正常";end)
  80.   end
  81.     def d_ah(actor, x, y)
  82.     draw_text(x, y, 30, line_height, Vocab::hp_a)
  83.     draw_text(x + 35, y, 100, line_height, actor.hp.to_s+"/"+actor.mhp.to_s)
  84.   end
  85.   def d_am(actor, x, y, width = 124)
  86.     draw_text(x, y, 30, line_height, Vocab::mp_a)
  87.     draw_text(x + 35, y, 100, line_height, actor.mp.to_s+"/"+actor.mmp.to_s)
  88.   end
  89.   def d_aexp(actor, x, y, width = 124)
  90.     s1 = actor.max_level? ? "-------" : actor.exp
  91.     s2 = actor.max_level? ? "-------" : actor.next_level_exp - actor.exp
  92.     draw_text(x, y, 30, line_height, "E")
  93.     draw_text(x + 35, y, 100, line_height, s1.to_s+"/"+s2.to_s)
  94.   end
  95. end
  96. class Scene_File < Scene_MenuBase
  97.   def visible_max
  98.     return 3
  99.   end
  100. end
  101. class Scene_Save < Scene_File
  102.   def help_window_text
  103.     MFXRB::FH+MFXRB::SAVETEXT+MFXRB::FH
  104.   end
  105. end
  106. class Window_SaveFile < Window_Base
  107.   def refresh
  108.     contents.clear
  109.     change_color(normal_color)
  110.     name = MFXRB::FHF+MFXRB::FILE + " #{@file_index + 1}"
  111.     draw_text(4, 0, 200, line_height, name)
  112.     @name_width = text_size(name).width
  113.     draw_party_face(140, y)
  114.     draw_map(-490, y + line_height)
  115.     draw_lv(-490, y + line_height*2)
  116.     draw_shp(-400, y + line_height*2)
  117.   end
  118.   def draw_map(x, y)
  119.     header = DataManager.load_header(@file_index)
  120.     return unless header
  121.     draw_text(x, y, width, line_height, header[:map], 2)
  122.   end
  123.   def draw_lv(x, y)
  124.     header = DataManager.load_header(@file_index)
  125.     return unless header
  126.     draw_text(x, y, width, line_height, "LV "+header[:lv].to_s, 2)
  127.   end
  128.   def draw_shp(x, y)
  129.     header = DataManager.load_header(@file_index)
  130.     return unless header
  131.     draw_text(x, y, width, line_height, "HP "+header[:hp].to_s, 2)
  132.   end
  133.   def draw_party_face(x, y)
  134.     header = DataManager.load_header(@file_index)
  135.     return unless header && header[:face]
  136.     header[:face].each_with_index do |data, i|
  137.       draw_face(data[0], data[1], x + i * 96, y)
  138.     end
  139.   end
  140. end

作者: wangxiaojiav6    时间: 2016-10-26 16:42
魔法丶小肉包 发表于 2016-10-25 23:30
根据楼主给出的菜单要求↓
效果图:

太感谢了!!!{:2_249:}好棒啊!!!QWQ,多谢大神拯救代码手残…………
作者: 魔法丶小肉包    时间: 2016-10-26 17:16
wangxiaojiav6 发表于 2016-10-26 16:42
太感谢了!!!好棒啊!!!QWQ,多谢大神拯救代码手残…………

不好意思,刚刚发现原来存档界面的是领队角色名而不是地图名,请把下面的脚本放在楼上脚本的下面
RUBY 代码复制
  1. module DataManager
  2.   def self.make_save_header
  3.     header = {}
  4.     header[:characters] = $game_party.characters_for_savefile
  5.     header[:playtime_s] = $game_system.playtime_s
  6.     header[:name] = $game_party.leader.name
  7.     header[:lv] = $game_party.leader.level
  8.     header[:hp] = $game_party.leader.hp
  9.     header[:face] = $game_party.face_for_savefile
  10.     header
  11.   end
  12. end
  13. class Window_SaveFile < Window_Base
  14.   def refresh
  15.     contents.clear
  16.     change_color(normal_color)
  17.     name = MFXRB::FHF+MFXRB::FILE + " #{@file_index + 1}"
  18.     draw_text(4, 0, 200, line_height, name)
  19.     @name_width = text_size(name).width
  20.     draw_party_face(140, y)
  21.     draw_an(-470, y + line_height)
  22.     draw_lv(-490, y + line_height*2)
  23.     draw_shp(-400, y + line_height*2)
  24.   end
  25.   def draw_an(x, y)
  26.     header = DataManager.load_header(@file_index)
  27.     return unless header
  28.     draw_text(x, y, width, line_height, header[:name], 2)
  29.   end
  30. end

作者: wangxiaojiav6    时间: 2016-10-26 17:47
魔法丶小肉包 发表于 2016-10-26 17:16
不好意思,刚刚发现原来存档界面的是领队角色名而不是地图名,请把下面的脚本放在楼上脚本的下面
module  ...

QWQ谢谢!!太感谢你了,已经放进去运行成功了~~大神受我一拜qwq





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1