1 module armos.app.windowconfig; 2 3 import armos.math; 4 import armos.utils.semver; 5 import std.conv; 6 7 /++ 8 +/ 9 class WindowConfig { 10 public{ 11 /// 12 int height()const{return _height;} 13 14 /// 15 typeof(this) height(in int h){_height = h;return this;} 16 17 /// 18 int width()const{return _width;} 19 20 /// 21 typeof(this) width(in int h){_width = h;return this;} 22 23 /// 24 Vector2i position()const{return _position;} 25 26 /// 27 typeof(this) position(in Vector2i p){_position = p;return this;} 28 29 /// 30 Vector2i size()const{return Vector2i(_height, _width);} 31 32 /// 33 typeof(this) size(in Vector2i p){ 34 _width = p.y; 35 _height = p.x; 36 return this; 37 } 38 39 /// 40 int glVersionMajor()const{return _glVersion.major;} 41 42 /// 43 int glVersionMinor()const{return _glVersion.minor;} 44 45 /// 46 SemVer glVersion()const{ 47 return _glVersion; 48 } 49 50 /// 51 typeof(this) glVersion(in string v){ 52 import std.algorithm; 53 import std.array; 54 const digits = v.split(".").map!(n => n.to!int).array; 55 glVersion = SemVer(digits[0], digits[1], digits[2]); 56 return this; 57 } 58 59 /// 60 typeof(this) glVersion(in SemVer v){ 61 _glVersion = v; 62 return this; 63 } 64 65 /// 66 typeof(this) glVersionMajor(in int versionMajor){_glVersion.major = versionMajor;return this;} 67 68 /// 69 typeof(this) glVersionMinor(in int versionMinor){_glVersion.minor = versionMinor;return this;} 70 }//public 71 72 private{ 73 int _height = 480; 74 int _width = 640; 75 Vector2i _position; 76 SemVer _glVersion = SemVer(3, 2, 0); 77 }//private 78 }//interface WindowConfig 79 // WindowConfig should be able to handle float version. 80 81 unittest{ 82 auto config = new WindowConfig; 83 config.glVersion = "3.3.0"; 84 assert(config.glVersionMajor == 3); 85 assert(config.glVersionMinor == 3); 86 assert(config.glVersion.to!string == "3.3.0"); 87 }