Standardised compiling-based console messages

This commit is contained in:
Maruno17
2022-11-05 16:18:24 +00:00
parent 6f7a714d48
commit c984fda1cf
9 changed files with 44 additions and 40 deletions

View File

@@ -87,6 +87,13 @@ module Console
echoln "" echoln ""
end end
# Same as echoln_li but text is in green
def echoln_li_done(msg)
self.echo_li(markup_style(msg, text: :green), 0, :green)
echoln ""
echoln ""
end
# paragraph with markup # paragraph with markup
def echo_p(msg) def echo_p(msg)
echoln markup(msg) echoln markup(msg)
@@ -170,7 +177,7 @@ module Console
options_pool = options.select { |key, val| font_options.key?(key) && val } options_pool = options.select { |key, val| font_options.key?(key) && val }
markup_pool = options_pool.keys.map { |opt| font_options[opt] }.join(";").squeeze markup_pool = options_pool.keys.map { |opt| font_options[opt] }.join(";").squeeze
# return formatted string # return formatted string
"\e[#{code_bg};#{markup_pool};#{code_text}m#{string}\e[0m".squeeze(";") return "\e[#{code_bg};#{markup_pool};#{code_text}m#{string}\e[0m".squeeze(";")
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@@ -295,7 +295,7 @@ module PluginManager
def self.error(msg) def self.error(msg)
Graphics.update Graphics.update
t = Thread.new do t = Thread.new do
Console.echo_error "Plugin Error:\r\n#{msg}" Console.echo_error("Plugin Error:\r\n#{msg}")
print("Plugin Error:\r\n#{msg}") print("Plugin Error:\r\n#{msg}")
Thread.exit Thread.exit
end end
@@ -594,7 +594,7 @@ module PluginManager
# Check if plugins need compiling # Check if plugins need compiling
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def self.compilePlugins(order, plugins) def self.compilePlugins(order, plugins)
Console.echo_li "Compiling plugin scripts..." Console.echo_li("Compiling plugin scripts...")
scripts = [] scripts = []
# go through the entire order one by one # go through the entire order one by one
order.each do |o| order.each do |o|
@@ -617,20 +617,19 @@ module PluginManager
# collect garbage # collect garbage
GC.start GC.start
Console.echo_done(true) Console.echo_done(true)
echoln "" if scripts.length == 0
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Check if plugins need compiling # Check if plugins need compiling
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def self.runPlugins def self.runPlugins
Console.echo_h1 "Checking plugins" Console.echo_h1("Checking plugins")
# get the order of plugins to interpret # get the order of plugins to interpret
order, plugins = self.getPluginOrder order, plugins = self.getPluginOrder
# compile if necessary # compile if necessary
if self.needCompiling?(order, plugins) if self.needCompiling?(order, plugins)
self.compilePlugins(order, plugins) self.compilePlugins(order, plugins)
else else
Console.echoln_li "Plugins were not compiled." Console.echoln_li("Plugins were not compiled")
end end
# load plugins # load plugins
scripts = load_data("Data/PluginScripts.rxdata") scripts = load_data("Data/PluginScripts.rxdata")
@@ -639,7 +638,7 @@ module PluginManager
# get the required data # get the required data
name, meta, script = plugin name, meta, script = plugin
if !meta[:essentials] || !meta[:essentials].include?(Essentials::VERSION) if !meta[:essentials] || !meta[:essentials].include?(Essentials::VERSION)
Console.echo_warn "Plugin '#{name}' may not be compatible with Essentials v#{Essentials::VERSION}. Trying to load anyway." Console.echo_warn("Plugin '#{name}' may not be compatible with Essentials v#{Essentials::VERSION}. Trying to load anyway.")
end end
# register plugin # register plugin
self.register(meta) self.register(meta)
@@ -655,7 +654,7 @@ module PluginManager
# try to run the code # try to run the code
begin begin
eval(code, TOPLEVEL_BINDING, fname) eval(code, TOPLEVEL_BINDING, fname)
Console.echoln_li "Loaded plugin: ==#{name}== (ver. #{meta[:version]})" if !echoed_plugins.include?(name) Console.echoln_li("Loaded plugin: ==#{name}== (ver. #{meta[:version]})") if !echoed_plugins.include?(name)
echoed_plugins.push(name) echoed_plugins.push(name)
rescue Exception # format error message to display rescue Exception # format error message to display
self.pluginErrorMsg(name, sname) self.pluginErrorMsg(name, sname)
@@ -664,10 +663,9 @@ module PluginManager
end end
end end
if scripts.length > 0 if scripts.length > 0
echoln "" Console.echoln_li_done("Successfully loaded #{scripts.length} plugin(s)")
Console.echo_h2("Successfully loaded #{scripts.length} plugin(s)", text: :green)
else else
Console.echo_h2("No plugins found", text: :green) Console.echoln_li_done("No plugins found")
end end
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@@ -195,14 +195,13 @@ module SaveData
conversions_to_run = self.get_conversions(save_data) conversions_to_run = self.get_conversions(save_data)
return false if conversions_to_run.none? return false if conversions_to_run.none?
File.open(SaveData::FILE_PATH + ".bak", "wb") { |f| Marshal.dump(save_data, f) } File.open(SaveData::FILE_PATH + ".bak", "wb") { |f| Marshal.dump(save_data, f) }
Console.echo_h1 "Running #{conversions_to_run.length} save file conversions" Console.echo_h1(_INTL("Converting save file"))
conversions_to_run.each do |conversion| conversions_to_run.each do |conversion|
Console.echo_li "#{conversion.title}..." Console.echo_li("#{conversion.title}...")
conversion.run(save_data) conversion.run(save_data)
Console.echo_done(true) Console.echo_done(true)
end end
echoln "" if conversions_to_run.length > 0 Console.echoln_li_done(_INTL("Successfully applied #{conversions_to_run.length} save file conversion(s)"))
Console.echo_h2("All save file conversions applied successfully", text: :green)
save_data[:essentials_version] = Essentials::VERSION save_data[:essentials_version] = Essentials::VERSION
save_data[:game_version] = Settings::GAME_VERSION save_data[:game_version] = Settings::GAME_VERSION
return true return true

View File

@@ -705,7 +705,7 @@ def pbDebugFixInvalidTiles
t = Time.now.to_i t = Time.now.to_i
Graphics.update Graphics.update
total_maps = mapData.mapinfos.keys.length total_maps = mapData.mapinfos.keys.length
Console.echo_h1 _INTL("Checking {1} maps for invalid tiles", total_maps) Console.echo_h1(_INTL("Checking {1} maps for invalid tiles", total_maps))
mapData.mapinfos.keys.sort.each do |id| mapData.mapinfos.keys.sort.each do |id|
if Time.now.to_i - t >= 5 if Time.now.to_i - t >= 5
Graphics.update Graphics.update
@@ -738,7 +738,7 @@ def pbDebugFixInvalidTiles
end end
next if map_errors == 0 next if map_errors == 0
# Map was changed; save it # Map was changed; save it
Console.echoln_li _INTL("{1} error tile(s) found on map {2}: {3}.", map_errors, id, mapData.mapinfos[id].name) Console.echoln_li(_INTL("{1} error tile(s) found on map {2}: {3}.", map_errors, id, mapData.mapinfos[id].name))
total_errors += map_errors total_errors += map_errors
num_error_maps += 1 num_error_maps += 1
mapData.saveMap(id) mapData.saveMap(id)
@@ -749,7 +749,7 @@ def pbDebugFixInvalidTiles
else else
echoln "" echoln ""
Console.echo_h2(_INTL("Done. {1} errors found and fixed.", total_errors), text: :green) Console.echo_h2(_INTL("Done. {1} errors found and fixed.", total_errors), text: :green)
Console.echo_warn _INTL("RMXP data was altered. Close RMXP now to ensure changes are applied.") Console.echo_warn(_INTL("RMXP data was altered. Close RMXP now to ensure changes are applied."))
echoln "" echoln ""
pbMessage(_INTL("{1} error(s) were found across {2} map(s) and fixed.", total_errors, num_error_maps)) pbMessage(_INTL("{1} error(s) were found across {2} map(s) and fixed.", total_errors, num_error_maps))
pbMessage(_INTL("Close RPG Maker XP to ensure the changes are applied properly.")) pbMessage(_INTL("Close RPG Maker XP to ensure the changes are applied properly."))

View File

@@ -17,7 +17,7 @@ module FilenameUpdater
def rename_berry_plant_charsets def rename_berry_plant_charsets
src_dir = "Graphics/Characters/" src_dir = "Graphics/Characters/"
return false if !FileTest.directory?(src_dir) return false if !FileTest.directory?(src_dir)
Console.echo_li _INTL("Renaming berry tree charsets...") Console.echo_li(_INTL("Renaming berry tree charsets..."))
ret = false ret = false
# generates a list of all graphic files # generates a list of all graphic files
files = readDirectoryFiles(src_dir, ["berrytree*.png"]) files = readDirectoryFiles(src_dir, ["berrytree*.png"])
@@ -38,7 +38,7 @@ module FilenameUpdater
mapData = Compiler::MapData.new mapData = Compiler::MapData.new
t = Time.now.to_i t = Time.now.to_i
Graphics.update Graphics.update
Console.echo_li _INTL("Checking {1} maps for used berry tree charsets...", mapData.mapinfos.keys.length) Console.echo_li(_INTL("Checking {1} maps for used berry tree charsets...", mapData.mapinfos.keys.length))
idx = 0 idx = 0
mapData.mapinfos.keys.sort.each do |id| mapData.mapinfos.keys.sort.each do |id|
echo "." if idx % 20 == 0 echo "." if idx % 20 == 0
@@ -71,19 +71,19 @@ module FilenameUpdater
end end
def rename_files def rename_files
Console.echo_h1 "Updating file names and locations" Console.echo_h1(_INTL("Updating file names and locations"))
change_record = [] change_record = []
# Add underscore to berry plant charsets # Add underscore to berry plant charsets
if rename_berry_plant_charsets if rename_berry_plant_charsets
Console.echo_warn _INTL("Berry plant charset files were renamed.") Console.echo_warn(_INTL("Berry plant charset files were renamed."))
end end
change_record += update_berry_tree_event_charsets change_record += update_berry_tree_event_charsets
# Warn if any map data has been changed # Warn if any map data has been changed
if !change_record.empty? if !change_record.empty?
change_record.each { |msg| Console.echo_warn msg } change_record.each { |msg| Console.echo_warn(msg) }
Console.echo_warn _INTL("RMXP data was altered. Close RMXP now to ensure changes are applied.") Console.echo_warn(_INTL("RMXP data was altered. Close RMXP now to ensure changes are applied."))
end end
echoln "" echoln ""
Console.echo_h2("Finished updating file names and locations", text: :green) Console.echo_h2(_INTL("Finished updating file names and locations"), text: :green)
end end
end end

View File

@@ -740,12 +740,12 @@ module Compiler
#============================================================================= #=============================================================================
def compile_pbs_file_message_start(filename) def compile_pbs_file_message_start(filename)
# The `` around the file's name turns it cyan # The `` around the file's name turns it cyan
Console.echo_li _INTL("Compiling PBS file `{1}`...", filename.split("/").last) Console.echo_li(_INTL("Compiling PBS file `{1}`...", filename.split("/").last))
end end
def write_pbs_file_message_start(filename) def write_pbs_file_message_start(filename)
# The `` around the file's name turns it cyan # The `` around the file's name turns it cyan
Console.echo_li _INTL("Writing PBS file `{1}`...", filename.split("/").last) Console.echo_li(_INTL("Writing PBS file `{1}`...", filename.split("/").last))
end end
def process_pbs_file_message_end def process_pbs_file_message_end
@@ -780,25 +780,25 @@ module Compiler
end end
def compile_all(mustCompile) def compile_all(mustCompile)
Console.echo_h1(_INTL("Checking game data"))
if !mustCompile if !mustCompile
Console.echo_h1(_INTL("Game did not compile data")) Console.echoln_li(_INTL("Game data was not compiled"))
echoln ""
return return
end end
FileLineData.clear FileLineData.clear
Console.echo_h1 _INTL("Compiling all data")
compile_pbs_files compile_pbs_files
compile_animations compile_animations
compile_trainer_events(mustCompile) compile_trainer_events(mustCompile)
Console.echo_li _INTL("Saving messages...") Console.echo_li(_INTL("Saving messages..."))
pbSetTextMessages pbSetTextMessages
MessageTypes.saveMessages MessageTypes.saveMessages
MessageTypes.loadMessageFile("Data/messages.dat") if safeExists?("Data/messages.dat") MessageTypes.loadMessageFile("Data/messages.dat") if safeExists?("Data/messages.dat")
Console.echo_done(true) Console.echo_done(true)
Console.echo_li _INTL("Reloading cache...") Console.echo_li(_INTL("Reloading cache..."))
System.reload_cache System.reload_cache
Console.echo_done(true) Console.echo_done(true)
echoln "" Console.echoln_li_done(_INTL("Successfully compiled all game data"))
Console.echo_h2("Successfully compiled all data", text: :green)
end end
def main def main

View File

@@ -1956,7 +1956,7 @@ module Compiler
# Compile battle animations # Compile battle animations
#============================================================================= #=============================================================================
def compile_animations def compile_animations
Console.echo_li _INTL("Compiling animations...") Console.echo_li(_INTL("Compiling animations..."))
begin begin
pbanims = load_data("Data/PkmnAnimations.rxdata") pbanims = load_data("Data/PkmnAnimations.rxdata")
rescue rescue

View File

@@ -962,7 +962,7 @@ module Compiler
# Save all data to PBS files # Save all data to PBS files
#============================================================================= #=============================================================================
def write_all def write_all
Console.echo_h1 _INTL("Writing all PBS files") Console.echo_h1(_INTL("Writing all PBS files"))
write_town_map write_town_map
write_connections write_connections
write_types write_types
@@ -986,6 +986,6 @@ module Compiler
write_dungeon_parameters write_dungeon_parameters
write_phone write_phone
echoln "" echoln ""
Console.echo_h2("Successfully rewrote all PBS files", text: :green) Console.echo_h2(_INTL("Successfully rewrote all PBS files"), text: :green)
end end
end end

View File

@@ -1681,7 +1681,7 @@ module Compiler
Graphics.update Graphics.update
trainerChecker = TrainerChecker.new trainerChecker = TrainerChecker.new
change_record = [] change_record = []
Console.echo_li _INTL("Processing {1} maps...", mapData.mapinfos.keys.length) Console.echo_li(_INTL("Processing {1} maps...", mapData.mapinfos.keys.length))
idx = 0 idx = 0
mapData.mapinfos.keys.sort.each do |id| mapData.mapinfos.keys.sort.each do |id|
echo "." if idx % 20 == 0 echo "." if idx % 20 == 0
@@ -1725,11 +1725,11 @@ module Compiler
end end
end end
Console.echo_done(true) Console.echo_done(true)
change_record.each { |msg| Console.echo_warn msg } change_record.each { |msg| Console.echo_warn(msg) }
changed = false changed = false
Graphics.update Graphics.update
commonEvents = load_data("Data/CommonEvents.rxdata") commonEvents = load_data("Data/CommonEvents.rxdata")
Console.echo_li _INTL("Processing common events...") Console.echo_li(_INTL("Processing common events..."))
commonEvents.length.times do |key| commonEvents.length.times do |key|
newevent = fix_event_use(commonEvents[key], 0, mapData) newevent = fix_event_use(commonEvents[key], 0, mapData)
if newevent if newevent
@@ -1740,7 +1740,7 @@ module Compiler
save_data(commonEvents, "Data/CommonEvents.rxdata") if changed save_data(commonEvents, "Data/CommonEvents.rxdata") if changed
Console.echo_done(true) Console.echo_done(true)
if change_record.length > 0 || changed if change_record.length > 0 || changed
Console.echo_warn _INTL("RMXP data was altered. Close RMXP now to ensure changes are applied.") Console.echo_warn(_INTL("RMXP data was altered. Close RMXP now to ensure changes are applied."))
end end
end end
end end