Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization Support && Chinese language #100

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
19 changes: 12 additions & 7 deletions AlternateResourcePanel/ARP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using KSPPluginFramework;

using ARPToolbarWrapper;
using KSP.Localization;

namespace KSPAlternateResourcePanel
{
Expand All @@ -19,7 +20,11 @@ private KSPAlternateResourcePanel()
{
APIInstance = this;
}

// Localization strings
private static string ARMEDWAITSTAGE = Localizer.Format("#ARP_LOC_005");
private static string RUNNING = Localizer.Format("#ARP_LOC_006");
private static string NOTARMED = Localizer.Format("#ARP_LOC_008");
private static string RUNCOMPLETE = Localizer.Format("#ARP_LOC_009");
//windows
internal ARPWindow windowMain;
internal ARPWindowSettings windowSettings;
Expand Down Expand Up @@ -452,7 +457,7 @@ internal override void OnGUIEvery()
rectButton.x = settings.vectButtonPos.x;
rectButton.y = settings.vectButtonPos.y;

if (GUI.Button(rectButton, "Alternate", SkinsLibrary.CurrentSkin.GetStyle("ButtonMain")))
if (GUI.Button(rectButton, "Alternate", SkinsLibrary.CurrentSkin.GetStyle("ButtonMain"))) //
{
settings.ToggleOn = !settings.ToggleOn;
settings.Save();
Expand Down Expand Up @@ -838,7 +843,7 @@ internal override void RepeatingWorker()
if (!AutoStagingRunning)
{
AutoStagingStatusColor = Color.white;
AutoStagingStatus = "Armed... waiting for stage";
AutoStagingStatus = ARMEDWAITSTAGE; //"Armed... waiting for stage"
//when to set it to running
if (lstLastStageEngineModules.Any(x => x.staged) || lstLastStageEngineFXModules.Any(x => x.staged))
AutoStagingRunning = true;
Expand All @@ -847,7 +852,7 @@ internal override void RepeatingWorker()
{
//we are running, so now what
AutoStagingStatusColor = new Color32(183, 254, 0, 255);
AutoStagingStatus = "Running";
AutoStagingStatus = RUNNING; // "Running"

//are all the engines that are active flamed out in the last stage
if (AutoStagingTriggeredAt == 0 && lstPartsLastStageEngines.Count > 0 &&
Expand All @@ -869,7 +874,7 @@ internal override void RepeatingWorker()
AutoStagingTriggeredAt = 0;
} else {
AutoStagingStatusColor = new Color32(232, 232, 0, 255);
AutoStagingStatus = String.Format("Delay:{0:0.0}s", ((Double)settings.AutoStagingDelayInTenths / 10) - (Planetarium.GetUniversalTime() -AutoStagingTriggeredAt ));
AutoStagingStatus = Localizer.Format("#ARP_LOC_007", ((Double)settings.AutoStagingDelayInTenths / 10) - (Planetarium.GetUniversalTime() -AutoStagingTriggeredAt )); //String.Format("Delay:{0:0.0}s", ((Double)settings.AutoStagingDelayInTenths / 10) - (Planetarium.GetUniversalTime() -AutoStagingTriggeredAt ))
}
}
}
Expand All @@ -886,15 +891,15 @@ internal override void RepeatingWorker()
if (AutoStagingTriggeredAt == 0)
{
AutoStagingStatusColor = new Color32(140, 140, 140,255);
AutoStagingStatus = "Not Armed";
AutoStagingStatus = NOTARMED; // "Not Armed"
}
else
{
if (Planetarium.GetUniversalTime() - AutoStagingTriggeredAt > 3)
AutoStagingTriggeredAt = 0;
else
{
AutoStagingStatus = "Run Complete";
AutoStagingStatus = RUNCOMPLETE; // "Run Complete"
AutoStagingStatusColor = new Color32(183, 254, 0, 255);
}
}
Expand Down
14 changes: 10 additions & 4 deletions AlternateResourcePanel/ARPPartWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
using KSP;
using UnityEngine;
using KSPPluginFramework;
using KSP.Localization;

namespace KSPAlternateResourcePanel
{
class ARPPartWindow : MonoBehaviourWindow
{
// Localization strings
private static string TRANSFER = Localizer.Format("#ARP_LOC_001");
private static string STOP = Localizer.Format("#ARP_LOC_002");
private static string IN = Localizer.Format("#ARP_LOC_003");
private static string OUT = Localizer.Format("#ARP_LOC_004");
//internal ARPPartWindow(Part Part)
//{
// this.Part = Part;
Expand Down Expand Up @@ -261,7 +267,7 @@ internal override void DrawWindow(int id)
styleTransfer.padding.top = -8;
styleTransfer.padding.bottom = 0;
//GUILayout.Label("Transfer: " + tmpTransfer.transferState, styleTransfer);
GUILayout.Label("Transfer: " , styleTransfer);
GUILayout.Label($"{TRANSFER}: " , styleTransfer); // Transfer

GUILayout.Space(21);

Expand All @@ -274,8 +280,8 @@ internal override void DrawWindow(int id)
styleTransferButton.margin = new RectOffset(0, 0, 0, 0);


String strOut = (tmpTransfer.transferState == TransferStateEnum.Out && tmpTransfer.Active) ? "Stop" : "Out";
String strIn = (tmpTransfer.transferState == TransferStateEnum.In && tmpTransfer.Active) ? "Stop" : "In";
String strOut = (tmpTransfer.transferState == TransferStateEnum.Out && tmpTransfer.Active) ? STOP : OUT; //"Stop""Out"
String strIn = (tmpTransfer.transferState == TransferStateEnum.In && tmpTransfer.Active) ? STOP : IN; // "Stop""In"
Boolean blnTempOut = GUILayout.Toggle(tmpTransfer.transferState == TransferStateEnum.Out, strOut, styleTransferButton);
Boolean blnTempIn = GUILayout.Toggle(tmpTransfer.transferState == TransferStateEnum.In, strIn, styleTransferButton);

Expand Down Expand Up @@ -355,7 +361,7 @@ internal override void OnGUIEvery()
if (Visible && !UIHidden)
{
Boolean oldMouseOver = MouseOver;
MouseOver = (Event.current.type== EventType.repaint) && WindowRect.Contains(Event.current.mousePosition);
MouseOver = (Event.current.type== EventType.Repaint) && WindowRect.Contains(Event.current.mousePosition);

if (oldMouseOver != MouseOver)
{
Expand Down
48 changes: 34 additions & 14 deletions AlternateResourcePanel/ARPWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using KSP.UI.Screens;
using UnityEngine;
using KSPPluginFramework;
using KSP.Localization;

namespace KSPAlternateResourcePanel
{
Expand Down Expand Up @@ -36,6 +37,24 @@ class ARPWindow: MonoBehaviourWindowPlus
private PartResourceVisibleList SelectedResources;
internal Int32 intLineHeight = 20;

// Localization strings
private static string NODISPLAY = Localizer.Format("#ARP_LOC_010");
private static string STAGE = Localizer.Format("#ARP_LOC_011");
private static string ACTSTAGE = Localizer.Format("#ARP_LOC_012");
private static string NOCONTROL = Localizer.Format("#ARP_LOC_013");
private static string AUTO = Localizer.Format("#ARP_LOC_014");
private static string TO = Localizer.Format("#ARP_LOC_015");
private static string ARM = Localizer.Format("#ARP_LOC_016");
private static string DISARM = Localizer.Format("#ARP_LOC_017");
private static string BACKTOVESSEL = Localizer.Format("#ARP_LOC_018");
private static string SHOWBASE = Localizer.Format("#ARP_LOC_019");
private static string HIDETIME = Localizer.Format("#ARP_LOC_020");
private static string SHOWTIME = Localizer.Format("#ARP_LOC_021");
private static string TOGGLERES = Localizer.Format("#ARP_LOC_022");
private static string SHOWSETTING = Localizer.Format("#ARP_LOC_023");
private static string HIDESETTING = Localizer.Format("#ARP_LOC_024");
private static string UPDATEVERSION = Localizer.Format("#ARP_LOC_025");

internal override void OnAwake()
{
TooltipMouseOffset = new Vector2d(-10, 10);
Expand Down Expand Up @@ -78,7 +97,7 @@ internal override void DrawWindow(Int32 id)

if (mbARP.lstResourcesToDisplay.Count == 0)
{
GUILayout.Label("No current resources configured to display");
GUILayout.Label(NODISPLAY); // "No current resources configured to display"
}
else
{
Expand Down Expand Up @@ -189,7 +208,7 @@ internal override void DrawWindow(Int32 id)
if (!settings.AutoStagingEnabled)
{
//GUILayout.Label("Stage:", Styles.styleStageTextHead, GUILayout.Width(50));
if (GUILayout.Button("Stage:", Styles.styleStageTextHead, GUILayout.Width(50)))
if (GUILayout.Button($"{STAGE}:", Styles.styleStageTextHead, GUILayout.Width(50))) // Stage
settings.AutoStagingEnabled = !settings.AutoStagingEnabled;
GUIStyle styleStageNum = new GUIStyle(Styles.styleStageTextHead);
GUIContent contStageNum = new GUIContent(StageManager.CurrentStage.ToString());
Expand All @@ -206,13 +225,13 @@ internal override void DrawWindow(Int32 id)
if (settings.StagingEnabledInMapView || !MapView.MapIsEnabled)
{
if (mbARP.blnVesselIsControllable) {
if (GUILayout.Button("Activate Stage", "ButtonGeneral", GUILayout.Width(100)))
if (GUILayout.Button(ACTSTAGE, "ButtonGeneral", GUILayout.Width(100))) // "Activate Stage"
StageManager.ActivateNextStage();
GUILayout.Space(21 + IconAlarmOffset);
//GUILayout.Space(51 + IconAlarmOffset);
}
else {
GUILayout.Label("No Vessel Control", GUILayout.Width(120));
GUILayout.Label(NOCONTROL, GUILayout.Width(120)); // "No Vessel Control"
GUILayout.Space(1 + IconAlarmOffset);
//GUILayout.Space(31 + IconAlarmOffset);
}
Expand All @@ -222,20 +241,20 @@ internal override void DrawWindow(Int32 id)
}
else
{
if (GUILayout.Button("Auto:", Styles.styleStageTextHead, GUILayout.Width(50)))
if (GUILayout.Button($"{AUTO}:", Styles.styleStageTextHead, GUILayout.Width(50))) // Auto
settings.AutoStagingEnabled = !settings.AutoStagingEnabled;
GUILayout.Label(StageManager.CurrentStage.ToString(),Styles.styleStageTextHead, GUILayout.Width(20));
GUILayout.Label("to", Styles.styleStageTextHead, GUILayout.Width(30));
GUILayout.Label(TO, Styles.styleStageTextHead, GUILayout.Width(30)); // "to"
GUILayout.Label(mbARP.AutoStagingTerminateAt.ToString(), Styles.styleStageTextHead, GUILayout.Width(30));
DrawHorizontalSlider(ref mbARP.AutoStagingTerminateAt, 0, mbARP.AutoStagingMaxStage);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();

String strButtonArm = "Arm";
String strButtonArm = ARM; // "Arm"
GUIStyle styleArm = new GUIStyle(SkinsLibrary.CurrentSkin.button) { fontStyle = FontStyle.Bold };
if (mbARP.AutoStagingArmed)
{
strButtonArm = "Disarm";
strButtonArm = DISARM; // "Disarm"
styleArm.normal.textColor = styleArm.hover.textColor = new Color32(207,31,31,255) ;
}
else
Expand All @@ -262,7 +281,7 @@ internal override void DrawWindow(Int32 id)

// ShowBase Button
Boolean blnShowBase = settings.ShowBase;
if (DrawToggle(ref blnShowBase, new GUIContent(Resources.btnViewBaseActive, blnShowBase ? "Back to Vessel Display" : "Show Base Display\r\nAll resource within 2km of active vessel"), SkinsLibrary.GetStyle(SkinsLibrary.CurrentSkin, "ButtonToggle").PaddingChange(1), GUILayout.Width(23)))
if (DrawToggle(ref blnShowBase, new GUIContent(Resources.btnViewBaseActive, blnShowBase ? BACKTOVESSEL : SHOWBASE), SkinsLibrary.GetStyle(SkinsLibrary.CurrentSkin, "ButtonToggle").PaddingChange(1), GUILayout.Width(23))) // "Back to Vessel Display"|"Show Base Display\r\nAll resource within 2km of active vessel"
{
settings.ShowBase = blnShowBase;
}
Expand All @@ -273,7 +292,8 @@ internal override void DrawWindow(Int32 id)

// ShowTime Button
Boolean blnShowTimeRem = settings.ShowTimeRem;
if (DrawToggle(ref blnShowTimeRem, new GUIContent(Resources.btnViewTimes, blnShowTimeRem ? "Hide time Remianing": "Show Time Remaining"), SkinsLibrary.GetStyle(SkinsLibrary.CurrentSkin,"ButtonToggle").PaddingChange(1), GUILayout.Width(23))) {
if (DrawToggle(ref blnShowTimeRem, new GUIContent(Resources.btnViewTimes, blnShowTimeRem ? HIDETIME : SHOWTIME), SkinsLibrary.GetStyle(SkinsLibrary.CurrentSkin,"ButtonToggle").PaddingChange(1), GUILayout.Width(23))) // "Hide time Remianing" "Show Time Remaining"
{
settings.ShowTimeRem = blnShowTimeRem;
}
//if (GUILayout.Button(new GUIContent(Resources.btnViewTimes, "Toggle Time Remaining"), SkinsLibrary.CurrentSkin.button.PaddingChange(1), GUILayout.Width(23)))
Expand All @@ -283,7 +303,7 @@ internal override void DrawWindow(Int32 id)

// ShowAll Button
Boolean blnToggleHidden = KSPAlternateResourcePanel.ShowAll;
if (DrawToggle(ref blnToggleHidden, new GUIContent(Resources.btnViewAll, "Toggle Hidden Resources"), SkinsLibrary.GetStyle(SkinsLibrary.CurrentSkin, "ButtonToggle").PaddingChange(1), GUILayout.Width(23)))
if (DrawToggle(ref blnToggleHidden, new GUIContent(Resources.btnViewAll, TOGGLERES), SkinsLibrary.GetStyle(SkinsLibrary.CurrentSkin, "ButtonToggle").PaddingChange(1), GUILayout.Width(23))) // "Toggle Hidden Resources"
{
KSPAlternateResourcePanel.ShowAll = blnToggleHidden;
}
Expand All @@ -293,15 +313,15 @@ internal override void DrawWindow(Int32 id)
//}

//Settings Toggle button
GUIContent btnMinMax = new GUIContent(Resources.btnChevronDown, "Show Settings...");
GUIContent btnMinMax = new GUIContent(Resources.btnChevronDown, SHOWSETTING); // "Show Settings..."
if (windowSettings.Visible) {
btnMinMax.image = Resources.btnChevronUp; btnMinMax.tooltip = "Hide Settings";
btnMinMax.image = Resources.btnChevronUp; btnMinMax.tooltip = HIDESETTING; // "Hide Settings"
}
else if (settings.VersionAttentionFlag && DateTime.Now.Millisecond < 500) {
btnMinMax.image = Resources.btnSettingsAttention;
}

if (settings.VersionAttentionFlag) btnMinMax.tooltip = "Updated Version Available - " + btnMinMax.tooltip;
if (settings.VersionAttentionFlag) btnMinMax.tooltip = $"{UPDATEVERSION} - " + btnMinMax.tooltip; // Updated Version Available

if (GUILayout.Button(btnMinMax,"ButtonSettings",GUILayout.Width(23)))
{
Expand Down
Loading