/
resourcesystem.h
841 lines (719 loc) · 26.4 KB
/
resourcesystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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
125
126
127
128
129
130
131
132
133
134
135
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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
/** @file resourcesystem.h Resource subsystem.
*
* @authors Copyright © 2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/
#ifndef DENG_RESOURCESYSTEM_H
#define DENG_RESOURCESYSTEM_H
#include "def_data.h"
#include "resourceclass.h"
#include "resource/animgroup.h"
#include "resource/colorpalette.h"
#ifdef __CLIENT__
# include "AbstractFont"
# include "FontScheme"
# include "MaterialVariantSpec"
# include "Model"
# include "ModelDef"
#endif
#include "Material"
#include "MaterialScheme"
#include "resource/sprite.h"
#include "Texture"
#include "TextureScheme"
#include <de/Error>
#include <de/String>
#include <de/System>
#ifdef __CLIENT__
/// Special value used to signify an invalid font id.
#define NOFONTID 0
#endif
/**
* Logical resources; materials, packages, textures, etc...
*
* Resource pointers are considered @em eternal in the sense that they will
* continue to reference the same logical resource data, even after the engine
* is reset. Public resource identifiers (e.g., materialid_t) are similarly
* eternal.
*
* Resource names (paths) are semi-independant from the resources. There may be
* multiple names for any given resource (aliases). The only requirement is that
* their symbolic name must be unique among resources in the same scheme.
*
* @par Classification
*
* @em Runtime resources are not loaded until precached or actually needed. They
* may be cleared, in which case they will be reloaded when needed.
*
* @em System resources are loaded at startup and remain in memory all the time.
* After clearing they must be manually reloaded.
*
* @par Texture resources
*
* @em Clearing a texture is to 'undefine' it - any names bound to it will be
* deleted and any GL textures acquired for it are 'released'. The logical
* Texture instance used to represent it is also deleted.
*
* @em Releasing a texture will leave it defined (any names bound to it will
* persist) but any GL textures acquired for it are 'released'. Note that the
* logical Texture instance used to represent is NOT be deleted.
*
* @ingroup resource
*/
class ResourceSystem : public de::System
{
public:
/// An unknown resource class identifier was specified. @ingroup errors
DENG2_ERROR(UnknownResourceClassError);
/// An unknown resource scheme was referenced. @ingroup errors
DENG2_ERROR(UnknownSchemeError);
/// The referenced manifest was not found. @ingroup errors
DENG2_ERROR(MissingManifestError);
/// The referenced color palette could not be found. @ingroup errors
DENG2_ERROR(MissingColorPaletteError);
/// The referenced sprite could not be found. @ingroup errors
DENG2_ERROR(MissingSpriteError);
/// An unknown material group was referenced. @ingroup errors
DENG2_ERROR(UnknownMaterialGroupError);
/// The specified material id was invalid (out of range). @ingroup errors
DENG2_ERROR(UnknownMaterialIdError);
#ifdef __CLIENT__
/// The specified font id was invalid (out of range). @ingroup errors
DENG2_ERROR(UnknownFontIdError);
#endif
typedef QSet<de::MaterialManifest *> MaterialManifestSet;
typedef MaterialManifestSet MaterialManifestGroup; // Alias
typedef QList<MaterialManifestGroup *> MaterialManifestGroups;
typedef QMap<de::String, de::MaterialScheme *> MaterialSchemes;
typedef QList<Material *> AllMaterials;
typedef QMap<de::String, de::TextureScheme *> TextureSchemes;
typedef QList<de::Texture *> AllTextures;
#ifdef __CLIENT__
typedef QMap<de::String, de::FontScheme *> FontSchemes;
typedef QList<AbstractFont *> AllFonts;
#endif
typedef QList<Sprite *> SpriteSet;
public:
/**
* Construct a new resource system, configuring all resource classes and
* their collections.
*/
ResourceSystem();
// System.
void timeChanged(de::Clock const &);
/**
* Lookup a ResourceClass by symbolic @a name.
*/
de::ResourceClass &resClass(de::String name);
/**
* Lookup a ResourceClass by @a id.
* @todo Refactor away.
*/
de::ResourceClass &resClass(resourceclassid_t id);
void clearAllResources();
void clearAllRuntimeResources();
void clearAllSystemResources();
/**
* Builds the sprite rotation matrixes to account for horizontally flipped
* sprites. Will report an error if the lumps are inconsistant.
*
* Sprite lump names are 4 characters for the actor, a letter for the frame,
* and a number for the rotation, A sprite that is flippable will have an
* additional letter/number appended. The rotation character can be 0 to
* signify no rotations.
*
* Can be reinitalized, clearing all sprites in the process.
*/
void initSprites();
/**
* Destroys all sprites in all sprite sets.
*/
void clearAllSprites();
/**
* Returns the total number of sprite @em sets.
*/
int spriteCount();
/**
* Returns @c true iff a sprite exists for the specified @a spriteId and @a frame;
*
* @param spriteId Unique identifier of the sprite set.
* @param frame Frame number from the set to lookup.
*/
bool hasSprite(spritenum_t spriteId, int frame);
/**
* Returns a pointer to the identified Sprite.
*
* @see hasSprite()
*/
inline Sprite *spritePtr(spritenum_t spriteId, int frame) {
return hasSprite(spriteId, frame)? spriteSet(spriteId).at(frame) : 0;
}
/**
* Lookup the sprite set for the specified @a spriteId.
*
* @param spriteId Unique identifier of the sprite set.
* @return The identified SpriteSet.
*/
SpriteSet const &spriteSet(spritenum_t spriteId);
#ifdef __CLIENT__
/**
* Precache resources from the set associated with the specified @a spriteId.
*
* @param spriteId Unique identifier of the sprite set to cache.
* @param materialSpec Specification to use when caching materials.
*/
void cacheSpriteSet(spritenum_t spriteId, de::MaterialVariantSpec const &materialSpec);
#endif
patchid_t declarePatch(de::String encodedName);
void initSystemTextures();
/**
* Convenient method of searching the texture collection for a texture with
* the specified @a schemeName and @a resourceUri.
*
* @param schemeName Unique name of the scheme in which to search.
* @param resourceUri Path to the (image) resource to find the texture for.
*
* @return The found texture; otherwise @c 0.
*/
de::Texture *texture(de::String schemeName, de::Uri const *resourceUri);
de::Texture *defineTexture(de::String schemeName, de::Uri const &resourceUri,
de::Vector2i const &dimensions = de::Vector2i());
/**
* Returns the total number of unique materials in the collection.
*/
uint materialCount() const { return allMaterials().count(); }
/**
* Determines if a manifest exists for a material on @a path.
* @return @c true if a manifest exists; otherwise @a false.
*/
bool hasMaterial(de::Uri const &path) const;
/**
* Find the material manifest on @a path.
*
* @param path The path to search for.
* @return Found material manifest.
*/
de::MaterialManifest &findMaterial(de::Uri const &path) const;
/**
* Lookup a manifest by unique identifier.
*
* @param id Unique identifier for the manifest to be looked up. Note
* that @c 0 is not a valid identifier.
*
* @return The associated manifest.
*/
de::MaterialManifest &toMaterialManifest(materialid_t id) const;
/**
* Lookup a subspace scheme by symbolic name.
*
* @param name Symbolic name of the scheme.
* @return Scheme associated with @a name.
*
* @throws UnknownSchemeError If @a name is unknown.
*/
de::MaterialScheme &materialScheme(de::String name) const;
/**
* Returns @c true iff a Scheme exists with the symbolic @a name.
*/
bool knownMaterialScheme(de::String name) const;
/**
* Returns a list of all the schemes for efficient traversal.
*/
MaterialSchemes const &allMaterialSchemes() const;
/**
* Returns the total number of manifest schemes in the collection.
*/
inline int materialSchemeCount() const { return allMaterialSchemes().count(); }
/**
* Clear all manifests and materials in all schemes.
*
* @see allSchemes(), Scheme::clear().
*/
inline void clearAllMaterialSchemes()
{
foreach(de::MaterialScheme *scheme, allMaterialSchemes())
{
scheme->clear();
}
}
/**
* Lookup a manifest group by unique @a number.
*/
MaterialManifestGroup &materialGroup(int number) const;
/**
* Create a new (empty) manifest group.
*/
MaterialManifestGroup &createMaterialGroup();
/**
* To be called to destroy all manifest groups when they are no longer needed.
*/
void destroyAllMaterialGroups();
/**
* Provides access to the list of manifest groups for efficient traversal.
*/
MaterialManifestGroups const &allMaterialGroups() const;
/**
* Returns the total number of manifest groups in the collection.
*/
inline int materialGroupCount() const { return allMaterialGroups().count(); }
/**
* Declare a material in the collection, producing a manifest for a logical
* Material which will be defined later. If a manifest with the specified
* @a uri already exists the existing manifest will be returned.
*
* @param uri Uri representing a path to the material in the virtual hierarchy.
*
* @return Manifest for this URI.
*/
inline de::MaterialManifest &declareMaterial(de::Uri const &uri)
{
return materialScheme(uri.scheme()).declare(uri.path());
}
/**
* Returns a list of all the unique material instances in the collection,
* from all schemes.
*/
AllMaterials const &allMaterials() const;
/**
* Determines if a manifest exists for a declared texture on @a path.
* @return @c true, if a manifest exists; otherwise @a false.
*/
bool hasTexture(de::Uri const &path) const;
/**
* Find the manifest for a declared texture.
*
* @param search The search term.
* @return Found unique identifier.
*/
de::TextureManifest &findTexture(de::Uri const &search) const;
/**
* Lookup a subspace scheme by symbolic name.
*
* @param name Symbolic name of the scheme.
* @return Scheme associated with @a name.
*
* @throws UnknownSchemeError If @a name is unknown.
*/
de::TextureScheme &textureScheme(de::String name) const;
/**
* Returns @c true iff a Scheme exists with the symbolic @a name.
*/
bool knownTextureScheme(de::String name) const;
/**
* Returns a list of all the schemes for efficient traversal.
*/
TextureSchemes const &allTextureSchemes() const;
/**
* Returns the total number of manifest schemes in the collection.
*/
inline int textureSchemeCount() const {
return allTextureSchemes().count();
}
/**
* Clear all textures in all schemes.
*
* @see Scheme::clear().
*/
inline void clearAllTextureSchemes()
{
foreach(de::TextureScheme *scheme, allTextureSchemes())
{
scheme->clear();
}
}
/**
* Declare a texture in the collection, producing a manifest for a logical
* Texture which will be defined later. If a manifest with the specified
* @a uri already exists the existing manifest will be returned.
*
* If any of the property values (flags, dimensions, etc...) differ from
* that which is already defined in the pre-existing manifest, any texture
* which is currently associated is released (any GL-textures acquired for
* it are deleted).
*
* @param uri Uri representing a path to the texture in the
* virtual hierarchy.
* @param flags Texture flags property.
* @param dimensions Logical dimensions property.
* @param origin World origin offset property.
* @param uniqueId Unique identifier property.
* @param resourceUri Resource URI property.
*
* @return Manifest for this URI.
*/
inline de::TextureManifest &declareTexture(de::Uri const &uri,
de::Texture::Flags flags, de::Vector2i const &dimensions,
de::Vector2i const &origin, int uniqueId, de::Uri const *resourceUri = 0)
{
return textureScheme(uri.scheme())
.declare(uri.path(), flags, dimensions, origin, uniqueId,
resourceUri);
}
/**
* Returns a list of all the unique texture instances in the collection,
* from all schemes.
*/
AllTextures const &allTextures() const;
#ifdef __CLIENT__
/**
* Returns the total number of resource manifests in the collection.
*/
uint fontCount() const { return allFonts().count(); }
/**
* Determines if a manifest exists for a resource on @a path.
* @return @c true, if a manifest exists; otherwise @a false.
*/
bool hasFont(de::Uri const &path) const;
/**
* Find a resource manifest.
*
* @param search The search term.
* @return Found unique identifier.
*/
de::FontManifest &findFont(de::Uri const &search) const;
/**
* Lookup a manifest by unique identifier.
*
* @param id Unique identifier for the manifest to be looked up. Note
* that @c 0 is not a valid identifier.
*
* @return The associated manifest.
*/
de::FontManifest &toFontManifest(fontid_t id) const;
/**
* Convenient method of looking up a concrete font resource in the collection
* given it's unique identifier.
*
* @return The associated font resource.
*
* @see toManifest(), FontManifest::hasResource()
*/
inline AbstractFont &font(fontid_t id) const {
return toFontManifest(id).resource();
}
/**
* Lookup a subspace scheme by symbolic name.
*
* @param name Symbolic name of the scheme.
* @return Scheme associated with @a name.
*
* @throws UnknownSchemeError If @a name is unknown.
*/
de::FontScheme &fontScheme(de::String name) const;
/**
* Returns @c true iff a Scheme exists with the symbolic @a name.
*/
bool knownFontScheme(de::String name) const;
/**
* Returns a list of all the schemes for efficient traversal.
*/
FontSchemes const &allFontSchemes() const;
/**
* Returns the total number of manifest schemes in the collection.
*/
inline int fontSchemeCount() const { return allFontSchemes().count(); }
/**
* Clear all resources in all schemes.
*
* @see allSchemes(), Scheme::clear().
*/
inline void clearAllFontSchemes() {
foreach(de::FontScheme *scheme, allFontSchemes()) {
scheme->clear();
}
}
/**
* Declare a resource in the collection, producing a (possibly new) manifest
* for a resource which may be defined later. If a manifest with the specified
* @a uri already exists the existing manifest will be returned.
*
* @param uri Uri representing a path to the resource in the virtual hierarchy.
*
* @return The associated manifest for this URI.
*/
inline de::FontManifest &declareFont(de::Uri const &uri) {
return fontScheme(uri.scheme()).declare(uri.path());
}
/**
* Returns a list of pointers to all the concrete resources in the collection,
* from all schemes.
*/
AllFonts const &allFonts() const;
/**
* @pre States must be initialized before this.
* Can be reinitalized, clearing all models in the process.
*/
void initModels();
/**
* Frees all memory allocated for models.
*/
void clearAllModels();
/**
* Lookup the unique index attributed to the given @a modelDef.
*
* @return Index of the definition; otherwise @c -1 if @a modelDef is unknown.
*/
int indexOf(ModelDef const *modelDef);
/**
* Retrieve a model by it's unique @a id. O(1)
*
* @return Pointer to the associated model; otherwise @c 0.
*/
Model *model(modelid_t id);
/**
* Returns the total number of model definitions in the system.
*/
int modelDefCount() const;
/**
* Retrieve a model definition by it's unique @a index. O(1)
*
* @return Pointer to the associated definition; otherwise @c 0.
*/
ModelDef *modelDef(int index);
/**
* Lookup a model definition by it's unique @a id. O(n)
*
* @return Found model definition; otherwise @c 0.
*/
ModelDef *modelDef(char const *id);
/**
* Lookup a model definition for the specified mobj @a stateIndex.
*
* @param stateIndex Index of the mobj state.
* @param select Model selector argument. There may be multiple models for
* a given mobj state. The selector determines which is used
* according to some external selection criteria.
*
* @return Found model definition; otherwise @c 0.
*/
ModelDef *modelDefForState(int stateIndex, int select = 0);
/**
* Is there a model for this mobj? The decision is made based on the state and tics
* of the mobj. Returns the modeldefs that are in effect at the moment (interlinks
* checked appropriately).
*/
float modelDefForMobj(struct mobj_s const *mo, ModelDef **mdef, ModelDef **nextmdef);
/// @todo Refactor away. Used for animating particle/sky models.
void setModelDefFrame(ModelDef &modelDef, int frame);
/**
* Release all GL-textures in all schemes.
*/
void releaseAllGLTextures();
/**
* Release all GL-textures in schemes flagged 'runtime'.
*/
void releaseAllRuntimeGLTextures();
/**
* Release all GL-textures in schemes flagged 'system'.
*/
void releaseAllSystemGLTextures();
/**
* Release all GL-textures in the identified scheme.
*
* @param schemeName Symbolic name of the texture scheme to process.
*/
void releaseGLTexturesByScheme(de::String schemeName);
/**
* Release all GL-textures prepared using @a colorPalette.
*/
void releaseGLTexturesFor(ColorPalette const &colorPalette);
/**
* Release all GL-textures associated with the specified variant @a texture.
*/
void releaseGLTexturesFor(de::TextureVariant &texture);
/**
* Release all GL-textures associated with the specified @a texture.
*/
void releaseGLTexturesFor(de::Texture &texture);
/**
* Release all variants of @a tex which match @a spec.
*
* @param texture Logical Texture to process. Can be @c NULL, in which case this is a null-op.
* @param spec Specification to match. Comparision mode is exact and not fuzzy.
*/
void releaseGLTexturesFor(de::Texture &texture, TextureVariantSpec &spec);
/**
* Prepare a material variant specification in accordance to the specified
* usage context. If incomplete context information is supplied, suitable
* default values will be chosen in their place.
*
* @param contextId Usage context identifier.
* @param flags @ref textureVariantSpecificationFlags
* @param border Border size in pixels (all edges).
* @param tClass Color palette translation class.
* @param tMap Color palette translation map.
* @param wrapS GL texture wrap/clamp mode on the horizontal axis (texture-space).
* @param wrapT GL texture wrap/clamp mode on the vertical axis (texture-space).
* @param minFilter Logical DGL texture minification level.
* @param magFilter Logical DGL texture magnification level.
* @param anisoFilter @c -1= User preference else a logical DGL anisotropic filter level.
* @param mipmapped @c true= use mipmapping.
* @param gammaCorrection @c true= apply gamma correction to textures.
* @param noStretch @c true= disallow stretching of textures.
* @param toAlpha @c true= convert textures to alpha data.
*
* @return Rationalized (and interned) copy of the final specification.
*/
de::MaterialVariantSpec const &materialSpec(MaterialContextId contextId,
int flags, byte border, int tClass, int tMap, int wrapS, int wrapT,
int minFilter, int magFilter, int anisoFilter, bool mipmapped,
bool gammaCorrection, bool noStretch, bool toAlpha);
void clearAllTextureSpecs();
void pruneUnusedTextureSpecs();
/**
* Prepare a TextureVariantSpecification according to usage context. If the
* specification is incomplete suitable defaults are chosen automatically.
*
* @param tc Usage context.
* @param flags @ref textureVariantSpecificationFlags
* @param border Border size in pixels (all edges).
* @param tClass Color palette translation class.
* @param tMap Color palette translation map.
*
* @return A rationalized and valid TextureVariantSpecification.
*/
TextureVariantSpec &textureSpec(texturevariantusagecontext_t tc, int flags,
byte border, int tClass, int tMap, int wrapS, int wrapT, int minFilter,
int magFilter, int anisoFilter, boolean mipmapped, boolean gammaCorrection,
boolean noStretch, boolean toAlpha);
/**
* Prepare a TextureVariantSpecification according to usage context. If the
* specification is incomplete suitable defaults are chosen automatically.
*
* @return A rationalized and valid TextureVariantSpecification.
*/
TextureVariantSpec &detailTextureSpec(float contrast);
/**
* To be called during a definition database reset to clear all definitions
* linked to by Font resources.
*/
void clearFontDefinitionLinks();
AbstractFont *createFontFromDef(ded_compositefont_t const &def);
AbstractFont *createFontFromFile(de::Uri const &uri, de::String filePath);
/**
* Release all GL-textures for fonts in the identified scheme.
*
* @param schemeName Symbolic name of the font scheme to process.
*/
void releaseFontGLTexturesByScheme(de::String schemeName);
#endif // __CLIENT__
/**
* Returns the total number of animation/precache groups.
*/
int animGroupCount();
/**
* Destroys all the animation groups.
*/
void clearAllAnimGroups();
/**
* Returns the AnimGroup associated with @a uniqueId (1-based); otherwise @c 0.
*/
de::AnimGroup *animGroup(int uniqueId);
/**
* Construct a new animation group.
*
* @param flags @ref animationGroupFlags
*/
de::AnimGroup &newAnimGroup(int flags);
/**
* Returns the total number of color palettes.
*/
int colorPaletteCount() const;
/**
* Destroys all the color palettes.
*/
void clearAllColorPalettes();
/**
* Returns the ColorPalette associated with unique @a id.
*/
ColorPalette &colorPalette(colorpaletteid_t id) const;
/**
* Returns the symbolic name of the specified color @a palette. A zero-length
* string is returned if no name is associated.
*/
de::String colorPaletteName(ColorPalette &palette) const;
/**
* Returns @c true iff a ColorPalette with the specified @a name is present.
*/
bool hasColorPalette(de::String name) const;
/**
* Returns the ColorPalette associated with @a name.
*
* @see hasColorPalette()
*/
ColorPalette &colorPalette(de::String name) const;
/**
* @param newPalette Color palette to add. Ownership of the palette is given
* to the resource system.
* @param name Symbolic name of the color palette.
*/
void addColorPalette(ColorPalette &newPalette, de::String const &name = de::String());
/**
* Returns the unique identifier of the current default color palette.
*/
colorpaletteid_t defaultColorPalette() const;
/**
* Change the default color palette.
*
* @param newDefaultPalette The color palette to make default.
*/
void setDefaultColorPalette(ColorPalette *newDefaultPalette);
#ifdef __CLIENT__
/**
* Rewind all material animations back to their initial/starting state.
*
* @see Materials::all(), MaterialVariant::restartAnimation()
*/
void restartAllMaterialAnimations();
/**
* Prepare resources for the current Map.
*/
void cacheForCurrentMap();
/**
* Add a variant of @a material to the cache queue for deferred preparation.
*
* @param material Base material from which to derive a context variant.
* @param spec Specification for the derivation of @a material.
* @param cacheGroups @c true= variants for all materials in any applicable
* groups are desired; otherwise just specified material.
*/
void cache(Material &material, de::MaterialVariantSpec const &spec,
bool cacheGroups = true);
/**
* Cache all resources needed to visualize models using the given @a modelDef.
*/
void cache(ModelDef *modelDef);
/**
* Process all queued material cache tasks.
*/
void processCacheQueue();
/**
* Cancel all queued material cache tasks.
*/
void purgeCacheQueue();
#endif // __CLIENT__
public: /// @todo Should be private:
void initCompositeTextures();
void initFlatTextures();
void initSpriteTextures();
public:
/**
* Register the console commands, variables, etc..., of this module.
*/
static void consoleRegister();
private:
DENG2_PRIVATE(d)
};
#endif // DENG_RESOURCESYSTEM_H