Class: Tester
Overview
Class designed to test an interface or a script
Constant Summary collapse
- @@args =
nil
- @@class =
nil
Class Method Summary collapse
-
.start(klass, *args)
Define the class and the arguments of it to test.
Instance Method Summary collapse
-
#data_load
Load the RMXP Data.
-
#initialize(script) ⇒ Tester
constructor
Create a new test.
-
#load_script ⇒ true
Load the script.
-
#main
Main process of the tester.
-
#manage_exception
Manage the exception.
-
#quit_test
Quit the test.
-
#restart_scene ⇒ true
Retart the scene.
-
#show_test_message
Show the test message.
Constructor Details
#initialize(script) ⇒ Tester
Create a new test
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'scripts/00700 Ajout_PSDK/00200 Tester.rb', line 9 def initialize(script) @script = script $tester = self Object.define_method(:reload) { $tester.load_script } Object.define_method(:restart) { $tester.restart_scene } Object.define_method(:quit) { $tester.quit_test } data_load PFM::GameState.new. @thread = Thread.new do while true sleep(0.1) if Input::Keyboard.press?(Input::Keyboard::F9) print "\rMouse coords = %d,%d\nCommande : " % [Mouse.x, Mouse.y] sleep(0.5) end end end load_script @unlocked = true rescue Exception manage_exception end |
Class Method Details
.start(klass, *args)
Define the class and the arguments of it to test
88 89 90 91 |
# File 'scripts/00700 Ajout_PSDK/00200 Tester.rb', line 88 def self.start(klass, *args) @@class = klass @@args = args end |
Instance Method Details
#data_load
Load the RMXP Data
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'scripts/00700 Ajout_PSDK/00200 Tester.rb', line 93 def data_load unless $data_actors $data_actors = _clean_name_utf8(load_data("Data/Actors.rxdata")) $data_classes = _clean_name_utf8(load_data("Data/Classes.rxdata")) $data_enemies = _clean_name_utf8(load_data("Data/Enemies.rxdata")) $data_troops = _clean_name_utf8(load_data("Data/Troops.rxdata")) $data_tilesets = _clean_name_utf8(load_data("Data/Tilesets.rxdata")) $data_common_events = _clean_name_utf8(load_data("Data/CommonEvents.rxdata")) $data_system = load_data_utf8("Data/System.rxdata") end $game_system = Game_System.new $game_temp = Game_Temp.new end |
#load_script ⇒ true
Load the script
70 71 72 73 74 |
# File 'scripts/00700 Ajout_PSDK/00200 Tester.rb', line 70 def load_script script = File.open(@script, "r") { |f| break(f.read(f.size)) } eval(script, $global_binding, @script) return true end |
#main
Main process of the tester
33 34 35 36 37 38 39 40 41 42 43 |
# File 'scripts/00700 Ajout_PSDK/00200 Tester.rb', line 33 def main Graphics.update until @unlocked $scene = @@class.new(*@@args) $scene.main if $scene != self $scene = nil @thread.kill end rescue Exception manage_exception end |
#manage_exception
Manage the exception
76 77 78 79 80 81 82 83 84 |
# File 'scripts/00700 Ajout_PSDK/00200 Tester.rb', line 76 def manage_exception raise if $!.class == LiteRGSS::DisplayWindow::ClosedWindowError puts Yuki::EXC.build_error_log($!) cc 0x01 puts "Test locked, type reload and restart to unlock" cc 0x07 restart_scene @unlocked = false end |
#quit_test
Quit the test
64 65 66 67 |
# File 'scripts/00700 Ajout_PSDK/00200 Tester.rb', line 64 def quit_test restart_scene $scene = nil end |
#restart_scene ⇒ true
Retart the scene
46 47 48 49 50 51 |
# File 'scripts/00700 Ajout_PSDK/00200 Tester.rb', line 46 def restart_scene $scene.instance_variable_set(:@running, false) $scene = self @unlocked = true return true end |
#show_test_message
Show the test message
53 54 55 56 57 58 59 60 61 62 |
# File 'scripts/00700 Ajout_PSDK/00200 Tester.rb', line 53 def cc 0x02 puts "Testing script #{@script}" cc 0x07 puts "Type : " puts "reload to reload the script" puts "restart to restart the scene" puts "quit to quit the test" print "Commande : " end |