找回密码
 注册用户
查看: 3|回复: 0

[RMVA] 限时数值输入

[复制链接]

98

主题

13

回帖

1319

积分

资深会员

积分
1319
发表于 7 小时前 | 显示全部楼层 |阅读模式
QQ图片20260214102544.png
QQ图片20260214102549.png

  1. module SL_Settings
  2.   module SL_Input_Process
  3.     VARIABLE_ID = 10  # 控制等待时间的变量,数值为0表示不限时
  4.   end
  5. end
  6. class Window_SL_Input_Process < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对象
  9.   #--------------------------------------------------------------------------
  10.   def initialize(width = 128, height = 48)
  11.     super(0, 0, width, height)
  12.     @process = 0.0
  13.     @cnt = 0
  14.     self.openness = 0
  15.     deactivate
  16.   end
  17.   def process
  18.     @process
  19.   end
  20.   def process=(process)
  21.     @process = process
  22.   end
  23.   #--------------------------------------------------------------------------
  24.   # ● 开始输入的处理
  25.   #--------------------------------------------------------------------------
  26.   def start
  27.     create_contents
  28.     update_placement
  29.     open
  30.     activate
  31.     @cnt = 0
  32.   end
  33.   def update_placement
  34.     self.x = (Graphics.width - self.width) / 2
  35.   end
  36.   def refresh
  37.     rate = @cnt.to_f / ($game_variables[SL_Settings::SL_Input_Process::VARIABLE_ID] * 60)
  38.     color1 = Color.new(0, 255, 0)
  39.     color2 = Color.new((rate * 255).to_i, ((1 - rate) * 255).to_i, 0)
  40.     _x = self.contents.rect.x
  41.     _y = self.contents.rect.y
  42.     _w = (self.contents.rect.width * rate).to_i
  43.     _h = self.contents.rect.height
  44.     self.contents.gradient_fill_rect(_x, _y, _w, _h, color1, color2)
  45.   end
  46.   def update
  47.     super
  48.     @cnt += 1 if active
  49.     @process += 1 if @cnt % 60 == 0 and active
  50.     p @process if @cnt % 60 == 0 and active
  51.     refresh if active
  52.   end
  53. end

  54. class Window_NumberInput < Window_Base
  55.   alias sl_input_process_orig_initialize initialize
  56.   def initialize(message_window)
  57.     sl_input_process_orig_initialize(message_window)  
  58.     @sip_window = Window_SL_Input_Process.new
  59.   end
  60.   alias sl_input_process_orig_update_placement update_placement
  61.   def update_placement
  62.     sl_input_process_orig_update_placement
  63.     return if $game_variables[SL_Settings::SL_Input_Process::VARIABLE_ID] <= 0
  64.     if @message_window.y >= Graphics.width / 2
  65.       @sip_window.y = self.y - @sip_window.height - 12
  66.     else
  67.       @sip_window.y = self.y + self.height + 12
  68.     end
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● 开始输入的处理(追加定义)
  72.   #--------------------------------------------------------------------------
  73.   alias sl_input_process_orig_start start
  74.   def start
  75.     sl_input_process_orig_start
  76.     return if $game_variables[SL_Settings::SL_Input_Process::VARIABLE_ID] <= 0
  77.     @sip_window.start
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 更新画面
  81.   #--------------------------------------------------------------------------
  82.   alias sl_input_process_orig_upadte update
  83.   def update
  84.     sl_input_process_orig_upadte
  85.     return if $game_variables[SL_Settings::SL_Input_Process::VARIABLE_ID] <= 0
  86.     @sip_window.update
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # ● “确定”和“取消”的处理(重定义)
  90.   #--------------------------------------------------------------------------
  91.   def process_handling
  92.     return unless active
  93.     return process_ok     if Input.trigger?(:C)
  94.     return process_cancel if Input.trigger?(:B)
  95.     return if $game_variables[SL_Settings::SL_Input_Process::VARIABLE_ID] <= 0
  96.     if @sip_window.process >= $game_variables[SL_Settings::SL_Input_Process::VARIABLE_ID]
  97.       process_ok
  98.     end
  99.   end
  100.   alias sl_input_process_orig_process_ok process_ok
  101.   def process_ok   
  102.     @sip_window.process = 0.0
  103.     @sip_window.close
  104.     @sip_window.deactivate
  105.     sl_input_process_orig_process_ok
  106.   end   
  107. end
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册用户

本版积分规则

Archiver|QQ群: 48625831|爱上RPG|哈库纳玛塔塔 |网站地图 Clicky

GMT+8, 2026-2-14 17:34 , Processed in 0.084277 second(s), 21 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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