RUIC 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +252 -207
- data/bin/ruic +0 -0
- 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 +20 -16
- data/lib/ruic/application.rb +0 -0
- data/lib/ruic/assets.rb +281 -281
- data/lib/ruic/attributes.rb +164 -164
- data/lib/ruic/behaviors.rb +0 -0
- data/lib/ruic/interfaces.rb +0 -0
- data/lib/ruic/presentation.rb +0 -0
- data/lib/ruic/statemachine.rb +0 -0
- data/lib/ruic/version.rb +2 -2
- data/ruic.gemspec +25 -24
- data/test/customclasses.ruic +0 -0
- data/test/filtering.ruic +38 -38
- data/test/nonmaster.ruic +0 -0
- data/test/projects/SimpleScene/SimpleScene.uia +4 -0
- data/test/projects/SimpleScene/SimpleScene.uip +35 -0
- data/test/properties.ruic +0 -0
- data/test/referencematerials.ruic +52 -52
- data/test/usage.ruic +20 -20
- metadata +38 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c4e1cec982987968c63ecbbafff9d3e411cde33
|
4
|
+
data.tar.gz: 12b6241b55467219a87ebdbe18b31a7a9c323cf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c16621f5aefc0467c4ebb18df1a76addf920001033127b920a5504b2227bfd88d63abfde631580371cefd6b1551a672117ecb9f5e05c4178ff6652533bb83299
|
7
|
+
data.tar.gz: b50269750f9bbecd3e94f19662c4e1c3897f8e2e00c24aaf01b2a0af29affc6ec6325ac264664fd159f03393d0de8fd42453338c21b10ccdebddf2dcd61491ea
|
data/README.md
CHANGED
@@ -1,207 +1,252 @@
|
|
1
|
-
# What is RUIC?
|
2
|
-
RUIC is a Ruby API for reading, analyzing, and manipulating application assets created by NVIDIA's [UI Composer][1]. Among other things, it allows you to:
|
3
|
-
|
4
|
-
* See if an application is missing any assets (e.g. images or meshes) and what parts of the application are looking for those.
|
5
|
-
* See if there are any files in the application folder that you can delete (e.g. images or materials that are no longer being used).
|
6
|
-
* Read and modify the attributes of elements on different slides.
|
7
|
-
* Batch change attributes (e.g. change all usage of one font or color to another).
|
8
|
-
* Procedurally generate many models with automated placement in your scene.
|
9
|
-
|
10
|
-
_Some of the features above are planned, but not yet implemented; see Known Limitations below._
|
11
|
-
|
12
|
-
## Table of Contents
|
13
|
-
* [Installing RUIC](#installing-ruic)
|
14
|
-
* [Using the RUIC DSL](#using-the-ruic-dsl)
|
15
|
-
* [Creating and Accessing Applications](#creating-and-accessing-applications)
|
16
|
-
* [Working with Presentations](#working-with-presentations)
|
17
|
-
* [Finding Many Assets](#finding-many-assets)
|
18
|
-
* [Working with References](#working-with-references)
|
19
|
-
* [Writing Assertions](#writing-assertions)
|
20
|
-
* [Locating MetaData.xml](#locating-metadataxml)
|
21
|
-
* [
|
22
|
-
* [
|
23
|
-
* [
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
show app.
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
# for
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
uia '
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
sub = app['
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
car =
|
81
|
-
|
82
|
-
|
83
|
-
show car.
|
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
|
-
group_models =
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
*
|
128
|
-
|
129
|
-
*
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
p ref['referencedmaterial'
|
142
|
-
p ref['referencedmaterial',0].
|
143
|
-
ref['referencedmaterial',0].
|
144
|
-
ref['referencedmaterial',0].
|
145
|
-
|
146
|
-
|
147
|
-
#
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
*
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
#
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
1
|
+
# What is RUIC?
|
2
|
+
RUIC is a Ruby API for reading, analyzing, and manipulating application assets created by NVIDIA's [UI Composer][1]. Among other things, it allows you to:
|
3
|
+
|
4
|
+
* See if an application is missing any assets (e.g. images or meshes) and what parts of the application are looking for those.
|
5
|
+
* See if there are any files in the application folder that you can delete (e.g. images or materials that are no longer being used).
|
6
|
+
* Read and modify the attributes of elements on different slides.
|
7
|
+
* Batch change attributes (e.g. change all usage of one font or color to another).
|
8
|
+
* Procedurally generate many models with automated placement in your scene.
|
9
|
+
|
10
|
+
_Some of the features above are planned, but not yet implemented; see Known Limitations below._
|
11
|
+
|
12
|
+
## Table of Contents
|
13
|
+
* [Installing RUIC](#installing-ruic)
|
14
|
+
* [Using the RUIC DSL](#using-the-ruic-dsl)
|
15
|
+
* [Creating and Accessing Applications](#creating-and-accessing-applications)
|
16
|
+
* [Working with Presentations](#working-with-presentations)
|
17
|
+
* [Finding Many Assets](#finding-many-assets)
|
18
|
+
* [Working with References](#working-with-references)
|
19
|
+
* [Writing Assertions](#writing-assertions)
|
20
|
+
* [Locating MetaData.xml](#locating-metadataxml)
|
21
|
+
* [Interactive RUIC](#interactive-ruic)
|
22
|
+
* [Known Limitations (aka TODO)](#known-limitations-aka-todo)
|
23
|
+
* [History](#history)
|
24
|
+
* [License & Contact](#license--contact)
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
# Installing RUIC
|
29
|
+
RUIC can be installed via RubyGems (part of Ruby) via the command:
|
30
|
+
|
31
|
+
gem install ruic # May need `sudo gem install ruic` depending on your setup
|
32
|
+
|
33
|
+
Although RUIC is a pure-Ruby library, it relies on [Nokogiri][2] for all the XML processing and manipulation. Installing RUIC will also automatically install Nokogiri, which may require some compilation.
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
# Using the RUIC DSL
|
38
|
+
|
39
|
+
RUIC scripts are pure Ruby with a few convenience methods added. You run them via the `ruic` command-line script, e.g.
|
40
|
+
|
41
|
+
ruic myscript.ruic # or .rb extension, for syntax highlighting while editing
|
42
|
+
|
43
|
+
|
44
|
+
## Creating and Accessing Applications
|
45
|
+
RUIC scripts must start with `uia` commands to load an application and all its assets.
|
46
|
+
After this you can access the application as `app`:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
uia '../MyApp.uia' # Relative to the ruic script file, or absolute
|
50
|
+
|
51
|
+
show app.file #=> /var/projects/UIC/MyApp/main/MyApp.uia
|
52
|
+
show app.filename #=> MyApp.uia
|
53
|
+
|
54
|
+
show app.assets.count #=> 7
|
55
|
+
# You can ask for app.behaviors, app.presentations, app.statemachines, and app.renderplugins
|
56
|
+
# for arrays of specific asset types
|
57
|
+
```
|
58
|
+
|
59
|
+
_The `show` command prints the result; it is simply a nicer alias for `puts`._
|
60
|
+
|
61
|
+
If you need to load multiple applications in the same script, subsequent `uia` commands will create
|
62
|
+
`app2`, `app3`, etc. for you to use.
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
uia '../MyApp.uia' # Available as 'app'
|
66
|
+
uia '../../v1/MyApp.uia' # Available as 'app2'
|
67
|
+
```
|
68
|
+
|
69
|
+
|
70
|
+
## Working with Presentations
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
uia '../MyApp.uia'
|
74
|
+
|
75
|
+
main = app.main_presentation # The presentation displayed as the main presentation (regardless of id)
|
76
|
+
sub = app['#nav'] # You can ask for an asset based on the id in the .uia...
|
77
|
+
sub = app['Navigation.uip'] # or based on the path to the file (relative to the .uia)
|
78
|
+
|
79
|
+
|
80
|
+
car = sub/"Scene.Vehicle.Group.Car" # Find elements in a presentation by presentation path…
|
81
|
+
car = app/"nav:Scene.Vehicle.Group.Car" # …or absolute application path
|
82
|
+
|
83
|
+
show car.name #=> Car
|
84
|
+
show car.type #=> Model # Scene, Layer, Camera, Light, Group, Model, Material,
|
85
|
+
# Image, Behavior, Effect, ReferencedMaterial, Text,
|
86
|
+
# RenderPlugin, Component, (custom materials)
|
87
|
+
|
88
|
+
show car.component? #=> false # Ask if an element is a component
|
89
|
+
assert car.component==sub.scene # Ask for the owning component; may be the scene
|
90
|
+
```
|
91
|
+
|
92
|
+
## Finding Many Assets
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
uia 'MyApp.uia'
|
96
|
+
main = app.main_presentation
|
97
|
+
|
98
|
+
every_asset = main.find # Array of matching assets
|
99
|
+
master_assets = main.find master:true # Test for master/nonmaster
|
100
|
+
models = main.find type:'Model' # …or based on type
|
101
|
+
gamecovers = main.find name:'Game Cover' # …or based on name
|
102
|
+
slide2_assets = main.find slide:2 # …or presence on slide
|
103
|
+
rectangles = main.find attributes:{sourcepath:'#Rectangle'} # …or attribute values
|
104
|
+
|
105
|
+
# Combine tests to get more specific
|
106
|
+
master_models = main.find type:'Model', master:true
|
107
|
+
slide2_rects = main.find type:'Model', slide:2, attributes:{sourcepath:'#Rectangle'}
|
108
|
+
nonmaster_s2 = main.find slide:2, master:false
|
109
|
+
red_materials = main.find type:'Material', attributes:{ diffuse:[1,0,0] }
|
110
|
+
|
111
|
+
# You can match values more loosely
|
112
|
+
pistons = main.find name:/^Piston/ # Regex for batch finding
|
113
|
+
bottom_row = main.find attributes:{position:[nil,-200,nil]} # nil for wildcards
|
114
|
+
|
115
|
+
# Restrict the search to a sub-tree
|
116
|
+
group = main/"Scene.Layer.Group"
|
117
|
+
group_models = group.find type:'Model' # Original asset is never included
|
118
|
+
group_models = main.find under:group, type:'Model' # Or use `under` for sub-tree
|
119
|
+
|
120
|
+
# Iterate the results as they are found
|
121
|
+
main.find type:'Model', name:/^Piston/ do |model, index| # Using the index is optional
|
122
|
+
show "Model #{index} is named #{model.name}"
|
123
|
+
end
|
124
|
+
```
|
125
|
+
|
126
|
+
Notes:
|
127
|
+
* `nil` inside an array is a "wildcard" value, allowing you to test only specific values
|
128
|
+
* Numbers (both in vectors/colors/rotations and float/long values) must only be within `0.001` to match.
|
129
|
+
* _For example, `attributes:{diffuse:[1,0,0]}` will match a color with `diffuse=".9997 0.0003 0"`_
|
130
|
+
* Results of `find` are always in scene-graph order.
|
131
|
+
|
132
|
+
|
133
|
+
## Working with References
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
uia 'MyApp.uia'
|
137
|
+
mat1 = app/"main:Scene.Layer.Sphere.Material" # A normal UIC Material
|
138
|
+
mat2 = app/"main:Scene.Layer.Cube.Material" # A normal UIC Material
|
139
|
+
p mat2.type #=> "Material"
|
140
|
+
ref = mat2.replace_with_referenced_material # A very specific method :)
|
141
|
+
p ref.properties['referencedmaterial'].type #=> "ObjectRef"
|
142
|
+
p ref['referencedmaterial',0].object #=> nil
|
143
|
+
p ref['referencedmaterial',0].type #=> :absolute
|
144
|
+
ref['referencedmaterial',0].object = mat1 #=> Sets an absolute reference
|
145
|
+
ref['referencedmaterial',0].type = :path #=> Use a relative path instead
|
146
|
+
|
147
|
+
# Alternatively, you can omit the .object when setting the reference:
|
148
|
+
# ref['referencedmaterial',0] = mat1
|
149
|
+
|
150
|
+
mat3 = ref['referencedmaterial',1].object #=> Get the asset pointed to
|
151
|
+
assert mat1 == mat3 #=> They are the same! It worked!
|
152
|
+
|
153
|
+
app.save_all! #=> Write presentations in place
|
154
|
+
```
|
155
|
+
|
156
|
+
## Writing Assertions
|
157
|
+
|
158
|
+
|
159
|
+
## Locating MetaData.xml
|
160
|
+
RUIC needs access to a UIC `MetaData.xml` file to understand the properties in the various XML files.
|
161
|
+
By default RUIC will look in the location specified by `RUIC::DEFAULTMETADATA`, e.g.
|
162
|
+
`C:/Program Files (x86)/NVIDIA Corporation/UI Composer 8.0/res/DataModelMetadata/en-us/MetaData.xml`
|
163
|
+
|
164
|
+
If this file is in another location, you can tell the script where to find it either:
|
165
|
+
|
166
|
+
* on the command line: `ruic -m path/to/MetaData.xml myscript.ruic`
|
167
|
+
* in your ruic script: `metadata 'path/to/MetaData.xml' # before any 'app' commands`
|
168
|
+
|
169
|
+
|
170
|
+
# Interactive RUIC
|
171
|
+
In addition to executing a standalone script, RUIC also has a REPL (like IRB) that allows you to
|
172
|
+
interactively execute and test changes to your application/presentations before saving.
|
173
|
+
There are two ways to enter interactive mode:
|
174
|
+
|
175
|
+
* If you invoke the `ruic` binary with a `.uia` file as the argument the interpreter will load
|
176
|
+
the application and enter the REPL:
|
177
|
+
```
|
178
|
+
$ ruic myapp.uia
|
179
|
+
(RUIC v0.2.2 interactive session; 'quit' or ctrl-d to end)
|
180
|
+
|
181
|
+
uia "test/projects/SimpleScene/SimpleScene.uia"
|
182
|
+
#=> <UIC::Application 'SimpleScene.uia'>
|
183
|
+
```
|
184
|
+
|
185
|
+
* Alternatively, you can have RUIC execute a script and then enter the interactive REPL
|
186
|
+
by supplying the `-i` command-line switch:
|
187
|
+
```
|
188
|
+
$ ruic -i test/referencematerials.ruic
|
189
|
+
(RUIC v0.2.2 interactive session; 'quit' or ctrl-d to end)
|
190
|
+
|
191
|
+
app
|
192
|
+
#=> <UIC::Application 'ReferencedMaterials.uia'>
|
193
|
+
|
194
|
+
cubemat
|
195
|
+
#=> <asset Material#Material_002>
|
196
|
+
```
|
197
|
+
As shown above, all local variables created by the script continue to be available
|
198
|
+
in the interactive session.
|
199
|
+
|
200
|
+
|
201
|
+
# Known Limitations (aka TODO)
|
202
|
+
_In decreasing priority…_
|
203
|
+
|
204
|
+
- Report on image assets, their sizes
|
205
|
+
- Report used assets (and where they are used)
|
206
|
+
- Report unused assets (in a format suitable for automated destruction)
|
207
|
+
- Report missing assets (and who was looking for them)
|
208
|
+
- Gobs more unit tests
|
209
|
+
- Parse .lua headers (in case one references an image)
|
210
|
+
- Parse render plugins
|
211
|
+
- Read/edit animation tracks
|
212
|
+
- Find all colors, and where they are used
|
213
|
+
- Visual actions for State Machines
|
214
|
+
- Create new presentation assets (e.g. add a new sphere)
|
215
|
+
- Modify the scene graph of presentations
|
216
|
+
- Create new presentations/applications from code
|
217
|
+
- Report on image asset file formats (e.g. find PNGs, find DXT1 vs DXT3 vs DXT Luminance…)
|
218
|
+
|
219
|
+
|
220
|
+
# History
|
221
|
+
|
222
|
+
## v0.2.2 - 2014-Nov-7
|
223
|
+
* REPL shows version number when it starts
|
224
|
+
|
225
|
+
## v0.2.1 - 2014-Nov-7
|
226
|
+
* REPL mode after script maintains binding of script (all local variables remain available)
|
227
|
+
* Customized `.irbrc` files will not cause warnings.
|
228
|
+
|
229
|
+
## v0.2.0 - 2014-Nov-7
|
230
|
+
* Add Presentation#save_as
|
231
|
+
* REPL working directory is same as .uia
|
232
|
+
|
233
|
+
## v0.1.0 - 2014-Nov-7
|
234
|
+
* Add REPL mode for ruic binary
|
235
|
+
|
236
|
+
## v0.0.1 - 2014-Nov-7
|
237
|
+
* Initial gem release
|
238
|
+
* Crawl presentations and modify attributes
|
239
|
+
* Batch find assets
|
240
|
+
* Save presentation changes back to disk
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
# License & Contact
|
245
|
+
RUIC is copyright ©2014 by Gavin Kistner and is licensed under the [MIT License][3]. See the `LICENSE` file for more details.
|
246
|
+
|
247
|
+
For bugs or feature requests please open [issues on GitHub][4]. For other communication you can [email the author directly](mailto:!@phrogz.net?subject=RUIC).
|
248
|
+
|
249
|
+
[1]: http://uicomposer.nvidia.com
|
250
|
+
[2]: http://nokogiri.org
|
251
|
+
[3]: http://opensource.org/licenses/MIT
|
252
|
+
[4]: https://github.com/Phrogz/RUIC/issues
|