1 module creator.core.dpi; 2 import creator.core.settings; 3 import i18n; 4 5 version (NoUIScaling) { } 6 else version(UseUIScaling) { 7 private { 8 float uiScale; 9 } 10 11 void incInitDPIScaling() { 12 13 // Load UI scale 14 uiScale = incSettingsGet!float("UIScale", 1.0); 15 } 16 } 17 18 /** 19 Sets the UI scale for fonts 20 */ 21 void incSetUIScale(float scale) { 22 version (UseUIScaling) { 23 incSettingsSet("UIScale", scale); 24 uiScale = scale; 25 } 26 } 27 28 /** 29 Get the UI scale in terms of font size 30 */ 31 float incGetUIScaleFont() { 32 // allow user to force the feature to be off 33 version (NoUIScaling) return 0.5; 34 else version (UseUIScaling) return incGetUIScale()/2; 35 else return 0.5; 36 } 37 38 /** 39 Returns the UI Scale 40 */ 41 float incGetUIScale() { 42 version (NoUIScaling) return 1; 43 else version (UseUIScaling) { 44 version (OSX) return 1; 45 else return uiScale; 46 } 47 else return 1; 48 } 49 50 /** 51 Gets the UI scale in text form 52 */ 53 string incGetUIScaleText() { 54 version (NoUIScaling) return _("100% (Locked)"); // UI scaling being locked due to being compiled in multi-window mode. 55 else version (UseUIScaling) { 56 import std.format : format; 57 return "%s%%".format(cast(int)(uiScale*100)); 58 } else return _("100% (Locked)"); 59 }