查看: 2970|回复: 2

[已经解决] 窗口皮肤

[复制链接]
梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
发表于 2022-11-20 10:54:31 | 显示全部楼层 |阅读模式

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

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

×
如何把这个窗口皮肤描绘,放到下面的文本显示脚本里
[fold=draw_windowskin]#==============================================================================
# ** RPG::Cache 高速缓存UI
#==============================================================================
module RPG::Cache
  def self.ui(filename)
    self.load_bitmap("Graphics/Windowskins/", filename)
  end
end

#==============================================================================
# ** Bitmap 拓展
#==============================================================================
class Bitmap
  #--------------------------------------------------------------------------
  # * draw_windowskin 描绘窗口皮肤
  # window_x      窗口X坐标  默认0
  # window_Y      窗口Y坐标  默认0
  # window_width  窗口width  默认self.width
  # window_height 窗口height 默认self.height
  #--------------------------------------------------------------------------
  def draw_windowskin(window_x = 0, window_y = 0, window_width = self.width, window_height = self.height)
    src_bitmap = RPG::Cache.ui("帮助窗口背景")
    src_rect = Rect.new(0, 0, 0, 0)
    dest_rect = Rect.new(0, 0, 0, 0)
    # 上
    src_rect.set(0, 0, 5, 5)
    self.blt(window_x, window_y, src_bitmap, src_rect)
    src_rect.set(6, 0, 5, 5)
    self.blt(window_x + window_width - 5, window_y, src_bitmap, src_rect)
    dest_rect.set(window_x + 5, window_y, window_width - 10, 5)
    src_rect.set(5, 0, 1, 5)
    self.stretch_blt(dest_rect, src_bitmap, src_rect)   
    # 下
    src_rect.set(0, 6, 5, 5)
    self.blt(window_x, window_y + window_height - 5, src_bitmap, src_rect)
    src_rect.set(6, 6, 5, 5)
    self.blt(window_x + window_width - 5, window_y + window_height - 5, src_bitmap, src_rect)
    dest_rect.set(window_x + 5, window_y + window_height - 5, window_width - 10, 5)
    src_rect.set(5, 6, 1, 5)
    self.stretch_blt(dest_rect, src_bitmap, src_rect)
    # 其余
    dest_rect.set(window_x, window_y + 5, 5, window_height - 10)
    src_rect.set(0, 5, 5, 1)
    self.stretch_blt(dest_rect, src_bitmap, src_rect)
    dest_rect.set(window_x + window_width - 5, window_y + 5, 5, window_height - 10)
    src_rect.set(6, 5, 5, 1)
    self.stretch_blt(dest_rect, src_bitmap, src_rect)
    dest_rect.set(window_x + 5, window_y + 5, window_width - 10, window_height - 10)
    src_rect.set(5, 5, 1, 1)
    self.stretch_blt(dest_rect, src_bitmap, src_rect)
  end
end[/fold]


[fold]#Graphics.tips(“你要说的话”, x = 0, y = 0, color = Color.new(238, 255, 64))

#==============================================================================
# ■ Graphics
#------------------------------------------------------------------------------
#  可以提示所有文本,支持所有场景显示。
#------------------------------------------------------------------------------
#   作者:你最珍贵

#   日期:2014-4-5 17:23

#   使用方法:Graphics.tips("")

#   版权说明:转载请保留作者信息,谢谢。
#==============================================================================

class << Graphics
  #--------------------------------------------------------------------------
  # ● 常量定义
  #--------------------------------------------------------------------------
  Tips_width      =  640                      # 底图宽度
  Tips_height     =  32                       # 底图高度
  Tips_ShowTime   =  60                       # 显示时间(最小35,最大不限)
  Tips_Color      =  Color.new(0,0,0,220)     # 底图颜色
  #---------------------------------------------------------------------------
  # ● 提示文本
  #---------------------------------------------------------------------------
  def tips(text, x = 0, y = 0, color = Color.new(238, 255, 64))
    y = (640 - Tips_height) / 2 - 132 if y == 0
    x = (480 - Tips_width) / 2 if x == 0
    tips_create_bitmap(x, y)
    tips_draw_text(text, color)
    @tips_sprite.opacity = 255
    @tips_time = Tips_ShowTime
  end
  #---------------------------------------------------------------------------
  # ● 提示文本
  #---------------------------------------------------------------------------
  def tips_draw_text(text, color)
    @tips_bitmap.font.size = 25
    @tips_bitmap.font.color = color
    cw = @tips_bitmap.text_size(text).width
    @tips_bitmap.fill_rect(0,0,Tips_width, Tips_height,Tips_Color)
    @tips_bitmap.draw_text(0,0,Tips_width,Tips_height,text,1)
  end
  #---------------------------------------------------------------------------
  # ● 创建精灵位图
  #---------------------------------------------------------------------------
  def tips_create_bitmap(x, y)
    if @tips_sprite.nil? or @tips_sprite.disposed?
      @tips_sprite = Sprite.new
      @tips_sprite.z = 9999
      @tips_bitmap = Bitmap.new(Tips_width, Tips_height)
      @tips_sprite.bitmap = @tips_bitmap
    end
    @tips_sprite.x, @tips_sprite.y = x, y
  end
  #---------------------------------------------------------------------------
  # ● 刷新提示信息
  #---------------------------------------------------------------------------
  alias tips_update update
  def update
    tips_update
    unless @tips_sprite.nil? or @tips_sprite.disposed?
      if @tips_time and @tips_time > 0
        @tips_sprite.opacity -= 8 if @tips_time <= 35
        @tips_time -= 1
      end
    end
  end
end[/fold]
梦石
0
星屑
3850
在线时间
1899 小时
注册时间
2010-6-19
回帖
917
 楼主| 发表于 2022-11-22 11:17:10 | 显示全部楼层
自行解决
回复

使用道具 举报

梦石
0
星屑
574
在线时间
80 小时
注册时间
2023-7-5
回帖
21
发表于 2025-6-2 08:20:52 | 显示全部楼层
怎么解决?
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部