查看: 2034|回复: 2

[已经过期] 修改内建NameInput

[复制链接]
梦石
0
星屑
55
在线时间
72 小时
注册时间
2008-10-27
回帖
47
发表于 2014-6-26 13:29:03 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 IRO 于 2014-6-26 13:31 编辑

我修改了RGSS里的Window_NameInput,想改成只有26个字母
但是光标上下移动的时后变得不正常......希望有高人能教我该怎么改OTZ

[pre lang="ruby" line="1"]#==============================================================================
# ■ Window_NameInput
#------------------------------------------------------------------------------
#  輸入名稱的畫面、文字選擇視窗。
#==============================================================================

class Window_NameInput < Window_Base
  CHARACTER_TABLE =
  [
    "A","B","C","D","E",
    "F","G","H","I","J",
    "K","L","M","N","O",
    "P","Q","R","S","T",
    "U","V","W","X","Y",
    "Z",
  ]
  #--------------------------------------------------------------------------
  # ● 初始化物件
  #--------------------------------------------------------------------------
  def initialize
    super(340, 160, 180, 260)
    self.contents = Bitmap.new(width - 32, height - 32)
    @index = 0
    refresh
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● 獲取文字
  #--------------------------------------------------------------------------
  def character
    return CHARACTER_TABLE[@index]
  end
  #--------------------------------------------------------------------------
  # ● 更新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0..25
      x = 1 + i / 5 / 6 * 152 + i % 5 * 28
      y = i / 5 % 6 * 32
      self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE, 1)
    end
    self.contents.draw_text(80, 6 * 32, 64, 32, "Finish", 1)
  end
  #--------------------------------------------------------------------------
  # ● 更新游標矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # 游標位置在 [確定] 的情況下
    if @index >= 26
      self.cursor_rect.set(80, 9 * 32, 64, 32)
    # 游標位置在 [確定] 以外的情況下
    else
      x = 1 + @index / 5 / 9 * 152 + @index % 5 * 28
      y = @index / 5 % 9 * 32
      self.cursor_rect.set(x, y, 28, 32)
    end
  end
  #--------------------------------------------------------------------------
  # ● 更新畫面
  #--------------------------------------------------------------------------
  def update
    super
    # 游標位置在 [確定] 的情況下
    if @index >= 180
      # 游標下
      if Input.trigger?(Input::DOWN)
        $game_system.se_play($data_system.cursor_se)
        @index -= 180
      end
      # 游標上
      if Input.repeat?(Input::UP)
        $game_system.se_play($data_system.cursor_se)
        @index -= 180 - 40
      end
    # 游標位置在 [確定] 以外的情況下
    else
      # 按下方向鍵右的情況下
      if Input.repeat?(Input::RIGHT)
        # 按下狀態不是重複的情況下、
        # 游標位置不在右端的情況下
        if Input.trigger?(Input::RIGHT) or
           @index / 30 < 3 or @index % 5 < 4
          # 游標向右移動
          $game_system.se_play($data_system.cursor_se)
          if @index % 5 < 4
            @index += 1
          else
            @index += 30 - 4
          end
          if @index >= 180
            @index -= 180
          end
        end
      end
      # 按下方向鍵左的情況下
      if Input.repeat?(Input::LEFT)
        # 按下狀態不是重複的情況下、
        # 游標位置不在左端的情況下
        if Input.trigger?(Input::LEFT) or
           @index / 30 > 0 or @index % 5 > 0
          # 游標向右移動
          $game_system.se_play($data_system.cursor_se)
          if @index % 5 > 0
            @index -= 1
          else
            @index -= 30 - 4
          end
          if @index < 0
            @index += 180
          end
        end
      end
      # 按下方向鍵下的情況下
      if Input.repeat?(Input::DOWN)
        # 游標向下移動
        $game_system.se_play($data_system.cursor_se)
        if @index % 30 < 25
          @index += 5
        else
          @index += 180 - 40
        end
      end
      # 按下方向鍵上的情況下
      if Input.repeat?(Input::UP)
        # 按下狀態不是重複的情況下、
        # 游標位置不在上端的情況下
        if Input.trigger?(Input::UP) or @index % 30 >= 5
          # 游標向上移動
          $game_system.se_play($data_system.cursor_se)
          if @index % 30 >= 5
            @index -= 5
          else
            @index += 180
          end
        end
      end
      # L 鍵與 R 鍵被按下的情況下
      if Input.repeat?(Input::L) or Input.repeat?(Input::R)
        # 平假名 / 片假名 之間移動
        $game_system.se_play($data_system.cursor_se)
        if @index / 30 < 2
          @index += 90
        else
          @index -= 90
        end
      end
    end
    update_cursor_rect
  end
end[/pre]

无节操

梦石
0
星屑
608
在线时间
795 小时
注册时间
2009-2-6
回帖
3910

开拓者贵宾

发表于 2014-6-26 13:38:37 | 显示全部楼层
不要修改原有的格式,只删改引号里的内容即可。
如果修改引号数目,会导致底下的许多数据都要修改,得不偿失。

点评

IRO
只是個解謎環節不是要取名,所以倒不需要小寫~  发表于 2014-6-26 14:28
IRO
刚刚试着把引号加回来,因为屏幕改小了所以光标会跑到屏幕外...有办法让它被忽略吗?><  发表于 2014-6-26 14:27
moy
况且,你难道不需要小写吗(  发表于 2014-6-26 14:20
moy
那些引号对应的就相当于屏幕中的位置,并且空的引号在光标移动时会被忽略,好好利用这点应该可以排版出来。  发表于 2014-6-26 14:20
IRO
呃...我想得的部分是版面会美观很多? 不需要那么多引号,有办法的话还是想改掉...  发表于 2014-6-26 14:15
Brandnew day, Brandnew Life
                             规 实在  中
暂为素材区版主,版其  琢磨
应援一下~
RPG制作大师授权素材推广计划
回复

使用道具 举报

无节操

梦石
0
星屑
608
在线时间
795 小时
注册时间
2009-2-6
回帖
3910

开拓者贵宾

发表于 2014-6-26 14:48:50 | 显示全部楼层
你改了分辨率的话,那只好都改了
修改引号数目以及坐标的话,这个页面里几乎所有牵扯到index的都需要调整。
不太清楚你要的效果,但最主要的是牵扯到这两段的刷新。
  1.   #--------------------------------------------------------------------------
  2.   # ● 更新
  3.   #--------------------------------------------------------------------------
  4.   def refresh
  5.     self.contents.clear
  6.     for i in 0..25
  7.       x = 1 + i / 5 / 6 * 152 + i % 5 * 28
  8.       y = i / 5 % 6 * 32
  9.       self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE[i], 1)
  10.     end
  11.     self.contents.draw_text(80, 6 * 32, 64, 32, "Finish", 1)
  12.   end
  13.   #--------------------------------------------------------------------------
  14.   # ● 更新游標矩形
  15.   #--------------------------------------------------------------------------
  16.   def update_cursor_rect
  17.     # 游標位置在 [確定] 的情況下
  18.     if @index >= 26
  19.       self.cursor_rect.set(80, 9 * 32, 64, 32)
  20.     # 游標位置在 [確定] 以外的情況下
  21.     else
  22.       x = 1 + @index / 5 / 9 * 152 + @index % 5 * 28
  23.       y = @index / 5 % 9 * 32
  24.       self.cursor_rect.set(x, y, 28, 32)
  25.     end
  26.   end
复制代码
这里有很多尺寸相关的数据,按照你的大小改吧。这个得自己调试才知道效果如何。

评分

参与人数 1星屑 +10 收起 理由
RyanBern + 10 塞糖

查看全部评分

Brandnew day, Brandnew Life
                             规 实在  中
暂为素材区版主,版其  琢磨
应援一下~
RPG制作大师授权素材推广计划
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部