Class: NPG::Project
Constant Summary collapse
- LDRHeader =
%{ module NPG class << self def rgss_run begin Dir.chdir NPG::Path $RGSS_SCRIPTS = open(NPG::RGSSScripts, "rb") do |f| Marshal.load(f) end $RGSS_SCRIPTS.each_with_index{|x, i| x[3] = Zlib::Inflate.inflate(x[2]) } type = (defined? msgbox) ? "{%04d}" : "Section%03d" $RGSS_SCRIPTS.each_with_index{|x, i| eval x[3], TOPLEVEL_BINDING, type % (i+1), 1 } rescue Object x = $!.backtrace.unshift($!.to_s).join("\n") open(".npg/error.txt", "w") do |f| f.write x f.write "\n" end end end end end }
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #config_file ⇒ Object
- #executable ⇒ Object
- #handle ⇒ Object
- #ini ⇒ Object
-
#initialize(path = nil) ⇒ Project
constructor
A new instance of Project.
- #run(opt = {}) ⇒ Object
Methods inherited from Directory
Constructor Details
#initialize(path = nil) ⇒ Project
Returns a new instance of Project.
25 26 27 |
# File 'lib/npg/project.rb', line 25 def initialize(path = nil) self.path = path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
24 25 26 |
# File 'lib/npg/project.rb', line 24 def path @path end |
Instance Method Details
#config_file ⇒ Object
124 125 126 |
# File 'lib/npg/project.rb', line 124 def config_file File.join(self.path, "Game.ini") end |
#executable ⇒ Object
41 42 43 |
# File 'lib/npg/project.rb', line 41 def executable File.join(self.path, "Game.exe") end |
#handle ⇒ Object
45 46 47 |
# File 'lib/npg/project.rb', line 45 def handle PGHandle.new File.join self.path, ".npg" end |
#ini ⇒ Object
128 129 130 |
# File 'lib/npg/project.rb', line 128 def ini a = IniParse.parse File.read config_file end |
#run(opt = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/npg/project.rb', line 49 def run(opt = {}) opt = { exe: executable, cmdline: nil, console: false, debug: false, }.update(opt) npg = handle if code = opt[:code] code = code.encode("UTF-8") FileUtils.cp self["Game.exe"], npg["Game.exe"] open npg["Game.ini"], 'w' do |f| f.write\ %{[Game] Scripts=npgldr RTP=#{ini["Game"]["RTP"]} RTP1=#{ini["Game"]["RTP1"]} RTP2=#{ini["Game"]["RTP2"]} RTP3=#{ini["Game"]["RTP3"]} Title=#{ini["Game"]["Title"]} Library=../#{ini["Game"]["Library"]} } end realcode = [LDRHeader, %{ NPG::StartupPath = Dir.getwd NPG::Path = #{path.inspect} NPG::RGSSScripts = #{ini["Game"]["Scripts"].inspect} }, code].join("\n\n") x = [[0, "npgldr", Zlib::Deflate.deflate(realcode)]] open npg["npgldr"], 'w' do |f| Marshal.dump(x, f) end opt.update exe: npg["Game.exe"] end File.delete npg["error.txt"] if FileTest.file?(npg["error.txt"]) cmdline = Shellwords.shelljoin([opt[:exe], opt[:cmdline], opt[:console] ? "console" : nil, opt[:debug] ? "debug": nil, opt[:debug] ? "test": nil, ].compact.map{|x| Shellwords.escape(x) }) system cmdline if FileTest.file?(npg["error.txt"]) raise File.read(npg["error.txt"]) end end |