幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
12
返回列表 发新帖
楼主: 轻舞飞猪

求助:关于Window_NameInput脚本

[复制链接]

1

主题

22

帖子

533

积分

⑤进阶

杀人皇帝

积分
533
发表于 2004-10-25 11:55:49 | 显示全部楼层
for i in @character_ranges[@current_page]
就是这句。。。。。。
男人掌握了世界,女人掌握了男人.
回复 支持 反对

使用道具 举报

5

主题

90

帖子

1049

积分

⑥精研

NY极恶党首席苦力

积分
1049
发表于 2004-10-25 12:27:22 | 显示全部楼层
呵呵,你只贴这个我什么也看不出来啊
劳驾你把整个Wndow_NameInput的脚本和调用这个脚本的代码(这个更重要)贴出来,要不我没法查错,谢谢!
毋意,毋必,毋固,毋我
回复 支持 反对

使用道具 举报

2

主题

25

帖子

1563

积分

⑥精研

积分
1563
发表于 2005-1-26 04:12:20 | 显示全部楼层
我也是……
調用腳本只有遊戲一開始那個場景,自動執行,第一行的『名稱自動處理』而已,在這之前啥都沒做過。
猜測,是不是張貼腳本在論壇裡被程序修改過?
能不能發一份『*.txt』傳上來啊?這樣比較不容易出錯的說……
拜託了~~~
最口胡的事情就是,自己的帳號只打一半…… 偶素維琪雅,後面那個_jia是Jiang……|||bbb QQ隱身中:29848696
回复 支持 反对

使用道具 举报

0

主题

1

帖子

1227

积分

⑥精研

积分
1227
发表于 2005-1-30 21:29:03 | 显示全部楼层
修正版

#==============================================================================
# ■ Window_NameInput
#------------------------------------------------------------------------------
#  输入名称的画面、文字选择窗口。
#==============================================================================

class Window_NameInput < Window_Base
CHARACTER_TABLE =
[
\"A\",\"B\",\"C\",\"D\",\"E\",
\"F\",\"G\",\"H\",\"I\",\"J\",
\"K\",\"L\",\"M\",\"N\",\"O\",
\"\",\"Q\",\"R\",\"S\",\"T\",
\"U\",\"V\",\"W\",\"X\",\"Y\",
\"Z\",\",\",\".\",\"?\",\"!\",
\"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\",\"-\",\"@\",\"#\",\"$\",
\"一\",\"二\",\"三\",\"四\",\"五\",
\"六\",\"七\",\"八\",\"九\",\"十\",
\"千\",\"百\",\"万\",\"亿\",\"兆\",
\"生\",\"年\",\"不\",\"满\",\"百\",
\"常\",\"怀\",\"千\",\"岁\",\"忧\",
\"昼\",\"短\",\"苦\",\"夜\",\"长\",
\"何\",\"不\",\"秉\",\"烛\",\"游\"
]

CHARACTER_INDEX_RANGE = 0..CHARACTER_TABLE.length
CHAR_PER_PAGE = 180
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
    super(0, 128, 640, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    @index = 0
    initial_pages
    refresh
    update_cursor_rect
end
#--------------------------------------------------------------------------
# ● 初始化分页
#--------------------------------------------------------------------------
def initial_pages
      @current_page = 0
      @character_ranges = []
      @page_count = (CHARACTER_TABLE.length / CHAR_PER_PAGE).to_i + 1
       for i in 0..(@page_count - 1)
        @character_ranges[ i ] = (i * CHAR_PER_PAGE)..([(i + 1) * CHAR_PER_PAGE - 1,CHARACTER_TABLE.length - 1].min)
      end
end
#--------------------------------------------------------------------------
# ● 获得@index在字符数组中的绝对偏移量
#--------------------------------------------------------------------------
def abs_index
    return -1 if @index >= CHAR_PER_PAGE
    return @index + @character_ranges[@current_page].first
end
#--------------------------------------------------------------------------
# ● 获取文字
#--------------------------------------------------------------------------
def character
    return CHARACTER_TABLE[abs_index] if CHARACTER_INDEX_RANGE === abs_index
    return nil
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
    self.contents.clear
    for i in @character_ranges[@current_page]
      offset = i - @character_ranges[@current_page].first
      x = 4 + offset / 5 / 9 * 152 + offset % 5 * 28
      y = offset / 5 % 9 * 32
      self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE[ i ], 1)
    end
    self.contents.draw_text(4, 9 * 32, 64, 32, \"第#{@current_page + 1}页\", 1)
    self.contents.draw_text(72, 9 * 32, 64, 32, \"共#{@page_count}页\", 1)
    self.contents.draw_text(544, 9 * 32, 64, 32, \"确定\", 1)
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置在 [确定] 的情况下
    if @index >= CHAR_PER_PAGE
      self.cursor_rect.set(544, 9 * 32, 64, 32)
      # 光标位置在 [确定] 以外的情况下
      else
      x = 4 + @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 >= CHAR_PER_PAGE
      # 光标下
      if Input.trigger?(Input:OWN)
          $game_system.se_play($data_system.cursor_se)
         @index -= CHAR_PER_PAGE
      end
      # 光标上
      if Input.repeat?(Input::UP)
         $game_system.se_play($data_system.cursor_se)
        @index -= CHAR_PER_PAGE - 40
      end
      # 光标位置在 [确定] 以外的情况下
  else
      # 按下方向键右的情况下
      if Input.repeat?(Input::RIGHT)
      # 按下状态不是重复的情况下、
      # 光标位置不在右端的情况下
          if Input.trigger?(Input::RIGHT) or
              @index / 45 < 3 or @index % 5 < 4
      # 光标向右移动
              $game_system.se_play($data_system.cursor_se)
              if @index % 5 < 4
                  @index += 1
              else
                  @index += 45 - 4
              end
              if @index >= CHAR_PER_PAGE
                  @index -= CHAR_PER_PAGE
              end
          end
        end
        # 按下方向键左的情况下
        if Input.repeat?(Input:EFT)
        # 按下状态不是重复的情况下、
        # 光标位置不在左端的情况下
            if Input.trigger?(Input:EFT) or
                @index / 45 > 0 or @index % 5 > 0
        # 光标向右移动
                $game_system.se_play($data_system.cursor_se)
                if @index % 5 > 0
                    @index -= 1
                else
                    @index -= 45 - 4
                end
                if @index < 0
                    @index += CHAR_PER_PAGE
                end
                end
              end
          # 按下方向键下的情况下
        if Input.repeat?(Input:OWN)
          # 光标向下移动
            $game_system.se_play($data_system.cursor_se)
            if @index % 45 < 40
                @index += 5
            else
                @index += CHAR_PER_PAGE - 40
            end
        end
          # 按下方向键上的情况下
      if Input.repeat?(Input::UP)
        # 按下状态不是重复的情况下、
        # 光标位置不在上端的情况下
        if Input.trigger?(Input::UP) or @index % 45 >= 5
        # 光标向上移动
            $game_system.se_play($data_system.cursor_se)
            if @index % 45 >= 5
              @index -= 5
            else
              @index += CHAR_PER_PAGE
            end
        end
      end
        #按下 L 键的情况
      if Input.repeat?(Input:)
          $game_system.se_play($data_system.cursor_se)
          @index = 0
          if @current_page > 0
              @current_page -= 1
              refresh
          end
      end
      #按下 R 键的情况
      if Input.repeat?(Input::R)
          $game_system.se_play($data_system.cursor_se)
          @index = 0
          if @current_page < @page_count - 1
              @current_page += 1
              refresh
          end
      end
      end
update_cursor_rect
end
end

[此贴子已经被作者于2005-1-30 21:40:30编辑过]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2025-6-19 03:07 , Processed in 0.011411 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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