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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a99bfd85a630d1804e5c38b33296883a2f43342
4
- data.tar.gz: f3233b7830899344bcee0c969fdb130e88143b1d
3
+ metadata.gz: 1c4a0b020e018104674acc04364e26190043161b
4
+ data.tar.gz: dfea032213116f92cd14c5eccb35286213b28a96
5
5
  SHA512:
6
- metadata.gz: 474bf2cda9e565b3a050fadb9b266980f3b36075f0a953eabf69106695e623575e980fab75c007e78e47f6de6f5e58f0fad217261008392616b47eeca66207d7
7
- data.tar.gz: 5a3066ad987ce4597b0ef47d935c8db28bc477ffb281300406184d1119539f84d6130478e3f7ca6dbb3b025d0603567cea0c208fa89867c75d81031832d1a8a0
6
+ metadata.gz: 2314350ab17e64a43e6afdf95537287e4ce781f023172634a02e7b285c38c88e1e344df87bbe1bb2feee655a17d1f5b4f0f8fcce0b7caf5e23dbe85b11d2728d
7
+ data.tar.gz: 1f2e65d2327897075f4c91917aa21d504a3919790d12cdd94a41392584291b1f5d1bd0600ebdf797be4e94afed51d7cbec9890dc74d8a63ad71cdda6240bf94c
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,86 +1,110 @@
1
- ## v0.6.0
2
-
3
- ### Backwards Incompatible Changes
4
-
5
- * Changed `FileBacked#resolve_file_path` to `FileBacked#absolute_path`, and added `FileBacked#relative_path`.
6
- * Removed `.errors?` and `.errors` for application and assets.
7
-
8
- ### New/Changed Features
9
-
10
- * State machines properly report on visual actions.
11
- * _Only `<set-attribute>` properly implemented so far._
12
- * Added much improved `Presentation#referenced_files`, `Application#missing_files`, `Application#unused_files`.
13
- * Tweaked REPL output.
14
- * `nil` results no longer print `#=> nil` in the REPL.
15
- * `show` prefixes the result with `#=>`.
16
- * Multi-line results are now wrapped, with each line prefixed with `#=>`.
17
- * Added beginnings of support for effects and renderplugins.
18
- * Presentations do not cause a runtime error if a custom class (e.g. behavior, effect, custom material) cannot be found.
19
-
20
- ### Bug Fixes
21
- * Fix bug that caused some properties to report their type as `nil` or `float` instead of `Float`.
22
- * Presentations are slightly more capable if they are created without an existing file.
23
-
24
- ## v0.5.0 - 2014-Nov-26
25
-
26
- * Fix bug that prevented loading an application from the command line in another directory.
27
- * Compatibility: `FileBacked#path_to` is now `FileBacked#resolve_file_path` to prevent conflict with `Presentation#path_to`.
28
- * Make `inspect` representation of assets more useful.
29
- * Add convenience methods for collections of assets by type on presentations:
30
- `.layers`, `.groups`, `.cameras`, `.lights`, `.components`, `.models`, `.materials`,
31
- `.images`, `.behaviors`, `.aliases`, `.paths`, `.anchor_points`, `.texts`
32
- * Fix bug that prevented behavior instances from having proper `name` or `sourcepath` attribute values.
33
- * Added `.hierarchy` to presentations and assets for printing the scene graph.
34
-
35
- ## v0.4.5 - 2014-Nov-19
36
-
37
- * Added a large amount of documentation.
38
- * Minor code refactoring:
39
- * Most (internal) Presentation methods that took a scene graph element as the argument now take an asset.
40
- * All `FileBacked` assets now have `save!` and `save_as`.
41
-
42
- ## v0.4.1 - 2014-Nov-16
43
-
44
- * Update `MetaData.xml` for tests to newest version.
45
- * Source paths for images/textures normalize the path (forward slashes and no leading `./`).
46
- * Added `app.main` as a simpler alias for `app.main_presentation`.
47
- * Add support for paths and anchor points, including `mypath.anchors` as an array of anchor points.
48
- * Assets present in MetaData and presentation, but not yet hand-entered into the hierarchy, now work and default to inherit from `Asset`.
49
-
50
- ## v0.4.0 - 2014-Nov-11
51
- * 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`.
52
-
53
- ## v0.3.0 - 2014-Nov-10
54
- * Switch attribute filtering to use `attr:{ … }` instead of `attributes:{ … }`
55
- * Attribute matching now requires that a requested attribute be present, or else the asset matching fails.
56
- * _For example, `main.find attr:{ diffusecolor:[nil,nil,nil] }` will now only find assets with a `diffusecolor` attribute._
57
-
58
- ## v0.2.5 - 2014-Nov-10
59
- * Re-adds blank line after REPL result.
60
-
61
- ## v0.2.4 - 2014-Nov-10
62
- * Fix bug with history editing in REPL (prompts no longer have a blank line before)
63
- * Add temporary hack to make projects using Float2 load correctly
64
-
65
- ## v0.2.3 - 2014-Nov-7
66
- * Cleaner mechanism for creating a truly blank binding
67
-
68
- ## v0.2.2 - 2014-Nov-7
69
- * REPL shows version number when it starts
70
-
71
- ## v0.2.1 - 2014-Nov-7
72
- * REPL mode after script maintains binding of script (all local variables remain available)
73
- * Customized `.irbrc` files will not cause warnings
74
-
75
- ## v0.2.0 - 2014-Nov-7
76
- * Add Presentation#save_as
77
- * REPL working directory is same as .uia
78
-
79
- ## v0.1.0 - 2014-Nov-7
80
- * Add REPL mode for ruic binary
81
-
82
- ## v0.0.1 - 2014-Nov-7
83
- * Initial gem release
84
- * Crawl presentations and modify attributes
85
- * Batch find assets
86
- * Save presentation changes back to disk
1
+ ## v0.6.1
2
+
3
+ ### New/Changed Features
4
+
5
+ * Support for the new `PathBuffer` property types (for paths that reference a `.path` on disk).
6
+ * Unsupported/invalid custom property types fall back to String (with a warning).
7
+
8
+ ### Bug Fixes
9
+ * Render plugins are now lightly tested and supported.
10
+
11
+
12
+ ## v0.6.0
13
+
14
+ ### Backwards Incompatible Changes
15
+
16
+ * Changed `FileBacked#resolve_file_path` to `FileBacked#absolute_path`, and added `FileBacked#relative_path`.
17
+ * Removed `.errors?` and `.errors` for application and assets.
18
+
19
+ ### New/Changed Features
20
+
21
+ * State machines properly report on visual actions.
22
+ * _Only `<set-attribute>` properly implemented so far._
23
+ * Added much improved `Presentation#referenced_files`, `Application#missing_files`, `Application#unused_files`.
24
+ * Tweaked REPL output.
25
+ * `nil` results no longer print `#=> nil` in the REPL.
26
+ * `show` prefixes the result with `#=>`.
27
+ * Multi-line results are now wrapped, with each line prefixed with `#=>`.
28
+ * Added beginnings of support for effects and renderplugins.
29
+ * Presentations do not cause a runtime error if a custom class (e.g. behavior, effect, custom material) cannot be found.
30
+
31
+ ### Bug Fixes
32
+ * Fix bug that caused some properties to report their type as `nil` or `float` instead of `Float`.
33
+ * Presentations are slightly more capable if they are created without an existing file.
34
+
35
+
36
+ ## v0.5.0 - 2014-Nov-26
37
+
38
+ * Fix bug that prevented loading an application from the command line in another directory.
39
+ * Compatibility: `FileBacked#path_to` is now `FileBacked#resolve_file_path` to prevent conflict with `Presentation#path_to`.
40
+ * Make `inspect` representation of assets more useful.
41
+ * Add convenience methods for collections of assets by type on presentations:
42
+ `.layers`, `.groups`, `.cameras`, `.lights`, `.components`, `.models`, `.materials`,
43
+ `.images`, `.behaviors`, `.aliases`, `.paths`, `.anchor_points`, `.texts`
44
+ * Fix bug that prevented behavior instances from having proper `name` or `sourcepath` attribute values.
45
+ * Added `.hierarchy` to presentations and assets for printing the scene graph.
46
+
47
+
48
+ ## v0.4.5 - 2014-Nov-19
49
+
50
+ * Added a large amount of documentation.
51
+ * Minor code refactoring:
52
+ * Most (internal) Presentation methods that took a scene graph element as the argument now take an asset.
53
+ * All `FileBacked` assets now have `save!` and `save_as`.
54
+
55
+
56
+ ## v0.4.1 - 2014-Nov-16
57
+
58
+ * Update `MetaData.xml` for tests to newest version.
59
+ * Source paths for images/textures normalize the path (forward slashes and no leading `./`).
60
+ * Added `app.main` as a simpler alias for `app.main_presentation`.
61
+ * Add support for paths and anchor points, including `mypath.anchors` as an array of anchor points.
62
+ * Assets present in MetaData and presentation, but not yet hand-entered into the hierarchy, now work and default to inherit from `Asset`.
63
+
64
+
65
+ ## v0.4.0 - 2014-Nov-11
66
+ * 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`.
67
+
68
+
69
+ ## v0.3.0 - 2014-Nov-10
70
+ * Switch attribute filtering to use `attr:{ … }` instead of `attributes:{ … }`
71
+ * Attribute matching now requires that a requested attribute be present, or else the asset matching fails.
72
+ * _For example, `main.find attr:{ diffusecolor:[nil,nil,nil] }` will now only find assets with a `diffusecolor` attribute._
73
+
74
+
75
+ ## v0.2.5 - 2014-Nov-10
76
+ * Re-adds blank line after REPL result.
77
+
78
+
79
+ ## v0.2.4 - 2014-Nov-10
80
+ * Fix bug with history editing in REPL (prompts no longer have a blank line before)
81
+ * Add temporary hack to make projects using Float2 load correctly
82
+
83
+
84
+ ## v0.2.3 - 2014-Nov-7
85
+ * Cleaner mechanism for creating a truly blank binding
86
+
87
+
88
+ ## v0.2.2 - 2014-Nov-7
89
+ * REPL shows version number when it starts
90
+
91
+
92
+ ## v0.2.1 - 2014-Nov-7
93
+ * REPL mode after script maintains binding of script (all local variables remain available)
94
+ * Customized `.irbrc` files will not cause warnings
95
+
96
+
97
+ ## v0.2.0 - 2014-Nov-7
98
+ * Add Presentation#save_as
99
+ * REPL working directory is same as .uia
100
+
101
+
102
+ ## v0.1.0 - 2014-Nov-7
103
+ * Add REPL mode for ruic binary
104
+
105
+
106
+ ## v0.0.1 - 2014-Nov-7
107
+ * Initial gem release
108
+ * Crawl presentations and modify attributes
109
+ * Batch find assets
110
+ * 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.6.0 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.6.0 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.6.0 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.6.0 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