Permanent
Creation

RPGツクールXP/VX用のRGSS素材です。
一部英語版対応です。 (A few materials can be used for English RPG MAKER XP/VX.)
競合率はルファーの独断と偏見なのでたまにハズレます。


スクリーンショット
↑スクリーンショット (クリックで拡大)
#==============================================================================
# ■ 名前入力ウィンドウの修正
#------------------------------------------------------------------------------
#  名前入力画面で、最大文字数を極端に大きくしたときに入力中の名前がウィンドウ
# をはみ出てしまうバグを修正します。
# (C) ルファー
# WebSite  https://tkoolerlufar.pages.dev/
#==============================================================================

=begin
  =対応RGSS
  2

  =必要なライブラリ
  矩形加減算ライブラリ

  =他の素材との競合の可能性
  !.. 名前入力を拡張する素材に注意

  =おまけ
  63 ~ 64 行目をマウスで選択して Ctrl+Q を押すと、
  最大文字数いっぱいまで入力したときのカーソルの形が変化します。
  あと、この素材は「画面解像度変更対応」と併用できます。

  =更新履歴
  2012/04/05 公開

  =再定義しているメソッド
  Window_NameEdit#initialize
  Window_NameEdit#item_rect (エイリアスなし)
=end
class Window_NameEdit < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     actor    : アクター
  #     max_char : 最大文字数
  #--------------------------------------------------------------------------
  alias _Lufar_NameEditFix_Init initialize
  def initialize(*args)
    _Lufar_NameEditFix_Init(*args)
    ## 幅を文字数に合わせて調整 (Max. 544px)
    self.width = 136 + (16 - @max_char) * 32/5 + (@max_char+1) * 24
    ## 座標を画面に合わせて調整
    self.x = (Graphics.width  - self.width) / 2
    unless defined? Lufar::AnyResolution then
      self.y += (Graphics.height -        416) / 2
    end
    create_contents
    refresh
    update_cursor
  end
  #--------------------------------------------------------------------------
  # ● 項目を描画する矩形の取得
  #     index : 項目番号
  #--------------------------------------------------------------------------
  def item_rect(index)
    return Rect.new(0, 0, 0, 0) if index < 0
    ## 文字の幅は 24 と仮定。
    start_rect = Rect.new(
      104 + (16 - @max_char) * 16/5,
      48 - WLH / 2,    ## 48 ... 顔グラフィックの高さ/2
      24, WLH)
#~     return start_rect +
#~       Rect.new(0, +WLH-4, 24*(@max_char-1), -WLH+4) if @max_char <= index
    return start_rect + Rect.new(+24*index, 0, 0, 0)
  end
end

戻る