1
1

ContentHandler.ts 789 B

1234567891011121314151617181920212223
  1. /**
  2. * Content types need to be allowed/forbidden at the global level, rather than a save level.
  3. * They should be able to be changed at any time.
  4. * They should be as little vague as is reasonable.
  5. */
  6. module ContentHandler {
  7. let contentHash : {[id : string] : ContentType} = {};
  8. let contentArray : Array<ContentType> = [];
  9. export function registerContentType (type : ContentType) {
  10. if (contentHash[type.getId()] != undefined) {
  11. console.error("[ContentHandler} Can't register the content.", type, "Old:", contentHash[type.getId()]);
  12. return;
  13. } else {
  14. contentHash[type.getId()] = type;
  15. contentArray.push(type);
  16. }
  17. }
  18. export function getContentTypes () {
  19. return contentArray.slice();
  20. }
  21. }