Keyboard Name Input
Seg Set 04, 2023 1:34 am
Keyboard Name Input
por Dekita
[title]
- Introdução:
[/title]Este script que permite que o nome do ator seja colocado com o teclado inteiro, bem mais útil, bonito e lógico para um jogo de computador.
[title]
- Imagens:
[/title]- Clique:
- [Tens de ter uma conta e sessão iniciada para poderes visualizar esta imagem]
[title]
- Código:
[/title]- Código:
if true # << Make true to use this script, false to disable.
#===============================================================================
#
# ☆ $D13x - Keyboard Name Input
# -- Author : Dekita
# -- Version : 1.0
# -- Level : Easy / Normal
# -- Requires : $D13x Core v1.6+
# -- Engine : RPG Maker VX Ace.
#
#===============================================================================
# ☆ Import
#-------------------------------------------------------------------------------
$D13x={}if$D13x==nil
$D13x[:Keyed_NI]=true
#===============================================================================
# ☆ Updates
#-------------------------------------------------------------------------------
# D /M /Y
# o4/o4/2o13 - Finished,
# - Added obscure keys,
# o3/o4/2o13 - Started,
#
#===============================================================================
# ☆ Introduction
#-------------------------------------------------------------------------------
# This script changes the way you rename your characters by allowing
# keyboard input. MOST keys are enabled. (all letters/numbers/symbols)
# You can also deny the usage of certain names, for example, not allowing
# 'naughty' words or any derivitave (uses name =~ regexp to determine match)
#
#===============================================================================
# ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
#===============================================================================
# 1. You MUST give credit to "Dekita" !!
# 2. You are NOT allowed to repost this script.(or modified versions)
# 3. You are NOT allowed to convert this script.
# 4. You are NOT allowed to use this script for Commercial games.
# 5. ENJOY!
#
# "FINE PRINT"
# By using this script you hereby agree to the above terms and conditions,
# if any violation of the above terms occurs "legal action" may be taken.
# Not understanding the above terms and conditions does NOT mean that
# they do not apply to you.
# If you wish to discuss the terms and conditions in further detail you can
# contact me at http://dekitarpg.wordpress.com/
#
#===============================================================================
# ☆ Instructions
#-------------------------------------------------------------------------------
# Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
#
#===============================================================================
# ☆ HELP
#-------------------------------------------------------------------------------
# You really should'nt need any...
#
#===============================================================================
module Keyed_NI
#===============================================================================
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ☆ Settings
#-----------------------------------------------------------------------------
# SE for pressing a key
Key_Press_SE = "Audio/SE/Book1" # "Audio/SE/Cursor1"
# When Key Pressed, Above SE Has Random Pitch ? ( 100+rand(value) )
Allow_Rand_Pitch = [true, 51] # << [ use? , rand value ]
# Help Info Shown In Help Window
Help_Info = [ "Input Name", "Enter = Confirm", "Esc = Cancel Rename" ]
# Allow rename scene to be exited using Esc Key
Allow_Exit = true
# The Way you delete characters, can be :press , :trigger , :release
Delete_Type = :trigger
# keys such as <>,/?;'#:@~[]{}-=_+\|
# if this is false only letter/number keys will show(and SHIFT+Number symbols)
Allow_Obscure_Keys = true
# Max Letters For Each Name (overwrited default setting)
Max_Name_Size = 16
# Names that are classed as illegal. ie not allowed
# uses regex =~ name to determine "illegal" names
Illegal_Names=[
# [ regex , vocab ],
[ /\\/i , "Illegal Character" ],
[ /\//i , "Illegal Character" ],
[ /fuck/i , "Illegal Name" ],
[ /cock/i , "Illegal Name" ],
[ /c0ck/i , "Illegal Name" ],
[ /cunt/i , "Illegal Name" ],
[ /wank/i , "Illegal Name" ],
[ /w4nk/i , "Illegal Name" ],
[ /bitch/i , "Illegal Name" ],
[ /pussy/i , "Illegal Name" ],
[ /pu$$y/i , "Illegal Name" ],
[ /pu$sy/i , "Illegal Name" ],
[ /pus$y/i , "Illegal Name" ],
[ /dick/i , "Illegal Name" ],
[ /d!ck/i , "Illegal Name" ],
] # << KEEP #####################
# CUSTOMISATION END #
end #####################
#☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
# #
# http://dekitarpg.wordpress.com/ #
# #
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
#===============================================================================#
# ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
# YES?\.\. #
# OMG, REALLY? \| #
# WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
# I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
#===============================================================================#
class Window_RenameInfo < Window_Selectable
#===============================================================================
#--------------------------------------------------------------------------
# Object Initialization
#--------------------------------------------------------------------------
def initialize(actor)
x = (Graphics.width - 100) / 2
y = (Graphics.height / 4 )
super(x, y, 104, 104)
@actor = actor
refresh
deactivate
end
#--------------------------------------------------------------------------
# Set Line Height
#--------------------------------------------------------------------------
def line_height
return 22
end
#--------------------------------------------------------------------------
# Set Padding
#--------------------------------------------------------------------------
def standard_padding
return 8
end
#--------------------------------------------------------------------------
# Set Actor
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_actor_face(@actor,-3,-2)
end
end
#===============================================================================
class Window_RenameInfo_II < Window_Selectable
#===============================================================================
#--------------------------------------------------------------------------
# Object Initialization
#--------------------------------------------------------------------------
def initialize(actor)
x = (Graphics.width - 360) / 2
y = (Graphics.height / 4 * 2 )
super(x, y, 360, y / 2)
@actor = actor
@help_text = ""
refresh
deactivate
end
#--------------------------------------------------------------------------
# Set Line Height
#--------------------------------------------------------------------------
def line_height
return 22
end
#--------------------------------------------------------------------------
# Set Standard Padding
#--------------------------------------------------------------------------
def standard_padding
return 8
end
#--------------------------------------------------------------------------
# Set Actor
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
if !General::Fonts.include?(self.contents.font.name)
self.contents.font.name = General::Fonts
end
if self.contents.font.size != General::Font_Size
self.contents.font.size = 22
end
if self.contents.font.bold != General::Font_Bold
self.contents.font.bold = false
end
change_color(Text_Color::White)
w = self.width-(standard_padding*2)
Keyed_NI::Help_Info.each_with_index do |text, i|
draw_text(0, line_height * i, w, line_height, text, 1)
end
change_color(Text_Color::Deep_Red)
text = @help_text
draw_text(0, line_height * 3, w, line_height, text, 1)
end
#--------------------------------------------------------------------------
# Set Help Text
#--------------------------------------------------------------------------
def help_text=(text)
return if @help_text == text
@help_text = text
refresh
end
end
#===============================================================================
class Window_NameEdit < Window_Base
#===============================================================================
#--------------------------------------------------------------------------
# Object Initialization
#--------------------------------------------------------------------------
def initialize(actor, max_char = 18)
x = (Graphics.width - 360) / 2
y = (Graphics.height / 4 * 3 )
super(x, y, 360, fitting_height(1))
@actor = actor
@max_char = max_char
@default_name = @name = actor.name[0, @max_char]
@index = @name.size
refresh
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
if !General::Fonts.include?(self.contents.font.name)
self.contents.font.name = General::Fonts
end
if self.contents.font.size != General::Font_Size
self.contents.font.size = 22
end
if self.contents.font.bold != General::Font_Bold
self.contents.font.bold = false
end
@name.size.times {|i| draw_char(i) }
new_c_rect
end
#--------------------------------------------------------------------------
# Draw Text
#--------------------------------------------------------------------------
def draw_char(index)
rect = item_rect(index)
rect.x -= 1
rect.y = 0
change_color(normal_color)
draw_text(rect, @name[index] || "")
end
#--------------------------------------------------------------------------
# Get Cursor Rect
#--------------------------------------------------------------------------
def new_c_rect
x = (item_rect(@name.size).x)
rect = Rect.new(x,0,2,22)
cursor_rect.set(rect)
end
end
#===============================================================================
class Window_NameInput < Window_Selectable
#===============================================================================
#--------------------------------------------------------------------------
# Object Initialization
#--------------------------------------------------------------------------
def initialize(edit_window)
super(0, Graphics.height, 0, 0)
@edit_window = edit_window
@halp_window = nil
@index = 0
@page = 0
refresh
update_cursor
activate
end
#--------------------------------------------------------------------------
# Set Info Window
#--------------------------------------------------------------------------
def halp_window=(window)
return if @halp_window == window
@halp_window = window
end
#--------------------------------------------------------------------------
# Cursor Movement Processing ( overwrite )
#--------------------------------------------------------------------------
def process_cursor_move
# << Removed Code
end
#--------------------------------------------------------------------------
# Processing for Key Presses ( overwrite )
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
check_letter_keys
check_number_keys
check_obscure_keys
check_delete_char
on_name_ok if Keys.trigger?(Keys::Key[:ENTER])
on_rename_exit if Keys.trigger?(Keys::Key[:ESC])
end
#--------------------------------------------------------------------------
# Processing for Deleting Characters
#--------------------------------------------------------------------------
def check_delete_char
case Keyed_NI::Delete_Type
when :press then process_back if Keys.press?( Keys::Key[:BACK])
when :trigger then process_back if Keys.trigger?(Keys::Key[:BACK])
when :release then process_back if Keys.release?(Keys::Key[:BACK])
else ; process_back if Keys.press?( Keys::Key[:BACK])
end
end
#--------------------------------------------------------------------------
# Processing for Key Presses [ LETTERS ]
#--------------------------------------------------------------------------
def check_letter_keys
pressed_key("a",true) if Keys.trigger?(Keys::Key[:A])
pressed_key("b",true) if Keys.trigger?(Keys::Key[:B])
pressed_key("c",true) if Keys.trigger?(Keys::Key[:C])
pressed_key("d",true) if Keys.trigger?(Keys::Key[:D])
pressed_key("e",true) if Keys.trigger?(Keys::Key[:E])
pressed_key("f",true) if Keys.trigger?(Keys::Key[:F])
pressed_key("g",true) if Keys.trigger?(Keys::Key[:G])
pressed_key("h",true) if Keys.trigger?(Keys::Key[:H])
pressed_key("i",true) if Keys.trigger?(Keys::Key[:I])
pressed_key("j",true) if Keys.trigger?(Keys::Key[:J])
pressed_key("k",true) if Keys.trigger?(Keys::Key[:K])
pressed_key("l",true) if Keys.trigger?(Keys::Key[:L])
pressed_key("m",true) if Keys.trigger?(Keys::Key[:M])
pressed_key("n",true) if Keys.trigger?(Keys::Key[:N])
pressed_key("o",true) if Keys.trigger?(Keys::Key[:O])
pressed_key("p",true) if Keys.trigger?(Keys::Key[:P])
pressed_key("q",true) if Keys.trigger?(Keys::Key[:Q])
pressed_key("r",true) if Keys.trigger?(Keys::Key[:R])
pressed_key("s",true) if Keys.trigger?(Keys::Key[:S])
pressed_key("t",true) if Keys.trigger?(Keys::Key[:T])
pressed_key("u",true) if Keys.trigger?(Keys::Key[:U])
pressed_key("v",true) if Keys.trigger?(Keys::Key[:V])
pressed_key("w",true) if Keys.trigger?(Keys::Key[:W])
pressed_key("x",true) if Keys.trigger?(Keys::Key[:X])
pressed_key("y",true) if Keys.trigger?(Keys::Key[:Y])
pressed_key("z",true) if Keys.trigger?(Keys::Key[:Z])
pressed_key(" ") if Keys.trigger?(Keys::Key[:SPACE])
end
#--------------------------------------------------------------------------
# Processing for Key Presses [ NUMBERS ]
#--------------------------------------------------------------------------
def check_number_keys
if Keys.trigger?(Keys::Key[:_1])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("!") : pressed_key("1")
end
if Keys.trigger?(Keys::Key[:_2])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key('"') : pressed_key("2")
end
if Keys.trigger?(Keys::Key[:_3])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("£") : pressed_key("3")
end
if Keys.trigger?(Keys::Key[:_4])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("$") : pressed_key("4")
end
if Keys.trigger?(Keys::Key[:_5])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("%") : pressed_key("5")
end
if Keys.trigger?(Keys::Key[:_6])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("^") : pressed_key("6")
end
if Keys.trigger?(Keys::Key[:_7])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("&") : pressed_key("7")
end
if Keys.trigger?(Keys::Key[:_8])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("*") : pressed_key("8")
end
if Keys.trigger?(Keys::Key[:_9])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("(") : pressed_key("9")
end
if Keys.trigger?(Keys::Key[:_0])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key(")") : pressed_key("0")
end
pressed_key("0") if Keys.trigger?(Keys::Key[:N_0])
pressed_key("1") if Keys.trigger?(Keys::Key[:N_1])
pressed_key("2") if Keys.trigger?(Keys::Key[:N_2])
pressed_key("3") if Keys.trigger?(Keys::Key[:N_3])
pressed_key("4") if Keys.trigger?(Keys::Key[:N_4])
pressed_key("5") if Keys.trigger?(Keys::Key[:N_5])
pressed_key("6") if Keys.trigger?(Keys::Key[:N_6])
pressed_key("7") if Keys.trigger?(Keys::Key[:N_7])
pressed_key("8") if Keys.trigger?(Keys::Key[:N_8])
pressed_key("9") if Keys.trigger?(Keys::Key[:N_9])
end
#--------------------------------------------------------------------------
# Check Obscure Keys
#--------------------------------------------------------------------------
def check_obscure_keys
return unless Keyed_NI::Allow_Obscure_Keys
pressed_key("/") if Keys.trigger?(Keys::Key[:DIV])
pressed_key("*") if Keys.trigger?(Keys::Key[:MUL])
pressed_key("-") if Keys.trigger?(Keys::Key[:SUB])
pressed_key("+") if Keys.trigger?(Keys::Key[:ADD])
pressed_key(".") if Keys.trigger?(Keys::Key[:DECI])
if Keys.trigger?(Keys::Key[:S_Colon])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key(":") : pressed_key(";")
end
if Keys.trigger?(Keys::Key[:Equal])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("+") : pressed_key("=")
end
if Keys.trigger?(Keys::Key[:Comma])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("<") : pressed_key(",")
end
if Keys.trigger?(Keys::Key[:Minus])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("_") : pressed_key("-")
end
if Keys.trigger?(Keys::Key[:Period])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key(">") : pressed_key(".")
end
if Keys.trigger?(Keys::Key[:F_Slash])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("?") : pressed_key("/")
end
if Keys.trigger?(Keys::Key[:HASH])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("~") : pressed_key("#")
end
if Keys.trigger?(Keys::Key[:L_Sqr_Brack])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("{") : pressed_key("[")
end
if Keys.trigger?(Keys::Key[:B_Slash])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("|") : pressed_key("\\")
end
if Keys.trigger?(Keys::Key[:R_Sqr_Brack])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("}") : pressed_key("]")
end
if Keys.trigger?(Keys::Key[:S_Quote])
Keys.press?(Keys::Key[:SHIFT]) ? pressed_key("@") : pressed_key("'")
end
end
#--------------------------------------------------------------------------
# Tranfer Key Press To Character
#--------------------------------------------------------------------------
def pressed_key(key, letter = false)
if letter
key = key.upcase if Keys.press?(Keys::Key[:SHIFT])
if Keys.repeat?(Keys::Key[:CAPS])
key = key.upcase
key = key.downcase if Keys.press?(Keys::Key[:SHIFT])
end
end
@edit_window.add(key)
mod = Keyed_NI::Allow_Rand_Pitch
pitch = mod[0] ? 100+rand(mod[1]) : 100
Audio.se_play(Keyed_NI::Key_Press_SE, 80, pitch)
end
#--------------------------------------------------------------------------
# Exit Rename Scene Using Esc Key
#--------------------------------------------------------------------------
def on_rename_exit
return unless Keyed_NI::Allow_Exit
if @edit_window.restore_default
call_ok_handler
Sound.play_ok
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# Decide Name
#--------------------------------------------------------------------------
def on_name_ok
if @edit_window.name.empty?
if @edit_window.restore_default
Sound.play_ok
else
Sound.play_buzzer
end
else
Keyed_NI::Illegal_Names.each do |bad_name|
if @edit_window.name =~ bad_name[0]
Sound.play_buzzer
return made_a_bo_bo(bad_name[1])
end
end
call_ok_handler
Sound.play_ok
end
end
#--------------------------------------------------------------------------
# Raise Name Error
#--------------------------------------------------------------------------
def made_a_bo_bo(name="NIL")
return if @halp_window == nil
text = "#{name}"
@halp_window.help_text = text
end
end
#===============================================================================
class Scene_Name < Scene_MenuBase
#===============================================================================
#--------------------------------------------------------------------------
# Start Processing
#--------------------------------------------------------------------------
def start
super
@actor = $game_actors[@actor_id]
@edit_window = Window_NameEdit.new(@actor, Keyed_NI::Max_Name_Size)
@input_window = Window_NameInput.new(@edit_window)
@input_window.set_handler(:ok, method(:on_input_ok))
@infoo_window = Window_RenameInfo.new(@actor)
@infoo_window2 = Window_RenameInfo_II.new(@actor)
@input_window.halp_window = @infoo_window2
end
end
#==============================================================================#
# http://dekitarpg.wordpress.com/ #
#==============================================================================#
end # if true # << Make true to use this script, false to disable.
[title]
- Créditos:
[/title]. Criado por: Dekita
Permissões neste sub-fórum
Não podes responder a tópicos
|
|