查看: 2640|回复: 1

[转载发布] VXAce信息系统脚本中英对照版

[复制链接]
梦石
0
星屑
208
在线时间
420 小时
注册时间
2020-1-11
回帖
175
发表于 2020-10-16 14:34:14 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 alianlord 于 2020-10-16 14:37 编辑

[pre lang="ruby" line="1"]# \fn[fontname] - Change the font to fontname. If you put multiple fontnames
#  { 【将字体改为fontname。如果你放了多个字体名 】  

#     separated by commas, then it will take the first one the user has installed
    #【用逗号分隔,那么它将使用用户安装的第一个】
    #==============================================================================
    #
    # ▼ Yanfly Engine VXAce - VXAce Message System v1.05 【扬飞VXAce引擎-- VXAce信息系统】
    # -- Last Updated: 2012.01.13                     【最后更新:2012.01.13】
    # -- Level: Normal                                【等级:普通】
    # -- Requires: n/a                                【要求:留白】
    #
    #==============================================================================
     
    $imported = {} if $imported.nil?
    $imported["YEA-MessageSystem"] = true
     
    #==============================================================================
    # ▼ Updates
    # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # 2012.07.21 - Fixed REGEXP error at line 824
    # 2012.01.13 - Bug Fixed: Negative tags didn't display other party members.
    # 2012.01.12 - Compatibility Update: Message Actor Codes
    # 2012.01.10 - Added Feature: \pic[x] text code.
    # 2012.01.04 - Bug Fixed: \ic tag was \ii. No longer the case.
    #            - Added: Scroll Text window now uses message window font.
    # 2011.12.31 - Started Script and Finished.
    #
    #==============================================================================
    # ▼ Introduction
    # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # While RPG Maker VX Ace certainly improved the message system a whole lot, it
    # wouldn't hurt to add in a few more features, such as name windows, converting
    # textcodes to write out the icons and/or names of items, weapons, armours, and
    # more in quicker fashion. This script also gives the developer the ability to
    # adjust the size of the message window during the game, give it a separate
    # font, and to give the player a text fast-forward feature.
    # 【 虽然RPG制造商VX Ace无疑对消息系统进行了很大改进,
    #   但添加一些其他功能也不会有什么坏处,比如名称窗口、
    #   转换文本代码以更快地写出物品、武器、防具的图标和/或名称等。
    #   这个脚本还让开发人员能够在游戏中调整消息窗口的大小,给它一个单独的字体,
    #   并给玩家一个文本快进功能。】
    #==============================================================================
    # ▼ Instructions 【说明书】
    # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # To install this script, open up your script editor and copy/paste this script
    #【 若要安装此脚本,请打开脚本编辑器并复制/粘贴此脚本 】
    #
    # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
    # 【 至▼材料/上方▼总管下方的开口槽。别忘做好备份的工作。】
    # -----------------------------------------------------------------------------
    # Message Window text Codes - These go inside of your message window.
    # 消息窗口文本代码-这些代码位于消息窗口内部
    # -----------------------------------------------------------------------------
    #  Default:    Effect: 【默认:  效果:】
    #    \v[x]     - Writes variable x's value.           【写入变量 x 的值。】
    #    \n[x]     - Writes actor x's name.               【写入角色 X 的名字。】
    #    \p[x]     - Writes party member x's name.        【写入队伍中第 X 人的名字。】
    #    \g        - Writes gold currency name.           【写入队伍中当前执有金额。】
    #    \c[x]     - Changes the colour of the text to x. 【将文本的颜色更改为x。】
    #    \i[x]     - Draws icon x at position of the text.【在文本位置绘制图标x。】
    #    \{        - Makes text bigger by 8 points.       【将字体的大小增加8像素。】
    #    \}        - Makes text smaller by 8 points.      【将字体的大小减小8像素。】
    #    \$        - Opens gold window.                   【打开所持金的窗口。】
    #    \.        - Waits 15 frames (quarter second).    【暂停15帧。(四分之一秒)】
    #    \|        - Waits 60 frames (a full second).     【暂停60帧。(一秒)】
    #    \!        - Waits until key is pressed.          【一直等到按键才解除暂停】
    #    \>        - Following text is instant.           【即时显示剩下来的文本。】
    #    \<        - Following text is no longer instant. 【回归正常方式显示剩下来的文本。】
    #    \^        - Skips to the next message.           【快进到下一条消息。】
    #    \\        - Writes a "\" in the window.          【在窗口中显示特殊符号"\"】
    #
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #
    #  Wait:       Effect:
    #    \w[x]     - Waits x frames (60 frames = 1 second). Message window only.
    #              【暂停 x 秒】 (仅在信息窗口有用)
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #
    #  NameWindow: Effect:
    #    \n<x>     - Creates a name box with x string. Left side. *Note
    #              【创建一个带有 x 字符串的名称框。靠左。附注1】
    #    \nc<x>    - Creates a name box with x string. Centered. *Note
    #              【创建一个带有 x 字符串的名称框。置中。附注1】
    #    \nr<x>    - Creates a name box with x string. Right side. *Note
    #              【创建一个带有 x 字符串的名称框。靠右。附注1】
    #            *Note: Works for message window only.
    #            *附注1内容:(仅在信息窗口有用)
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #
    #  Position:   Effect:
    #    \px[x]    - Sets x position of text to x.
    #              【设置文本的位置的 x 坐标】
    #    \py[x]    - Sets y position of text to y.
    #              【设置文本的位置的 y 坐标】
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #
    #  Picture:    Effect:
    #    \pic[x]   - Draws picture x from the Graphics\Pictures folder.
    #              【描画一个图片 从Graphics\Pictures的文件夹。】
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #
    #  Outline:    Effect:
    #    \oc[x]    - Sets outline colour to x.
    #               【设置窗口的外框的颜色 x】
    #    \oo[x]    - Sets outline opacity to x.
    #               【设置窗口的外框的不透明度 x】
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #
    #  Font:       Effect:
    #    \fr       - Resets all font changes.
    #              【重置所有字体的设定】
    #    \fz[x]    - Changes font size to x.
    #              【转变字体的大小为 x】
    #    \fn[x]    - Changes font name to x.
    #              【转变字体的名称为 x】
    #    \fb       - Toggles font boldness.
    #              【转变字体为粗体】
    #    \fi       - Toggles font italic.
    #              【转变字体为斜体】
    #    \fo       - Toggles font outline.
    #               【转变字体为附带外轮廓】
    #    \fs       - Toggles font shadow.
    #               【转变字体为附带阴影】
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #
    #  Actor:      Effect:
    #    \af[x]    - Shows face of actor x. *Note
    #               【显示角色的脸图 x】 附注 2
    #    \ac[x]    - Writes out actor's class name. *Note
    #               【描写出角色的职业名称 x】 附注 2
    #    \as[x]    - Writes out actor's subclass name. Req: Class System. *Note
    #               【描写出角色的分支子职业 x】  要求:职业系统 附注 2
    #    \an[x]    - Writes out actor's nickname. *Note
    #               【描写出角色的别名 x】 附注 2
    #
    #            *Note: If x is 0 or negative, it will show the respective
    #            *附注2内容: 如果 x为0 或 负数,它将有不同的显示
    #               party member's face instead.           【小队成员的特殊调用值】
    #                   0 - Party Leader                   【小队的领导】
    #                  -1 - 1st non-leader member.         【非小队的领导的第一人】
    #                  -2 - 2nd non-leader member. So on.  【非小队的领导的店二人等等】
    #
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #
    #  Names:      Effect:
    #    \nc[x]    - Writes out class x's name. 【描写出职业 x 的名称】
    #    \ni[x]    - Writes out item x's name.  【描写出物品 x 的名称】
    #    \nw[x]    - Writes out weapon x's name.【描写出武器 x 的名称】
    #    \na[x]    - Writes out armour x's name.【描写出护具 x 的名称】
    #    \ns[x]    - Writes out skill x's name. 【描写出特技 x 的名称】
    #    \nt[x]    - Writes out state x's name. 【描写出状态 x 的名称】
    #
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #
    #  Icon Names: Effect:
    #    \ic[x]    - Writes out class x's name including icon. 【描写出职业 x 的图标】附注3
    #    \ii[x]    - Writes out item x's name including icon.  【描写出物品 x 的图标】
    #    \iw[x]    - Writes out weapon x's name including icon.【描写出武器 x 的图标】
    #    \ia[x]    - Writes out armour x's name including icon.【描写出护具 x 的图标】
    #    \is[x]    - Writes out skill x's name including icon. 【描写出特技 x 的图标】
    #    \it[x]    - Writes out state x's name including icon. 【描写出状态 x 的图标】
    #
    #             *Note: Requires YEA - Class System
    #             * 附注3 需要 YEA - Class System 的脚本
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #
    # And those are the text codes added with this script. Keep in mind that some
    # of these text codes only work for the Message Window. Otherwise, they'll work
    # for help descriptions, actor biographies, and others.
    # 【这些是用这个脚本添加的文本代码。请记住,其中一些文本代码仅适用于消息窗口。
    #  不在此限的,他们可用于 帮助描述,角色传记,和其他。】
    #==============================================================================
    # ▼ Compatibility 【兼容性】
    # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
    # it will run with RPG Maker VX without adjusting.
    # 这个脚本是严格为RPG Maker VX Ace编写的。
    # 它不太可能在没有调整的情况下在RPG Maker VX Ace顺利运行?
    #==============================================================================
     
    module YEA
      module MESSAGE
     
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # - General Message Settings - 【常规消息设置】
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # The following below will adjust the basic settings and that will affect
        # the majority of the script. Adjust them as you see fit.
        # 【下面将调整基本设置,这将影响脚本的大部分。根据需要调整它们。】
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # This button is the button used to make message windows instantly skip
        # forward. Hold down for the effect. Note that when held down, this will
        # speed up the messages, but still wait for the pauses. However, it will
        # automatically go to the next page when prompted.
        #【此按钮用于使消息窗口立即向前跳转。按住以获得效果。请注意,当按下时,
        #  这将加快消息的速度,但仍要等待暂停。但是,当提示时,它将自动转到下一页。】
        TEXT_SKIP = :A     # Input::A is the shift button on keyboard.
         ##【快进键的设定】#  Input::A 在键盘上是 shift 键
     
        # This variable adjusts the number of visible rows shown in the message
        # window. If you do not wish to use this feature, set this constant to 0.
        # If the row value is 0 or below, it will automatically default to 4 rows.
        #【此变量调整消息窗口中显示的可见行数。如果不希望使用此功能,
        #  请将此常量设置为0。如果行值为0或更低,它将自动默认为4行。】
        VARIABLE_ROWS  = 0  ##【窗口的行数设定】
     
        # This variable adjusts the width of the message window shown. If you do
        # not wish to use this feature, set this constant to 0. If the width value
        # is 0 or below, it will automatically default to the screen width.
        #【此变量调整显示的消息窗口的宽度。如果不希望使用此功能,
        #  请将此常量设置为0。如果宽度值为0或更低,它将自动默认为屏幕宽度。】
        VARIABLE_WIDTH = 0  ##【窗口的宽度设定】
     
        # This is the amount of space that the message window will indent whenever
        # a face is used. Default: 112
        #【信息窗口使用脸图时,文本缩进的距离。默认值:112】
        FACE_INDENT_X = 112  ##【窗口的带脸图文本缩进量设定】
     
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # - Name Window Settings - 【名称窗口设置】
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # The name window is a window that appears outside of the main message
        # window box to display whatever text is placed inside of it like a name.
        # 【“名称窗口”是一个出现在主消息窗口框外部的窗口,
        #     用于显示放在其中的任何文本,就像名称一样。】
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        NAME_WINDOW_X_BUFFER = -20     # Buffer x position of the name window.
                                       #【名称窗口的缓冲区x坐标偏移。】
        NAME_WINDOW_Y_BUFFER = 0       # Buffer y position of the name window.
                                       #【名称窗口的缓冲区y坐标偏移。】
        NAME_WINDOW_PADDING  = 20      # Padding added to the horizontal position.
                                       #【添加到水平位置的填充。】
        NAME_WINDOW_OPACITY  = 255     # Opacity of the name window.
                                       #【名称窗口的不透明度。】
        NAME_WINDOW_COLOUR   = 6       # Text colour used by default for names.
                                       # 【名称默认使用的文本颜色】
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # - Message Font Settings - 【信息字体设置】
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # Ace Message System separates the in-game system font form the message
        # font. Adjust the settings here for your fonts.
        #【Ace Message System将游戏中的系统字体与消息字体分开。在此处设定的字体参数。】
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # This array constant determines the fonts used. If the first font does not
        # exist on the player's computer, the next font in question will be used
        # in place instead and so on.
        #【此数组常量决定使用的字体。如果第一种字体在玩家的计算机上不存在,
        #  数组常量下一个的字体将被使用,以此类推。】
        MESSAGE_WINDOW_FONT_NAME = ["Microsoft YaHei"]  ##【窗口的使用角体的设定】
     
        # These adjust the other settings regarding the way the game font appears
        # including the font size, whether or not the font is bolded by default,
        # italic by default, etc.
        #【这些设置会调整游戏字体显示方式的其他设置,
        #  包括字体大小、字体是否默认为粗体、默认为斜体等。】
        MESSAGE_WINDOW_FONT_SIZE    = 24       # Font size.        【字体大小】   
        MESSAGE_WINDOW_FONT_BOLD    = false    # Default bold?     【字体粗体】
        MESSAGE_WINDOW_FONT_ITALIC  = false    # Default italic?   【字体斜体】
        MESSAGE_WINDOW_FONT_OUTLINE = true     # Default outline?  【字体外轮廓】
        MESSAGE_WINDOW_FONT_SHADOW  = false    # Default shadow?   【字体阴影】
     
      end # MESSAGE
    end # YEA
     
    #==============================================================================
    # ▼ Editting anything past this point may potentially result in causing
    # computer damage, incontinence, explosion of user's head, coma, death, and/or
    # halitosis so edit at your own risk.
    #【编辑任何超过此点的内容可能会导致计算机损坏、大小便失禁、用户头部爆炸、
    #  昏迷、死亡和/或口臭,请自行承担编辑风险。】
    #==============================================================================
     
    #==============================================================================
    # ■ Variable
    #==============================================================================
     
    module Variable
     
      #--------------------------------------------------------------------------
      # self.message_rows
      #--------------------------------------------------------------------------
      def self.message_rows
        return 4 if YEA::MESSAGE::VARIABLE_ROWS <= 0
        return 4 if $game_variables[YEA::MESSAGE::VARIABLE_ROWS] <= 0
        return $game_variables[YEA::MESSAGE::VARIABLE_ROWS]
      end
     
      #--------------------------------------------------------------------------
      # self.message_width
      #--------------------------------------------------------------------------
      def self.message_width
        return Graphics.width if YEA::MESSAGE::VARIABLE_WIDTH <= 0
        return Graphics.width if $game_variables[YEA::MESSAGE::VARIABLE_WIDTH] <= 0
        return $game_variables[YEA::MESSAGE::VARIABLE_WIDTH]
      end
     
    end # Variable
     
    #==============================================================================
    # ■ Game_Interpreter
    #==============================================================================
     
    class Game_Interpreter
     
      #--------------------------------------------------------------------------
      # overwrite method: command_101
      #--------------------------------------------------------------------------
      def command_101
        wait_for_message
        $game_message.face_name = @params[0]
        $game_message.face_index = @params[1]
        $game_message.background = @params[2]
        $game_message.position = @params[3]
        while continue_message_string?
          @index += 1
          if @list[@index].code == 401
            $game_message.add(@list[@index].parameters[0])
          end
          break if $game_message.texts.size >= Variable.message_rows
        end
        case next_event_code
        when 102
          @index += 1
          setup_choices(@list[@index].parameters)
        when 103
          @index += 1
          setup_num_input(@list[@index].parameters)
        when 104
          @index += 1
          setup_item_choice(@list[@index].parameters)
        end
        wait_for_message
      end
     
      #--------------------------------------------------------------------------
      # new method: continue_message_string?
      #--------------------------------------------------------------------------
      def continue_message_string?
        return true if next_event_code == 101 && Variable.message_rows > 4
        return next_event_code == 401
      end
     
    end # Game_Interpreter
     
    #==============================================================================
    # ■ Window_Base
    #==============================================================================
     
    class Window_Base < Window
     
      #--------------------------------------------------------------------------
      # new method: setup_message_font
      #--------------------------------------------------------------------------
      def setup_message_font
        @message_font = true
        change_color(normal_color)
        contents.font.out_color = Font.default_out_color
        contents.font.name = YEA::MESSAGE::MESSAGE_WINDOW_FONT_NAME
        contents.font.size = YEA::MESSAGE::MESSAGE_WINDOW_FONT_SIZE
        contents.font.bold = YEA::MESSAGE::MESSAGE_WINDOW_FONT_BOLD
        contents.font.italic = YEA::MESSAGE::MESSAGE_WINDOW_FONT_ITALIC
        contents.font.outline = YEA::MESSAGE::MESSAGE_WINDOW_FONT_OUTLINE
        contents.font.shadow = YEA::MESSAGE::MESSAGE_WINDOW_FONT_SHADOW
      end
     
      #--------------------------------------------------------------------------
      # alias method: reset_font_settings
      #--------------------------------------------------------------------------
      alias window_base_reset_font_settings_ams reset_font_settings
      def reset_font_settings
        if @message_font
          setup_message_font
        else
          window_base_reset_font_settings_ams
          contents.font.out_color = Font.default_out_color
          contents.font.outline = Font.default_outline
          contents.font.shadow = Font.default_shadow
        end
      end
     
      #--------------------------------------------------------------------------
      # alias method: convert_escape_characters
      #--------------------------------------------------------------------------
      alias window_base_convert_escape_characters_ams convert_escape_characters
      def convert_escape_characters(text)
        result = window_base_convert_escape_characters_ams(text)
        result = convert_ace_message_system_new_escape_characters(result)
        return result
      end
     
      #--------------------------------------------------------------------------
      # new method: convert_ace_message_system_new_escape_characters
      #--------------------------------------------------------------------------
      def convert_ace_message_system_new_escape_characters(result)
        #---
        result.gsub!(/\eFR/i) { "\eAMSF[0]" }
        result.gsub!(/\eFB/i) { "\eAMSF[1]" }
        result.gsub!(/\eFI/i) { "\eAMSF[2]" }
        result.gsub!(/\eFO/i) { "\eAMSF[3]" }
        result.gsub!(/\eFS/i) { "\eAMSF[4]" }
        #---
        result.gsub!(/\eAC\[([-+]?\d+)\]/i) { escape_actor_class_name($1.to_i) }
        result.gsub!(/\eAS\[([-+]?\d+)\]/i) { escape_actor_subclass_name($1.to_i) }
        result.gsub!(/\eAN\[([-+]?\d+)\]/i) { escape_actor_nickname($1.to_i) }
        #---
        result.gsub!(/\eNC\[(\d+)\]/i) { $data_classes[$1.to_i].name }
        result.gsub!(/\eNI\[(\d+)\]/i) { $data_items[$1.to_i].name }
        result.gsub!(/\eNW\[(\d+)\]/i) { $data_weapons[$1.to_i].name }
        result.gsub!(/\eNA\[(\d+)\]/i) { $data_armors[$1.to_i].name }
        result.gsub!(/\eNS\[(\d+)\]/i) { $data_skills[$1.to_i].name }
        result.gsub!(/\eNT\[(\d+)\]/i) { $data_states[$1.to_i].name }
        #---
        result.gsub!(/\eIC\[(\d+)\]/i) { escape_icon_item($1.to_i, :class) }
        result.gsub!(/\eII\[(\d+)\]/i) { escape_icon_item($1.to_i, :item) }
        result.gsub!(/\eIW\[(\d+)\]/i) { escape_icon_item($1.to_i, :weapon) }
        result.gsub!(/\eIA\[(\d+)\]/i) { escape_icon_item($1.to_i, :armour) }
        result.gsub!(/\eIS\[(\d+)\]/i) { escape_icon_item($1.to_i, :skill) }
        result.gsub!(/\eIT\[(\d+)\]/i) { escape_icon_item($1.to_i, :state) }
        #---
        return result
      end
     
      #--------------------------------------------------------------------------
      # new method: escape_actor_class_name
      #--------------------------------------------------------------------------
      def escape_actor_class_name(actor_id)
        actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
        actor = $game_actors[actor_id]
        return "" if actor.nil?
        return actor.class.name
      end
     
      #--------------------------------------------------------------------------
      # new method: actor_subclass_name
      #--------------------------------------------------------------------------
      def escape_actor_subclass_name(actor_id)
        return "" unless $imported["YEA-ClassSystem"]
        actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
        actor = $game_actors[actor_id]
        return "" if actor.nil?
        return "" if actor.subclass.nil?
        return actor.subclass.name
      end
     
      #--------------------------------------------------------------------------
      # new method: escape_actor_nickname
      #--------------------------------------------------------------------------
      def escape_actor_nickname(actor_id)
        actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
        actor = $game_actors[actor_id]
        return "" if actor.nil?
        return actor.nickname
      end
     
      #--------------------------------------------------------------------------
      # new method: escape_icon_item
      #--------------------------------------------------------------------------
      def escape_icon_item(data_id, type)
        case type
        when :class
          return "" unless $imported["YEA-ClassSystem"]
          icon = $data_classes[data_id].icon_index
          name = $data_items[data_id].name
        when :item
          icon = $data_items[data_id].icon_index
          name = $data_items[data_id].name
        when :weapon
          icon = $data_weapons[data_id].icon_index
          name = $data_weapons[data_id].name
        when :armour
          icon = $data_armors[data_id].icon_index
          name = $data_armors[data_id].name
        when :skill
          icon = $data_skills[data_id].icon_index
          name = $data_skills[data_id].name
        when :state
          icon = $data_states[data_id].icon_index
          name = $data_states[data_id].name
        else; return ""
        end
        text = "\eI[#{icon}]" + name
        return text
      end
     
      #--------------------------------------------------------------------------
      # alias method: process_escape_character
      #--------------------------------------------------------------------------
      alias window_base_process_escape_character_ams process_escape_character
      def process_escape_character(code, text, pos)
        case code.upcase
        #---
        when 'FZ'
          contents.font.size = obtain_escape_param(text)
        when 'FN'
          text.sub!(/\[(.*?)\]/, "")
          font_name = $1.to_s
          font_name = Font.default_name if font_name.nil?
          contents.font.name = font_name.to_s
        #---
        when 'OC'
          colour = text_color(obtain_escape_param(text))
          contents.font.out_color = colour
        when 'OO'
          contents.font.out_color.alpha = obtain_escape_param(text)
        #---
        when 'AMSF'
          case obtain_escape_param(text)
          when 0; reset_font_settings
          when 1; contents.font.bold = !contents.font.bold
          when 2; contents.font.italic = !contents.font.italic
          when 3; contents.font.outline = !contents.font.outline
          when 4; contents.font.shadow = !contents.font.shadow
          end
        #---
        when 'PX'
          pos[:x] = obtain_escape_param(text)
        when 'PY'
          pos[:y] = obtain_escape_param(text)
        #---
        when 'PIC'
          text.sub!(/\[(.*?)\]/, "")
          bmp = Cache.picture($1.to_s)
          rect = Rect.new(0, 0, bmp.width, bmp.height)
          contents.blt(pos[:x], pos[:y], bmp, rect)
        #---
        else
          window_base_process_escape_character_ams(code, text, pos)
        end
      end
     
    end # Window_Base
     
    #==============================================================================
    # ■ Window_ChoiceList
    #==============================================================================
     
    class Window_ChoiceList < Window_Command
     
      #--------------------------------------------------------------------------
      # alias method: initialize
      #--------------------------------------------------------------------------
      alias window_choicelist_initialize_ams initialize
      def initialize(message_window)
        window_choicelist_initialize_ams(message_window)
        setup_message_font
      end
     
    end # Window_ChoiceList
     
    #==============================================================================
    # ■ Window_ScrollText
    #==============================================================================
     
    class Window_ScrollText < Window_Base
     
      #--------------------------------------------------------------------------
      # alias method: initialize
      #--------------------------------------------------------------------------
      alias window_scrolltext_initialize_ams initialize
      def initialize
        window_scrolltext_initialize_ams
        setup_message_font
      end
     
    end # Window_ScrollText
     
    #==============================================================================
    # ■ Window_NameMessage
    #==============================================================================
     
    class Window_NameMessage < Window_Base
     
      #--------------------------------------------------------------------------
      # initialize
      #--------------------------------------------------------------------------
      def initialize(message_window)
        @message_window = message_window
        super(0, 0, Graphics.width, fitting_height(1))
        self.opacity = YEA::MESSAGE::NAME_WINDOW_OPACITY
        self.z = @message_window.z + 1
        self.openness = 0
        setup_message_font
        @close_counter = 0
        deactivate
      end
     
      #--------------------------------------------------------------------------
      # update
      #--------------------------------------------------------------------------
      def update
        super
        return if self.active
        return if self.openness == 0
        return if @closing
        @close_counter -= 1
        return if @close_counter > 0
        close
      end
     
      #--------------------------------------------------------------------------
      # start_close
      #--------------------------------------------------------------------------
      def start_close
        @close_counter = 4
        deactivate
      end
     
      #--------------------------------------------------------------------------
      # force_close
      #--------------------------------------------------------------------------
      def force_close
        @close_counter = 0
        deactivate
        close
      end
     
      #--------------------------------------------------------------------------
      # start
      #--------------------------------------------------------------------------
      def start(text, x_position)
        @text = text.clone
        set_width
        create_contents
        set_x_position(x_position)
        set_y_position
        refresh
        activate
        open
      end
     
      #--------------------------------------------------------------------------
      # set_width
      #--------------------------------------------------------------------------
      def set_width
        text = @text.clone
        dw = standard_padding * 2 + text_size(text).width
        dw += YEA::MESSAGE::NAME_WINDOW_PADDING * 2
        dw += calculate_size(text.slice!(0, 1), text) until text.empty?
        self.width = dw
      end
     
      #--------------------------------------------------------------------------
      # calculate_size
      #--------------------------------------------------------------------------
      def calculate_size(code, text)
        case code
        when "\e"
          return calculate_escape_code_width(obtain_escape_code(text), text)
        else
          return 0
        end
      end
     
      #--------------------------------------------------------------------------
      # calculate_escape_code_width
      #--------------------------------------------------------------------------
      def calculate_escape_code_width(code, text)
        dw = -text_size("\e").width - text_size(code).width
        case code.upcase
        when 'C', 'OC', 'OO'
          dw += -text_size("[" + obtain_escape_param(text).to_s + "]").width
          return dw
        when 'I'
          dw += -text_size("[" + obtain_escape_param(text).to_s + "]").width
          dw += 24
          return dw
        when '{'
          make_font_bigger
        when '}'
          make_font_smaller
        when 'FZ'
          contents.font.size = obtain_escape_param(text)
        when 'FN'
          text.sub!(/\[(.*?)\]/, "")
          font_name = $1.to_s
          font_name = Font.default_name if font_name.nil?
          contents.font.name = font_name.to_s
        when 'AMSF'
          case obtain_escape_param(text)
          when 0; reset_font_settings
          when 1; contents.font.bold = !contents.font.bold
          when 2; contents.font.italic = !contents.font.italic
          when 3; contents.font.outline = !contents.font.outline
          when 4; contents.font.shadow = !contents.font.shadow
          end
        else
          return dw
        end
      end
     
      #--------------------------------------------------------------------------
      # set_y_position
      #--------------------------------------------------------------------------
      def set_x_position(x_position)
        case x_position
        when 1 # Left
          self.x = @message_window.x
          self.x += YEA::MESSAGE::NAME_WINDOW_X_BUFFER
        when 2 # 3/10
          self.x = @message_window.x
          self.x += @message_window.width * 3 / 10
          self.x -= self.width / 2
        when 3 # Center
          self.x = @message_window.x
          self.x += @message_window.width / 2
          self.x -= self.width / 2
        when 4 # 7/10
          self.x = @message_window.x
          self.x += @message_window.width * 7 / 10
          self.x -= self.width / 2
        when 5 # Right
          self.x = @message_window.x + @message_window.width
          self.x -= self.width
          self.x -= YEA::MESSAGE::NAME_WINDOW_X_BUFFER
        end
        self.x = [[self.x, Graphics.width - self.width].min, 0].max
      end
     
      #--------------------------------------------------------------------------
      # set_y_position
      #--------------------------------------------------------------------------
      def set_y_position
        case $game_message.position
        when 0
          self.y = @message_window.height
          self.y -= YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
        else
          self.y = @message_window.y - self.height
          self.y += YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
        end
      end
     
      #--------------------------------------------------------------------------
      # refresh
      #--------------------------------------------------------------------------
      def refresh
        contents.clear
        reset_font_settings
        @text = sprintf("\eC[%d]%s", YEA::MESSAGE::NAME_WINDOW_COLOUR, @text)
        draw_text_ex(YEA::MESSAGE::NAME_WINDOW_PADDING, 0, @text)
      end
     
    end # Window_NameMessage
     
    #==============================================================================
    # ■ Window_Message
    #==============================================================================
     
    class Window_Message < Window_Base
     
      #--------------------------------------------------------------------------
      # alias method: initialize
      #--------------------------------------------------------------------------
      alias window_message_initialize_ams initialize
      def initialize
        window_message_initialize_ams
        setup_message_font
      end
     
      #--------------------------------------------------------------------------
      # overwrite method: window_width
      #--------------------------------------------------------------------------
      def window_width
        return Variable.message_width
      end
     
      #--------------------------------------------------------------------------
      # overwrite method: window_height
      #--------------------------------------------------------------------------
      def window_height
        return fitting_height(Variable.message_rows)
      end
     
      #--------------------------------------------------------------------------
      # alias method: create_all_windows
      #--------------------------------------------------------------------------
      alias window_message_create_all_windows_ams create_all_windows
      def create_all_windows
        window_message_create_all_windows_ams
        @name_window = Window_NameMessage.new(self)
      end
     
      #--------------------------------------------------------------------------
      # overwrite method: create_back_bitmap
      #--------------------------------------------------------------------------
      def create_back_bitmap
        @back_bitmap = Bitmap.new(width, height)
        rect1 = Rect.new(0, 0, Graphics.width, 12)
        rect2 = Rect.new(0, 12, Graphics.width, fitting_height(4) - 24)
        rect3 = Rect.new(0, fitting_height(4) - 12, Graphics.width, 12)
        @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
        @back_bitmap.fill_rect(rect2, back_color1)
        @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
      end
     
      #--------------------------------------------------------------------------
      # alias method: dispose_all_windows
      #--------------------------------------------------------------------------
      alias window_message_dispose_all_windows_ams dispose_all_windows
      def dispose_all_windows
        window_message_dispose_all_windows_ams
        @name_window.dispose
      end
     
      #--------------------------------------------------------------------------
      # alias method: update_all_windows
      #--------------------------------------------------------------------------
      alias window_message_update_all_windows_ams update_all_windows
      def update_all_windows
        window_message_update_all_windows_ams
        @name_window.update
        @name_window.back_opacity = self.back_opacity
        @name_window.opacity = self.opacity
      end
     
      #--------------------------------------------------------------------------
      # alias method: update_show_fast
      #--------------------------------------------------------------------------
      alias window_message_update_show_fast_ams update_show_fast
      def update_show_fast
        @show_fast = true if Input.press?(YEA::MESSAGE::TEXT_SKIP)
        window_message_update_show_fast_ams
      end
     
      #--------------------------------------------------------------------------
      # overwrite method: input_pause
      #--------------------------------------------------------------------------
      def input_pause
        self.pause = true
        wait(10)
        Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) ||
          Input.press?(YEA::MESSAGE::TEXT_SKIP)
        Input.update
        self.pause = false
      end
     
      #--------------------------------------------------------------------------
      # overwrite method: convert_escape_characters
      #--------------------------------------------------------------------------
      def convert_escape_characters(text)
        result = super(text.to_s.clone)
        result = namebox_escape_characters(result)
        result = message_escape_characters(result)
        return result
      end
     
      #--------------------------------------------------------------------------
      # new method: namebox_escape_characters
      #--------------------------------------------------------------------------
      def namebox_escape_characters(result)
        result.gsub!(/\eN\<(.+?)\>/i)  { namewindow($1, 1) }
        result.gsub!(/\eN1\<(.+?)\>/i) { namewindow($1, 1) }
        result.gsub!(/\eN2\<(.+?)\>/i) { namewindow($1, 2) }
        result.gsub!(/\eNC\<(.+?)\>/i) { namewindow($1, 3) }
        result.gsub!(/\eN3\<(.+?)\>/i) { namewindow($1, 3) }
        result.gsub!(/\eN4\<(.+?)\>/i) { namewindow($1, 4) }
        result.gsub!(/\eN5\<(.+?)\>/i) { namewindow($1, 5) }
        result.gsub!(/\eNR\<(.+?)\>/i) { namewindow($1, 5) }
        return result
      end
     
      #--------------------------------------------------------------------------
      # new method: namebox
      #--------------------------------------------------------------------------
      def namewindow(text, position)
        @name_text = text
        @name_position = position
        return ""
      end
     
      #--------------------------------------------------------------------------
      # new method: message_escape_characters
      #--------------------------------------------------------------------------
      def message_escape_characters(result)
        result.gsub!(/\eAF\[(-?\d+)]/i) { change_face($1.to_i) }
        return result
      end
     
      #--------------------------------------------------------------------------
      # new method: change_face
      #--------------------------------------------------------------------------
      def change_face(actor_id)
        actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
        actor = $game_actors[actor_id]
        return "" if actor.nil?
        $game_message.face_name = actor.face_name
        $game_message.face_index = actor.face_index
        return ""
      end
     
      #--------------------------------------------------------------------------
      # alias method: new_page
      #--------------------------------------------------------------------------
      alias window_message_new_page_ams new_page
      def new_page(text, pos)
        adjust_message_window_size
        window_message_new_page_ams(text, pos)
      end
     
      #--------------------------------------------------------------------------
      # overwrite method: new_line_x
      #--------------------------------------------------------------------------
      def new_line_x
        return $game_message.face_name.empty? ? 0 : YEA::MESSAGE::FACE_INDENT_X
      end
     
      #--------------------------------------------------------------------------
      # new method: adjust_message_window_size
      #--------------------------------------------------------------------------
      def adjust_message_window_size
        self.height = window_height
        self.width = window_width
        create_contents
        update_placement
        self.x = (Graphics.width - self.width) / 2
        start_name_window
      end
     
      #--------------------------------------------------------------------------
      # new method: clear_name_window
      #--------------------------------------------------------------------------
      def clear_name_window
        @name_text = ""
        @name_position = 0
      end
     
      #--------------------------------------------------------------------------
      # new method: start_name_window
      #--------------------------------------------------------------------------
      def start_name_window
        @name_text ||= ""
        return if @name_text == ""
        @name_window.start(@name_text, @name_position)
      end
     
      #--------------------------------------------------------------------------
      # overwrite method: fiber_main
      #--------------------------------------------------------------------------
      def fiber_main
        $game_message.visible = true
        update_background
        update_placement
        loop do
          process_all_text if $game_message.has_text?
          process_input
          $game_message.clear
          @gold_window.close
          @name_window.start_close
          Fiber.yield
          break unless text_continue?
        end
        close_and_wait
        $game_message.visible = false
        @fiber = nil
      end
     
      #--------------------------------------------------------------------------
      # alias method: open_and_wait
      #--------------------------------------------------------------------------
      alias window_message_open_and_wait_ams open_and_wait
      def open_and_wait
        clear_name_window
        adjust_message_window_size
        window_message_open_and_wait_ams
      end
     
      #--------------------------------------------------------------------------
      # alias method: close_and_wait
      #--------------------------------------------------------------------------
      alias window_message_close_and_wait_ams close_and_wait
      def close_and_wait
        @name_window.force_close
        window_message_close_and_wait_ams
      end
     
      #--------------------------------------------------------------------------
      # alias method: all_close?
      #--------------------------------------------------------------------------
      alias window_message_all_close_ams all_close?
      def all_close?
        return window_message_all_close_ams && @name_window.close?
      end
     
      #--------------------------------------------------------------------------
      # alias method: process_escape_character
      #--------------------------------------------------------------------------
      alias window_message_process_escape_character_ams process_escape_character
      def process_escape_character(code, text, pos)
        case code.upcase
        when 'W' # Wait
          wait(obtain_escape_param(text))
        else
          window_message_process_escape_character_ams(code, text, pos)
        end
      end
     
    end # Window_Message
     
    #==============================================================================
    #
    # ▼ End of File
    #
    #==============================================================================[/pre]
头像被屏蔽
梦石
0
星屑
172
在线时间
935 小时
注册时间
2010-11-13
回帖
897
发表于 2020-10-16 23:55:40 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 0 1

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部