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

[转载发布] [简化脚本]对于bluefool所写的仿网游显示即时信息脚本的修改

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    5 小时前
  • 签到天数: 114 天

    连续签到: 4 天

    [LV.6]常住居民II

    2338

    主题

    403

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    10607
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    13376

    灌水之王

    发表于 2024-4-19 17:34:44 | 显示全部楼层 |阅读模式
    对于原作者在每个要显示的即时消息的脚本中加入
    def ……
      不怎么方便实用
    end
    本人修改后只需2个脚本就能添加
    不过在某些方面还比不上原作者的脚本
    比如 大量消息她不会自动换行!其他的应该没什么了吧

    窗口脚本:
    #==============================================================================
    # ■ Window_Down
    #------------------------------------------------------------------------------
    #   信息窗口。Instant_Messaging
    #==============================================================================
    class Window_Instant_Messaging < Window_Selectable
      # 显示行数数列
      INSTANT_SIZE = 10
      #--------------------------------------------------------------------------
      # ● 初始化对像
      #--------------------------------------------------------------------------
      def initialize
        # 设置窗口坐标,和窗口大小
        super(0, 250, 330, 240)
        # 绝对透明处理
        self.opacity = 0
        # 激活处理
        self.active = false
        self.index = 0
      end
      #--------------------------------------------------------------------------
      # ● 刷新
      #--------------------------------------------------------------------------
      def refresh(count = 0)
        if $old_messaging.size > 0
          # 如果hash表的键值数值大于显示的所能容下的行数
          if $old_messaging.size > INSTANT_SIZE
            # 计算多出来的部分
            @size = INSTANT_SIZE
            @count = $old_messaging.size
            @count -= INSTANT_SIZE
          else
            # 如果没有超过…就返回0
            @size = $old_messaging.size
            @count = 0
          end
          self.contents = Bitmap.new(width - 32, INSTANT_SIZE * 16)
          # 清理不需要的字符串--清楚多出来的字
          self.contents.clear
          @count_no = 0
          # 循环处理能够显示的
          for i in 0...@size
            if i + count + @count >= 0
              @no = i + count + @count
              # 变量 = 键值
              item = $old_messaging[@no]
              x = 0
              y = (i - @count_no) * 16 # ----显示"常量:INSTANT_SIZE"行,不介意很大
              # 显示键值
              self.contents.font.size = 14
              self.contents.font.color = Color.new(-170,-170,-170,255)
              self.contents.draw_text(x + 6, y + 1, self.contents.text_size(item).width, 16, item, 0)
              self.contents.font.color = normal_color
              self.contents.draw_text(x + 5, y, self.contents.text_size(item).width, 16, item, 0)
            end
          end
        end
      end
      #--------------------------------------
      #  ● 刷新光标
      #--------------------------------------
      def update_cursor_rect
        # 光标位置不满 0 的情况下
        if @index < 0
          self.cursor_rect.empty
          return
        end
        # 获取当前的行
        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
        # cursor_width = 0
        # 计算光标坐标
        x = @index % @column_max * (cursor_width + 32)
        y = @index / @column_max * 32 - self.oy
        # 更新国标矩形
        self.cursor_rect.set(x, y, self.width - 32, 96)
      end
    end

    #-------------------------------------------------------------------------------
    # □ Game_Instant_Messaging处理即时信息的系统类
    #-------------------------------------------------------------------------------
    # 从游戏重新开始 或者是 游戏读档 都会工作,如果清除过那么自己看效果吧
    class Game_Instant_Messaging
      #--------------------------------------------------------------------------
      # ● 初始化
      #--------------------------------------------------------------------------
      def initialize
        # 生成即时信息显示窗口
        @instant_messaging_window = Window_Instant_Messaging.new
        @instant_messaging_window.z = -1
        @instant_messaging_window.index = -1
        @instant_messaging_window.active = @look = false
        @count = 0
      end
      #--------------------------------------------------------------------------
      # ● 刷新 $game_instant_messaging.update
      #--------------------------------------------------------------------------
      def update
        @instant_messaging_window.refresh
        @instant_messaging_window.update
      end
      #--------------------------------------------------------------------------
      # ● 清除 $game_instant_messaging.clear
      #--------------------------------------------------------------------------
      def clear
        @instant_messaging_window.dispose
      end
      #--------------------------------------------------------------------------
      # ● 设置即时消息 $game_instant_messaging.setup("你好") or
      # ● 用法:        messagin = "你好"
      #                 $game_instant_messaging.setup(messagin)
      #--------------------------------------------------------------------------
      def setup(messaging)
        $old_messaging[$old_messaging.size] = messaging
      end
        #--------------------------------------------------------------------------
      # ● 往上查看(查看过期信息) $game_instant_messaging.up
      #--------------------------------------------------------------------------
      def up
        @size = 0 - $old_messaging.size + 11
        if @count >= @size   
        @count -= 1
        end
        @instant_messaging_window.refresh(@count)
        @instant_messaging_window.update
      end
      #--------------------------------------------------------------------------
      # ● 往下查看---不能超过0--超过0后果自付  $game_instant_messaging.down
      #--------------------------------------------------------------------------
      def down
        if @count < 0
         @count += 1
        end
         @instant_messaging_window.refresh(@count)
         @instant_messaging_window.update
      end
    end  



    用法上面都有,请看注释!在读档 开始处希望添加个全局变量$game_instant_messaging = Game_Instant_Messaging.new
    就可以了

    附件
                 本帖来自P1论坛作者kula1900,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=127618  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

    关闭

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2025-3-14 23:12 , Processed in 0.090873 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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