查看: 2008|回复: 3

[已经过期] EngShun 的便民任务界面 窗口大小修改问题

[复制链接]
梦石
0
星屑
94
在线时间
157 小时
注册时间
2006-7-2
回帖
250
发表于 2015-10-28 10:53:13 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×

看到技术区的EngShun大神的便民任务界面用注释来添加觉得这个创意很好,想挪用到自己的游戏。
但是窗口的大小不同,其他的窗口都略作了调改,就右侧的文本输入窗口的大小不知道在哪里修改
应该是个小问题,但是难倒脚本盲啊
求指点

QQ截图20151028105503.png


[pre lang="ruby"]#==============================================================================#
#                          便民任务界面 by EngShun                             #
#                                                                              #
#    设置方法请参考范例                                                        #
#                                                                              #
#    效果说明:                                                                #
#    支持普通对话框效果                                                        #
#    \a[号码]     :更改左右对齐方式(0,1,2)。                                 #
#    \va[号码]    :更改垂直对齐方式(0,1,2)。                                 #
#    \itm[物品id] :物品数量                                                    #
#    \wpn[武器id] :武器数量                                                    #
#    \amr[防具id] :防具数量                                                    #
#    \eval{脚本}  :运行脚本                                                    #
#    \1line{内容} :把多行的内容显示为一行                                      #
#    \bold        :字体加粗,插入多一次关闭                                    #
#    \italic      :字体打斜,插入多一次关闭                                    #
#    \f[字体名称] :更改字体                                                    #
#    \s[号码]     :更改字体大小                                                #
#    \p[名称]     :插入图片                                                    #
#    \icon[名称]  :插入图标                                                    #
#                                                                              #
#==============================================================================#

#===============================================================================
# ■ 队伍
#===============================================================================
class Game_Party
  Mission = Struct.new(:id, :name, :info, :status)
  alias org_init_mission initialize if !defined?(org_init_mission)
  #--------------------------------------------------------------------------
  # ● 重定义初始化对象
  #--------------------------------------------------------------------------
  def initialize
    @mission = {}
    org_init_mission
  end
  def no_mission?
    return @mission == {}
  end
  def missions
    if no_mission?
      m = Mission.new(0,"没有错题","\n\n\n\\a[1]\\s[32]你还没有任何错题记录",0)
      return [m]
    end
    return @mission.values.sort_by {|m|m.id}
  end
  def get_mission(mission,info)
    return if @mission.has_key?(mission)
    id = missions[-1].id + 1
    @mission[mission] = Mission.new(id,mission,info,0)
  end
  def done_mission(mission)
    @mission[mission].status = 1 if @mission[mission].status == 0
  end
  def delete_mission(mission)
    @mission.delete(mission)
  end
  def fail_mission(mission)
    @mission[mission].status = 2 if @mission[mission].status == 0
  end
  def resume_mission(mission)
    @mission[mission].status = 0 if @mission[mission].status == 2
  end
  def done_all_mission
    @mission.each{|k,m|m.status = 1}
  end
  def update_mission(mission,info)
    @mission[mission].info = info
  end
  def add_mission_info(mission,info)
    @mission[mission].info += "\n" + info
  end
  def delete_all_mission
    @mission = {}
  end
  def resume_all_mission
    @mission.each{|k,m|m.status = 0 if m.status == 2}
  end
end

#===============================================================================
# ■ 任务列表窗口
#===============================================================================
class Window_Mission < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 165, 416)
    self.index = 0
    @mission = $game_party.missions
    @item_max = @mission.size
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    for i in 0...@mission.size
      t = @mission.status != 0
      self.contents.font.color = t ? disabled_color : normal_color
      text = @mission.name
      self.contents.draw_text(4, i * 32, 160, 32, text.to_s)
      self.contents.font.color = system_color
      self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "",1) unless $game_party.no_mission?
      if @mission.status == 1
        self.contents.font.color = crisis_color
        self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "√",1)
      elsif @mission.status == 2
        self.contents.font.color = knockout_color
        self.contents.draw_text(self.contents.width-32, i * 32, 32, 32, "×",1)
      end
    end
  end
end

#===============================================================================
# ■ 任务详情窗口
#===============================================================================
class Window_MissionInfo < Window_Base
  attr_accessor :wait
  attr_accessor :scroll_up
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize
    super(165,64,475,416)
    self.contents =  Bitmap.new(408, 384)
    @scroll_up = false
    @wait = 90
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
    return if self.contents.height <= 384
    return @wait -= 1 if @wait > 0
    self.oy += @scroll_up ? -1 : 1
    self.oy = 0 if self.oy < 0
    self.oy = oy_max if self.oy > oy_max
    if self.oy <= 0
      @scroll_up = false
      @wait = 60
    elsif self.oy >= oy_max
      @scroll_up = true
      @wait = 60
    end
  end
  #--------------------------------------------------------------------------
  # ● 滚动最大值
  #--------------------------------------------------------------------------
  def oy_max
    return self.contents.height - 384
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh(str)
    str = str.clone
    @scroll_up = false
    @wait = 120
    @ver_align = 1
    self.oy = 0
    bitmap_height = 0
    align = 0
    begin
      last_text = str.clone
      str.gsub!(/\\v\[(\d+)\]/i) { $game_variables[$1.to_i] }
      str.gsub!(/\\g/i) { $game_party.gold.to_s }
      str.gsub!(/\\itm\[(\d+)\]/i) { $game_party.item_number($1.to_i) }
      str.gsub!(/\\wpn\[(\d+)\]/i) { $game_party.weapon_number($1.to_i) }
      str.gsub!(/\\amr\[(\d+)\]/i) { $game_party.armor_number($1.to_i) }
      str.gsub!(/\\1line{(.+?)}/im) { $1.delete("\n") }
      str.gsub!(/\\eval{(.+?)}/im) { eval($1) }
    end until str == last_text
      str.gsub!(/\\n\[(\d+)\]/i) do
      $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
    end
    lines = str.split("\n")
    bitmaps = []
    lines.each do |line|
      bitmap,align = bitmap_line(line,align)
      w = bitmap.width
      h = bitmap.height
      bitmap2 = Bitmap.new(408,h)
      case align
      when 0
        x = 4
      when 1
        x = 204 - w / 2
      when 2
        x = 404 - w
      end
      bitmap_height += h
      bitmap2.blt(x,0,bitmap,Rect.new(0,0,w,h))
      bitmaps.push(bitmap2)
    end
    self.contents.dispose
    self.contents = Bitmap.new(408, bitmap_height < 384 ? 384 : bitmap_height)
    y = 0
    bitmaps.each do |bitmap|
      self.contents.blt(0,y,bitmap,Rect.new(0,0,408,bitmap.height))
      y += bitmap.height
    end
  end
  #--------------------------------------------------------------------------
  # ● 描绘内容
  #--------------------------------------------------------------------------
  def bitmap_line(str,old_align)
    w,h = get_wh(str.clone)
    w = 1 if w == 0
    bitmap = Bitmap.new(w,h)
    text = str
    align = old_align
    x = 0
    text.gsub!(/\\\\/) { "\000" }
    text.gsub!(/\\a\[([0-2])\]/i){ align = $1.to_i; "" }
    text.gsub!(/\\va\[([0-2])\]/i) { "\005[#{$1}]" }
    text.gsub!(/\\c\[(\d+)\]/i) { "\001[#{$1}]" }
    text.gsub!(/\\bold/i) { "\002" }
    text.gsub!(/\\italic/i) { "\003" }
    text.gsub!(/\\f\[(\w+)\]/i) { "\004[#{$1}]" }
    text.gsub!(/\\s\[(\d+)\]/i) { "\006[#{$1}]" }
    text.gsub!(/\\p\[(.+?)\]/i) { "\007[#{$1}]" }
    text.gsub!(/\\icon\[(.+?)\]/i){ "\201[#{$1}]" }
    while ((c = text.slice!(/./)) != nil)
      if c == "\000"
        c = "\\"
      end
      if c == "\001"
        text.sub!(/\[(\d+)\]/, "")
        color = $1.to_i
        if color >= 0 and color <= 9
          bitmap.font.color = text_color(color)
        elsif color == 8
          bitmap.font.color = disabled_color
        elsif color == 9
          bitmap.font.color = system_color
        end
        next
      end
      if c == "\002"
        bitmap.font.bold = !bitmap.font.bold
        next
      end
      if c == "\003"
        bitmap.font.italic = !bitmap.font.italic
        next
      end
      if c == "\004"
        text.sub!(/\[(\w+)\]/,"")
        bitmap.font.name = $1
        next
      end
      if c == "\005"
        text.sub!(/\[([0-2])\]/,"")
        @ver_align = $1.to_i
        next
      end
      if c == "\006"
        text.sub!(/\[(\d+)\]/,"")
        bitmap.font.size = $1.to_i
        next
      end
      if c == "\007" or c == "\201"
        text.sub!(/\[(.+?)\]/,"")
        pic = c == "\007" ? RPG::Cache.picture($1) : pic = RPG::Cache.icon($1)
        r = Rect.new(0,0,pic.width,pic.height)
        y = h / 2 - pic.height / 2
        y = 2 if @ver_align == 0
        y = (h - pic.height - 2) if @ver_align == 2
        bitmap.blt(x+2,y,pic,r)
        x += pic.width + 4
        next
      end
      dh = @ver_align != 1 ? bitmap.text_size(c).height : h
      y = @ver_align == 2  ? h - dh - 2 : 2
      y = 0 if @ver_align == 1
      bitmap.draw_text(x,y,w,dh,c)
      x += bitmap.text_size(c).width
    end
    return bitmap.clone,align
  end
  #--------------------------------------------------------------------------
  # ● 计算高与宽
  #--------------------------------------------------------------------------
  def get_wh(str)
    bitmap = Bitmap.new(160,160)
    w = 0
    h = 32
    text = str
    text.gsub!(/\\\\/) { "\000" }
    text.gsub!(/\\a\[([0-2])\]/i) { "" }
    text.gsub!(/\\c\[(\d+)\]/i) { "" }
    text.gsub!(/\\bold/i) { "" }
    text.gsub!(/\\italic/i) { "" }
    text.gsub!(/\\f\[(\w+)\]/i) { "\001[#{$1}]" }
    text.gsub!(/\\s\[(\d+)\]/i) { "\002[#{$1}]" }
    text.gsub!(/\\p\[(.+?)\]/i) { "\003[#{$1}]" }
    text.gsub!(/\\icon\[(.+?)\]/i) { "\004[#{$1}]" }
    while ((c = text.slice!(/./)) != nil)
      if c == "\000"
        c = "\\"
      end
      if c == "\001"
        text.sub!(/\[(\w+)]/,"")
        bitmap.font.name = $1
        next
      end
      if c == "\002"
        text.sub!(/\[(\d+)]/,"")
        bitmap.font.size = $1.to_i
        next
      end
      if c == "\003" or c == "\004"
        text.sub!(/\[(.+?)\]/,"")
        pic = c == "\003" ? RPG::Cache.picture($1) : pic = RPG::Cache.icon($1)
        w += pic.width + 4
        h = pic.height + 4 if pic.height + 4 > h
        next
      end
      w += bitmap.text_size(c).width
      h = bitmap.text_size(c).height + 4 if bitmap.text_size(c).height + 4 > h
    end
    h = h < 32 ? 32 : h
    return w,h
  end
end

#===============================================================================
# ■ 任务界面
#===============================================================================
class Scene_Mission
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize
    @last_scene = $scene
  end
  #--------------------------------------------------------------------------
  # ● 主处理
  #--------------------------------------------------------------------------
  def main
    @mission = $game_party.missions
    @window1 = Window_Base.new(0,0,165,64)
    @window1.contents = Bitmap.new(168,32)
    @window1.contents.draw_text(0,0,140,32,"错题",1)
    @window2 = Window_Base.new(165,0,475,64)
    @window2.contents = Bitmap.new(408,32)
    @window2.contents.draw_text(0,0,458,32,"错题说明",1)
    @mission_window = Window_Mission.new
    @mission_window.index = @mission.size - 1
    @index = @mission_window.index
    @info_window = Window_MissionInfo.new
    @info_window.refresh(@mission[@index].info)
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @window1.dispose
    @window2.dispose
    @mission_window.dispose
    @info_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    @mission_window.update
    @info_window.update
    if @index != @mission_window.index
      @index = @mission_window.index
      @info_window.refresh(@mission[@index].info)
    end
    return update_mission if @mission_window.active
    update_info
  end
  #--------------------------------------------------------------------------
  # ● 刷新任务
  #--------------------------------------------------------------------------
  def update_mission
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @mission_window.active = false
      @info_window.oy = 0
    elsif Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = @last_scene
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新人物详情
  #--------------------------------------------------------------------------
  def update_info
    @info_window.wait = 90
    if Input.press?(Input::UP)
      @info_window.oy -= 3
      @info_window.oy = 0 if @info_window.oy < 0
    elsif Input.press?(Input::DOWN)
      @info_window.oy += 3
      @info_window.oy = @info_window.oy_max if @info_window.oy > @info_window.oy_max
    elsif Input.repeat?(Input::L)
      $game_system.se_play($data_system.cursor_se)
      @mission_window.index -= 1
      @mission_window.index = $game_party.mission.size - 1 if @mission_window.index < 0
    elsif Input.repeat?(Input::R)
      $game_system.se_play($data_system.cursor_se)
      @mission_window.index += 1
      @mission_window.index = 0 if @mission_window.index >= $game_party.mission.size
    elsif Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @mission_window.active = true
      @info_window.scroll_up = false
      @info_window.oy = 0
    end
  end
end

#===============================================================================
# ■ 事件处理器
#===============================================================================
class Interpreter
  alias orig_ec_mission execute_command if !defined?(orig_ec_mission)
  #--------------------------------------------------------------------------
  # ● 重定义执行事件命令
  #--------------------------------------------------------------------------
  def execute_command
    if @index >= @list.size - 1
      command_end
      return true
    end
    @parameters = @list[@index].parameters
    return command_108 if @list[@index].code == 108
    return orig_ec_mission
  end
  #--------------------------------------------------------------------------
  # ● 注释
  #--------------------------------------------------------------------------
  def command_108
    case @list[@index].parameters[0]
    when (/^删除错题\[(\w+)\]$/)
      $game_party.delete_mission($1)
      return true
    when (/^完成错题\[(\w+)\]$/)
      $game_party.done_mission($1)
      return true
    when "删除所有错题"
      $game_party.delete_all_mission
      return true
    when "完成所有错题"
      $game_party.done_all_mission
      return true
    when (/^放弃错题\[(\w+)\]$/)
      $game_party.fail_mission($1)
      return true
    when (/^恢复错题\[(\w+)\]$/)
      $game_party.resume_mission($1)
      return true
    when "恢复所有错题"
      $game_party.resume_all_mission
      return true
    end
    text = @list[@index].parameters[0]
    loop do
      if @list[@index+1].code == 108 or @list[@index+1].code == 408
        text += "\n" + @list[@index+1].parameters[0]
      else
        break
      end
      @index += 1
    end
    split = text.split("\n")
    if (split[0] == "错题设置" or split[0] == "错题更新" or split[0] == "错题说明") and split.size >= 3
      info , name = split[2] , split[1]
      if split.size >= 4
        for i in 3...split.size
          info += "\n" + split
        end
      end
      $game_party.get_mission(name,info) if split[0] == "错题设置"
      $game_party.update_mission(name,info) if split[0] == "错题更新"
      $game_party.add_mission_info(name,info) if split[0] == "追加说明"
    end
    return true
  end
end[/pre]
甘泉幻想物语 试玩版4.0
https://rpg.blue/forum.php?mod=viewthread&tid=369490&page=1&extra=#pid2534710
梦石
0
星屑
1788
在线时间
1313 小时
注册时间
2012-8-4
回帖
724
发表于 2015-10-28 14:18:45 | 显示全部楼层
是不是字体大小大了些

点评

貌似这个脚本原本就是基于xp的诶。。  发表于 2015-10-28 23:47
VX的画面分辨率是544×416 XP是640X480,不知道是不是分配的问题  发表于 2015-10-28 22:31
字体大小倒还行,就是右边被遮掉了两个字不知道什原因。  发表于 2015-10-28 19:00
回复

使用道具 举报

路人党员

梦石
0
星屑
52
在线时间
2276 小时
注册时间
2010-12-30
回帖
3011
发表于 2015-10-28 23:25:18 | 显示全部楼层
你用的不是最新版本,最新版本有自动换行

点评

右边的框到外面去了,但是能显示字的范围还是没有变。  发表于 2015-10-29 13:39
initialize里的super  发表于 2015-10-29 00:29
确实能用了,但是自动换行功能很纠结诶,不需要换行的也会自动换。 大大你还是教我一下之前那个怎么该文本框大小吧,或者怎么改字体大小  发表于 2015-10-29 00:21
那是论坛的bug,把那[email]和[/email]去掉就行了  发表于 2015-10-28 23:53
文本书写的大小吗?  发表于 2015-10-28 23:44
本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到engshun@1ppl.me咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复

使用道具 举报

梦石
0
星屑
463
在线时间
193 小时
注册时间
2014-8-25
回帖
30
发表于 2015-10-29 09:13:37 | 显示全部楼层
126行括号里面的数字改一下就行了

点评

改了这行数据只能调整框的大小,但是右侧的字还是显示不出来。  发表于 2015-10-29 13:40
黄海有狂人,欲与日月争,还我三万六千晨
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部