RUIC 0.4.6 → 0.5.0

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -3
  3. data/HISTORY +63 -52
  4. data/README.md +220 -220
  5. data/bin/ruic +12 -11
  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 +182 -175
  15. data/lib/ruic/application.rb +2 -2
  16. data/lib/ruic/assets.rb +436 -421
  17. data/lib/ruic/attributes.rb +170 -165
  18. data/lib/ruic/behaviors.rb +1 -1
  19. data/lib/ruic/interfaces.rb +23 -1
  20. data/lib/ruic/presentation.rb +100 -34
  21. data/lib/ruic/ripl-after-result.rb +24 -24
  22. data/lib/ruic/statemachine.rb +1 -1
  23. data/lib/ruic/version.rb +3 -3
  24. data/ruic.gemspec +25 -25
  25. data/test/MetaData-simple.xml +28 -28
  26. data/test/MetaData.xml +435 -435
  27. data/test/customclasses.ruic +31 -21
  28. data/test/filtering.ruic +43 -43
  29. data/test/futureassets.ruic +8 -8
  30. data/test/nonmaster.ruic +0 -0
  31. data/test/paths.ruic +18 -18
  32. data/test/projects/CustomClasses/CustomClasses.uia +7 -7
  33. data/test/projects/CustomClasses/CustomClasses.uip +7 -1
  34. data/test/projects/CustomClasses/FutureAsset.uip +17 -17
  35. data/test/projects/CustomClasses/scripts/DataDrivenTime.lua +58 -0
  36. data/test/projects/CustomClasses/scripts/TimeDrivenAttribute.lua +49 -0
  37. data/test/projects/Paths/Paths.uia +4 -4
  38. data/test/projects/Paths/Paths.uip +98 -98
  39. data/test/projects/SimpleScene/SimpleScene.uia +4 -4
  40. data/test/projects/SimpleScene/SimpleScene.uip +35 -35
  41. data/test/properties.ruic +82 -82
  42. data/test/referencematerials.ruic +52 -52
  43. data/test/usage.ruic +20 -20
  44. metadata +32 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c02aa4df35663e830ed819350a0977a7f0805f4e
4
- data.tar.gz: 1d728ca47f6e2c213028c6b14b0eedf6023390a1
3
+ metadata.gz: 105e49557e0d92a463d1630cd6fa42d078048e44
4
+ data.tar.gz: 21db139d873cbcfa3ad7f9c66c85a2ffc151f9ac
5
5
  SHA512:
6
- metadata.gz: d42a1b9a3fe8aab26634db101d656c28a9f893bc95cb2e9a1c89068019f2e41af38399573e9c06cae7b3c32e50fc4a9865e3316889c421b50be4ce40db075e67
7
- data.tar.gz: 2d07ec0c134530522a6afba063b622519084d632ac1440b030a7badbcf6e47eae78c590be2a653dc2d41a2e7d86b2d71c4c78d9da78f4a4abd2f84049f621cec
6
+ metadata.gz: 2e4f62d1164c63510bb3cc931870b3b353e28439fecf38076b6ac8ad3dca09a528c5fedb32c6b613115b1d248fda324a11fac912d873da83e57fd16bd1a82586
7
+ data.tar.gz: 0eeb2a2ab41c848feef5859a7f0810584de7f89beb785c9bb29a1c7f55a72495a7234ecc5514e8e45b765ba13aea650a0e7685f7d9a903fcd08baa45527fa19e
data/.yardopts CHANGED
@@ -1,4 +1,4 @@
1
- --no-private
2
- --markup markdown
3
- lib/**/*.rb -
1
+ --no-private
2
+ --markup markdown
3
+ lib/**/*.rb -
4
4
  README.md LICENSE HISTORY
data/HISTORY CHANGED
@@ -1,52 +1,63 @@
1
- ## v0.4.5 - 2014-Nov-19
2
-
3
- * Added a large amount of documentation.
4
- * Minor code refactoring:
5
- * Most (internal) Presentation methods that took a scene graph element as the argument now take an asset.
6
- * All `FileBacked` assets now have `save!` and `save_as`.
7
-
8
- ## v0.4.1 - 2014-Nov-16
9
-
10
- * Update `MetaData.xml` for tests to newest version.
11
- * Source paths for images/textures normalize the path (forward slashes and no leading `./`).
12
- * Added `app.main` as a simpler alias for `app.main_presentation`.
13
- * Add support for paths and anchor points, including `mypath.anchors` as an array of anchor points.
14
- * Assets present in MetaData and presentation, but not yet hand-entered into the hierarchy, now work and default to inherit from `Asset`.
15
-
16
- ## v0.4.0 - 2014-Nov-11
17
- * Switch attribute filtering again; now all attributes are inline in the `find()` hash, and the four special keys are prefixed with an underscore: `_type`, `_slide`, `_master`, and `_under`.
18
-
19
- ## v0.3.0 - 2014-Nov-10
20
- * Switch attribute filtering to use `attr:{ … }` instead of `attributes:{ … }`
21
- * Attribute matching now requires that a requested attribute be present, or else the asset matching fails.
22
- * _For example, `main.find attr:{ diffusecolor:[nil,nil,nil] }` will now only find assets with a `diffusecolor` attribute._
23
-
24
- ## v0.2.5 - 2014-Nov-10
25
- * Re-adds blank line after REPL result.
26
-
27
- ## v0.2.4 - 2014-Nov-10
28
- * Fix bug with history editing in REPL (prompts no longer have a blank line before)
29
- * Add temporary hack to make projects using Float2 load correctly
30
-
31
- ## v0.2.3 - 2014-Nov-7
32
- * Cleaner mechanism for creating a truly blank binding
33
-
34
- ## v0.2.2 - 2014-Nov-7
35
- * REPL shows version number when it starts
36
-
37
- ## v0.2.1 - 2014-Nov-7
38
- * REPL mode after script maintains binding of script (all local variables remain available)
39
- * Customized `.irbrc` files will not cause warnings
40
-
41
- ## v0.2.0 - 2014-Nov-7
42
- * Add Presentation#save_as
43
- * REPL working directory is same as .uia
44
-
45
- ## v0.1.0 - 2014-Nov-7
46
- * Add REPL mode for ruic binary
47
-
48
- ## v0.0.1 - 2014-Nov-7
49
- * Initial gem release
50
- * Crawl presentations and modify attributes
51
- * Batch find assets
52
- * Save presentation changes back to disk
1
+ ## v0.5.0 - 2014-Nov-26
2
+
3
+ * Fix bug that prevented loading an application from the command line in another directory.
4
+ * Compatibility: `FileBacked#path_to` is now `FileBacked#resolve_file_path` to prevent conflict with `Presentation#path_to`.
5
+ * Make `inspect` representation of assets more useful.
6
+ * Add convenience methods for collections of assets by type on presentations:
7
+ `.layers`, `.groups`, `.cameras`, `.lights`, `.components`, `.models`, `.materials`,
8
+ `.images`, `.behaviors`, `.aliases`, `.paths`, `.anchor_points`, `.texts`
9
+ * Fix bug that prevented behavior instances from having proper `name` or `sourcepath` attribute values.
10
+ * Added `.hierarchy` to presentations and assets for printing the scene graph.
11
+
12
+ ## v0.4.5 - 2014-Nov-19
13
+
14
+ * Added a large amount of documentation.
15
+ * Minor code refactoring:
16
+ * Most (internal) Presentation methods that took a scene graph element as the argument now take an asset.
17
+ * All `FileBacked` assets now have `save!` and `save_as`.
18
+
19
+ ## v0.4.1 - 2014-Nov-16
20
+
21
+ * Update `MetaData.xml` for tests to newest version.
22
+ * Source paths for images/textures normalize the path (forward slashes and no leading `./`).
23
+ * Added `app.main` as a simpler alias for `app.main_presentation`.
24
+ * Add support for paths and anchor points, including `mypath.anchors` as an array of anchor points.
25
+ * Assets present in MetaData and presentation, but not yet hand-entered into the hierarchy, now work and default to inherit from `Asset`.
26
+
27
+ ## v0.4.0 - 2014-Nov-11
28
+ * Switch attribute filtering again; now all attributes are inline in the `find()` hash, and the four special keys are prefixed with an underscore: `_type`, `_slide`, `_master`, and `_under`.
29
+
30
+ ## v0.3.0 - 2014-Nov-10
31
+ * Switch attribute filtering to use `attr:{ … }` instead of `attributes:{ … }`
32
+ * Attribute matching now requires that a requested attribute be present, or else the asset matching fails.
33
+ * _For example, `main.find attr:{ diffusecolor:[nil,nil,nil] }` will now only find assets with a `diffusecolor` attribute._
34
+
35
+ ## v0.2.5 - 2014-Nov-10
36
+ * Re-adds blank line after REPL result.
37
+
38
+ ## v0.2.4 - 2014-Nov-10
39
+ * Fix bug with history editing in REPL (prompts no longer have a blank line before)
40
+ * Add temporary hack to make projects using Float2 load correctly
41
+
42
+ ## v0.2.3 - 2014-Nov-7
43
+ * Cleaner mechanism for creating a truly blank binding
44
+
45
+ ## v0.2.2 - 2014-Nov-7
46
+ * REPL shows version number when it starts
47
+
48
+ ## v0.2.1 - 2014-Nov-7
49
+ * REPL mode after script maintains binding of script (all local variables remain available)
50
+ * Customized `.irbrc` files will not cause warnings
51
+
52
+ ## v0.2.0 - 2014-Nov-7
53
+ * Add Presentation#save_as
54
+ * REPL working directory is same as .uia
55
+
56
+ ## v0.1.0 - 2014-Nov-7
57
+ * Add REPL mode for ruic binary
58
+
59
+ ## v0.0.1 - 2014-Nov-7
60
+ * Initial gem release
61
+ * Crawl presentations and modify attributes
62
+ * Batch find assets
63
+ * Save presentation changes back to disk
data/README.md CHANGED
@@ -1,220 +1,220 @@
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
-
13
- # Documentation
14
-
15
- In addition to the examples in this file full API documentation is available at:
16
- http://www.rubydoc.info/gems/RUIC/
17
-
18
-
19
-
20
- # Installing RUIC
21
- RUIC can be installed via RubyGems (part of Ruby) via the command:
22
-
23
- gem install ruic # May need `sudo gem install ruic` depending on your setup
24
-
25
- 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.
26
-
27
-
28
-
29
- # Using the RUIC DSL
30
-
31
- RUIC scripts are pure Ruby with a few convenience methods added. You run them via the `ruic` command-line script, e.g.
32
-
33
- ruic myscript.ruic # or .rb extension, for syntax highlighting while editing
34
-
35
-
36
- ## Creating and Accessing Applications
37
- RUIC scripts must start with `uia` commands to load an application and all its assets.
38
- After this you can access the application as `app`:
39
-
40
- ```ruby
41
- uia '../MyApp.uia' # Relative to the ruic script file, or absolute
42
-
43
- show app.file #=> /var/projects/UIC/MyApp/main/MyApp.uia
44
- show app.filename #=> MyApp.uia
45
-
46
- show app.assets.count #=> 7
47
- # You can ask for app.behaviors, app.presentations, app.statemachines, and app.renderplugins
48
- # for arrays of specific asset types
49
- ```
50
-
51
- _The `show` command prints the result; it is simply a nicer alias for `puts`._
52
-
53
- If you need to load multiple applications in the same script, subsequent `uia` commands will create
54
- `app2`, `app3`, etc. for you to use.
55
-
56
- ```ruby
57
- uia '../MyApp.uia' # Available as 'app'
58
- uia '../../v1/MyApp.uia' # Available as 'app2'
59
- ```
60
-
61
-
62
- ## Working with Presentations
63
-
64
- ```ruby
65
- uia '../MyApp.uia'
66
-
67
- main = app.main_presentation # The presentation displayed as the main presentation (regardless of id)
68
- sub = app['#nav'] # You can ask for an asset based on the id in the .uia...
69
- sub = app['Navigation.uip'] # or based on the path to the file (relative to the .uia)
70
-
71
-
72
- car = sub/"Scene.Vehicle.Group.Car" # Find elements in a presentation by presentation path…
73
- car = app/"nav:Scene.Vehicle.Group.Car" # …or absolute application path
74
-
75
- show car.name #=> Car
76
- show car.type #=> Model # Scene, Layer, Camera, Light, Group, Model, Material,
77
- # Image, Behavior, Effect, ReferencedMaterial, Text,
78
- # RenderPlugin, Component, (custom materials)
79
-
80
- show car.component? #=> false # Ask if an element is a component
81
- assert car.component==sub.scene # Ask for the owning component; may be the scene
82
- ```
83
-
84
- ## Finding Many Assets
85
-
86
- ```ruby
87
- uia 'MyApp.uia'
88
- main = app.main_presentation
89
-
90
- every_asset = main.find # Array of matching assets
91
- master_assets = main.find _master:true # Test for master/nonmaster
92
- models = main.find _type:'Model' # …or based on type
93
- slide2_assets = main.find _slide:2 # …or presence on slide
94
- rectangles = main.find sourcepath:'#Rectangle' # …or attribute values
95
- gamecovers = main.find name:'Game Cover' # …including the name
96
-
97
- # Combine tests to get more specific
98
- master_models = main.find _type:'Model', _master:true
99
- slide2_rects = main.find _type:'Model', _slide:2, sourcepath:'#Rectangle'
100
- nonmaster_s2 = main.find _slide:2, _master:false
101
- red_materials = main.find _type:'Material', diffuse:[1,0,0]
102
-
103
- # You can match values more loosely
104
- pistons = main.find name:/^Piston/ # Regex for batch finding
105
- bottom_row = main.find position:[nil,-200,nil] # nil for wildcards in vectors
106
-
107
- # Restrict the search to a sub-tree
108
- group = main/"Scene.Layer.Group"
109
- group_models = group.find _type:'Model' # Orig asset is never included
110
- group_models = main.find _under:group, _type:'Model' # Or, use `_under` to limit
111
-
112
- # Iterate the results as they are found
113
- main.find _type:'Model', name:/^Piston/ do |model, index| # Using the index is optional
114
- show "Model #{index} is named #{model.name}"
115
- end
116
- ```
117
-
118
- Notes:
119
-
120
- * `nil` inside an array is a "wildcard" value, allowing you to test only specific values
121
- * Numbers (both in vectors/colors/rotations and float/long values) must only be within `0.001` to match.
122
- * _For example, `attr:{diffuse:[1,0,0]}` will match a color with `diffuse=".9997 0.0003 0"`_
123
- * Results of `find` are always in scene-graph order.
124
-
125
-
126
- ## Working with References
127
-
128
- ```ruby
129
- uia 'MyApp.uia'
130
- mat1 = app/"main:Scene.Layer.Sphere.Material" # A normal UIC Material
131
- mat2 = app/"main:Scene.Layer.Cube.Material" # A normal UIC Material
132
- p mat2.type #=> "Material"
133
- ref = mat2.replace_with_referenced_material # A very specific method :)
134
- p ref.properties['referencedmaterial'].type #=> "ObjectRef"
135
- p ref['referencedmaterial',0].object #=> nil
136
- p ref['referencedmaterial',0].type #=> :absolute
137
- ref['referencedmaterial',0].object = mat1 #=> Sets an absolute reference
138
- ref['referencedmaterial',0].type = :path #=> Use a relative path instead
139
-
140
- # Alternatively, you can omit the .object when setting the reference:
141
- # ref['referencedmaterial',0] = mat1
142
-
143
- mat3 = ref['referencedmaterial',1].object #=> Get the asset pointed to
144
- assert mat1 == mat3 #=> They are the same! It worked!
145
-
146
- app.save_all! #=> Write presentations in place
147
- ```
148
-
149
-
150
- ## Locating MetaData.xml
151
- RUIC needs access to a UIC `MetaData.xml` file to understand the properties in the various XML files.
152
- By default RUIC will look in the location specified by `RUIC::DEFAULTMETADATA`, e.g.
153
- `C:/Program Files (x86)/NVIDIA Corporation/UI Composer 8.0/res/DataModelMetadata/en-us/MetaData.xml`
154
-
155
- If this file is in another location, you can tell the script where to find it either:
156
-
157
- * on the command line: `ruic -m path/to/MetaData.xml myscript.ruic`
158
- * in your ruic script: `metadata 'path/to/MetaData.xml' # before any 'app' commands`
159
-
160
-
161
- # Interactive RUIC
162
- In addition to executing a standalone script, RUIC also has a REPL (like IRB) that allows you to
163
- interactively execute and test changes to your application/presentations before saving.
164
- There are two ways to enter interactive mode:
165
-
166
- * If you invoke the `ruic` binary with a `.uia` file as the argument the interpreter will load
167
- the application and enter the REPL:
168
-
169
- $ ruic myapp.uia
170
- (RUIC v0.2.2 interactive session; 'quit' or ctrl-d to end)
171
-
172
- uia "test/projects/SimpleScene/SimpleScene.uia"
173
- #=> <UIC::Application 'SimpleScene.uia'>
174
-
175
- * Alternatively, you can have RUIC execute a script and then enter the interactive REPL
176
- by supplying the `-i` command-line switch:
177
-
178
- $ ruic -i test/referencematerials.ruic
179
- (RUIC v0.2.2 interactive session; 'quit' or ctrl-d to end)
180
-
181
- app
182
- #=> <UIC::Application 'ReferencedMaterials.uia'>
183
-
184
- cubemat
185
- #=> <asset Material#Material_002>
186
-
187
- As shown above, all local variables created by the script continue to be available
188
- in the interactive session.
189
-
190
-
191
-
192
- # Known Limitations (aka TODO)
193
- _In decreasing priority…_
194
-
195
- - Report on image assets, their sizes
196
- - Report used assets (and where they are used)
197
- - Report unused assets (in a format suitable for automated destruction)
198
- - Report missing assets (and who was looking for them)
199
- - Gobs more unit tests
200
- - Parse .lua headers (in case one references an image)
201
- - Parse render plugins
202
- - Read/edit animation tracks
203
- - Find all colors, and where they are used
204
- - Visual actions for State Machines
205
- - Create new presentation assets (e.g. add a new sphere)
206
- - Modify the scene graph of presentations
207
- - Create new presentations/applications from code
208
- - Report on image asset file formats (e.g. find PNGs, find DXT1 vs DXT3 vs DXT Luminance…)
209
-
210
-
211
-
212
- # License & Contact
213
- RUIC is copyright ©2014 by Gavin Kistner and is licensed under the [MIT License][3]. See the `LICENSE` file for more details.
214
-
215
- 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).
216
-
217
- [1]: http://uicomposer.nvidia.com
218
- [2]: http://nokogiri.org
219
- [3]: http://opensource.org/licenses/MIT
220
- [4]: https://github.com/Phrogz/RUIC/issues
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
+
13
+ # Documentation
14
+
15
+ In addition to the examples in this file full API documentation is available at:
16
+ http://www.rubydoc.info/gems/RUIC/
17
+
18
+
19
+
20
+ # Installing RUIC
21
+ RUIC can be installed via RubyGems (part of Ruby) via the command:
22
+
23
+ gem install ruic # May need `sudo gem install ruic` depending on your setup
24
+
25
+ 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.
26
+
27
+
28
+
29
+ # Using the RUIC DSL
30
+
31
+ RUIC scripts are pure Ruby with a few convenience methods added. You run them via the `ruic` command-line script, e.g.
32
+
33
+ ruic myscript.ruic # or .rb extension, for syntax highlighting while editing
34
+
35
+
36
+ ## Creating and Accessing Applications
37
+ RUIC scripts must start with `uia` commands to load an application and all its assets.
38
+ After this you can access the application as `app`:
39
+
40
+ ```ruby
41
+ uia '../MyApp.uia' # Relative to the ruic script file, or absolute
42
+
43
+ show app.file #=> /var/projects/UIC/MyApp/main/MyApp.uia
44
+ show app.filename #=> MyApp.uia
45
+
46
+ show app.assets.count #=> 7
47
+ # You can ask for app.behaviors, app.presentations, app.statemachines, and app.renderplugins
48
+ # for arrays of specific asset types
49
+ ```
50
+
51
+ _The `show` command prints the result; it is simply a nicer alias for `puts`._
52
+
53
+ If you need to load multiple applications in the same script, subsequent `uia` commands will create
54
+ `app2`, `app3`, etc. for you to use.
55
+
56
+ ```ruby
57
+ uia '../MyApp.uia' # Available as 'app'
58
+ uia '../../v1/MyApp.uia' # Available as 'app2'
59
+ ```
60
+
61
+
62
+ ## Working with Presentations
63
+
64
+ ```ruby
65
+ uia '../MyApp.uia'
66
+
67
+ main = app.main_presentation # The presentation displayed as the main presentation (regardless of id)
68
+ sub = app['#nav'] # You can ask for an asset based on the id in the .uia...
69
+ sub = app['Navigation.uip'] # or based on the path to the file (relative to the .uia)
70
+
71
+
72
+ car = sub/"Scene.Vehicle.Group.Car" # Find elements in a presentation by presentation path…
73
+ car = app/"nav:Scene.Vehicle.Group.Car" # …or absolute application path
74
+
75
+ show car.name #=> Car
76
+ show car.type #=> Model # Scene, Layer, Camera, Light, Group, Model, Material,
77
+ # Image, Behavior, Effect, ReferencedMaterial, Text,
78
+ # RenderPlugin, Component, (custom materials)
79
+
80
+ show car.component? #=> false # Ask if an element is a component
81
+ assert car.component==sub.scene # Ask for the owning component; may be the scene
82
+ ```
83
+
84
+ ## Finding Many Assets
85
+
86
+ ```ruby
87
+ uia 'MyApp.uia'
88
+ main = app.main_presentation
89
+
90
+ every_asset = main.find # Array of matching assets
91
+ master_assets = main.find _master:true # Test for master/nonmaster
92
+ models = main.find _type:'Model' # …or based on type
93
+ slide2_assets = main.find _slide:2 # …or presence on slide
94
+ rectangles = main.find sourcepath:'#Rectangle' # …or attribute values
95
+ gamecovers = main.find name:'Game Cover' # …including the name
96
+
97
+ # Combine tests to get more specific
98
+ master_models = main.find _type:'Model', _master:true
99
+ slide2_rects = main.find _type:'Model', _slide:2, sourcepath:'#Rectangle'
100
+ nonmaster_s2 = main.find _slide:2, _master:false
101
+ red_materials = main.find _type:'Material', diffuse:[1,0,0]
102
+
103
+ # You can match values more loosely
104
+ pistons = main.find name:/^Piston/ # Regex for batch finding
105
+ bottom_row = main.find position:[nil,-200,nil] # nil for wildcards in vectors
106
+
107
+ # Restrict the search to a sub-tree
108
+ group = main/"Scene.Layer.Group"
109
+ group_models = group.find _type:'Model' # Orig asset is never included
110
+ group_models = main.find _under:group, _type:'Model' # Or, use `_under` to limit
111
+
112
+ # Iterate the results as they are found
113
+ main.find _type:'Model', name:/^Piston/ do |model, index| # Using the index is optional
114
+ show "Model #{index} is named #{model.name}"
115
+ end
116
+ ```
117
+
118
+ Notes:
119
+
120
+ * `nil` inside an array is a "wildcard" value, allowing you to test only specific values
121
+ * Numbers (both in vectors/colors/rotations and float/long values) must only be within `0.001` to match.
122
+ * _For example, `attr:{diffuse:[1,0,0]}` will match a color with `diffuse=".9997 0.0003 0"`_
123
+ * Results of `find` are always in scene-graph order.
124
+
125
+
126
+ ## Working with References
127
+
128
+ ```ruby
129
+ uia 'MyApp.uia'
130
+ mat1 = app/"main:Scene.Layer.Sphere.Material" # A normal UIC Material
131
+ mat2 = app/"main:Scene.Layer.Cube.Material" # A normal UIC Material
132
+ p mat2.type #=> "Material"
133
+ ref = mat2.replace_with_referenced_material # A very specific method :)
134
+ p ref.properties['referencedmaterial'].type #=> "ObjectRef"
135
+ p ref['referencedmaterial',0].object #=> nil
136
+ p ref['referencedmaterial',0].type #=> :absolute
137
+ ref['referencedmaterial',0].object = mat1 #=> Sets an absolute reference
138
+ ref['referencedmaterial',0].type = :path #=> Use a relative path instead
139
+
140
+ # Alternatively, you can omit the .object when setting the reference:
141
+ # ref['referencedmaterial',0] = mat1
142
+
143
+ mat3 = ref['referencedmaterial',1].object #=> Get the asset pointed to
144
+ assert mat1 == mat3 #=> They are the same! It worked!
145
+
146
+ app.save_all! #=> Write presentations in place
147
+ ```
148
+
149
+
150
+ ## Locating MetaData.xml
151
+ RUIC needs access to a UIC `MetaData.xml` file to understand the properties in the various XML files.
152
+ By default RUIC will look in the location specified by `RUIC::DEFAULTMETADATA`, e.g.
153
+ `C:/Program Files (x86)/NVIDIA Corporation/UI Composer 8.0/res/DataModelMetadata/en-us/MetaData.xml`
154
+
155
+ If this file is in another location, you can tell the script where to find it either:
156
+
157
+ * on the command line: `ruic -m path/to/MetaData.xml myscript.ruic`
158
+ * in your ruic script: `metadata 'path/to/MetaData.xml' # before any 'app' commands`
159
+
160
+
161
+ # Interactive RUIC
162
+ In addition to executing a standalone script, RUIC also has a REPL (like IRB) that allows you to
163
+ interactively execute and test changes to your application/presentations before saving.
164
+ There are two ways to enter interactive mode:
165
+
166
+ * If you invoke the `ruic` binary with a `.uia` file as the argument the interpreter will load
167
+ the application and enter the REPL:
168
+
169
+ $ ruic myapp.uia
170
+ (RUIC v0.2.2 interactive session; 'quit' or ctrl-d to end)
171
+
172
+ uia "test/projects/SimpleScene/SimpleScene.uia"
173
+ #=> <UIC::Application 'SimpleScene.uia'>
174
+
175
+ * Alternatively, you can have RUIC execute a script and then enter the interactive REPL
176
+ by supplying the `-i` command-line switch:
177
+
178
+ $ ruic -i test/referencematerials.ruic
179
+ (RUIC v0.2.2 interactive session; 'quit' or ctrl-d to end)
180
+
181
+ app
182
+ #=> <UIC::Application 'ReferencedMaterials.uia'>
183
+
184
+ cubemat
185
+ #=> <asset Material#Material_002>
186
+
187
+ As shown above, all local variables created by the script continue to be available
188
+ in the interactive session.
189
+
190
+
191
+
192
+ # Known Limitations (aka TODO)
193
+ _In decreasing priority…_
194
+
195
+ - Report on image assets, their sizes
196
+ - Report used assets (and where they are used)
197
+ - Report unused assets (in a format suitable for automated destruction)
198
+ - Report missing assets (and who was looking for them)
199
+ - Gobs more unit tests
200
+ - Parse .lua headers (in case one references an image)
201
+ - Parse render plugins
202
+ - Read/edit animation tracks
203
+ - Find all colors, and where they are used
204
+ - Visual actions for State Machines
205
+ - Create new presentation assets (e.g. add a new sphere)
206
+ - Modify the scene graph of presentations
207
+ - Create new presentations/applications from code
208
+ - Report on image asset file formats (e.g. find PNGs, find DXT1 vs DXT3 vs DXT Luminance…)
209
+
210
+
211
+
212
+ # License & Contact
213
+ RUIC is copyright ©2014 by Gavin Kistner and is licensed under the [MIT License][3]. See the `LICENSE` file for more details.
214
+
215
+ 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).
216
+
217
+ [1]: http://uicomposer.nvidia.com
218
+ [2]: http://nokogiri.org
219
+ [3]: http://opensource.org/licenses/MIT
220
+ [4]: https://github.com/Phrogz/RUIC/issues