Skip to content

Commit

Permalink
Bold font option added.
Browse files Browse the repository at this point in the history
  • Loading branch information
formicant committed Dec 16, 2019
1 parent b143d35 commit b0f0287
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 12 deletions.
11 changes: 8 additions & 3 deletions CriticalTemperatureGauge/GaugeWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class GaugeWindow : Window
static readonly Color TextColor = Color.white;
static readonly Color[] TextShadowColors =
{
new Color(0, 0, 0, 1.0F),
new Color(0, 0, 0, 0.8F),
new Color(0, 0, 0, 0.3F),
new Color(0, 0, 0, 0.2F),
new Color(0, 0, 0, 0.5F),
};

static readonly Rect GaugeFrameRectangle = new Rect(0, 0, 240, 24);
Expand Down Expand Up @@ -87,6 +87,7 @@ protected override void WindowGUI(int windowId)
new Rect(0, 0, gaugeScaleValue * GaugeScaleNominalLength / GaugeScaleRectangle.width, 1));

int fontSize = (int)Math.Round(scale * FontSize);
FontStyle fontStyle = Static.Settings.UseBoldFont ? FontStyle.Bold : FontStyle.Normal;
var innerLabelRectangle = InnerLabelRectangle.Scale(scale);

// Drawing temperature and temperature limit values
Expand All @@ -95,6 +96,7 @@ protected override void WindowGUI(int windowId)
innerLabelRectangle,
TextAnchor.MiddleCenter,
fontSize,
fontStyle,
Format.Temperature(
Static.CriticalPartState.CriticalTemperature,
Static.Settings.ShowTemperatureLimit.Then(Static.CriticalPartState.CriticalTemperatureLimit)));
Expand All @@ -105,6 +107,7 @@ protected override void WindowGUI(int windowId)
innerLabelRectangle,
TextAnchor.MiddleLeft,
fontSize,
fontStyle,
Format.TemperatureRate(Static.CriticalPartState.CriticalTemperatureRate));

// Drawing critical part name
Expand All @@ -113,6 +116,7 @@ protected override void WindowGUI(int windowId)
OuterLabelRectangle.Scale(scale),
TextAnchor.MiddleLeft,
fontSize,
FontStyle.Normal,
Format.PartName(Static.CriticalPartState.Title, Static.CriticalPartState.IsSkinCritical));

GUILayout.EndVertical();
Expand All @@ -127,12 +131,13 @@ protected override void WindowGUI(int windowId)
/// <param name="alignment">Text alignment.</param>
/// <param name="fontSize">Font size.</param>
/// <param name="text">Text to draw.</param>
void DrawContrastLabel(Rect rectangle, TextAnchor alignment, int fontSize, string text)
void DrawContrastLabel(Rect rectangle, TextAnchor alignment, int fontSize, FontStyle fontStyle, string text)
{
var style = new GUIStyle(GUI.skin.label)
{
alignment = alignment,
fontSize = fontSize,
fontStyle = fontStyle,
wordWrap = false,
};

Expand Down
2 changes: 1 addition & 1 deletion CriticalTemperatureGauge/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.8.1.0")]
[assembly: AssemblyVersion("1.8.1.1")]

// Use KSPAssembly to allow other DLLs to make this DLL a dependency in a
// non-hacky way in KSP. Format is (AssemblyProduct, major, minor), and it
Expand Down
11 changes: 8 additions & 3 deletions CriticalTemperatureGauge/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Settings<TAddon>
public bool ShowTemperature { get; set; }
public bool ShowTemperatureLimit { get; set; }
public bool ShowTemperatureRate { get; set; }
public bool UseBoldFont { get; set; }
public bool ShowCriticalPart { get; set; }
public bool HighlightCriticalPart { get; set; }

Expand All @@ -41,15 +42,17 @@ public class Settings<TAddon>
public double GaugeShowingThreshold
{
get => _gaugeShowingThreshold;
set => _gaugeShowingThreshold = value > 0 && value < 1 ? value : DefaultGaugeShowingThreshold;
set => _gaugeShowingThreshold =
value > 0 && value < 1 ? value : DefaultGaugeShowingThreshold;
}

const double DefaultGaugeHidingThreshold = 0.4;
const double DefaultGaugeHidingThreshold = 0.45;
double _gaugeHidingThreshold;
public double GaugeHidingThreshold
{
get => _gaugeHidingThreshold;
set => _gaugeHidingThreshold = Math.Min(GaugeShowingThreshold, value > 0 && value < 1 ? value : DefaultGaugeHidingThreshold);
set => _gaugeHidingThreshold =
Math.Min(GaugeShowingThreshold, value > 0 && value < 1 ? value : DefaultGaugeHidingThreshold);
}

// Exclusion list settings
Expand Down Expand Up @@ -87,6 +90,7 @@ public void Save()
settings.SetValue(nameof(ShowTemperature), ShowTemperature);
settings.SetValue(nameof(ShowTemperatureLimit), ShowTemperatureLimit);
settings.SetValue(nameof(ShowTemperatureRate), ShowTemperatureRate);
settings.SetValue(nameof(UseBoldFont), UseBoldFont);
settings.SetValue(nameof(ShowCriticalPart), ShowCriticalPart);
settings.SetValue(nameof(HighlightCriticalPart), HighlightCriticalPart);
settings.SetValue(nameof(PartMenuTemperature), PartMenuTemperature);
Expand Down Expand Up @@ -118,6 +122,7 @@ public static Settings<TAddon> Load()
ShowTemperature = settings.GetValue(nameof(ShowTemperature), true),
ShowTemperatureLimit = settings.GetValue(nameof(ShowTemperatureLimit), true),
ShowTemperatureRate = settings.GetValue(nameof(ShowTemperatureRate), true),
UseBoldFont = settings.GetValue(nameof(UseBoldFont), true),
ShowCriticalPart = settings.GetValue(nameof(ShowCriticalPart), true),
HighlightCriticalPart = settings.GetValue(nameof(HighlightCriticalPart), true),
PartMenuTemperature = settings.GetValue(nameof(PartMenuTemperature), true),
Expand Down
4 changes: 4 additions & 0 deletions CriticalTemperatureGauge/SettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ protected override void WindowGUI(int windowId)
Static.Settings.ShowTemperatureRate,
Localizer.Format("#LOC_CriticalTemperatureGauge_ShowTemperatureRate"),
ToggleStyle);
Static.Settings.UseBoldFont = GUILayout.Toggle(
Static.Settings.UseBoldFont,
Localizer.Format("#LOC_CriticalTemperatureGauge_UseBoldFont"),
ToggleStyle);
Static.Settings.ShowCriticalPart = GUILayout.Toggle(
Static.Settings.ShowCriticalPart,
Localizer.Format("#LOC_CriticalTemperatureGauge_ShowCriticalPartName"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"MAJOR": 1,
"MINOR": 8,
"PATCH": 1,
"BUILD": 0
"BUILD": 1
},
"KSP_VERSION":
{
Expand Down
1 change: 1 addition & 0 deletions GameData/CriticalTemperatureGauge/Localization/en-us.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#LOC_CriticalTemperatureGauge_ShowTemperature = Show temperature
#LOC_CriticalTemperatureGauge_ShowTemperatureLimit = Show temperature limit
#LOC_CriticalTemperatureGauge_ShowTemperatureRate = Show temperature rate
#LOC_CriticalTemperatureGauge_UseBoldFont = Use bold font
#LOC_CriticalTemperatureGauge_ShowCriticalPartName = Show critical part name
#LOC_CriticalTemperatureGauge_HighlightCriticalPart = Highlight critical part
#LOC_CriticalTemperatureGauge_IgnorePartModules = Ignore parts with following\n modules (comma-separated):
Expand Down
1 change: 1 addition & 0 deletions GameData/CriticalTemperatureGauge/Localization/es-es.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#LOC_CriticalTemperatureGauge_ShowTemperature = Mostrar temperatura
#LOC_CriticalTemperatureGauge_ShowTemperatureLimit = Mostrar límite de temperatura
#LOC_CriticalTemperatureGauge_ShowTemperatureRate = Mostrar tasa de temperatura
#LOC_CriticalTemperatureGauge_UseBoldFont = Use bold font
#LOC_CriticalTemperatureGauge_ShowCriticalPartName = Mostrar nombre de la parte crítica
#LOC_CriticalTemperatureGauge_HighlightCriticalPart = Resaltar la parte crítica
#LOC_CriticalTemperatureGauge_IgnorePartModules = Ignorar partes con los siguientes\n módulos (separado por comas):
Expand Down
1 change: 1 addition & 0 deletions GameData/CriticalTemperatureGauge/Localization/es-mx.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#LOC_CriticalTemperatureGauge_ShowTemperature = Mostrar temperatura
#LOC_CriticalTemperatureGauge_ShowTemperatureLimit = Mostrar límite de temperatura
#LOC_CriticalTemperatureGauge_ShowTemperatureRate = Mostrar tasa de temperatura
#LOC_CriticalTemperatureGauge_UseBoldFont = Use bold font
#LOC_CriticalTemperatureGauge_ShowCriticalPartName = Mostrar nombre de la parte crítica
#LOC_CriticalTemperatureGauge_HighlightCriticalPart = Resaltar la parte crítica
#LOC_CriticalTemperatureGauge_IgnorePartModules = Ignorar partes con los siguientes\n módulos (separado por comas):
Expand Down
1 change: 1 addition & 0 deletions GameData/CriticalTemperatureGauge/Localization/ru.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#LOC_CriticalTemperatureGauge_ShowTemperature = Показывать температуру на шкале
#LOC_CriticalTemperatureGauge_ShowTemperatureLimit = Показывать температурный предел
#LOC_CriticalTemperatureGauge_ShowTemperatureRate = Показывать скорость изменения температуры
#LOC_CriticalTemperatureGauge_UseBoldFont = Жирный шрифт
#LOC_CriticalTemperatureGauge_ShowCriticalPartName = Показывать название критической детали
#LOC_CriticalTemperatureGauge_HighlightCriticalPart = Подсвечивать критическую деталь
#LOC_CriticalTemperatureGauge_IgnorePartModules = Игнорировать детали со следующими\n модулями (через запятую):
Expand Down
1 change: 1 addition & 0 deletions GameData/CriticalTemperatureGauge/Localization/zh-cn.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#LOC_CriticalTemperatureGauge_ShowTemperature = 显示温度的数值
#LOC_CriticalTemperatureGauge_ShowTemperatureLimit = 显示温度的上限
#LOC_CriticalTemperatureGauge_ShowTemperatureRate = 显示升降温速率
#LOC_CriticalTemperatureGauge_UseBoldFont = Use bold font
#LOC_CriticalTemperatureGauge_ShowCriticalPartName = 显示危险组件名
#LOC_CriticalTemperatureGauge_HighlightCriticalPart = 高亮最危险组件
#LOC_CriticalTemperatureGauge_IgnorePartModules = 忽略带有下列module\n的组件(以逗号分隔):
Expand Down
Binary file not shown.
9 changes: 5 additions & 4 deletions MakeRelease.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
$name = "CriticalTemperatureGauge"
$srcDir = "GameData\$name"
$srcDir = "GameData"
$dstDir = "Releases"

$verFile = Get-Content "$srcDir\$name.version" -Raw | ConvertFrom-Json
$ver = $verFile.VERSION
$verFile = "$srcDir\$name\$name.version"
$verJson = Get-Content $verFile -Raw | ConvertFrom-Json
$ver = $verJson.VERSION
$verString = "$($ver.MAJOR).$($ver.MINOR).$($ver.PATCH).$($ver.BUILD)"

$zipFile = "$dstDir\$name-$verString.zip"
Expand All @@ -13,4 +14,4 @@ If (Test-Path $zipFile) {
Read-Host "Press Enter to overwrite or Ctrl+Break to quit"
}

Compress-Archive $srcDir $zipFile -Force -CompressionLevel Optimal
Compress-Archive $srcDir $zipFile -Force

0 comments on commit b0f0287

Please sign in to comment.