RUIC 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -3
  3. data/HISTORY +110 -86
  4. data/README.md +220 -220
  5. data/bin/ruic +61 -61
  6. data/gui/TODO +2 -2
  7. data/gui/appattributesmodel.rb +51 -51
  8. data/gui/appelementsmodel.rb +126 -126
  9. data/gui/launch.rb +19 -19
  10. data/gui/makefile +14 -14
  11. data/gui/resources/style/dark.qss +459 -459
  12. data/gui/window.rb +90 -90
  13. data/gui/window.ui +753 -753
  14. data/lib/ruic.rb +191 -190
  15. data/lib/ruic/application.rb +25 -3
  16. data/lib/ruic/assets.rb +441 -436
  17. data/lib/ruic/attributes.rb +179 -178
  18. data/lib/ruic/behaviors.rb +0 -0
  19. data/lib/ruic/effect.rb +31 -31
  20. data/lib/ruic/interfaces.rb +0 -0
  21. data/lib/ruic/nicebytes.rb +29 -0
  22. data/lib/ruic/presentation.rb +6 -3
  23. data/lib/ruic/renderplugin.rb +17 -17
  24. data/lib/ruic/ripl.rb +45 -45
  25. data/lib/ruic/statemachine.rb +6 -0
  26. data/lib/ruic/version.rb +3 -3
  27. data/ruic.gemspec +25 -25
  28. data/test/MetaData-simple.xml +28 -28
  29. data/test/MetaData.xml +435 -435
  30. data/test/customclasses.ruic +29 -29
  31. data/test/filtering.ruic +42 -42
  32. data/test/futureassets.ruic +7 -7
  33. data/test/nonmaster.ruic +20 -20
  34. data/test/paths.ruic +16 -16
  35. data/test/projects/CustomClasses/CustomClasses.uia +7 -7
  36. data/test/projects/CustomClasses/CustomClasses.uip +40 -40
  37. data/test/projects/CustomClasses/FutureAsset.uip +17 -17
  38. data/test/projects/MissingAssets/Existing.uip +87 -87
  39. data/test/projects/MissingAssets/MissingAssets.uia +0 -0
  40. data/test/projects/MissingAssets/MissingAssets.uia-user +14 -14
  41. data/test/projects/MissingAssets/RoundedPlane-1/RoundedPlane-1.import +18 -18
  42. data/test/projects/MissingAssets/RoundedPlane-1/meshes/RoundedPlane.mesh +0 -0
  43. data/test/projects/MissingAssets/effects/effects.txt +0 -0
  44. data/test/projects/MissingAssets/effects/existing.effect +0 -0
  45. data/test/projects/MissingAssets/fonts/Arimo-Regular.ttf +0 -0
  46. data/test/projects/MissingAssets/fonts/Chivo-Black.ttf +0 -0
  47. data/test/projects/MissingAssets/fonts/OFL.txt +0 -0
  48. data/test/projects/MissingAssets/maps/effects/brushnoise.dds +0 -0
  49. data/test/projects/MissingAssets/maps/existing.png +0 -0
  50. data/test/projects/MissingAssets/maps/maps.txt +0 -0
  51. data/test/projects/MissingAssets/maps/materials/concrete_plain.png +0 -0
  52. data/test/projects/MissingAssets/maps/materials/concrete_plain_bump.png +0 -0
  53. data/test/projects/MissingAssets/maps/materials/spherical_checker.png +0 -0
  54. data/test/projects/MissingAssets/materials/concrete.material +0 -0
  55. data/test/projects/MissingAssets/materials/materials.txt +0 -0
  56. data/test/projects/MissingAssets/scripts/existing1.lua +0 -0
  57. data/test/projects/MissingAssets/scripts/existing2.lua +0 -0
  58. data/test/projects/MissingAssets/states/existing.scxml +0 -0
  59. data/test/projects/MissingAssets/tests/interface-navigation.scxml-test +0 -0
  60. data/test/projects/Paths/Paths.uia +4 -4
  61. data/test/projects/Paths/Paths.uip +98 -98
  62. data/test/projects/SimpleScene/SimpleScene.uia +4 -4
  63. data/test/projects/SimpleScene/SimpleScene.uip +35 -35
  64. data/test/properties.ruic +80 -80
  65. data/test/referencematerials.ruic +50 -50
  66. data/test/usage.ruic +54 -54
  67. metadata +5 -54
@@ -1,178 +1,179 @@
1
- #encoding: utf-8
2
- class UIC::Property
3
- # Each property has a generic default value
4
- class << self; attr_accessor :default; end
5
-
6
- # …and instances of a particular property can have their own default value
7
- attr_accessor :default
8
- def initialize(el); @el = el; end
9
- def name; @name||=@el['name']; end
10
- def type; @type||=@el['type'] ? (@el['type']=='float' ? 'Float' : @el['type']) : 'Float'; end
11
- def formal; @formal||=@el['formalName'] || @el['name']; end
12
- def min; @el['min']; end
13
- def max; @el['max']; end
14
- def description; @desc||=@el['description']; end
15
- def default; @default ||= (@el['default'] || self.class.default); end
16
- def get(asset,slide)
17
- if asset.slide? || asset.has_slide?(slide)
18
- asset.presentation.get_attribute(asset,name,slide) || default
19
- end
20
- end
21
- def set(asset,new_value,slide_name_or_index)
22
- asset.presentation.set_attribute(asset,name,slide_name_or_index,new_value)
23
- end
24
- def inspect
25
- "<#{type} '#{name}'>"
26
- end
27
-
28
- class String < self
29
- self.default = ''
30
- end
31
- MultiLineString = String
32
-
33
- class Float < self
34
- self.default = 0.0
35
- def get(asset,slide); super.to_f; end
36
- end
37
- class Long < self
38
- self.default = 0
39
- def get(asset,slide); super.to_i; end
40
- end
41
- class Boolean < self
42
- self.default = false
43
- def get(asset,slide); super=='True'; end
44
- def set(asset,new_value,slide_name_or_index)
45
- super( asset, new_value ? 'True' : 'False', slide_name_or_index )
46
- end
47
- end
48
- class Vector < self
49
- self.default = '0 0 0'
50
- def get(asset,slide)
51
- VectorValue.new(asset,self,slide,super)
52
- end
53
- def set(asset,new_value,slide_name_or_index)
54
- new_value = new_value.join(' ') if new_value.is_a?(Array)
55
- super( asset, new_value, slide_name_or_index )
56
- end
57
- end
58
- Rotation = Vector
59
- Color = Vector
60
- Float2 = Vector
61
- class Image < self
62
- self.default = nil
63
- def get(asset,slide)
64
- if idref = super
65
- result = asset.presentation.asset_by_id( idref[1..-1] )
66
- # slide ? result.on_slide( slide ) : result
67
- # Getting the asset on a particular slide makes it weird
68
- end
69
- end
70
- def set(asset,new_value,slide)
71
- raise "Setting image attributes not yet supported"
72
- end
73
- end
74
- class Texture < String
75
- def get(asset,slide)
76
- if path=super
77
- path.empty? ? nil : path.gsub( '\\', '/' ).sub( /^.\// ,'' )
78
- end
79
- end
80
- end
81
-
82
- class ObjectRef < self
83
- self.default = nil
84
- def get(asset,slide)
85
- ref = super
86
- type = :absolute
87
- obj = nil
88
- unless ref=='' || ref.nil?
89
- type = ref[0]=='#' ? :absolute : :path
90
- ref = type==:absolute ? asset.presentation.asset_by_id( ref[1..-1] ) : asset.presentation.at( ref, asset )
91
- end
92
- ObjectReference.new(asset,self,slide,ref,type)
93
- end
94
- def set(asset,new_object,slide)
95
- get(asset,slide).object = new_object
96
- end
97
- end
98
-
99
- class ObjectReference
100
- attr_reader :object, :type
101
- def initialize(asset,property,slide,object=nil,type=nil)
102
- @asset = asset
103
- @name = property.name
104
- @slide = slide
105
- @object = object
106
- @type = type
107
- end
108
- def object=(new_object)
109
- raise "ObjectRef must be set to an asset (not a #{new_object.class.name})" unless new_object.is_a?(UIC::MetaData::AssetBase)
110
- @object = new_object
111
- write_value!
112
- end
113
- def type=(new_type)
114
- raise "ObjectRef types must be either :absolute or :path (not #{new_type.inspect})" unless [:absolute,:path].include?(new_type)
115
- @type = new_type
116
- write_value!
117
- end
118
- private
119
- def write_value!
120
- path = case @object
121
- when NilClass then ""
122
- else case @type
123
- when :absolute then "##{@object.el['id']}"
124
- when :path then @asset.presentation.path_to( @object, @asset ).sub(/^[^:.]+:/,'')
125
- # when :root then @asset.presentation.path_to( @object ).sub(/^[^:.]+:/,'')
126
- end
127
- end
128
- @asset.presentation.set_attribute( @asset, @name, @slide, path )
129
- end
130
- end
131
-
132
- class Font < self
133
- self.default = 'Arimo-Regular'
134
- def get(asset,slide); "fonts/#{super}.ttf"; end # TODO: how to support non-ttf fonts?
135
- def set(asset,new_value,slide_name_or_index)
136
- # TODO: how to support non-ttf fonts?
137
- super( asset, new_value.sub(%r{^\.[/\\]},'').sub(%r{^fonts[/\\]},'').sub(%r{\.ttf$},''), slide_name_or_index )
138
- end
139
- end
140
-
141
- Import = String #TODO: a real class
142
- Mesh = String #TODO: a real class
143
- Renderable = String #TODO: a real class
144
- FontSize = Long
145
-
146
- StringListOrInt = String #TODO: a real class
147
-
148
- class VectorValue
149
- attr_reader :x, :y, :z
150
- def initialize(asset,property,slide,str)
151
- @asset = asset
152
- @property = property
153
- @slide = slide
154
- @x, @y, @z = str.split(/\s+/).map(&:to_f)
155
- end
156
- def setall
157
- @property.set( @asset, to_s, @slide )
158
- end
159
- def x=(n); @x=n; setall end
160
- def y=(n); @y=n; setall end
161
- def z=(n); @z=n; setall end
162
- alias_method :r, :x
163
- alias_method :g, :y
164
- alias_method :b, :z
165
- alias_method :r=, :x=
166
- alias_method :g=, :y=
167
- alias_method :b=, :z=
168
- def inspect
169
- "<#{@asset.path}.#{@property.name}: #{self}>"
170
- end
171
- def to_s
172
- to_a.join(' ')
173
- end
174
- def to_a
175
- [x,y,z]
176
- end
177
- end
178
- end
1
+ #encoding: utf-8
2
+ class UIC::Property
3
+ # Each property has a generic default value
4
+ class << self; attr_accessor :default; end
5
+
6
+ # …and instances of a particular property can have their own default value
7
+ attr_accessor :default
8
+ def initialize(el); @el = el; end
9
+ def name; @name||=@el['name']; end
10
+ def type; @type||=@el['type'] ? (@el['type']=='float' ? 'Float' : @el['type']) : 'Float'; end
11
+ def formal; @formal||=@el['formalName'] || @el['name']; end
12
+ def min; @el['min']; end
13
+ def max; @el['max']; end
14
+ def description; @desc||=@el['description']; end
15
+ def default; @default ||= (@el['default'] || self.class.default); end
16
+ def get(asset,slide)
17
+ if asset.slide? || asset.has_slide?(slide)
18
+ asset.presentation.get_attribute(asset,name,slide) || default
19
+ end
20
+ end
21
+ def set(asset,new_value,slide_name_or_index)
22
+ asset.presentation.set_attribute(asset,name,slide_name_or_index,new_value)
23
+ end
24
+ def inspect
25
+ "<#{type} '#{name}'>"
26
+ end
27
+
28
+ class String < self
29
+ self.default = ''
30
+ end
31
+ MultiLineString = String
32
+
33
+ class Float < self
34
+ self.default = 0.0
35
+ def get(asset,slide); super.to_f; end
36
+ end
37
+ class Long < self
38
+ self.default = 0
39
+ def get(asset,slide); super.to_i; end
40
+ end
41
+ class Boolean < self
42
+ self.default = false
43
+ def get(asset,slide); super=='True'; end
44
+ def set(asset,new_value,slide_name_or_index)
45
+ super( asset, new_value ? 'True' : 'False', slide_name_or_index )
46
+ end
47
+ end
48
+ class Vector < self
49
+ self.default = '0 0 0'
50
+ def get(asset,slide)
51
+ VectorValue.new(asset,self,slide,super)
52
+ end
53
+ def set(asset,new_value,slide_name_or_index)
54
+ new_value = new_value.join(' ') if new_value.is_a?(Array)
55
+ super( asset, new_value, slide_name_or_index )
56
+ end
57
+ end
58
+ Rotation = Vector
59
+ Color = Vector
60
+ Float2 = Vector
61
+ class Image < self
62
+ self.default = nil
63
+ def get(asset,slide)
64
+ if idref = super
65
+ result = asset.presentation.asset_by_id( idref[1..-1] )
66
+ # slide ? result.on_slide( slide ) : result
67
+ # Getting the asset on a particular slide makes it weird
68
+ end
69
+ end
70
+ def set(asset,new_value,slide)
71
+ raise "Setting image attributes not yet supported"
72
+ end
73
+ end
74
+ class Texture < String
75
+ def get(asset,slide)
76
+ if path=super
77
+ path.empty? ? nil : path.gsub( '\\', '/' ).sub( /^.\// ,'' )
78
+ end
79
+ end
80
+ end
81
+ class PathBuffer < Texture; end
82
+
83
+ class ObjectRef < self
84
+ self.default = nil
85
+ def get(asset,slide)
86
+ ref = super
87
+ type = :absolute
88
+ obj = nil
89
+ unless ref=='' || ref.nil?
90
+ type = ref[0]=='#' ? :absolute : :path
91
+ ref = type==:absolute ? asset.presentation.asset_by_id( ref[1..-1] ) : asset.presentation.at( ref, asset )
92
+ end
93
+ ObjectReference.new(asset,self,slide,ref,type)
94
+ end
95
+ def set(asset,new_object,slide)
96
+ get(asset,slide).object = new_object
97
+ end
98
+ end
99
+
100
+ class ObjectReference
101
+ attr_reader :object, :type
102
+ def initialize(asset,property,slide,object=nil,type=nil)
103
+ @asset = asset
104
+ @name = property.name
105
+ @slide = slide
106
+ @object = object
107
+ @type = type
108
+ end
109
+ def object=(new_object)
110
+ raise "ObjectRef must be set to an asset (not a #{new_object.class.name})" unless new_object.is_a?(UIC::MetaData::AssetBase)
111
+ @object = new_object
112
+ write_value!
113
+ end
114
+ def type=(new_type)
115
+ raise "ObjectRef types must be either :absolute or :path (not #{new_type.inspect})" unless [:absolute,:path].include?(new_type)
116
+ @type = new_type
117
+ write_value!
118
+ end
119
+ private
120
+ def write_value!
121
+ path = case @object
122
+ when NilClass then ""
123
+ else case @type
124
+ when :absolute then "##{@object.el['id']}"
125
+ when :path then @asset.presentation.path_to( @object, @asset ).sub(/^[^:.]+:/,'')
126
+ # when :root then @asset.presentation.path_to( @object ).sub(/^[^:.]+:/,'')
127
+ end
128
+ end
129
+ @asset.presentation.set_attribute( @asset, @name, @slide, path )
130
+ end
131
+ end
132
+
133
+ class Font < self
134
+ self.default = 'Arimo-Regular'
135
+ def get(asset,slide); "fonts/#{super}.ttf"; end # TODO: how to support non-ttf fonts?
136
+ def set(asset,new_value,slide_name_or_index)
137
+ # TODO: how to support non-ttf fonts?
138
+ super( asset, new_value.sub(%r{^\.[/\\]},'').sub(%r{^fonts[/\\]},'').sub(%r{\.ttf$},''), slide_name_or_index )
139
+ end
140
+ end
141
+
142
+ Import = String #TODO: a real class
143
+ Mesh = String #TODO: a real class
144
+ Renderable = String #TODO: a real class
145
+ FontSize = Long
146
+
147
+ StringListOrInt = String #TODO: a real class
148
+
149
+ class VectorValue
150
+ attr_reader :x, :y, :z
151
+ def initialize(asset,property,slide,str)
152
+ @asset = asset
153
+ @property = property
154
+ @slide = slide
155
+ @x, @y, @z = str.split(/\s+/).map(&:to_f)
156
+ end
157
+ def setall
158
+ @property.set( @asset, to_s, @slide )
159
+ end
160
+ def x=(n); @x=n; setall end
161
+ def y=(n); @y=n; setall end
162
+ def z=(n); @z=n; setall end
163
+ alias_method :r, :x
164
+ alias_method :g, :y
165
+ alias_method :b, :z
166
+ alias_method :r=, :x=
167
+ alias_method :g=, :y=
168
+ alias_method :b=, :z=
169
+ def inspect
170
+ "<#{@asset.path}.#{@property.name}: #{self}>"
171
+ end
172
+ def to_s
173
+ to_a.join(' ')
174
+ end
175
+ def to_a
176
+ [x,y,z]
177
+ end
178
+ end
179
+ end
File without changes
@@ -1,32 +1,32 @@
1
- class UIC::Effect
2
- include UIC::FileBacked
3
- attr_reader :lua
4
- def initialize( lua_path )
5
- self.file = lua_path
6
- load_from_file if file_found?
7
- end
8
- def load_from_file
9
- @lua = File.read(file,encoding:'utf-8')
10
- end
11
-
12
- def errors?
13
- !errors.empty?
14
- end
15
-
16
- def errors
17
- file_found? ? [] : ["File not found: '#{file}'"]
18
- end
19
-
20
- end
21
-
22
- class UIC::Application::Effect < UIC::Effect
23
- include UIC::ElementBacked
24
- # @!parse extend UIC::ElementBacked::ClassMethods
25
- xmlattribute :id
26
- xmlattribute :src
27
- def initialize(application,el)
28
- self.owner = application
29
- self.el = el
30
- super( application.absolute_path(src) )
31
- end
1
+ class UIC::Effect
2
+ include UIC::FileBacked
3
+ attr_reader :lua
4
+ def initialize( lua_path )
5
+ self.file = lua_path
6
+ load_from_file if file_found?
7
+ end
8
+ def load_from_file
9
+ @lua = File.read(file,encoding:'utf-8')
10
+ end
11
+
12
+ def errors?
13
+ !errors.empty?
14
+ end
15
+
16
+ def errors
17
+ file_found? ? [] : ["File not found: '#{file}'"]
18
+ end
19
+
20
+ end
21
+
22
+ class UIC::Application::Effect < UIC::Effect
23
+ include UIC::ElementBacked
24
+ # @!parse extend UIC::ElementBacked::ClassMethods
25
+ xmlattribute :id
26
+ xmlattribute :src
27
+ def initialize(application,el)
28
+ self.owner = application
29
+ self.el = el
30
+ super( application.absolute_path(src) )
31
+ end
32
32
  end
File without changes
@@ -0,0 +1,29 @@
1
+ module NiceBytes
2
+ K = 2.0**10
3
+ M = 2.0**20
4
+ G = 2.0**30
5
+ T = 2.0**40
6
+ def nice_bytes( bytes, max_digits=3 )
7
+ value, suffix, precision = case bytes
8
+ when 0...K
9
+ [ bytes, 'B', 0 ]
10
+ else
11
+ value, suffix = case bytes
12
+ when K...M then [ bytes / K, 'kB' ]
13
+ when M...G then [ bytes / M, 'MB' ]
14
+ when G...T then [ bytes / G, 'GB' ]
15
+ else [ bytes / T, 'TB' ]
16
+ end
17
+ used_digits = case value
18
+ when 0...10 then 1
19
+ when 10...100 then 2
20
+ when 100...1000 then 3
21
+ else 4
22
+ end
23
+ leftover_digits = max_digits - used_digits
24
+ [ value, suffix, leftover_digits > 0 ? leftover_digits : 0 ]
25
+ end
26
+ "%.#{precision}f#{suffix}" % value
27
+ end
28
+ module_function :nice_bytes
29
+ end