From 1479dbd702f0ec103c5232a292a610e71c979084 Mon Sep 17 00:00:00 2001 From: m3rein Date: Wed, 9 Sep 2020 14:34:08 +0200 Subject: [PATCH] Fixed compiler always triggering --- .../001_Technical/001_MKXP_Compatibility.rb | 20 +++++++++ ...uby Utilities.rb => 002_Ruby Utilities.rb} | 16 ------- ...atibility.rb => 003_RGSS2Compatibility.rb} | 0 ...{003_RPG__Sprite.rb => 004_RPG__Sprite.rb} | 0 .../{004_Win32API.rb => 005_Win32API.rb} | 0 .../{005_Sockets.rb => 006_Sockets.rb} | 0 ...06_DebugConsole.rb => 007_DebugConsole.rb} | 0 ...prite_Resizer.rb => 008_Sprite_Resizer.rb} | 0 ...lugin_Manager.rb => 009_Plugin_Manager.rb} | 0 Data/Scripts/022_Compiler/001_Compiler.rb | 45 ++++++++++--------- .../003_Compiler_MapsAndEvents.rb | 4 +- 11 files changed, 46 insertions(+), 39 deletions(-) create mode 100644 Data/Scripts/001_Technical/001_MKXP_Compatibility.rb rename Data/Scripts/001_Technical/{001_Ruby Utilities.rb => 002_Ruby Utilities.rb} (93%) rename Data/Scripts/001_Technical/{002_RGSS2Compatibility.rb => 003_RGSS2Compatibility.rb} (100%) rename Data/Scripts/001_Technical/{003_RPG__Sprite.rb => 004_RPG__Sprite.rb} (100%) rename Data/Scripts/001_Technical/{004_Win32API.rb => 005_Win32API.rb} (100%) rename Data/Scripts/001_Technical/{005_Sockets.rb => 006_Sockets.rb} (100%) rename Data/Scripts/001_Technical/{006_DebugConsole.rb => 007_DebugConsole.rb} (100%) rename Data/Scripts/001_Technical/{007_Sprite_Resizer.rb => 008_Sprite_Resizer.rb} (100%) rename Data/Scripts/001_Technical/{008_Plugin_Manager.rb => 009_Plugin_Manager.rb} (100%) diff --git a/Data/Scripts/001_Technical/001_MKXP_Compatibility.rb b/Data/Scripts/001_Technical/001_MKXP_Compatibility.rb new file mode 100644 index 000000000..367d7fed7 --- /dev/null +++ b/Data/Scripts/001_Technical/001_MKXP_Compatibility.rb @@ -0,0 +1,20 @@ +$MKXP = !!defined?(System) + +def mkxp? + return $MKXP +end + +CHARACTER_OFFSETS = { + "p" => [0, 2], + "g" => [0, 2], + "y" => [0, 2], + "q" => [0, 2] +} + +def pbSetWindowText(string) + if mkxp? + System.set_window_title(string || System.game_title) + else + Win32API.SetWindowText(string || "RGSS Player") + end +end diff --git a/Data/Scripts/001_Technical/001_Ruby Utilities.rb b/Data/Scripts/001_Technical/002_Ruby Utilities.rb similarity index 93% rename from Data/Scripts/001_Technical/001_Ruby Utilities.rb rename to Data/Scripts/001_Technical/002_Ruby Utilities.rb index 2cdea4115..d59d5ca63 100644 --- a/Data/Scripts/001_Technical/001_Ruby Utilities.rb +++ b/Data/Scripts/001_Technical/002_Ruby Utilities.rb @@ -1,19 +1,3 @@ -#=============================================================================== -# mkxp setup -#=============================================================================== -$MKXP = !!defined?(System) - -def mkxp? - return $MKXP -end - -CHARACTER_OFFSETS = { - "p" => [0, 2], - "g" => [0, 2], - "y" => [0, 2], - "q" => [0, 2] -} - #=============================================================================== # class Class #=============================================================================== diff --git a/Data/Scripts/001_Technical/002_RGSS2Compatibility.rb b/Data/Scripts/001_Technical/003_RGSS2Compatibility.rb similarity index 100% rename from Data/Scripts/001_Technical/002_RGSS2Compatibility.rb rename to Data/Scripts/001_Technical/003_RGSS2Compatibility.rb diff --git a/Data/Scripts/001_Technical/003_RPG__Sprite.rb b/Data/Scripts/001_Technical/004_RPG__Sprite.rb similarity index 100% rename from Data/Scripts/001_Technical/003_RPG__Sprite.rb rename to Data/Scripts/001_Technical/004_RPG__Sprite.rb diff --git a/Data/Scripts/001_Technical/004_Win32API.rb b/Data/Scripts/001_Technical/005_Win32API.rb similarity index 100% rename from Data/Scripts/001_Technical/004_Win32API.rb rename to Data/Scripts/001_Technical/005_Win32API.rb diff --git a/Data/Scripts/001_Technical/005_Sockets.rb b/Data/Scripts/001_Technical/006_Sockets.rb similarity index 100% rename from Data/Scripts/001_Technical/005_Sockets.rb rename to Data/Scripts/001_Technical/006_Sockets.rb diff --git a/Data/Scripts/001_Technical/006_DebugConsole.rb b/Data/Scripts/001_Technical/007_DebugConsole.rb similarity index 100% rename from Data/Scripts/001_Technical/006_DebugConsole.rb rename to Data/Scripts/001_Technical/007_DebugConsole.rb diff --git a/Data/Scripts/001_Technical/007_Sprite_Resizer.rb b/Data/Scripts/001_Technical/008_Sprite_Resizer.rb similarity index 100% rename from Data/Scripts/001_Technical/007_Sprite_Resizer.rb rename to Data/Scripts/001_Technical/008_Sprite_Resizer.rb diff --git a/Data/Scripts/001_Technical/008_Plugin_Manager.rb b/Data/Scripts/001_Technical/009_Plugin_Manager.rb similarity index 100% rename from Data/Scripts/001_Technical/008_Plugin_Manager.rb rename to Data/Scripts/001_Technical/009_Plugin_Manager.rb diff --git a/Data/Scripts/022_Compiler/001_Compiler.rb b/Data/Scripts/022_Compiler/001_Compiler.rb index 4a15c203c..d3b96bf83 100644 --- a/Data/Scripts/022_Compiler/001_Compiler.rb +++ b/Data/Scripts/022_Compiler/001_Compiler.rb @@ -197,7 +197,7 @@ def pbEachFileSectionEx(f) end lineno += 1 Graphics.update if lineno%500==0 - Win32API.SetWindowText(_INTL("Processing line {1}",lineno)) if lineno%50==0 + pbSetWindowText(_INTL("Processing line {1}",lineno)) if lineno%50==0 } yield lastsection,sectionname if havesection end @@ -1167,18 +1167,19 @@ def pbCompileAllData(mustCompile) yield(_INTL("Compiling shadow move data")) pbCompileShadowMoves yield(_INTL("Compiling messages")) + pbCompileAnimations + pbCompileTrainerEvents(mustCompile) + pbSetTextMessages + MessageTypes.saveMessages else if (!$INEDITOR || LANGUAGES.length<2) && safeExists?("Data/messages.dat") MessageTypes.loadMessageFile("Data/messages.dat") end end - pbCompileAnimations - pbCompileTrainerEvents(mustCompile) - pbSetTextMessages - MessageTypes.saveMessages if !$INEDITOR && LANGUAGES.length>=2 pbLoadMessages("Data/"+LANGUAGES[$PokemonSystem.language][1]) end + pbSetWindowText(nil) if mkxp? end def pbCompiler @@ -1242,24 +1243,26 @@ def pbCompiler end # Check data files and PBS files, and recompile if any PBS file was edited # more recently than the data files were last created - for i in 0...dataFiles.length - begin - File.open("Data/#{dataFiles[i]}") { |file| - latestDataTime = [latestDataTime,file.mtime.to_i].max - } - rescue SystemCallError - mustCompile = true + if !mkxp? + for i in 0...dataFiles.length + begin + File.open("Data/#{dataFiles[i]}") { |file| + latestDataTime = [latestDataTime,file.mtime.to_i].max + } + rescue SystemCallError + mustCompile = true + end end - end - for i in 0...textFiles.length - begin - File.open("PBS/#{textFiles[i]}") { |file| - latestTextTime = [latestTextTime,file.mtime.to_i].max - } - rescue SystemCallError + for i in 0...textFiles.length + begin + File.open("PBS/#{textFiles[i]}") { |file| + latestTextTime = [latestTextTime,file.mtime.to_i].max + } + rescue SystemCallError + end end + mustCompile |= (latestTextTime>=latestDataTime) end - mustCompile |= (latestTextTime>=latestDataTime) # Should recompile if holding Ctrl Input.update mustCompile = true if Input.press?(Input::CTRL) @@ -1273,7 +1276,7 @@ def pbCompiler end end # Recompile all data - pbCompileAllData(mustCompile) { |msg| Win32API.SetWindowText(msg) } + pbCompileAllData(mustCompile) { |msg| pbSetWindowText(msg) } rescue Exception e = $! raise e if "#{e.class}"=="Reset" || e.is_a?(Reset) || e.is_a?(SystemExit) diff --git a/Data/Scripts/022_Compiler/003_Compiler_MapsAndEvents.rb b/Data/Scripts/022_Compiler/003_Compiler_MapsAndEvents.rb index 0ec07f932..55828207a 100644 --- a/Data/Scripts/022_Compiler/003_Compiler_MapsAndEvents.rb +++ b/Data/Scripts/022_Compiler/003_Compiler_MapsAndEvents.rb @@ -1416,7 +1416,7 @@ def pbCompileTrainerEvents(_mustcompile) changed = false map = mapData.getMap(id) next if !map || !mapData.mapinfos[id] - Win32API.SetWindowText(_INTL("Processing map {1} ({2})",id,mapData.mapinfos[id].name)) + pbSetWindowText(_INTL("Processing map {1} ({2})",id,mapData.mapinfos[id].name)) for key in map.events.keys if Time.now.to_i-t>=5 Graphics.update @@ -1448,7 +1448,7 @@ def pbCompileTrainerEvents(_mustcompile) changed = false Graphics.update commonEvents = pbLoadRxData("Data/CommonEvents") - Win32API.SetWindowText(_INTL("Processing common events")) + pbSetWindowText(_INTL("Processing common events")) for key in 0...commonEvents.length newevent = pbFixEventUse(commonEvents[key],0,mapData) if newevent