zyps 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/zyps +32 -26
- data/lib/zyps/views/canvas/wx.rb +5 -6
- metadata +58 -51
data/bin/zyps
CHANGED
@@ -98,19 +98,20 @@ class Application < Wx::App
|
|
98
98
|
frame.evt_close {on_exit}
|
99
99
|
|
100
100
|
@log.debug "Create a view and canvas."
|
101
|
+
drawing_area = Wx::Window.new(frame)
|
102
|
+
drawing_area.min_size = [0, 0]
|
103
|
+
frame.sizer.add(drawing_area, 1, Wx::GROW)
|
101
104
|
@view = TrailsView.new(
|
102
105
|
:width => @options[:width],
|
103
106
|
:height => @options[:height],
|
104
|
-
:canvas => WxCanvas.new(
|
107
|
+
:canvas => WxCanvas.new(drawing_area)
|
105
108
|
)
|
106
|
-
frame.sizer.add(@view.canvas.drawing_area, 1, Wx::GROW)
|
107
109
|
@log.debug "Set up mouse click/drag handlers for canvas."
|
108
110
|
@press_location = nil
|
109
|
-
|
110
|
-
|
111
|
+
drawing_area.evt_left_down {|event| on_mouse_press(event)}
|
112
|
+
drawing_area.evt_left_up {|event| on_mouse_release(event)}
|
111
113
|
@log.debug "Resize view and enclosure when canvas changes size."
|
112
|
-
|
113
|
-
|
114
|
+
|
114
115
|
@log.debug "Create an interface."
|
115
116
|
@controls = ControlPanel.new(frame)
|
116
117
|
@controls.clear_button.evt_button(@controls.clear_button.get_id) do |event|
|
@@ -133,8 +134,8 @@ class Application < Wx::App
|
|
133
134
|
@enclosure = Enclosure.new(
|
134
135
|
:left => 0,
|
135
136
|
:bottom => 0,
|
136
|
-
:top =>
|
137
|
-
:right =>
|
137
|
+
:top => drawing_area.size.height,
|
138
|
+
:right => drawing_area.size.width
|
138
139
|
)
|
139
140
|
@environment.environmental_factors << @enclosure
|
140
141
|
end
|
@@ -149,18 +150,31 @@ class Application < Wx::App
|
|
149
150
|
@log.debug "Timer will fire every #{milliseconds_per_frame} milliseconds."
|
150
151
|
timer_id = Wx::ID_HIGHEST + 1
|
151
152
|
timer = Wx::Timer.new(self, timer_id)
|
152
|
-
evt_timer(timer_id)
|
153
|
-
@environment.interact
|
154
|
-
#Keeps dead objects from accumulating and causing hiccups later.
|
155
|
-
GC.start
|
156
|
-
end
|
153
|
+
evt_timer(timer_id) {on_timer}
|
157
154
|
timer.start(milliseconds_per_frame)
|
158
155
|
|
159
156
|
@log.debug "Display GUI."
|
157
|
+
frame.send_size_event
|
160
158
|
frame.show
|
161
159
|
|
162
160
|
end
|
163
161
|
|
162
|
+
|
163
|
+
#Update environment and view.
|
164
|
+
def on_timer
|
165
|
+
#Resize playfield if window has been resized.
|
166
|
+
if @view.height != @view.canvas.drawing_area.size.height || @view.width != @view.canvas.drawing_area.size.width
|
167
|
+
@view.height = @view.canvas.drawing_area.size.height
|
168
|
+
@view.width = @view.canvas.drawing_area.size.width
|
169
|
+
@enclosure.top = @view.canvas.drawing_area.size.height
|
170
|
+
@enclosure.right = @view.canvas.drawing_area.size.width
|
171
|
+
end
|
172
|
+
#Update environment.
|
173
|
+
@environment.interact
|
174
|
+
#Keeps dead objects from accumulating and causing hiccups later.
|
175
|
+
GC.start
|
176
|
+
end
|
177
|
+
|
164
178
|
|
165
179
|
#Save config and shut down.
|
166
180
|
def on_exit
|
@@ -203,15 +217,6 @@ class Application < Wx::App
|
|
203
217
|
end
|
204
218
|
|
205
219
|
|
206
|
-
#Resize objects that are dependent on the view size.
|
207
|
-
def on_view_resize(event)
|
208
|
-
@view.height = @view.canvas.drawing_area.size.height
|
209
|
-
@view.width = @view.canvas.drawing_area.size.width
|
210
|
-
@enclosure.top = @view.canvas.drawing_area.size.height
|
211
|
-
@enclosure.right = @view.canvas.drawing_area.size.width
|
212
|
-
end
|
213
|
-
|
214
|
-
|
215
220
|
end
|
216
221
|
|
217
222
|
|
@@ -248,7 +253,7 @@ class ControlPanel < Wx::Panel
|
|
248
253
|
super(parent)
|
249
254
|
self.sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
250
255
|
|
251
|
-
action_controls = add_panel(self)
|
256
|
+
action_controls = add_panel(self, :proportion => 2)
|
252
257
|
add_label(action_controls, :label => "Actions")
|
253
258
|
@turn_flag = add_check_box(action_controls, :label => "Turn")
|
254
259
|
@approach_flag = add_check_box(action_controls, :label => "Chase")
|
@@ -258,13 +263,13 @@ class ControlPanel < Wx::Panel
|
|
258
263
|
@breed_flag = add_check_box(action_controls, :label => "Breed")
|
259
264
|
@eat_flag = add_check_box(action_controls, :label => "Eat")
|
260
265
|
|
261
|
-
display_controls = add_panel(self)
|
266
|
+
display_controls = add_panel(self, :proportion => 1)
|
262
267
|
add_label(display_controls, :label => "Length")
|
263
268
|
@length_slider = add_slider(display_controls, :min_value => 2, :max_value => 100)
|
264
269
|
@length_slider.value = 5
|
265
270
|
@trails_flag = add_check_box(display_controls, :label => "Trails")
|
266
271
|
|
267
|
-
environment_controls = add_panel(self)
|
272
|
+
environment_controls = add_panel(self, :proportion => 1)
|
268
273
|
add_label(environment_controls, :label => "Environment")
|
269
274
|
@clear_button = add_button(environment_controls, :label => "Clear")
|
270
275
|
|
@@ -315,10 +320,11 @@ class ControlPanel < Wx::Panel
|
|
315
320
|
def add_panel(parent, options = {})
|
316
321
|
options = {
|
317
322
|
:sizer => Wx::BoxSizer.new(Wx::VERTICAL),
|
323
|
+
:proportion => 1,
|
318
324
|
}.merge(options)
|
319
325
|
panel = Wx::Panel.new(parent, options)
|
320
326
|
panel.sizer = options[:sizer]
|
321
|
-
panel.parent.sizer.add(panel,
|
327
|
+
panel.parent.sizer.add(panel, options[:proportion], Wx::GROW|Wx::ALL, 3)
|
322
328
|
panel
|
323
329
|
end
|
324
330
|
|
data/lib/zyps/views/canvas/wx.rb
CHANGED
@@ -35,14 +35,14 @@ class WxCanvas
|
|
35
35
|
attr_reader :width, :height
|
36
36
|
|
37
37
|
#Takes the wxRuby GUI object that will be its parent.
|
38
|
-
def initialize (
|
38
|
+
def initialize (drawing_area)
|
39
|
+
|
40
|
+
@drawing_area = drawing_area
|
39
41
|
|
40
42
|
#Will be resized later.
|
41
|
-
@width =
|
42
|
-
@height =
|
43
|
+
@width = @drawing_area.size.width
|
44
|
+
@height = @drawing_area.size.height
|
43
45
|
|
44
|
-
#Create a drawing area.
|
45
|
-
@drawing_area = Wx::Window.new(parent)
|
46
46
|
#Set to correct size.
|
47
47
|
resize
|
48
48
|
|
@@ -134,7 +134,6 @@ class WxCanvas
|
|
134
134
|
|
135
135
|
#Resize buffer and drawing area.
|
136
136
|
def resize
|
137
|
-
@drawing_area.set_size(Wx::Size.new(@width, @height))
|
138
137
|
@buffer = nil #Causes buffer to reset its size next time it's accessed.
|
139
138
|
end
|
140
139
|
|
metadata
CHANGED
@@ -1,81 +1,88 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.2
|
3
|
-
specification_version: 1
|
4
2
|
name: zyps
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.7.
|
7
|
-
date: 2008-01-23 00:00:00 -07:00
|
8
|
-
summary: A game library for Ruby
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: jay@mcgavren.com
|
12
|
-
homepage: http://jay.mcgavren.com/zyps/
|
13
|
-
rubyforge_project: zyps
|
14
|
-
description:
|
15
|
-
autorequire: zyps
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.7.1
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Jay McGavren
|
8
|
+
autorequire: zyps
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-01-25 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: wxruby
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.9.2
|
23
|
+
version:
|
24
|
+
description:
|
25
|
+
email: jay@mcgavren.com
|
26
|
+
executables:
|
27
|
+
- zyps
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README.txt
|
32
|
+
- COPYING.LESSER.txt
|
33
|
+
- COPYING.txt
|
31
34
|
files:
|
32
35
|
- COPYING.LESSER.txt
|
33
36
|
- COPYING.txt
|
34
37
|
- README.txt
|
35
|
-
- bin/zyps
|
36
38
|
- bin/zyps_demo
|
39
|
+
- bin/zyps
|
37
40
|
- lib/zyps
|
38
|
-
- lib/zyps/actions.rb
|
39
|
-
- lib/zyps/conditions.rb
|
40
|
-
- lib/zyps/environmental_factors.rb
|
41
|
-
- lib/zyps/remote.rb
|
42
41
|
- lib/zyps/views
|
43
42
|
- lib/zyps/views/canvas
|
44
43
|
- lib/zyps/views/canvas/gtk2.rb
|
45
44
|
- lib/zyps/views/canvas/wx.rb
|
46
45
|
- lib/zyps/views/trails.rb
|
46
|
+
- lib/zyps/remote.rb
|
47
|
+
- lib/zyps/environmental_factors.rb
|
48
|
+
- lib/zyps/actions.rb
|
49
|
+
- lib/zyps/conditions.rb
|
47
50
|
- lib/zyps.rb
|
48
|
-
- test/test_zyps.rb
|
49
51
|
- test/zyps
|
50
|
-
- test/zyps/test_actions.rb
|
51
52
|
- test/zyps/test_behaviors.rb
|
52
|
-
- test/zyps/test_conditions.rb
|
53
53
|
- test/zyps/test_environmental_factors.rb
|
54
54
|
- test/zyps/test_remote.rb
|
55
|
-
|
55
|
+
- test/zyps/test_actions.rb
|
56
|
+
- test/zyps/test_conditions.rb
|
56
57
|
- test/test_zyps.rb
|
58
|
+
has_rdoc: true
|
59
|
+
homepage: http://jay.mcgavren.com/zyps/
|
60
|
+
post_install_message:
|
57
61
|
rdoc_options:
|
58
62
|
- --title
|
59
63
|
- Zyps - A game library for Ruby
|
60
64
|
- --main
|
61
65
|
- README.txt
|
62
|
-
|
63
|
-
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
-
|
68
|
-
|
69
|
-
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
70
80
|
requirements: []
|
71
81
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: 1.9.2
|
81
|
-
version:
|
82
|
+
rubyforge_project: zyps
|
83
|
+
rubygems_version: 1.0.1
|
84
|
+
signing_key:
|
85
|
+
specification_version: 2
|
86
|
+
summary: A game library for Ruby
|
87
|
+
test_files:
|
88
|
+
- test/test_zyps.rb
|