RUIC 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +3 -3
- data/HISTORY +110 -86
- data/README.md +220 -220
- data/bin/ruic +61 -61
- data/gui/TODO +2 -2
- data/gui/appattributesmodel.rb +51 -51
- data/gui/appelementsmodel.rb +126 -126
- data/gui/launch.rb +19 -19
- data/gui/makefile +14 -14
- data/gui/resources/style/dark.qss +459 -459
- data/gui/window.rb +90 -90
- data/gui/window.ui +753 -753
- data/lib/ruic.rb +191 -190
- data/lib/ruic/application.rb +25 -3
- data/lib/ruic/assets.rb +441 -436
- data/lib/ruic/attributes.rb +179 -178
- data/lib/ruic/behaviors.rb +0 -0
- data/lib/ruic/effect.rb +31 -31
- data/lib/ruic/interfaces.rb +0 -0
- data/lib/ruic/nicebytes.rb +29 -0
- data/lib/ruic/presentation.rb +6 -3
- data/lib/ruic/renderplugin.rb +17 -17
- data/lib/ruic/ripl.rb +45 -45
- data/lib/ruic/statemachine.rb +6 -0
- data/lib/ruic/version.rb +3 -3
- data/ruic.gemspec +25 -25
- data/test/MetaData-simple.xml +28 -28
- data/test/MetaData.xml +435 -435
- data/test/customclasses.ruic +29 -29
- data/test/filtering.ruic +42 -42
- data/test/futureassets.ruic +7 -7
- data/test/nonmaster.ruic +20 -20
- data/test/paths.ruic +16 -16
- data/test/projects/CustomClasses/CustomClasses.uia +7 -7
- data/test/projects/CustomClasses/CustomClasses.uip +40 -40
- data/test/projects/CustomClasses/FutureAsset.uip +17 -17
- data/test/projects/MissingAssets/Existing.uip +87 -87
- data/test/projects/MissingAssets/MissingAssets.uia +0 -0
- data/test/projects/MissingAssets/MissingAssets.uia-user +14 -14
- data/test/projects/MissingAssets/RoundedPlane-1/RoundedPlane-1.import +18 -18
- data/test/projects/MissingAssets/RoundedPlane-1/meshes/RoundedPlane.mesh +0 -0
- data/test/projects/MissingAssets/effects/effects.txt +0 -0
- data/test/projects/MissingAssets/effects/existing.effect +0 -0
- data/test/projects/MissingAssets/fonts/Arimo-Regular.ttf +0 -0
- data/test/projects/MissingAssets/fonts/Chivo-Black.ttf +0 -0
- data/test/projects/MissingAssets/fonts/OFL.txt +0 -0
- data/test/projects/MissingAssets/maps/effects/brushnoise.dds +0 -0
- data/test/projects/MissingAssets/maps/existing.png +0 -0
- data/test/projects/MissingAssets/maps/maps.txt +0 -0
- data/test/projects/MissingAssets/maps/materials/concrete_plain.png +0 -0
- data/test/projects/MissingAssets/maps/materials/concrete_plain_bump.png +0 -0
- data/test/projects/MissingAssets/maps/materials/spherical_checker.png +0 -0
- data/test/projects/MissingAssets/materials/concrete.material +0 -0
- data/test/projects/MissingAssets/materials/materials.txt +0 -0
- data/test/projects/MissingAssets/scripts/existing1.lua +0 -0
- data/test/projects/MissingAssets/scripts/existing2.lua +0 -0
- data/test/projects/MissingAssets/states/existing.scxml +0 -0
- data/test/projects/MissingAssets/tests/interface-navigation.scxml-test +0 -0
- data/test/projects/Paths/Paths.uia +4 -4
- data/test/projects/Paths/Paths.uip +98 -98
- data/test/projects/SimpleScene/SimpleScene.uia +4 -4
- data/test/projects/SimpleScene/SimpleScene.uip +35 -35
- data/test/properties.ruic +80 -80
- data/test/referencematerials.ruic +50 -50
- data/test/usage.ruic +54 -54
- metadata +5 -54
data/lib/ruic/attributes.rb
CHANGED
@@ -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
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
@
|
104
|
-
@
|
105
|
-
@
|
106
|
-
@
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
when :
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
def
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
@
|
153
|
-
@
|
154
|
-
@
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
def
|
161
|
-
def
|
162
|
-
|
163
|
-
alias_method :
|
164
|
-
alias_method :
|
165
|
-
alias_method :
|
166
|
-
alias_method :
|
167
|
-
alias_method :
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
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
|
data/lib/ruic/behaviors.rb
CHANGED
File without changes
|
data/lib/ruic/effect.rb
CHANGED
@@ -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
|
data/lib/ruic/interfaces.rb
CHANGED
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
|