1 /** 2 * Copyright: Copyright (C) 2018 Gabriel Gheorghe, All Rights Reserved 3 * Authors: $(Gabriel Gheorghe) 4 * License: $(LINK2 https://www.gnu.org/licenses/gpl-3.0.txt, GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007) 5 * Source: $(LINK2 https://github.com/GabyForceQ/LibertyEngine/blob/master/source/liberty/text/system.d) 6 * Documentation: 7 * Coverage: 8 **/ 9 module liberty.text.system; 10 11 import liberty.text.impl; 12 import liberty.text.renderer; 13 import liberty.text.shader; 14 import liberty.scene.impl; 15 16 /** 17 * System class holding basic text functionality. 18 * It contains references to the $(D TextRenderer), $(D TextShader) and $(D Scene). 19 * It also contains a map with all texts in the current scene. 20 **/ 21 final class TextSystem { 22 private { 23 TextRenderer renderer; 24 //TextShader shader; 25 Text[string] map; 26 Scene scene; 27 } 28 29 /** 30 * Create and initialize text system using a $(D Scene) reference. 31 **/ 32 this(Scene scene) { 33 this.scene = scene; 34 //shader = new TextShader(); 35 renderer = new TextRenderer(this, scene); 36 } 37 38 /** 39 * Register a text entity to the text system. 40 * Returns reference to this so it can be used in a stream. 41 **/ 42 typeof(this) registerElement(Text entity) { 43 //map[entity.getId] = entity; 44 return this; 45 } 46 47 /** 48 * Remove the given text entity from the text map. 49 * Returns reference to this so it can be used in a stream. 50 **/ 51 typeof(this) removeElement(Text entity) { 52 //map.remove(entity.getId); 53 return this; 54 } 55 56 /** 57 * Remove the text entity that has the given id from the text map. 58 * Returns reference to this so it can be used in a stream. 59 **/ 60 typeof(this) removeElementById(string id) { 61 map.remove(id); 62 return this; 63 } 64 65 /** 66 * Returns all elements in the text map. 67 **/ 68 Text[string] getMap() { 69 return map; 70 } 71 72 /** 73 * Returns the text element in the map that has the given id. 74 **/ 75 Text getElementById(string id) { 76 return map[id]; 77 } 78 79 /** 80 * Returns a text renderer reference. 81 **/ 82 TextRenderer getRenderer() { 83 return renderer; 84 } 85 86 /** 87 * Returns a text shader reference. 88 **/ 89 //TextShader getShader() { 90 // return shader; 91 //} 92 }