From 90825e2392b2d70e43c7a25b8a3752299a933894 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- qtruby/rubylib/examples/ruboids/ruboids/Params.rb | 87 +++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 qtruby/rubylib/examples/ruboids/ruboids/Params.rb (limited to 'qtruby/rubylib/examples/ruboids/ruboids/Params.rb') diff --git a/qtruby/rubylib/examples/ruboids/ruboids/Params.rb b/qtruby/rubylib/examples/ruboids/ruboids/Params.rb new file mode 100644 index 00000000..9ff57851 --- /dev/null +++ b/qtruby/rubylib/examples/ruboids/ruboids/Params.rb @@ -0,0 +1,87 @@ +# +# Copyright (c) 2001 by Jim Menard +# +# Released under the same license as Ruby. See +# http://www.ruby-lang.org/en/LICENSE.txt. +# + +require 'singleton' + +$PARAMS = { + 'world_sleep_millis' => 75, + 'world_width' => 400, + 'world_height' => 400, + 'world_depth' => 400, + 'window_width' => 500, + 'window_height' => 500, + 'flock_boids' => 10, + 'boid_max_speed' => 30, + 'boid_bounds_limit_pull' => 5, + 'boid_bounds_limit_above_ground_level' => 5, + 'boid_wing_length' => 10, + 'boid_personal_space_dist' => 12, + 'boid_square_of_personal_space_dist' => 144, + 'boid_max_perching_turns' => 150, + 'boid_perch_wing_flap_percent' => 30, + 'cloud_count' => 10, + 'cloud_min_speed' => 2, + 'cloud_max_speed' => 50, + 'cloud_min_bubbles' => 3, + 'cloud_max_bubbles' => 10, + 'cloud_max_bubble_radius' => 10, + 'cloud_min_altitude' => 250, + 'camera_x' => 0, + 'camera_y' => 0, + 'camera_z' => 60, + 'camera_rot_x' => 50, + 'camera_rot_y' => 10, + 'camera_rot_z' => 0, + 'camera_zoom' => 1 +} + +class Params + + @@reals = %w( +world_width +world_height +world_depth +boid_max_speed +boid_bounds_limit_pull +boid_bounds_limit_above_ground_level +boid_wing_length +boid_personal_space_dist +boid_square_of_personal_space_dist +cloud_min_speed +cloud_max_speed +cloud_max_bubble_radius +cloud_min_altitude +camera_x +camera_y +camera_z +camera_rot_x +camera_rot_y +camera_rot_z +camera_zoom +) + + def Params.readParamsFromFile(paramFileName) + File.open(paramFileName).each { | line | + line.chomp! + next if line.empty? || line =~ /^#/ + + key, value = line.split(/\s*=\s*/) + next unless value + key.downcase!() + key.gsub!(/\./, '_') + + isReal = @@reals.include?(key) + value = value.to_f if isReal + value = value.to_i if !isReal + $PARAMS[key] = value + } + $PARAMS['boid_square_of_personal_space_dist'] = + $PARAMS['boid_personal_space_dist'] * + $PARAMS['boid_personal_space_dist'] + end + +end -- cgit v1.2.3