ボトムキーヘルプ



今は無きスクリプトシェルフ(のOut of Support Scripts)の
ステータス・ウィンドウインフロントにあったボトムキーヘルプを参考に拡張を行ってみました。

※ちなみに、これだけを導入してもなにも使えませんが・・・

変更点
2011:03:05
・キーを画像に変更可能に

2012:03:03
・moduleで定義していたものをclassで定義しなおし

#==============================================================================
# ○ボトムキーヘルプ By 貪藻矢射妥←
#  今は無きスクリプトシェルフ(のOut of Support Scripts)の
#  ステータス・ウィンドウインフロントにあったボトムキーヘルプを参考に
#  拡張を行ってみました。
#==============================================================================
# 変更履歴
# 2011:03:05
# ・キーを画像に変更可能に
# 
# 2012:03:03
# ・moduleで定義していたものをclassで定義しなおし

module BTN_SET
  # キー情報の色
  KEY_COLOR  = Color.new(160, 255, 255, 255)
  # ヘルプの色
  DRAW_COLOR = Color.new(180, 255, 220, 255)
  # 描画フォント
  DRAW_FONT = ["HGPゴシックM", Font.default_name]
  
  # ボタンの画像
  # ※画像はGraphics/Iconフォルダにインポートしてください
  BTN_A     = "btn_a"
  BTN_B     = "btn_b"
  BTN_C     = "btn_c"
  BTN_X     = "btn_x"
  BTN_Y     = "btn_y"
  BTN_Z     = "btn_z"
  
  BTN_LR    = "btn_2lr"
  BTN_XY    = "btn_2xy"
  
  BTN_CLR   = "btn_clr"
  BTN_CUD   = "btn_cud"
  BTN_CLRUD = "btn_clrud"
  
  # ボタンの画像セット
  # ※ボタンを画像にする場合、キー情報は必ずこのハッシュのキーにしてください
  BTN_HASH = {
    "A"   =>BTN_A, 
    "B"   =>BTN_B, 
    "C"   =>BTN_C, 
    "X"   =>BTN_X, 
    "Y"   =>BTN_Y, 
    "Z"   =>BTN_Z, 
    "LR"  =>BTN_LR, 
    "XY"  =>BTN_XY, 
    "←→"=>BTN_CLR, 
    "↑↓"=>BTN_CUD, 
    "矢印"=>BTN_CLRUD, 
  }
  # 画像を使うかどうか
  USE_PIC = true
  # キー情報の描画サイズ
  KEY_SIZE = 20
  # ヘルプの描画サイズ
  DRAW_SIZE = 16
  # 余白サイズ
  BLANK = 24
end

#==============================================================================
# □ Window_BottomKeyHelp
#------------------------------------------------------------------------------
#     画面下で操作説明をする透明なウィンドウです。
#==============================================================================
class Window_BottomKeyHelp < Window_Base
  include DIAMOND
  include BTN_SET
  
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    super(0, 432, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    clear
  end
  #--------------------------------------------------------------------------
  # ○ クリア
  #--------------------------------------------------------------------------
  def clear
    self.contents.clear
    @now_x = 640 - 32
  end
  #--------------------------------------------------------------------------
  # ○ 追加
  #   key         : ボタンの情報
  #   explanation : ヘルプ
  #--------------------------------------------------------------------------
  def add(key, explanation)
    # 描画位置の計算
    font = self.contents.font.name
    self.contents.font.name = DRAW_FONT
    
    if USE_PIC
      x = KEY_SIZE
    else
      self.contents.font.size = KEY_SIZE
      x  = self.contents.text_size(key).width
    end
    self.contents.font.size = DRAW_SIZE
    x += self.contents.text_size(explanation).width + 8
    @now_x -= x
    # 描写
    rectr = [@now_x, 0, x, 32]
    if USE_PIC
      pic = RPG::Cache.icon(BTN_HASH[key])
      self.contents.blt(@now_x, 0 + 4, pic, pic.rect)
      
      # アイコンサイズが24×24じゃない場合はこっち?
      #dest_rect = Rect.new(@now_x, 0 + 4, KEY_SIZE, KEY_SIZE)
      #self.contents.stretch_blt(dest_rect, pic, pic.rect)
      
      pic.dispose
    else
      self.contents.font.size = KEY_SIZE
      draw_shadow_text(rectr, key, KEY_COLOR)
    end
    self.contents.font.size = DRAW_SIZE
    draw_shadow_text(rectr, explanation, DRAW_COLOR, 2)
    # 余白の設定
    if @now_x < 0
      p "描画しきれません!"
    end
    @now_x -= BLANK
    
    self.contents.font.name = font
  end
  #--------------------------------------------------------------------------
  # ○ セッティング
  #  hash : キーとヘルプのハッシュ
  #         (ハッシュの内容が1つしかない場合、addでOKだったり・・・)
  #--------------------------------------------------------------------------
  def set_bottom_help(hash)
    for key in hash.keys
      add(key, hash[key])
    end
  end
end
ちなみに、ボトムキーヘルプ用アイコン素材はこちら

戻る