Files
2026-10-29 21:59:06 +04:00

741 lines
26 KiB
Ruby

unless defined?(Ruby310Compat)
begin
compat_candidates = []
begin
compat_candidates << File.expand_path('000_Ruby310_Compat.rb', File.dirname(__FILE__))
rescue StandardError
end
begin
cwd = Dir.pwd.to_s
compat_candidates << File.expand_path('Data/Scripts/000_Ruby310_Compat.rb', cwd) unless cwd.empty?
compat_candidates << File.expand_path('000_Ruby310_Compat.rb', cwd) unless cwd.empty?
rescue StandardError
end
compat_candidates.compact.uniq.each do |compat_path|
next unless File.file?(compat_path)
load compat_path
break if defined?(Ruby310Compat)
end
rescue StandardError
end
end
#==============================================================================
#
# ▼ Yanfly Engine Ace - Debug Extension v1.01
# -- Last Updated: 2012.01.05
# -- Level: Easy, Normal
# -- Requires: n/a
#
#==============================================================================
$imported = {} if $imported.nil?
$imported["YEA-DebugExtension"] = true
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2015.09.01 - Delayed the generation of the windows until they are needed.
# 2012.01.05 - Script no longer conflicts with conditional Key presses.
# 2012.01.04 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# While the RPG Maker VX Ace debug menu gets the basics done, this script will
# add on even more functionality. This script provides an extended debug menu,
# common event shortcuts that can be ran from a few key presses, and even an
# input console to manually insert code and run it.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Debug Shortcuts - Only during $TEST and $BTEST mode
# -----------------------------------------------------------------------------
# Alt + F5-F9 - Common Event Debug Shortcut
# Ctrl + F5-F9 - Common Event Debug Shortcut
# Shift + F5-F9 - Common Event Debug Shortcut
# F9 on the map - Open Debug Menu.
#
# F10 anywhere - Opens up the Debug Entry Window.
# Here, you may enter in a piece of code and the script itself will run it
# using the current scene as its host. So long as the code doesn't contain
# any syntax errors, it'll run right immediately. Idea by OriginalWij.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================
module YEA
module DEBUG
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Common Event Shortcut Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Here, you can define common event shortcuts to launch during test play
# mode and pressing the right shortcut combination. If you do not wish to
# use a particular shortcut key, set it to 0.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Common event shortcuts when holding down ALT and pressing an F5-F9 key.
ALT ={ # Only works during test play mode.
:F5 => 0,
:F6 => 0,
:F7 => 0,
:F8 => 0,
:F9 => 0,
} # Do not remove this.
# Common event shortcuts when holding down CTRL and pressing an F5-F9 key.
CTRL ={ # Only works during test play mode.
:F5 => 0,
:F6 => 0,
:F7 => 0,
:F8 => 0,
:F9 => 0,
} # Do not remove this.
# Common event shortcuts when holding down SHIFT and pressing an F5-F9 key.
SHIFT ={ # Only works during test play mode.
:F5 => 0,
:F6 => 0,
:F7 => 0,
:F8 => 0,
:F9 => 0,
} # Do not remove this.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Debug Menu Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# The following adjusts debug menu data. There's no real need to edit
# anything here unless you feel like it. Here's what the commands do:
# :switches Adjust switches like default.
# :variables Adjust variables like default.
# :teleport Teleport to different maps.
# :battle Enter the selected battle.
# :events Call common events from menu.
# :items Adjust item quantities.
# :weapons Adjust weapon quantities.
# :armours Adjust armour quantities.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Command window layout for the debug menu. Determines order and which
# commands will be shown in the command window.
COMMANDS =[
[ :switches, "Switches"],
[:variables, "Variables"],
[ :teleport, "Teleport"],
[ :battle, "Battle"],
[ :events, "Events"],
[ :items, "Items"],
[ :weapons, "Weapons"],
[ :armours, "Armours"],
] # Do not remove this.
end # DEBUG
end # YEA
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================
#==============================================================================
# ■ Numeric
#==============================================================================
class Numeric
#--------------------------------------------------------------------------
# new method: group_digits
#--------------------------------------------------------------------------
unless $imported["YEA-CoreEngine"]
def group; return self.to_s; end
end # $imported["YEA-CoreEngine"]
end # Numeric
#==============================================================================
# ■ Input
#==============================================================================
module Input
#--------------------------------------------------------------------------
# constants - Created by OriginalWij and Yanfly
#--------------------------------------------------------------------------
#DEFAULT = [:DOWN, :LEFT, :RIGHT, :UP, :A, :B, :C, :X, :Y, :Z, :L, :R, :SHIFT, :CTRL, :ALT, :F5, :F6, :F7, :F8, :F9]
DEFAULT = [:A, :B, :C, :X, :Y, :Z, :L, :R, :SHIFT, :CTRL, :ALT, :F5, :F6, :F7, :F8, :F9]
LETTERS = {}
LETTERS['A'] = 65; LETTERS['B'] = 66; LETTERS['C'] = 67; LETTERS['D'] = 68
LETTERS['E'] = 69; LETTERS['F'] = 70; LETTERS['G'] = 71; LETTERS['H'] = 72
LETTERS['I'] = 73; LETTERS['J'] = 74; LETTERS['K'] = 75; LETTERS['L'] = 76
LETTERS['M'] = 77; LETTERS['N'] = 78; LETTERS['O'] = 79; LETTERS['P'] = 80
LETTERS['Q'] = 81; LETTERS['R'] = 82; LETTERS['S'] = 83; LETTERS['T'] = 84
LETTERS['U'] = 85; LETTERS['V'] = 86; LETTERS['W'] = 87; LETTERS['X'] = 88
LETTERS['Y'] = 89; LETTERS['Z'] = 90
NUMBERS = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
NUMPAD = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105]
BACK = 0x08; ENTER = 0x0d; SPACE = 32; SCOLON = 186; ESC = 157
QUOTE = 222; EQUALS = 187; COMMA = 188; USCORE = 189; PERIOD = 190
SLASH = 191; LBRACE = 219; RBRACE = 221; BSLASH = 220; TILDE = 192
F10 = 121; F11 = 122; CAPS = 20; NMUL = 106; NPLUS = 107
NSEP = 108; NMINUS = 109; NDECI = 110; NDIV = 111;
Extras = [USCORE, EQUALS, LBRACE, RBRACE, BSLASH, SCOLON, QUOTE, COMMA,
PERIOD, SLASH, NMUL, NPLUS, NSEP, NMINUS, NDECI, NDIV]
#--------------------------------------------------------------------------
# initial module settings - Created by OriginalWij and Yanfly
#--------------------------------------------------------------------------
GetKeyState = Ruby310Compat.native_api("user32", "GetAsyncKeyState", "i", "i")
GetCapState = Ruby310Compat.native_api("user32", "GetKeyState", "i", "i")
KeyRepeatCounter = {}
module_function
#--------------------------------------------------------------------------
# alias method: update - Created by OriginalWij
#--------------------------------------------------------------------------
#class <<self; alias input_update_debug update; end
#
##--------------------------------------------------------------------------
## alias method: press? - Created by OriginalWij
##--------------------------------------------------------------------------
#class <<self; alias input_press_debug press?; end
#def self.press?(key)
# return input_press_debug(key) if default_key?(key)
# adjusted_key = adjust_key(key)
# return true unless KeyRepeatCounter[adjusted_key].nil?
# return key_pressed?(adjusted_key)
#end
#
##--------------------------------------------------------------------------
## alias method: trigger? - Created by OriginalWij
##--------------------------------------------------------------------------
#class <<self; alias input_trigger_debug trigger?; end
#def self.trigger?(key)
# return input_trigger_debug(key) if default_key?(key)
# adjusted_key = adjust_key(key)
# count = KeyRepeatCounter[adjusted_key]
# return ((count == 0) || (count.nil? ? key_pressed?(adjusted_key) : false))
#end
#
##--------------------------------------------------------------------------
## alias method: repeat? - Created by OriginalWij
##--------------------------------------------------------------------------
#class <<self; alias input_repeat_debug repeat?; end
#def self.repeat?(key)
# return input_repeat_debug(key) if default_key?(key)
# adjusted_key = adjust_key(key)
# count = KeyRepeatCounter[adjusted_key]
# return true if count == 0
# if count.nil?
# return key_pressed?(adjusted_key)
# else
# return (count >= 23 && (count - 23) % 6 == 0)
# end
#end
#--------------------------------------------------------------------------
# new method: default_key? - Created by Yanfly
#--------------------------------------------------------------------------
def self.default_key?(key)
return true if key.is_a?(Integer) && key < 30
return DEFAULT.include?(key)
end
#--------------------------------------------------------------------------
# new method: adjust_key - Created by OriginalWij
#--------------------------------------------------------------------------
def self.adjust_key(key)
key -= 130 if key.between?(130, 158)
return key
end
#--------------------------------------------------------------------------
# new method: key_pressed? - Created by OriginalWij
#--------------------------------------------------------------------------
def self.key_pressed?(key)
if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
KeyRepeatCounter[key] = 0
return true
end
return false
end
#--------------------------------------------------------------------------
# new method: typing? - Created by Yanfly
#--------------------------------------------------------------------------
def self.typing?
return true if repeat?(SPACE)
for i in 'A'..'Z'
return true if repeat?(LETTERS[i])
end
for i in 0...NUMBERS.size
return true if repeat?(NUMBERS[i])
return true if repeat?(NUMPAD[i])
end
for key in Extras
return true if repeat?(key)
end
return false
end
#--------------------------------------------------------------------------
# new method: key_type - Created by Yanfly
#--------------------------------------------------------------------------
def self.key_type
return " " if repeat?(SPACE)
for i in 'A'..'Z'
next unless repeat?(LETTERS[i])
return upcase? ? i.upcase : i.downcase
end
for i in 0...NUMBERS.size
return i.to_s if repeat?(NUMPAD[i])
if !press?(KEYMAP[:SHIFT])
return i.to_s if repeat?(NUMBERS[i])
elsif repeat?(NUMBERS[i])
case i
when 1; return "!"
when 2; return "@"
when 3; return "#"
when 4; return "$"
when 5; return "%"
when 6; return "^"
when 7; return "&"
when 8; return "*"
when 9; return "("
when 0; return ")"
end
end
end
for key in Extras
next unless repeat?(key)
case key
when USCORE; return press?(KEYMAP[:SHIFT]) ? "_" : "-"
when EQUALS; return press?(KEYMAP[:SHIFT]) ? "+" : "="
when LBRACE; return press?(KEYMAP[:SHIFT]) ? "{" : "["
when RBRACE; return press?(KEYMAP[:SHIFT]) ? "}" : "]"
when BSLASH; return press?(KEYMAP[:SHIFT]) ? "|" : "\\"
when SCOLON; return press?(KEYMAP[:SHIFT]) ? ":" : ";"
when QUOTE; return press?(KEYMAP[:SHIFT]) ? '"' : "'"
when COMMA; return press?(KEYMAP[:SHIFT]) ? "<" : ","
when PERIOD; return press?(KEYMAP[:SHIFT]) ? ">" : "."
when SLASH; return press?(KEYMAP[:SHIFT]) ? "?" : "/"
when NMUL; return "*"
when NPLUS; return "+"
when NSEP; return ","
when NMINUS; return "-"
when NDECI; return "."
when NDIV; return "/"
end
end
return ""
end
#--------------------------------------------------------------------------
# new method: upcase? - Created by Yanfly
#--------------------------------------------------------------------------
def self.upcase?
return !press?(KEYMAP[:SHIFT]) if GetCapState.call(CAPS) == 1
return true if press?(KEYMAP[:SHIFT])
return false
end
end # Input
#==============================================================================
# ■ Clipboard
#==============================================================================
module Clipboard
# Version: 1.2.3
# Last Update: March 22nd, 2014
# Author: Zalerinian (~ZF)
# Clipboard functions
OpenClipboard = Ruby310Compat.native_api('user32', 'OpenClipboard', ['I'], 'I');
CloseClipboard = Ruby310Compat.native_api('user32', 'CloseClipboard', [], 'I');
EmptyClipboard = Ruby310Compat.native_api('user32', 'EmptyClipboard', [], 'I');
GetClipboardData = Ruby310Compat.native_api('user32', 'GetClipboardData', ['I'], 'I');
SetClipboardData = Ruby310Compat.native_api('user32', 'SetClipboardData', ['I', 'I'], 'I');
Alloc = Ruby310Compat.native_api('kernel32', 'GlobalAlloc', ['I','I'], 'I');
Lock = Ruby310Compat.native_api('kernel32', 'GlobalLock', ['I'], 'P');
Unlock = Ruby310Compat.native_api('kernel32', 'GlobalUnlock', ['I'], 'I');
Len = Ruby310Compat.native_api('kernel32', 'lstrlenA', ['P'], 'I');
Copy = Ruby310Compat.native_api('kernel32', 'lstrcpyA', ['I', 'P'], 'P');
LockI = Ruby310Compat.native_api('kernel32', 'GlobalLock', ['I'], 'I');
#--------------------------------------------------------------------------
# Clipboard: GetText NEW METHOD
# * This method will get the text currently on the users clipboard and
# * return it.
#--------------------------------------------------------------------------
def self.GetText
result = ""
if OpenClipboard.Call(0) != 0
if (h = GetClipboardData.Call(1)) != 0
if (p = Lock.Call(h)) != 0
result = p;
Unlock.Call(h);
end
end
CloseClipboard.Call;
end
return result;
end
#--------------------------------------------------------------------------
# Clipboard: SetText NEW METHOD
# * This will allow you to set the text of the clipboard so that the user
# * may paste information elsewhere.
#--------------------------------------------------------------------------
def self.SetText(text)
if (text == nil) || (text == "")
return
end
if OpenClipboard.Call(0) != 0
EmptyClipboard.Call();
len = Len.Call(text);
hmem = Alloc.Call(0x2000, len+1);
pmem = LockI.Call(hmem);
Copy.Call(pmem, text);
SetClipboardData.Call(1, hmem);
Unlock.Call(hmem);
CloseClipboard.Call;
end
end
end # Clipboard
#==============================================================================
# ■ SceneManager
#==============================================================================
module SceneManager
#--------------------------------------------------------------------------
# new method: self.force_recall
#--------------------------------------------------------------------------
def self.force_recall(scene_class)
@scene = scene_class
end
end # SceneManager
#==============================================================================
# ■ Sprite_DebugMap
#==============================================================================
#==============================================================================
# ■ Scene_Base
#==============================================================================
class Scene_Base
#attr_accessor :code_rec
#attr_accessor :code_rec_cur
#--------------------------------------------------------------------------
# alias method: update_basic
#--------------------------------------------------------------------------
alias scene_base_update_debug update
def update
scene_base_update_debug
trigger_debug_window_entry
end
#--------------------------------------------------------------------------
# new method: trigger_debug_window_entry
#--------------------------------------------------------------------------
def trigger_debug_window_entry
if defined?(Input) && ((defined?(Input::F10) && Input.trigger?(Input::F10)) || (defined?(Input::TILDE) && Input.trigger?(Input::TILDE)))
LonaCoreSecurity.blocked_console! if defined?(LonaCoreSecurity)
end
false
rescue
false
end
#--------------------------------------------------------------------------
# new method: process_debug_window_entry
#--------------------------------------------------------------------------
def process_debug_window_entry
return false
return LonaCoreSecurity.blocked_console! if defined?(LonaCoreSecurity) && !LonaCoreSecurity.console_allowed?
if !@code_rec
@code_rec = [] if !$TEST
@code_rec = ['load_script("asd.rb")','$game_map.interpreter.new_game_GetDebugSkills'] if $TEST
end
@code_rec_cur = 0 if @code_rec_cur
Graphics.freeze
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 8000
@debug_entry_window = Window_DebugEntry.new(@code_rec)
@debug_entry_window.viewport = viewport
@debug_entry_window_PRP_REC = Window_Debug_PRP_REC.new
@debug_entry_window_PRP_REC.viewport = viewport
Graphics.transition(4)
#---
update_debug_window_entry
#---
Graphics.freeze
@debug_entry_window.dispose
@debug_entry_window = nil
@debug_entry_window_PRP_REC.dispose
@debug_entry_window_PRP_REC = nil
viewport.dispose
Graphics.transition(4)
end
#--------------------------------------------------------------------------
# new method: update_debug_window_entry
#--------------------------------------------------------------------------
def update_debug_window_entry
return false
loop do
Graphics.update
Input.update
@debug_entry_window.update
@debug_entry_window_PRP_REC.update
if Input.trigger?(Input::F10) || Input.trigger?(Input::TILDE)
SndLib.sys_cancel
break
end
if Input.trigger?(Input::ENTER)
code = @debug_entry_window.text
begin
return LonaCoreSecurity.blocked_console! if defined?(LonaCoreSecurity) && !LonaCoreSecurity.console_allowed?
@code_rec = @code_rec.last(9) if @code_rec.length >= 10
@code_rec << code
@debug_entry_window.code_rec = @code_rec
eval(code)
prp "EXEC: #{code}",2
SndLib.sys_ok
#if !Input.press?(:SHIFT)
# break
#else
@debug_entry_window.clearn_characters
@debug_entry_window.update_record_array(@code_rec)
@debug_entry_window.refresh
@debug_entry_window_PRP_REC.refresh
#end
rescue Exception => ex
prp "ERROR: #{ex.message}",1 #print error message
@debug_entry_window_PRP_REC.refresh
SndLib.sys_buzzer
end
end
end
end
end # Scene_Base
class Window_Debug_PRP_REC < Window_Base
def initialize
dx = -standard_padding
@dy = 0-standard_padding
dw = Graphics.width + standard_padding * 2
dh = Graphics.height #- standard_padding * 1
super(dx, @dy, dw, dh)
contents.font.name = System_Settings::MESSAGE_WINDOW_FONT_NAME
contents.font.bold = false
contents.font.italic = false
contents.font.shadow = false
contents.font.outline = true
contents.font.color = Color.new(255,255, 255)
contents.font.size = 12
self.z = self.z-1
self.y = -dh
self.opacity = 255
#@rect = Rect.new(4, 0, Graphics.width, 24)
refresh
end
def refresh
contents.clear
vol = 0
contents.font.color = Color.new(255, 255, 255)
contents.draw_text(Rect.new(4, Graphics.height-contents.font.size*4, Graphics.width-standard_padding, 24), "#{$data_system.game_title}.#{ $data_system.version_id.to_s(16).upcase}" , 2)
$PRP_REC.each{|rec,color|
case color
when 1 ; contents.font.color = Color.new(255, 63, 0)
when 2 ; contents.font.color = Color.new(42, 255, 0)
when 3 ; contents.font.color = Color.new(66, 101, 255)
when 4 ; contents.font.color = Color.new(0, 255, 255)
when 5 ; contents.font.color = Color.new(255, 0, 255)
when 6 ; contents.font.color = Color.new(255, 255, 0)
else ; contents.font.color = Color.new(255, 255, 255)
end
contents.draw_text(Rect.new(8, vol*contents.font.size, 8192, 24), rec , 0)
#contents.draw_text(Rect.new(8, standard_padding+vol*16, 8192, 24), rec , 0)
vol+=1
}
end
def update
super
return if self.y >= @dy
self.y += Graphics.height/4
self.y = @dy if self.y >= @dy
end
end #Window_Debug_PRP_REC
class Window_DebugEntry < Window_Base
attr_accessor :text
attr_accessor :code_rec
def initialize(code_rec)
dx = -standard_padding
dy = Graphics.height - fitting_height(1) + standard_padding
dw = Graphics.width + standard_padding * 2
dh = fitting_height(1)
super(dx, dy, dw, dh)
contents.font.name = System_Settings::MESSAGE_WINDOW_FONT_NAME
contents.font.bold = false
contents.font.italic = false
contents.font.shadow = false
contents.font.outline = false
contents.font.size = 20
contents.font.color = Color.new(255, 255, 255)
self.opacity = 0
@text = ""
update_record_array(code_rec)
@text_pos = 0
@rect = Rect.new(4, 0, 8192, 24)
refresh
end
def refresh
contents.clear
cw = contents.width
contents.fill_rect(0, 0, cw, line_height, Color.new(192, 192, 192))
contents.fill_rect(1, 1, contents.width-2, line_height-2, Color.new(0, 0, 0))
if @blink
tmpTEXT = @text.clone
contents.draw_text(@rect, tmpTEXT.insert(@text_pos, "|"), 0)
else
tmpTEXT = @text.clone
contents.draw_text(@rect, tmpTEXT.insert(@text_pos, " "), 0)
end
end
def update
super
@blink = !@blink if (Graphics.frame_count % 30 == 0)
maximum = 256
if Input.repeat?(:DOWN) && @code_rec.length > 0
@text = "#{@code_rec[@current_code_rec]}"
@text_pos = @text.size
@current_code_rec += 1
@current_code_rec = @code_rec.length-1 if @current_code_rec > @code_rec.length-1
# user clipboard access:
elsif Input.repeat?(:LETTER_V) && Input.press?(:CTRL) && @text.size <= maximum
clipboard_text = Clipboard.GetText
# parse multi-line input:
regex_map = {
# multiple spaces at the start of the line:
/^\s+/ => " ",
# \ at the end of line:
/\\[\r\n]+\s?/ => "",
# commas:
/,[\r\n]+/ => ", ",
/;[\r\n]+/ => "; ",
# {} block:
/(?<=\=\s\{|\=\{)([\S\s]+?)(?=})(?!}\S)/ => proc { |s| s.gsub(/\s+/, ' ') },
# [] block:
/(?<=\[)([\S\s]+?)(?=\])/ => proc { |s| s.gsub(/\s+/, ' ') },
# () block:
/(?<=\()([\S\s]+?)(?=\))/ => proc { |s| s.gsub(/\s+/, ' ') },
# standard behavior:
/[\r\n]+/ => "; ",
}
regex_map.each { |key, value|
value.is_a?(Proc) ? clipboard_text.gsub!(key, &value) : clipboard_text.gsub!(key, value)
}
# remove 'v' that was typed:
if @text[@text_pos] == 'v'
char_arr = @text.chars
char_arr.delete_at(@text_pos)
@text = char_arr.join
end
if @text.size + clipboard_text.size <= maximum
@text.insert(@text_pos, clipboard_text)
@text_pos += clipboard_text.size
else
prp "Error: clipboard text too long.",1
end
#
elsif Input.repeat?(:UP) && @code_rec.length > 0
@text = "#{@code_rec[@current_code_rec]}"
@text_pos = @text.size
@current_code_rec -= 1
@current_code_rec = 0 if @current_code_rec < 0
elsif Input.repeat?(:RIGHT) && @text.size > 0
Input.press?(:CTRL) ? @text_pos += 7 : @text_pos += 1
if @text_pos > @text.size
SndLib.sys_buzzer
@text_pos = @text.size
end
elsif Input.repeat?(:LEFT) && @text.size > 0
Input.press?(:CTRL) ? @text_pos -= 7 : @text_pos -=1
if @text_pos < 0
SndLib.sys_buzzer
@text_pos = 0
end
elsif Input.repeat?(:DELETE)# && @text.size > 0
Input.press?(:CTRL) ? howMany = 7 : howMany =1
howMany.times{
if @text_pos >= @text.size
#SndLib.sys_buzzer
@text_pos = @text.size
else
@text[@text_pos] = ""
end
}
elsif Input.typing? && @text.size <= maximum
#@text += Input.key_type
@text.insert(@text_pos, Input.key_type)
@text_pos +=1
elsif Input.repeat?(Input::BACK) && @text.size > 0
Input.press?(:CTRL) ? howMany = 7 : howMany =1
howMany.times{
return if @text_pos == 0
@text[@text_pos - 1] = ""
@text_pos -=1
}
end
refresh
end
def clearn_characters
@text_pos = 0
@text = ""
end
def update_record_array(data)
@code_rec = data
@current_code_rec = [0,@code_rec.length-1].max
end
end # Window_DebugEntry