- UID
- 117
- 帖子
- 14934
- 主题
- 1013
- 精华
- 2
- 积分
- 23743
- 历练
- 3
- 声望
- 133
- 人气
- 2622
- 经验
- 21523
- 金钱
- 3490
- 注册时间
- 2009-10-1
- 最后登录
- 2024-11-22
- 在线时间
- 2308 小时
- 阅读权限
- 100
TA的每日心情 | 无聊 昨天 22:27 |
---|
签到天数: 1407 天 [LV.10]以坛为家III - 精华
- 2
- 积分
- 23743
- 历练
- 3
- 声望
- 133
- 人气
- 2622
|
- #==========================================================================
- #RM计算机……无用产物之一
- #脚本作者by 七夕小雨
- #============================================================================
- #Window_Command懒得写了……直接用星辰大人的好了……
- class Window_Command_Compute < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # width : 每格的的宽
- # row : 行数 自己根据命令数算好行列的值,否则^^b
- # column : 列数
- # commands : 命令字符串序列
- #--------------------------------------------------------------------------
- def initialize(width, commands, column=1)
- row = commands.size / column
- # 由命令的个数计算出窗口的宽和高
- super(0, 0, width, row * 32 + 32)
- @item_max = commands.size
- @commands = commands
- @row = row
- @width_txt = (width-32)/column
- @column_max = column
- self.contents = Bitmap.new(width-32, @row * 32)
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- self.contents.font.size = 18
- for i in 0...@item_max
- draw_item(i, normal_color)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- # color : 文字色
- #--------------------------------------------------------------------------
- def draw_item(index, color)
- self.contents.font.color = color
- # 计算得出当前index所对应的内容所在的行
- row_index = index / @column_max
- # 根据余数得出所在的列
- for y in 0...@column_max
- if index % @column_max == y
- rect = Rect.new(y * @width_txt, 32 * row_index , @width_txt, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- self.contents.draw_text(rect, @commands[index],1)
- break
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 项目无效化
- # index : 项目编号
- #--------------------------------------------------------------------------
- def disable_item(index)
- draw_item(index, disabled_color)
- end
- #--------------------------------------------------------------------------
- # ● 项目有效化
- # index : 项目编号
- #--------------------------------------------------------------------------
- def able_item(index)
- draw_item(index, normal_color)
- end
- #--------------------------------------------------------------------------
- # ● 更新光标举行
- #--------------------------------------------------------------------------
- def update_cursor_rect
- # 光标位置不满 0 的情况下
- if @index < 0
- self.cursor_rect.empty
- return
- end
- # 获取当前的行
- row = @index / @column_max
- # 当前行被显示开头行前面的情况下
- if row < self.top_row
- # 从当前行向开头行滚动
- self.top_row = row
- end
- # 当前行被显示末尾行之后的情况下
- if row > self.top_row + (self.page_row_max - 1)
- # 从当前行向末尾滚动
- self.top_row = row - (self.page_row_max - 1)
- end
- # 计算光标的宽
- cursor_width = @width_txt
- # 计算光标坐标
- x = @index % @column_max * cursor_width
- y = @index / @column_max * 32 - self.oy
- # 更新国标矩形
- self.cursor_rect.set(x, y, @width_txt, 32)
- end
- end
- #-------------------------七夕小雨华丽的分割线-------------------------------
- class Window_Compute < Window_Base
- def initialize
- super(250, 64, 182, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- $compute = "0"
- refresh
- end
- def refresh
-
- self.contents.clear
- self.contents.font.color = normal_color
- self.contents.draw_text(-32, 0, 180, 32, $compute.to_s, 2)
- end
- end
- #-------------------------七夕小雨华丽的分割线--------------------------------
- class Scene_Compute
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # menu_index : 命令光标的初期位置
- #--------------------------------------------------------------------------
- def initialize(menu_index = 0)
- @menu_index = menu_index
- end
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- @back = Spriteset_Map.new
- @command_window = Window_Command_Compute.new(180, ["1","2","3","4","5","6","7","8","9","0","+","-","×","÷","=","归零"],4)
- @command_window.x = 250
- @command_window.y = 140
- @command_window.index = @menu_index
- @compute_window = Window_Compute.new
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果切换画面就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- @compute_window.dispose
- @command_window.dispose
- @back.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- @compute_window.update
- @compute_window.refresh
- @command_window.update
- # 命令窗口被激活的情况下: 调用 update_command
- if @command_window.active
- update_command
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (命令窗口被激活的情况下)
- #--------------------------------------------------------------------------
- def update_command
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Map.new
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- case @command_window.index
- when 0 # 1
- $game_system.se_play($data_system.decision_se)
- if $compute != "0"
- $compute += "1"
- else
- $compute = "1"
- end
- when 1 # 2
- $game_system.se_play($data_system.decision_se)
- if $compute != "0"
- $compute += "2"
- else
- $compute = "2"
- end
- when 2 # 3
- $game_system.se_play($data_system.decision_se)
- if $compute != "0"
- $compute += "3"
- else
- $compute = "3"
- end
- when 3 # 4
- $game_system.se_play($data_system.decision_se)
- if $compute != "0"
- $compute += "4"
- else
- $compute = "4"
- end
- when 4 # 5
- $game_system.se_play($data_system.decision_se)
- if $compute != "0"
- $compute += "5"
- else
- $compute = "5"
- end
- when 5 # 6
- $game_system.se_play($data_system.decision_se)
- if $compute != "0"
- $compute += "6"
- else
- $compute = "6"
- end
- when 6 # 7
- $game_system.se_play($data_system.decision_se)
- if $compute != "0"
- $compute += "7"
- else
- $compute = "7"
- end
- when 7 # 8
- $game_system.se_play($data_system.decision_se)
- if $compute != "0"
- $compute += "8"
- else
- $compute = "8"
- end
- when 8 # 9
- $game_system.se_play($data_system.decision_se)
- if $compute != "0"
- $compute += "9"
- else
- $compute = "9"
- end
- when 9 # 0
- $game_system.se_play($data_system.decision_se)
- if $compute != "0"
- $compute += "0"
- else
- $compute = "0"
- end
- when 10 # +
- $game_system.se_play($data_system.decision_se)
- @a = $compute.to_i
- @Operation = 1
- $compute = "0"
- when 11 # -
- $game_system.se_play($data_system.decision_se)
- @a = $compute.to_i
- @Operation = 2
- $compute = "0"
- when 12 # x
- $game_system.se_play($data_system.decision_se)
- @a = $compute.to_i
- @Operation = 3
- $compute = "0"
- when 13 # /
- $game_system.se_play($data_system.decision_se)
- @a = $compute.to_i
- @Operation = 4
- $compute = "0"
- when 14 # =
- case @Operation
- when 0
- $game_system.se_play($data_system.cancel_se)
- when 1
- $game_system.se_play($data_system.decision_se)
- @b = $compute.to_i
- $c = @a + @b
- $c = $c.to_s
- $compute = $c
- when 2
- $game_system.se_play($data_system.decision_se)
- @b = $compute.to_i
- $c = @a - @b
- $c = $c.to_s
- $compute = $c
- when 3
- $game_system.se_play($data_system.decision_se)
- @b = $compute.to_i
- $c = @a * @b
- $c = $c.to_s
- $compute = $c
- when 4
- $game_system.se_play($data_system.decision_se)
- @b = $compute.to_i
- $c = @a / @b
- $c = $c.to_s
- $compute = $c
- end
- when 15
- $game_system.se_play($data_system.cancel_se)
- $compute = "0"
- @Operation = 0
- end
- return
- end
- end
- end
复制代码 |
|