mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 21:24:59 +00:00
Remove Scripts folder to convert to submodule
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
module PBDebug
|
||||
@@log = []
|
||||
|
||||
def self.logonerr
|
||||
begin
|
||||
yield
|
||||
rescue
|
||||
PBDebug.log("")
|
||||
PBDebug.log("**Exception: #{$!.message}")
|
||||
PBDebug.log("#{$!.backtrace.inspect}")
|
||||
PBDebug.log("")
|
||||
# if $INTERNAL
|
||||
pbPrintException($!)
|
||||
# end
|
||||
PBDebug.flush
|
||||
end
|
||||
end
|
||||
|
||||
def self.flush
|
||||
if $DEBUG && $INTERNAL && @@log.length>0
|
||||
File.open("Data/debuglog.txt", "a+b") { |f| f.write("#{@@log}") }
|
||||
end
|
||||
@@log.clear
|
||||
end
|
||||
|
||||
def self.log(msg)
|
||||
if $DEBUG && $INTERNAL
|
||||
@@log.push("#{msg}\r\n")
|
||||
# if @@log.length>1024
|
||||
PBDebug.flush
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
def self.dump(msg)
|
||||
if $DEBUG && $INTERNAL
|
||||
File.open("Data/dumplog.txt", "a+b") { |f| f.write("#{msg}\r\n") }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,54 +0,0 @@
|
||||
# To use the console, use the executable explicitly built
|
||||
# with the console enabled on Windows. On Linux and macOS,
|
||||
# just launch the executable directly from a terminal.
|
||||
module Console
|
||||
def self.setup_console
|
||||
return unless $DEBUG
|
||||
echoln "--------------------------------"
|
||||
echoln "#{System.game_title} Output Window"
|
||||
echoln "--------------------------------"
|
||||
echoln "If you are seeing this window, you are running"
|
||||
echoln "#{System.game_title} in Debug Mode. This means"
|
||||
echoln "that you're either playing a Debug Version, or"
|
||||
echoln "you are playing from within RPG Maker XP."
|
||||
echoln ""
|
||||
echoln "Closing this window will close the game. If"
|
||||
echoln "you want to get rid of this window, run the"
|
||||
echoln "program from the Shell, or download a Release"
|
||||
echoln "version."
|
||||
echoln ""
|
||||
echoln "--------------------------------"
|
||||
echoln "Debug Output:"
|
||||
echoln "--------------------------------"
|
||||
echoln ""
|
||||
end
|
||||
|
||||
def self.readInput
|
||||
return gets.strip
|
||||
end
|
||||
|
||||
def self.readInput2
|
||||
return self.readInput
|
||||
end
|
||||
|
||||
def self.get_input
|
||||
echo self.readInput2
|
||||
end
|
||||
end
|
||||
|
||||
module Kernel
|
||||
def echo(string)
|
||||
return unless $DEBUG
|
||||
printf(string.is_a?(String) ? string : string.inspect)
|
||||
end
|
||||
|
||||
def echoln(string)
|
||||
caller_info = caller(1..1).first
|
||||
file, line, method = caller_info.split(":")
|
||||
echo "#{file}, #{line}:\t"
|
||||
echo(string)
|
||||
echo("\r\n")
|
||||
end
|
||||
end
|
||||
|
||||
Console.setup_console
|
||||
@@ -1,93 +0,0 @@
|
||||
#===============================================================================
|
||||
# Exceptions and critical code
|
||||
#===============================================================================
|
||||
class Reset < Exception
|
||||
end
|
||||
|
||||
def pbGetExceptionMessage(e,_script="")
|
||||
emessage = e.message.dup
|
||||
emessage.force_encoding(Encoding::UTF_8)
|
||||
if e.is_a?(Hangup)
|
||||
emessage = "The script is taking too long. The game will restart."
|
||||
elsif e.is_a?(Errno::ENOENT)
|
||||
filename = emessage.sub("No such file or directory - ", "")
|
||||
emessage = "File #{filename} not found."
|
||||
end
|
||||
emessage.gsub!(/Section(\d+)/) { $RGSS_SCRIPTS[$1.to_i][1] } rescue nil
|
||||
return emessage
|
||||
end
|
||||
|
||||
def pbPrintException(e)
|
||||
emessage = ""
|
||||
if $EVENTHANGUPMSG && $EVENTHANGUPMSG!=""
|
||||
emessage = $EVENTHANGUPMSG # Message with map/event ID generated elsewhere
|
||||
$EVENTHANGUPMSG = nil
|
||||
else
|
||||
emessage = pbGetExceptionMessage(e)
|
||||
end
|
||||
# begin message formatting
|
||||
message = "[Infinite Fusion version #{Settings::GAME_VERSION_NUMBER}]\r\n"
|
||||
if $game_switches
|
||||
message += "Randomized trainers, " if $game_switches[SWITCH_RANDOM_TRAINERS]
|
||||
message += "Randomized gym trainers, " if $game_switches[SWITCH_RANDOMIZE_GYMS_SEPARATELY]
|
||||
message += "Randomized wild Pokemon (global), " if $game_switches[SWITCH_WILD_RANDOM_GLOBAL]
|
||||
message += "Randomized wild Pokemon (area), " if $game_switches[RandomizerWildPokemonOptionsScene::RANDOM_WILD_AREA]
|
||||
message += "All fused, " if $game_switches[SWITCH_RANDOM_TRAINERS]
|
||||
message += "Randomized trainers, " if $game_switches[RandomizerWildPokemonOptionsScene::REGULAR_TO_FUSIONS]
|
||||
end
|
||||
message += "#{Essentials::ERROR_TEXT}\r\n" # For third party scripts to add to
|
||||
message += "Exception: #{e.class}\r\n"
|
||||
message += "Message: #{emessage}\r\n"
|
||||
# show last 10/25 lines of backtrace
|
||||
message += "\r\nBacktrace:\r\n"
|
||||
btrace = ""
|
||||
if e.backtrace
|
||||
maxlength = ($INTERNAL) ? 25 : 10
|
||||
e.backtrace[0, maxlength].each { |i| btrace += "#{i}\r\n" }
|
||||
end
|
||||
btrace.gsub!(/Section(\d+)/) { $RGSS_SCRIPTS[$1.to_i][1] } rescue nil
|
||||
message += btrace
|
||||
# output to log
|
||||
errorlog = "errorlog.txt"
|
||||
errorlog = RTP.getSaveFileName("errorlog.txt") if (Object.const_defined?(:RTP) rescue false)
|
||||
File.open(errorlog, "ab") do |f|
|
||||
f.write("\r\n=================\r\n\r\n[#{Time.now}]\r\n")
|
||||
f.write(message)
|
||||
end
|
||||
# format/censor the error log directory
|
||||
errorlogline = errorlog.gsub("/", "\\")
|
||||
errorlogline.sub!(Dir.pwd + "\\", "")
|
||||
errorlogline.sub!(pbGetUserName, "USERNAME")
|
||||
errorlogline = "\r\n" + errorlogline if errorlogline.length > 20
|
||||
# output message
|
||||
print("#{message}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl when closing this message to copy it to the clipboard.")
|
||||
# Give a ~500ms coyote time to start holding Control
|
||||
t = System.delta
|
||||
until (System.delta - t) >= 500000
|
||||
Input.update
|
||||
if Input.press?(Input::CTRL)
|
||||
Input.clipboard = message
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbCriticalCode
|
||||
ret = 0
|
||||
begin
|
||||
yield
|
||||
ret = 1
|
||||
rescue Exception
|
||||
e = $!
|
||||
if e.is_a?(Reset) || e.is_a?(SystemExit)
|
||||
raise
|
||||
else
|
||||
pbPrintException(e)
|
||||
if e.is_a?(Hangup)
|
||||
ret = 2
|
||||
raise Reset.new
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -1,31 +0,0 @@
|
||||
# The Kernel module is extended to include the validate method.
|
||||
module Kernel
|
||||
private
|
||||
|
||||
# Used to check whether method arguments are of a given class or respond to a method.
|
||||
# @param value_pairs [Hash{Object => Class, Array<Class>, Symbol}] value pairs to validate
|
||||
# @example Validate a class or method
|
||||
# validate foo => Integer, baz => :to_s # raises an error if foo is not an Integer or if baz doesn't implement #to_s
|
||||
# @example Validate a class from an array
|
||||
# validate foo => [Sprite, Bitmap, Viewport] # raises an error if foo isn't a Sprite, Bitmap or Viewport
|
||||
# @raise [ArgumentError] if validation fails
|
||||
def validate(value_pairs)
|
||||
unless value_pairs.is_a?(Hash)
|
||||
raise ArgumentError, "Non-hash argument #{value_pairs.inspect} passed into validate."
|
||||
end
|
||||
errors = value_pairs.map do |value, condition|
|
||||
if condition.is_a?(Array)
|
||||
unless condition.any? { |klass| value.is_a?(klass) }
|
||||
next "Expected #{value.inspect} to be one of #{condition.inspect}, but got #{value.class.name}."
|
||||
end
|
||||
elsif condition.is_a?(Symbol)
|
||||
next "Expected #{value.inspect} to respond to #{condition}." unless value.respond_to?(condition)
|
||||
elsif !value.is_a?(condition)
|
||||
next "Expected #{value.inspect} to be a #{condition.name}, but got #{value.class.name}."
|
||||
end
|
||||
end
|
||||
errors.compact!
|
||||
return if errors.empty?
|
||||
raise ArgumentError, "Invalid argument passed to method.\r\n" + errors.join("\r\n")
|
||||
end
|
||||
end
|
||||
@@ -1,53 +0,0 @@
|
||||
# The Deprecation module is used to warn game & plugin creators of deprecated
|
||||
# methods.
|
||||
module Deprecation
|
||||
module_function
|
||||
|
||||
# Sends a warning of a deprecated method into the debug console.
|
||||
# @param method_name [String] name of the deprecated method
|
||||
# @param removal_version [String] version the method is removed in
|
||||
# @param alternative [String] preferred alternative method
|
||||
def warn_method(method_name, removal_version = nil, alternative = nil)
|
||||
text = _INTL('WARN: usage of deprecated method "{1}" or its alias.', method_name)
|
||||
unless removal_version.nil?
|
||||
text += _INTL("\nThe method is slated to be"\
|
||||
" removed in Essentials {1}.", removal_version)
|
||||
end
|
||||
unless alternative.nil?
|
||||
text += _INTL("\nUse \"{1}\" instead.", alternative)
|
||||
end
|
||||
echoln text
|
||||
end
|
||||
end
|
||||
|
||||
# The Module class is extended to allow easy deprecation of instance and class methods.
|
||||
class Module
|
||||
private
|
||||
|
||||
# Creates a deprecated alias for a method.
|
||||
# Using it sends a warning to the debug console.
|
||||
# @param name [Symbol] name of the new alias
|
||||
# @param aliased_method [Symbol] name of the aliased method
|
||||
# @param removal_in [String] version the alias is removed in
|
||||
# @param class_method [Boolean] whether the method is a class method
|
||||
def deprecated_method_alias(name, aliased_method, removal_in: nil, class_method: false)
|
||||
validate name => Symbol, aliased_method => Symbol, removal_in => [NilClass, String],
|
||||
class_method => [TrueClass, FalseClass]
|
||||
|
||||
target = class_method ? self.class : self
|
||||
class_name = self.name
|
||||
|
||||
unless target.method_defined?(aliased_method)
|
||||
raise ArgumentError, "#{class_name} does not have method #{aliased_method} defined"
|
||||
end
|
||||
|
||||
delimiter = class_method ? '.' : '#'
|
||||
|
||||
target.define_method(name) do |*args, **kvargs|
|
||||
alias_name = format('%s%s%s', class_name, delimiter, name)
|
||||
aliased_method_name = format('%s%s%s', class_name, delimiter, aliased_method)
|
||||
Deprecation.warn_method(alias_name, removal_in, aliased_method_name)
|
||||
method(aliased_method).call(*args, **kvargs)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user