扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 131|回复: 0

[转载发布] GDC - Message

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    昨天 18:01
  • 签到天数: 114 天

    连续签到: 4 天

    [LV.6]常住居民II

    2338

    主题

    403

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    10622
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    13391

    灌水之王

    发表于 2024-4-19 17:35:12 | 显示全部楼层 |阅读模式
    =begin



      GDC - Message  GDC = Goldencolor  = =找戳。。。
           = =b未完善啊。还有部分功能没有写出来。。。时间。不够。这个工程写好好了N9。
    没有来得及完善。算了。有兴趣的朋友帮忙加强完善。


          
    准备把那个漫画对话框加强一下。。结果一看。那个什么啊。啊。咋么可以那样写。
    因为是RMXP Standard Development Kit (SDK)基础上扩展的。。
    看不懂。。

           算了等下次更新。= =b我坑坑坑
          
                                                V1.0    by Goldencolor

    注:本脚本和公共事件开关变量使用起来会更加方便。如:用变量来控制显示头像。开关
    来控制各种文字效果。
    还有那个初始化配置不要乱改。
    颜色的设置 在text_color方法内。  ●  枚举颜色  

       
    ┏━━━━ 使用说明 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    ┠──── Class - 显示文章 ──────────────────────────
    ┃ \V[n]          - N = 变量ID 显示第 n 号变量中的值。

    ┃ \C[n]          - N = 枚举颜色值  之后的文字用第 n 号的颜色显示。
    ┃                 定义枚举颜色:def text_color(n)

    ┃ \G             - 显示金钱窗口

    ┃ \F[name]       - name = 图片名字。显示一张图片在信息框里面.注:Pictures文件内

    ┃ \FL            - 设置显示图片的位置在左边。

    ┃ \FR            - 设置显示图片的位置在右边。

    ┃ \BT[name]      - name = 战斗图名字。显示一张战斗图。注:Battlers 文件内

    ┃ \BL            - 设置战斗图片的位置在左边。

    ┃ \BR            - 设置战斗图片的位置在右边。

    ┃ \H             - 可以和NPC对话的时候走动~-_-!! 具体实现方法见Game_Player
    ┃                - 修改部分地方就可以实现了。

    ┃ \NA[name]      - name =你要设定角色的名字。 会在左上角出现一个名字窗口(俗称盒子= =b)

    ┃ \MW[N]         -  改变窗口的宽度\MH   n=数字

    ┃ \MH[N]         -  改变窗口的高度\MH   n=数字

    ┃ \B             - 之后的文字为粗体 \i 文字 \i 这样可以只让文字2个字呈现粗体

    ┃ \I             - 之后的文字为斜体 重复2个可以取消效

    ┃ \U             - 下划线~

    ┃ \SH            - 文字带有投影效果

    ┃ \WX[n]         - 信息窗口的X位置  N=数字

    ┃ \WY[n]         - 信息窗口的X位置  N=数字

    ┃ \TP[n]         - 出现在目标身上。N = EVENT ID 。0指角色。

    ┃ \MW[n]         - 层叠窗口 N=数字。

    ┃ \MT[n]         - 自动根据文字内容调整大小。0=不适用。1=使用。

    ┃ \SCO           — 实现对话框卷动效果(像读书系统一样自动翻页阅读)

    ┃ \SCO           — 停止卷动
    ┃   
    ┃ \CD            — 显示多窗口。可以多人同时说话 注:使用如果使用这个,
    ┃                — 请设置好每个对话框的位置否则会重叠

    ┃ \CT[ n ]       — 等待n帧数  N=数字

    ┃ \CL            — 停止等待

    ┃ \Sk         — 显示技能图标及名字  I = 技能ID

    ┃ \WP         — 显示物品图标及名字  I = 物品ID

    ┃ \WQ         — 显示武器图标及名字  I = 武器ID



    ┃= =b其他没有来得及写。下次补上









    ┠──── Class - 事件 ────────────────────────────

    ┃ 一坨。。。。。。。。。。。。。。。。。。。。。。。。。。。
    ┃ 有时间在补上吧。啊

















    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    =end
    #==============================================================================
    # ■ Game_Temp
    #------------------------------------------------------------------------------
    #  在没有存档的情况下,处理临时数据的类。这个类的实例请参考
    # $game_temp 。
    #==============================================================================
    class Game_System
      
      alias mrmo_settings_ms_system_initialize initialize #别名
      #--------------------------------------------------------------------------
      # ● 定义实例变量
      #--------------------------------------------------------------------------
      attr_accessor :letterBYletter
      attr_accessor :letter_speed
      attr_accessor :letter_se
      attr_accessor :window_x
      attr_accessor :window_y
      attr_accessor :player_skip
      attr_accessor :window_to_text
      attr_accessor :message_width
      attr_accessor :message_height
      attr_accessor :nameBox_opacity
      attr_accessor :nameBox_to_window_opacity
      attr_accessor :message_font
      attr_accessor :hover_message
      attr_accessor :face_graphic
      attr_accessor :face_justify
      attr_accessor :battler_graphic
      attr_accessor :battler_justify
      attr_accessor :multiple_windows
      attr_accessor :scrolling_text
      attr_accessor :scroll_speed
      attr_accessor :scroll_lines
      attr_accessor :auto_scroll
      attr_accessor :close_on_display
      attr_accessor :close_on_time
      #--------------------------------------------------------------------------
      # ● 初始化对像
      # 下面是对整个对话框的配置
      #--------------------------------------------------------------------------
      def initialize
       
        mrmo_settings_ms_system_initialize


        @nameBox_opacity = 0      # 名字窗口不透明度数
       
        @nameBox_to_window_opacity = true # true对名字框不设置不透明,false设置
                                           
        @letterBYletter = true      # 如果真可以用\lbl控制显示样式。
        #0=直接在上面显示文本。其他以打字方式出现
       
        @letter_speed = 2            # 控制对话框的速度
        #建议变量控制起来
                                    
        @player_skip = true          #如果按下决定键可以让对话跳过吗?
        #\ps[0]  可以跳过。\PS[1]不可以
                                  
                                    
        @letter_se = ""#"033-Switch02"   对话打字效果播放的SE音效
        #如果不想使用""就可以了
                                    
        @window_x  = 80                  #对话框的X位置。\wx
                                    
        @window_y  = 304                 #对话框的X位置。\wy
                                    
        @window_to_text =false            #使用模式对话框。对话框会根据文本大小自动调整。
        #建议用开关控制起来               #\mt[0]
                                          
        @message_width = 480              # 信息窗口的宽度
        # \mw[width]
                                    
        @message_height = 160             # 信息窗口的高度
        # \mh[height]
                                           
        @message_font = Font.default_name  # 信息框字体类型
        # \ft[name]
                            
        @hover_message = false             # 对话框的时候玩家可以移动
        # \h
                
        @face_graphic = ""                 # 信息框显示图片。这个用变量控制起来最好用了
        # \f[name]
        # 注:在 picture
                                           
        @face_justify = 0                  # 0 = 左边 1 = 右边  #图片
        # \fl = 左边 \fr = 右边
                                           
        @battler_justify = 0               # 0 = 左边 1 = 右边
        # \bl = 左边 \br = 右边
                
        @battler_graphic = ""              #显示战斗图。   
        # \bt[name]
       
        @scroll_speed = 30                 # 卷动速度。数字越高越慢。
       
        @scroll_lines = 4                  # 卷动数字
       
        @close_on_display = false          # 结束等待。
        # \cl
        @close_on_time = nil               # 等待时间
        # \ct[time]
        #############下面东西不要修改。                                    
        @multiple_windows = []
        @scrolling_text = nil     
        @auto_scroll = true   #决定键
      end
      #--------------------------------------------------------------------------
      # ●  枚举颜色。可以自定义颜色\C[n] 文字用第 n 号的颜色显示。
      #---------------------------------------------------------------------------
      #  例:
      #  when N Color.new(R,R,R,A)
      #  N = 你枚举的数
      #  R = RGB标准值
      #  A = 颜色透明度
      #--------------------------------------------------------------------------
      def text_color(n)
        case n
        when 0
          return Color.new(255, 255, 255, 255) # 白色
        when 1
          return Color.new(128, 128, 255, 255) # 黑色
        when 2
          return Color.new(255, 128, 128, 255) # 红色
        when 3
          return Color.new(128, 255, 128, 255) # 绿色
        when 4
          return Color.new(128, 255, 255, 255) # 浅蓝
        when 5
          return Color.new(255, 128, 255, 255) # 紫色
        when 6
          return Color.new(255, 255, 128, 255) # 黄色
        when 7
          return Color.new(192, 192, 192, 255) # 灰色
          #when 8
          #return Color.new(RED,BLUE,GREEN,ALPHA)#枚举标准格式
        else
          normal_color
        end
      end
      
      #--------------------------------------------------------------------------
      # ● 定义实例变量(如果想要添加:实例Name)
      #--------------------------------------------------------------------------
      attr_accessor :letterBYletter, :letter_speed, :letter_se, :window_x, :window_y,
        :player_skip, :window_to_text, :message_width, :message_height, :nameBox_opacity,
        :nameBox_to_window_opacity, :message_font, :hover_message, :face_graphic,
        :face_justify, :battler_graphic, :battler_justify, :multiple_windows,
        :scrolling_text, :scroll_speed, :scroll_lines, :auto_scroll, :close_on_display,
        :close_on_time
    end

    class Window_Message < Window_Selectable
      #--------------------------------------------------------------------------
      attr_accessor :text
      attr_accessor :messboxStyle
      attr_accessor :messboxName
      
      #--------------------------------------------------------------------------
      #  ● 初始化对像
      #--------------------------------------------------------------------------
      def initialize
        super(80, 304, $game_system.message_width, $game_system.message_height)
        self.contents = Bitmap.new(width - 32, height - 32)
        self.visible = false
        self.z = 9998
        @fade_in = @fade_out = @contents_showing = false
        @cursor_width = 0
        self.active = false
        self.index = -1
        @lbl_count = @face_width = @battler_width = 0
        @name_box = Window_NameBoxMd.new
        # 空文本
        @text = nil
      end
      #--------------------------------------------------------------------------
      #  ● 释放
      #--------------------------------------------------------------------------
      def dispose
        terminate_message
        $game_temp.message_window_showing = false
        @input_number_window.dispose if @input_number_window != nil
        @name_box.dispose
        super
      end
      #--------------------------------------------------------------------------
      # ● 处理信息结束
      #--------------------------------------------------------------------------
      def terminate_message
        self.active = false
        self.pause = false
        self.index = -1
        self.contents.clear
        ####
        $game_system.hover_message = false
        # 清除显示中标志
       
        @contents_showing = false
       
        # 呼叫信息调用
        $game_temp.message_proc.call if $game_temp.message_proc != nil
       
        # 清除文章、选择项、输入数值的相关变量
        $game_temp.message_text = nil
        $game_temp.message_proc = nil
        $game_temp.choice_start = 99
        $game_temp.choice_max = 0
        $game_temp.choice_cancel_type = 0
        $game_temp.choice_proc = nil
        $game_temp.num_input_start = 99
        $game_temp.num_input_variable_id = 0
        $game_temp.num_input_digits_max = 0
       
        # 开放金钱窗口
        if @gold_window != nil
          @gold_window.dispose
          @gold_window = nil
        end
        # 其他
        @lbl_count = 0
        @temp_skip = false
        $game_system.close_on_display = false
        $game_system.close_on_time = nil
        @name_box.visible = false
        # Text
        @text = nil
        $game_system.scrolling_text = nil
        # 多重窗口
        if !$game_system.multiple_windows.include?(self)
          for i in 0..$game_system.multiple_windows.size
            w = $game_system.multiple_windows
            next if w.nil?
            w.terminate_message
            w.dispose
          end
          $game_system.multiple_windows = []
        end
        # ShowImamgs =v-!
        self.contents.dispose
        self.contents = Bitmap.new(width - 32, height - 32)
        self.oy = 0
        @scroll_up = nil
      end
      #--------------------------------------------------------------------------
      # ● 刷新
      #--------------------------------------------------------------------------
      def refresh
        self.contents.clear
        self.contents.font.color = normal_color
        @scroll_up = nil
        x = y = 0
        @cursor_width = 0
        # 到选择项的下一行字
        x = 8 if $game_temp.choice_start == 0
        # 有等待显示的文字的情况下
        if $game_temp.message_text != nil
          @text = $game_temp.message_text if @text.nil?
          @saved_text = @text
          #调整改变窗口大小
          modify_window
          #开始文本处理~
          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     
          #跳动
          @text.gsub!(/\\[Pp][Ss]\[([0-9]+)\]/) do
            bool = $1.to_i
            $game_system.player_skip = (bool == 0 ? false : true)
            ""
          end
          # 为了方便、将 "\\\\" 变换为 "\000"
          @text.gsub!(/\\\\/) { "\000" }
          # "\\C" 变为 "\001" 、"\\G" 变为 "\002"
          @text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
          @text.gsub!(/\\[Gg]/) { "\002" }
          # lbl
          @text.gsub!(/\\[Ll][Bb][Ll]\[([0-9]+)\]/) { "\003[#{$1}]" }
          # lse =w= 音效!
          @text.gsub!(/\\[Ss][Ee]\[(.*?)\]/) { "\004[#{$1}]" }
          # ls
          @text.gsub!(/\\[Ll][Ss]\[([0-9]+)\]/) { "\005[#{$1}]" }
          # 图标
          @text.gsub!(/\\[Ii][Cc]\[(.*?)\]/) { "\015[#{$1}]" }
          # 物品图标
          @text.gsub!(/\\[Ww][Pp]\[([0-9]+)\]/) {
            item = $data_items[$1.to_i]
          "\016[#{$1}]"+item.name }
          # 武器图标
          @text.gsub!(/\\[Ww][Qq]\[([0-9]+)\]/) {
            item = $data_weapons[$1.to_i]
            "\017[#{$1}]" + item.name
          }
          # 防具图标
          @text.gsub!(/\\[Dd][Ff]\[([0-9]+)\]/) {
            item = $data_armors[$1.to_i]
            "\018[#{$1}]" + item.name
          }
          # 技能图标
          @text.gsub!(/\\[Ss][Kk]\[([0-9]+)\]/) {
            item = $data_skills[$1.to_i]
            "\019[#{$1}]"+ item.name
          }
          # 字体
          @text.gsub!(/\\[Ff][Tt]\[(.*?)\]/) { "\013[#{$1}]" }
          # b - 粗体
          @text.gsub!(/\\[Bb]/) { "\006" }
          # i - 斜体字
          @text.gsub!(/\\[Ii]/) { "\007" }
          # st - 特殊字符
          @text.gsub!(/\\[Tt][Ss]/) { "\010" }
          # u - 文字下划线
          @text.gsub!(/\\[Uu]/) { "\011" }
          # sh - 文字影子
          @text.gsub!(/\\[Yy][Zz]/) { "\014" }
          # 等待?帧数 \CT[帧数]
          @text.gsub!(/\\[Cc][Tt]\[([0-9]+)\]/) do
            $game_system.close_on_time = $1.to_i
            ""
          end
          # 停止等待
          @text.gsub!(/\\[Cc][Ll]/) do
            $game_system.close_on_display = true
            ""
          end
          #= =b这个暂时丢掉不用。以后更新在、、
          #      @text.gsub!(/\\[Pp][Ee]/) { "#{$game_player.social.personality}" }
          if $game_system.face_graphic != ""
            bitmap = RPG::Cache.picture($game_system.face_graphic)
            if $game_system.face_justify == 0
              self.contents.blt(0, y + 4, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
            else
              self.contents.blt(self.width-bitmap.width-32, y + 4, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
            end
            @face_width = bitmap.width
            x = 0
            x += @face_width if $game_system.face_justify == 0
          else
            @face_width = 0
          end
          # 显示Battle
          if $game_system.battler_graphic != ""
            bitmap = RPG::Cache.battler($game_system.battler_graphic,0)
            if $game_system.battler_justify == 0
              self.contents.blt(0, y + 4, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
            else
              self.contents.blt(self.width-bitmap.width-32, y + 4, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
            end
            @battler_width = bitmap.width
            x = 0
            x += @battler_width if $game_system.battler_justify == 0
          else
            @battler_width = 0
          end
          #循环获取文本。
          while ((c = @text.slice!(/./m)) != nil)#54就可用了
            # 卷动情况全解!!!!!独家啊
            
            if !$game_system.scrolling_text.nil?
              if !@scroll_up.nil?
                if @scroll_up == y
                  scroll_frames = $game_system.scroll_speed
                  # 等待。。。。等啊等啊
                  while scroll_frames > 0
                    scroll_frames -= 1
                  end
                  @scroll_up = y+1
                  auto_s += 1
                  @temp_skip = false
                  if !$game_system.auto_scroll and auto_s == 4
                    auto_s = 0
                    #循环
                    loop do
                      #刷新游戏画面
                      Graphics.update
                      # Player Skip
                      Input.update         
                      #按下C停止跳动
                      if Input.trigger?(Input::C)
                        break
                      end           
                    end
                  end
                  #向上卷动
                  self.oy+=32
                end
              else
                auto_s = 0
                self.oy -= 32*3
                @scroll_up = 1
              end
            end
            # \lbl 的情况下卷动
            if c == "\003"
              @text.sub!(/\[([0-9]+)\]/, "")
              bool = $1.to_i
              $game_system.letterBYletter = (bool == 0 ? false : true)
              next
            end
            # \ls 的情况下
            if c == "\005"
              @text.sub!(/\[([0-9]+)\]/, "")
              bool = $1.to_i
              $game_system.letter_speed = bool
              next
            end
            # \lse 的情况下
            if c == "\004"
              @text.sub!(/\[(.*?)\]/, "")
              $game_system.letter_se = $1.to_s
              next
            end
            if $game_system.letterBYletter and !@temp_skip
              @lbl_count = $game_system.letter_speed
              # 循环
              while @lbl_count > 0
                # 刷新画面
                Graphics.update
                if $game_system.player_skip
                  Input.update         
                  if Input.trigger?(Input::C)
                    @temp_skip = true
                  end           
                end
                #更新计数
                @lbl_count -= 1
              end
              if $game_system.letter_se != ""
                Audio.se_play("Audio/SE/" + $game_system.letter_se, 100, 100)
              end
            end
            # \\ 的情况下
            if c == "\000"
              # 还原为本来的文字
              c = "\\"
            end
            # \C[n] 的情况下
            if c == "\001"
              # 更改文字色
              @text.sub!(/\[([0-9]+)\]/, "")
              color = $1.to_i
              if color >= 0 and color = $game_temp.choice_start
                @cursor_width = [@cursor_width, x].max
              end
              # y 加 1
              y += 1
              x = 0
              x += @face_width if $game_system.face_justify == 0
              x += @battler_width if $game_system.battler_justify == 0
              # 刷新选择项及光标的高
              if y >= $game_temp.choice_start
                index = y-$game_temp.choice_start
                cursor_width = self.width / 2 - 32
                x = index % 2 * (cursor_width + 32) + 8
              end
              # 下面的文字
              next
            end
            # 图标的情况下
            if c == "\015"
              @text.sub!(/\[(.*?)\]/, "")
              bitmap = RPG::Cache.icon($1.to_s)
              self.contents.blt(x, 32*y + 4, bitmap, Rect.new(0, 0, 24, 24))
              # x 为要描绘文字的加法运算
              x += 24
              next
            end
            # 物品图标的情况下
            if c == "\016"
              @text.sub!(/\[([0-9]+)\]/, "")
              name = $data_items[$1.to_i]
              next if name.nil?
              bitmap = RPG::Cache.icon(name.icon_name)
              self.contents.blt(x, 32*y + 4, bitmap, Rect.new(0, 0, 24, 24))
              # x 为要描绘文字的加法运算
              x += 24
              next
            end
            # 武器图标的情况下
            if c == "\017"
              @text.sub!(/\[([0-9]+)\]/, "")
              name = $data_weapons[$1.to_i]
              next if name.nil?
              bitmap = RPG::Cache.icon(name.icon_name)
              self.contents.blt(x, 32*y + 4, bitmap, Rect.new(0, 0, 24, 24))
              # x 为要描绘文字的加法运算
              x += 24
              next
            end
            # 防具图标情况下
            if c == "\018"
              @text.sub!(/\[([0-9]+)\]/, "")
              name = $data_armors[$1.to_i]
              next if name.nil?
              bitmap = RPG::Cache.icon(name.icon_name)
              self.contents.blt(x, 32*y + 4, bitmap, Rect.new(0, 0, 24, 24))
              # x 为要描绘文字的加法运算
              x += 24
              next
            end
            # 技能图标的情况下
            if c == "\019"
              @text.sub!(/\[([0-9]+)\]/, "")
              index = $1.to_i
             # name = $data_skills[$1.to_i]
              item = $data_skills[index]
              next if name.nil?
              icon = RPG::Cache.icon(item.icon_name)
              bitmap = RPG::Cache.icon(name.icon_name)
              self.contents.blt(x, 32*y + 4, bitmap, Rect.new(0, 0, 24, 24))
              #self.contents.blt(@x + 2, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
              # x 为要描绘文字的加法运算
              x += 24
              next
            end
            # 描绘文字
            self.contents.draw_text(4 + x, 32 * y, 40, 32, c) if y < $game_temp.choice_start
            index = y - $game_temp.choice_start
            self.contents.draw_text(4 + x, (index/2*32)+((y-index)*32), 40, 32, c) if y >= $game_temp.choice_start
            # x 为要描绘文字的加法运算
            x += self.contents.text_size(c).width
          end
        end
        self.oy += 32 if !$game_system.scrolling_text.nil?
        # 选择项的情况
        if $game_temp.choice_max > 0
          @item_max = $game_temp.choice_max
          self.active = true
          @column_max = 2 if $game_temp.choice_max > 1
          self.index = 0
        end
        # 输入数值的情况
        if $game_temp.num_input_variable_id > 0
          digits_max = $game_temp.num_input_digits_max
          number = $game_variables[$game_temp.num_input_variable_id]
          @input_number_window = Window_InputNumber.new(digits_max)
          @input_number_window.number = number
          @input_number_window.x = self.x + 8
          @input_number_window.y = self.y + $game_temp.num_input_start * 32
        end
        if $game_system.close_on_display
          if $game_temp.choice_max > 0
            $game_system.se_play($data_system.decision_se)
            $game_temp.choice_proc.call(self.index)
          end
          terminate_message
        end
        if $game_system.close_on_time != nil
          loop do
            Graphics.update
            $game_system.close_on_time -= 1
            break if $game_system.close_on_time  0
            $game_system.se_play($data_system.decision_se)
            $game_temp.choice_proc.call(self.index)
          end
          terminate_message
        end
      end
      #--------------------------------------------------------------------------
      # ● 改变窗口
      #--------------------------------------------------------------------------
      #   有关控制信息窗口的都在这里
      #--------------------------------------------------------------------------
      def modify_window
        # 改变窗口的宽度
        @text.gsub!(/\\[Mm][Ww]\[([0-9]+)\]/) do
          $game_system.message_width = self.width = $1.to_i
          ""
        end
        # 改变窗口的高度\MH
        @text.gsub!(/\\[Mm][Hh]\[([0-9]+)\]/) do
          $game_system.message_height = self.height = $1.to_i
          ""
        end
        # 窗口的大小根据文本长度改变\Mt 模态窗口
        @text.gsub!(/\\[Mm][Tt]\[([0-9]+)\]/) do
       
          bool = $1.to_i
          $game_system.window_to_text = (bool == 0 ? false : true)
          ""
        end   
        if $game_system.window_to_text
          size = 0
          for string in (@text.clone).split("\n")
            next if string.nil?
            w = contents.text_size(string).width+32
            size = w+32 if size+32 < w
          end
          self.width = size
          self.width = size*2 if $game_temp.choice_start == 0
          self.height = (@text.clone).split("\n").size * 32 + 32
          self.height = self.height/2 + 32 if $game_temp.choice_start == 0
          self.contents.dispose
          if $game_system.scrolling_text.nil?
            self.contents = Bitmap.new(width - 32, height - 32)
          else
            h = ($game_temp.message_text.clone).split("\n").size * 32 + 32
            self.contents.dispose
            self.contents = Bitmap.new(width - 32, h+32)
          end
        else
          self.width = $game_system.message_width
          self.height = $game_system.message_height
          if $game_system.scrolling_text.nil?
            self.contents = Bitmap.new(width - 32, height - 32)
          else
            h = ($game_temp.message_text.clone).split("\n").size * 32 + 32
            self.contents.dispose
            self.contents = Bitmap.new(width - 32, h+32)
          end
        end
        # X 位置
        @text.gsub!(/\\[Ww][Xx]\[([0-9]+)\]/) do
          $game_system.window_x = self.x = $1.to_i
          ""
        end
        # Y 位置
        @text.gsub!(/\\[Ww][Yy]\[([0-9]+)\]/) do
          $game_system.window_y = self.y = $1.to_i
          ""
        end
        # 消息框的位置。0=角色
        @text.gsub!(/\\[Ww][Zz]\[([0-9]+)\]/) do
          id = $1.to_i
          if id == 0
            self.x = $game_player.screen_x - self.width/2
            self.y = $game_player.screen_y
            self.y = $game_player.screen_y - (64+self.height) if $game_system.window_to_text
          else
            self.x = $game_map.events[id].screen_x - self.width/2
            self.y = $game_map.events[id].screen_y
            self.y = $game_map.events[id].screen_y - (64+self.height) if $game_system.window_to_text
          end
          ""
        end
        # 正常窗口
        correct_window
        # 显示名字盒子\Nm[name]
        @text.gsub!(/\\[Nn][Mm]\[(.*?)\]/) do
          name = $1.to_s
          @name_box.text = name
          @name_box.visible = true
          @name_box.y = self.y-@name_box.height
          @name_box.x = self.x
          @name_box.y = self.height if @name_box.y < 0
          ""
        end
        # 显示图片
        @text.gsub!(/\\[Ff]\[(.*?)\]/) do
          name = $1.to_s
          $game_system.face_graphic = name
          @face_width = 0 if name == ""
          ""
        end
        # 设置头像位置左边
        @text.gsub!(/\\[Ff][Ll]/) do
          $game_system.face_justify = 0
          ""
        end
        # 设置头像位置右边
        @text.gsub!(/\\[Ff][Rr]/) do
          $game_system.face_justify = 1
          ""
        end
        # 显示战斗图片
        @text.gsub!(/\\[Bb][Tt]\[(.*?)\]/) do
          name = $1.to_s
          $game_system.battler_graphic = name
          @battler_width = 0 if name == ""
          ""
        end
        # 设置战斗图位置左边
        @text.gsub!(/\\[Bb][Ll]/) do
          $game_system.battler_justify = 0
          ""
        end
        # 设置战斗图位置右边
        @text.gsub!(/\\[Bb][Rr]/) do
          $game_system.battler_justify = 1
          ""
        end
      end
      #--------------------------------------------------------------------------
      # ● 正常窗口
      #--------------------------------------------------------------------------
      def correct_window
        if self.x > 640-self.width
          self.x = 640-self.width
        elsif self.x < 0
          self.x = 0
        end
        if self.y > 480-self.height
          self.y = 480-self.height
        elsif self.y = self.contents.height
            break
          end
        end
      end
      #--------------------------------------------------------------------------
      # ● 搞定卷动
      #--------------------------------------------------------------------------
      def scroll_done
        return true if self.oy >= self.contents.height - 32*4
        return false
      end
      #--------------------------------------------------------------------------
      # ● 显示多个窗口(本脚本的特点啊!)
      #--------------------------------------------------------------------------
      def show_m_window
        @contents_showing = true
        reset_window
        self.visible = true if $game_system.letterBYletter or !$game_system.scrolling_text.nil?
        refresh
        Graphics.frame_reset
        self.visible = true
        if @input_number_window != nil
          @input_number_window.contents_opacity = 0 if !$game_system.letterBYletter and $game_system.scrolling_text.nil?
        end
      end
      #--------------------------------------------------------------------------
      # ● 刷新画面 = =b又到了刷新的时候了。刷一刷天天都干净!-_-!!
      #--------------------------------------------------------------------------
      def update
        super
        #在存在的时候。名字框刷新。
        @name_box.update if @name_box.visible
        @name_box.opacity = $game_system.nameBox_opacity if !$game_system.nameBox_to_window_opacity and @name_box.opacity != $game_system.nameBox_opacity
        @name_box.opacity = self.opacity if $game_system.nameBox_to_window_opacity and @name_box.opacity != self.opacity
        # 渐变的情况下
        if @fade_in and !$game_system.letterBYletter and $game_system.scrolling_text.nil?
          self.contents_opacity += 24
          if @input_number_window != nil
            @input_number_window.contents_opacity += 24
          end
          if self.contents_opacity == 255
            @fade_in = false
          end
          return
        elsif ($game_system.letterBYletter or !$game_system.scrolling_text.nil?) and @fade_in
          return @fade_in = false
        end
        # 输入数值的情况下
        if @input_number_window != nil
          @input_number_window.update
          #确定
          if Input.trigger?(Input::C)
            $game_system.se_play($data_system.decision_se)
            $game_variables[$game_temp.num_input_variable_id] = @input_number_window.number
            $game_map.need_refresh = true
            # 释放输入数值窗口
            @input_number_window.dispose
            @input_number_window = nil
            terminate_message
          end
          return
        end
        # 显示信息中的情况下
        if @contents_showing
          # 如果不是在显示选择项中就显示暂停标志
          if $game_temp.choice_max == 0
            self.pause = true
          end
          # 确定
          if Input.trigger?(Input::B)
            if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
              $game_system.se_play($data_system.cancel_se)
              $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
              terminate_message
            end
          end
          # 确定  
          if Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or
              Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
            if $game_temp.choice_max  0
              $game_system.se_play($data_system.decision_se)
              $game_temp.choice_proc.call(self.index)
            end
            terminate_message
          end
          return
        end
        # 在渐变以外的状态下有等待显示的信息与选择项的场合
        if @fade_out == false and $game_temp.message_text != nil
          @contents_showing = true
          $game_temp.message_window_showing = true
          reset_window
          self.visible = true if $game_system.letterBYletter or !$game_system.scrolling_text.nil?
          refresh
          Graphics.frame_reset
          self.visible = true
          self.contents_opacity = 0 if !$game_system.letterBYletter and $game_system.scrolling_text.nil?
          if @input_number_window != nil
            @input_number_window.contents_opacity = 0 if !$game_system.letterBYletter and $game_system.scrolling_text.nil?
          end
          # 显示多窗口
          if !$game_system.multiple_windows.include?(self)
            for w in $game_system.multiple_windows
              next if w.nil?
              w.show_m_window
            end
          end
          return @fade_in = true
        end
        # 没有可以显示的信息、但是窗口为可见的情况下
        if self.visible   
          @fade_out = true
          self.opacity -= 48
          if self.opacity == 0
            self.visible = false
            @fade_out = false
            $game_temp.message_window_showing = false
          end
          return
        end
      end
      #--------------------------------------------------------------------------
      # ● 更新光标矩形
      #-------------------------------------------------------------------------- def update_cursor_rect
      def update_cursor_rect
        # 光标位置不满 0 的情况下
        return self.cursor_rect.empty if @index < 0
        # 获取当前的行
        row = @index / @column_max
        # 当前行被显示开头行前面的情况下
        if row < self.top_row
          # 从当前行向开头行滚动
          self.top_row = row
        end
        # 当前行被显示末尾行之后的情况下
        if row > self.top_row + (self.page_row_max - 1)
          # 从当前行向末尾滚动
          self.top_row = row - (self.page_row_max - 1)
        end
        # 计算光标的宽度
        cursor_width = self.width / @column_max - 32
        # 计算光标坐标
        x = @index % @column_max * (cursor_width + 32)
        y = @index / @column_max * 32 - self.oy
        # 更新光标矩形
        self.cursor_rect.set(x, y+($game_temp.choice_start*32), cursor_width, 32)
      end
    end
    #==============================================================================
    #● 名字框家族= =b之一
    #-------------------------------------------------------------------------------
    # 这个算老大吧。
    #===============================================================================
    class Window_NameBoxMd < Window_Base
      #--------------------------------------------------------------------------
      #  ● 初始化对像
      #--------------------------------------------------------------------------
      def initialize
        super(0, 0, 160, 32)
        self.visible = false
        @text = ""
        @dummy_window = Window_NameBoxModel.new(self)
      end
      #--------------------------------------------------------------------------
      # ● 文本
      #--------------------------------------------------------------------------
      def text=(t)
        return if @text == t
        # 编辑文本
        @dummy_window.text = @text = t
      end
      #--------------------------------------------------------------------------
      #  ● 释放
      #--------------------------------------------------------------------------
      def dispose
        super
        @dummy_window.dispose if !@dummy_window.nil?
      end
      # X
      def y=(v)
        super(v)
        @dummy_window.y = v-16 if !@dummy_window.nil?
      end
      # Y
      def x=(v)
        super(v)
        @dummy_window.x = v if !@dummy_window.nil?
      end
      #--------------------------------------------------------------------------
      # ● 显示端口
      #--------------------------------------------------------------------------
      def visible=(v)
        super(v)
        @dummy_window.visible = v if !@dummy_window.nil?
      end
    end
    #==============================================================================
    # ● 名字框家族= =b之一
    #------------------------------------------------------------------------------
    # 这个就是传说中又上角那个小框框~显示名字那个地方
    #===============================================================================
    class Window_NameBoxModel < Window_Base
      #--------------------------------------------------------------------------
      #  ● 初始化对像
      #--------------------------------------------------------------------------
      def initialize(parent)
        super(0, 0, 160, 64)
        self.visible = false
        self.opacity = 0
        @name_box = parent
        self.contents = Bitmap.new(width - 32, height - 32)
        @text = ""
      end
      #--------------------------------------------------------------------------
      # ● 文本
      #--------------------------------------------------------------------------
      def text=(t)
        return if @text == t
        @text = t
        refresh
      end
      #--------------------------------------------------------------------------
      # ● 刷新
      #--------------------------------------------------------------------------
      def refresh
        # 变化大小~
        self.width = cx = contents.text_size(@text).width + 32
        @name_box.width = self.width
        self.contents.dispose if !self.contents.disposed?
        self.contents = Bitmap.new(width - 32, height - 32)
        self.contents.draw_text(0, 0, cx-32, 32, @text)
      end
      
    end
    =begin
    -------------------------------------------------------------------------------

    -------------------------------------------------------------------------------
    =end
    #==============================================================================
    # ■ Scene_Map
    #------------------------------------------------------------------------------
    #  处理地图画面的类。
    #==============================================================================
    class Scene_Map
      #--------------------------------------------------------------------------
      # ● 刷新画面
      #--------------------------------------------------------------------------
      def update
        # 循环
        loop do
          # 按照地图、实例、主角的顺序刷新
          # (本更新顺序不会在满足事件的执行条件下成为给予角色瞬间移动
          #  的机会的重要因素)
          $game_map.update
          $game_system.map_interpreter.update
          $game_player.update
          # 系统 (计时器)、画面刷新
          $game_system.update
          $game_screen.update
          # 如果主角在场所移动中就中断循环
          unless $game_temp.player_transferring
            break
          end
          # 执行场所移动
          transfer_player
          #  处理过渡中的情况下、中断循环
          if $game_temp.transition_processing
            break
          end
        end
        # 刷新活动块
        @spriteset.update
        # 刷新信息窗口
        @message_window.update
        # 游戏结束的情况下
        if $game_temp.gameover
          # 切换的游戏结束画面
          $scene = Scene_Gameover.new
          return
        end
        # 返回标题画面的情况下
        if $game_temp.to_title
          # 切换到标题画面
          $scene = Scene_Title.new
          return
        end
        # 处理过渡中的情况下
        if $game_temp.transition_processing
          # 清除过渡处理中标志
          $game_temp.transition_processing = false
          # 执行过渡
          if $game_temp.transition_name == ""
            Graphics.transition(20)
          else
            Graphics.transition(40, "Graphics/Transitions/" +
                $game_temp.transition_name)
          end
        end
        # 显示信息窗口中的情况下。
        if $game_temp.message_window_showing and !$game_system.hover_message
          return
        end
        # 遇敌计数为 0 且、且遇敌列表不为空的情况下
        if $game_player.encounter_count == 0 and $game_map.encounter_list != []
          # 不是在事件执行中或者禁止遇敌中
          unless $game_system.map_interpreter.running? or
              $game_system.encounter_disabled
            # 确定队伍
            n = rand($game_map.encounter_list.size)
            troop_id = $game_map.encounter_list[n]
            # 队伍有效的话
            if $data_troops[troop_id] != nil
              # 设置调用战斗标志
              $game_temp.battle_calling = true
              $game_temp.battle_troop_id = troop_id
              $game_temp.battle_can_escape = true
              $game_temp.battle_can_lose = false
              $game_temp.battle_proc = nil
            end
          end
        end
        # 按下 B 键的情况下
        if Input.trigger?(Input::B)
          # 不是在事件执行中或菜单禁止中
          unless ($game_system.map_interpreter.running? and !$game_system.hover_message) or
              $game_system.menu_disabled
            # 设置菜单调用标志以及 SE 演奏
            $game_temp.menu_calling = true
            $game_temp.menu_beep = true
          end
        end
        # 调试模式为 ON 并且按下 F9 键的情况下
        if $DEBUG and Input.press?(Input::F9)
          # 设置调用调试标志
          $game_temp.debug_calling = true
        end
        # 不在主角移动中的情况下
        unless $game_player.moving?
          # 执行各种画面的调用
          if $game_temp.battle_calling
            call_battle
          elsif $game_temp.shop_calling
            call_shop
          elsif $game_temp.name_calling
            call_name
          elsif $game_temp.menu_calling
            call_menu
          elsif $game_temp.save_calling
            call_save
          elsif $game_temp.debug_calling
            call_debug
          end
        end
      end
    end
    #==============================================================================
    # ■ Game_Player
    #------------------------------------------------------------------------------
    #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
    # 本类的实例请参考 $game_player。
    #==============================================================================
    class Game_Player < Game_Character
      #--------------------------------------------------------------------------
      # ● 画面更新
      #--------------------------------------------------------------------------
      def update
        # 本地变量记录移动信息
        last_moving = moving?
        # 移动中、事件执行中、强制移动路线中、
        # 信息窗口一个也不显示的时候
        unless moving? or ($game_system.map_interpreter.running? and !$game_system.hover_message) or
            @move_route_forcing or ($game_temp.message_window_showing and !$game_system.hover_message)
          # 如果方向键被按下、主角就朝那个方向移动
          #= =b我个人比较喜欢8方向行走所有改了这里如果你喜欢改下面注释就好了
          case Input.dir8 #表示8方向
          when 2
            move_down
          when 4
            move_left
          when 6
            move_right
          when 8
            move_up
          when 1
            move_lower_left
          when 3
            move_lower_right
          when 7  
            move_upper_left
          when 9
            move_upper_right
          end
          #case Input.dir4  #表示4方向
          #  when 2  
          #    move_down   
          #  when 4
          #    move_left
          #  when 6
          #   move_right
          #  when 8
          #   move_up
          #  end
        end
        # 本地变量记忆坐标
        last_real_x = @real_x
        last_real_y = @real_y
        super
        # 角色向下移动、画面上的位置在中央下方的情况下
        if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
          # 画面向下卷动
          $game_map.scroll_down(@real_y - last_real_y)
        end
        # 角色向左移动、画面上的位置在中央左方的情况下
        if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
          # 画面向左卷动
          $game_map.scroll_left(last_real_x - @real_x)
        end
        # 角色向右移动、画面上的位置在中央右方的情况下
        if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
          # 画面向右卷动
          $game_map.scroll_right(@real_x - last_real_x)
        end
        # 角色向上移动、画面上的位置在中央上方的情况下
        if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
          # 画面向上卷动
          $game_map.scroll_up(last_real_y - @real_y)
        end
        # 不在移动中的情况下
        unless moving?
          # 上次主角移动中的情况
          if last_moving
            # 与同位置的事件接触就判定为事件启动
            result = check_event_trigger_here([1,2])
            # 没有可以启动的事件的情况下
            if result == false
              # 调试模式为 ON 并且按下 CTRL 键的情况下除外
              unless $DEBUG and Input.press?(Input::CTRL)
                # 遇敌计数下降
                if @encounter_count > 0
                  @encounter_count -= 1
                end
              end
            end
          end
          # 按下 C 键的情况下
          if Input.trigger?(Input::C)
            # 判定为同位置以及正面的事件启动
            check_event_trigger_here([0])
            check_event_trigger_there([0,1,2])
          end
        end
      end
    end

    #==============================================================================
    # ■ Interpreter (分割定义 3)
    #------------------------------------------------------------------------------
    #  执行事件指令的解释器。本类在 Game_System 类
    # 和 Game_Event 类的内部使用。
    # 重新定义101号事件 = =b这里也是整个信息框的核心部分
    #==============================================================================

    class Interpreter
      #--------------------------------------------------------------------------
      # ● 显示文章
      #  重定义。
      #--------------------------------------------------------------------------
      def command_101
        # # 结束已经设置过 message_text 的情况
        return false if $game_temp.message_text != nil
             
        # 设置信息结束后待机和返回调用标志
        @message_waiting = true
        $game_temp.message_proc = Proc.new { @message_waiting = false }
        # message_text 设置为 1 行
        $game_temp.message_text = @list[@index].parameters[0] + "\n"
        line_count = 1
        #  循环
        loop do
          # 下一个事件指令为文章两行以上的情况
          if @list[@index+1].code == 401
            # message_text 添加到第 2 行以下
            $game_temp.message_text += @list[@index+1].parameters[0] + "\n"
            line_count += 1
            # 事件指令不在文章两行以下的情况
          else
            # 下一个事件指令为显示选择项的情况下
            if @list[@index+1].code == 102
              # 如果选择项能收纳在画面里
              if @list[@index+1].parameters[0].size

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2025-3-15 00:02 , Processed in 0.132750 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表