Skip to content

Commit

Permalink
Resources cleanup. Initial settings window
Browse files Browse the repository at this point in the history
  • Loading branch information
jwvanderbeck committed Jan 4, 2015
1 parent 081799a commit 3fc2637
Show file tree
Hide file tree
Showing 12 changed files with 658 additions and 183 deletions.
Binary file added TestFlight/Resources/ChevronDown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TestFlight/Resources/ChevronUp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
451 changes: 451 additions & 0 deletions TestFlightCore/TestFlightCore/Framework/PartModuleExtended.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,15 @@ internal static Boolean DrawHorizontalSlider(ref Single dblVar, Single leftValue
Single intOld = dblVar;

dblVar = GUILayout.HorizontalSlider(dblVar, leftValue, rightValue, options);
return DrawResultChanged(intOld, dblVar, "Integer HorizSlider");
return DrawResultChanged(intOld, dblVar, "Single HorizSlider");
}

internal static Boolean DrawHorizontalSlider(ref double dblVar, double leftValue, double rightValue, params GUILayoutOption[] options)
{
double dblOld = dblVar;

dblVar = (float)GUILayout.HorizontalSlider((float)dblVar, (float)leftValue, (float)rightValue, options);
return DrawResultChanged(dblOld, dblVar, "Double HorizSlider");
}

/// <summary>
Expand Down
83 changes: 2 additions & 81 deletions TestFlightCore/TestFlightCore/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,113 +33,34 @@ internal class Resources


internal static Texture2D texPanel = new Texture2D(16, 16, TextureFormat.ARGB32, false);
internal static Texture2D texBarBlue = new Texture2D(13, 13, TextureFormat.ARGB32, false);
internal static Texture2D texBarBlue_Back = new Texture2D(13, 13, TextureFormat.ARGB32, false);
internal static Texture2D texBarGreen = new Texture2D(13, 13, TextureFormat.ARGB32, false);
internal static Texture2D texBarGreen_Back = new Texture2D(13, 13, TextureFormat.ARGB32, false);

internal static Texture2D texBarHighlight = new Texture2D(9, 9, TextureFormat.ARGB32, false);
internal static Texture2D texBarHighlightGreen = new Texture2D(9, 9, TextureFormat.ARGB32, false);
internal static Texture2D texBarHighlightRed = new Texture2D(9, 9, TextureFormat.ARGB32, false);

internal static Texture2D btnChevronUp = new Texture2D(17, 16, TextureFormat.ARGB32, false);
internal static Texture2D btnChevronDown = new Texture2D(17, 16, TextureFormat.ARGB32, false);

internal static Texture2D btnChevronLeft = new Texture2D(38, 38, TextureFormat.ARGB32, false);
internal static Texture2D btnChevronRight = new Texture2D(38, 38, TextureFormat.ARGB32, false);

internal static Texture2D btnViewAll = new Texture2D(16, 16, TextureFormat.ARGB32, false);
internal static Texture2D btnViewTimes = new Texture2D(16, 16, TextureFormat.ARGB32, false);

internal static Texture2D btnSettingsAttention = new Texture2D(17, 16, TextureFormat.ARGB32, false);

internal static Texture2D texPartWindowHead = new Texture2D(16, 16, TextureFormat.ARGB32, false);

//internal static Texture2D texTooltipBackground; // = new Texture2D(9, 9);//, TextureFormat.ARGB32, false);

internal static Texture2D texRateUp = new Texture2D(10, 10, TextureFormat.ARGB32, false);
internal static Texture2D texRateDown = new Texture2D(10, 10, TextureFormat.ARGB32, false);

internal static Texture2D btnAlarm = new Texture2D(16, 16, TextureFormat.ARGB32, false);
internal static Texture2D btnAlarmEnabled = new Texture2D(16, 16, TextureFormat.ARGB32, false);
internal static Texture2D btnAlarmWarn = new Texture2D(16, 16, TextureFormat.ARGB32, false);
internal static Texture2D btnAlarmAlert = new Texture2D(16, 16, TextureFormat.ARGB32, false);

//internal static Texture2D btnLock;
//internal static Texture2D btnUnlock;

internal static Texture2D btnDropDown = new Texture2D(10, 10, TextureFormat.ARGB32, false);
internal static Texture2D btnPlay = new Texture2D(10, 10, TextureFormat.ARGB32, false);
internal static Texture2D btnStop = new Texture2D(10, 10, TextureFormat.ARGB32, false);

internal static Texture2D texResourceMove = new Texture2D(378, 9, TextureFormat.ARGB32, false);

internal static Texture2D texBox = new Texture2D(9, 9, TextureFormat.ARGB32, false);
internal static Texture2D texBoxUnity = new Texture2D(9, 9, TextureFormat.ARGB32, false);

internal static Texture2D texSeparatorV = new Texture2D(6, 2, TextureFormat.ARGB32, false);
internal static Texture2D texSeparatorH = new Texture2D(2, 20, TextureFormat.ARGB32, false);

internal static Texture2D texAppLaunchIcon = new Texture2D(38, 38, TextureFormat.ARGB32, false);

internal static void LoadTextures()
{
MonoBehaviourExtended.LogFormatted("Loading Textures");

LoadImageFromFile(ref btnChevronLeft, "ChevronLeft", PathPluginResources);
LoadImageFromFile(ref btnChevronRight, "ChevronRight", PathPluginResources);
LoadImageFromFile(ref btnChevronUp, "ChevronUp.png", PathPluginResources);
LoadImageFromFile(ref btnChevronDown, "ChevronDown.png", PathPluginResources);

LoadImageFromFile(ref texPanel, "img_PanelBack.png");

LoadImageFromFile(ref texBarBlue, "img_BarBlue.png");
LoadImageFromFile(ref texBarBlue_Back, "img_BarBlue_Back.png");
LoadImageFromFile(ref texBarGreen, "img_BarGreen.png");
LoadImageFromFile(ref texBarGreen_Back, "img_BarGreen_Back.png");

LoadImageFromFile(ref texBarHighlight, "img_BarHighlight.png");
LoadImageFromFile(ref texBarHighlightGreen, "img_BarHighlightGreen.png");
LoadImageFromFile(ref texBarHighlightRed, "img_BarHighlightRed.png");

LoadImageFromFile(ref btnChevronUp, "img_buttonChevronUp.png");
LoadImageFromFile(ref btnChevronDown, "img_buttonChevronDown.png");

LoadImageFromFile(ref btnViewAll, "img_buttonEye.png");
LoadImageFromFile(ref btnViewTimes, "img_buttonClock.png");

LoadImageFromFile(ref btnSettingsAttention, "img_buttonSettingsAttention.png");

LoadImageFromFile(ref texPartWindowHead, "img_PartWindowHead.png");

//LoadImageFromFile(ref texTooltipBackground, "tex_TooltipBackground.png");

LoadImageFromFile(ref texRateUp, "img_RateUp.png");
LoadImageFromFile(ref texRateDown, "img_RateDown.png");

LoadImageFromFile(ref btnAlarm, "img_Alarm.png");
LoadImageFromFile(ref btnAlarmEnabled, "img_AlarmEnabled.png");
LoadImageFromFile(ref btnAlarmWarn, "img_AlarmWarn.png");
LoadImageFromFile(ref btnAlarmAlert, "img_AlarmAlert.png");

//LoadImageFromFile(ref btnLock, "img_Lock.png");
//LoadImageFromFile(ref btnUnlock, "img_Unlock.png");

LoadImageFromFile(ref btnDropDown, "img_DropDown.png");
LoadImageFromFile(ref btnPlay, "img_Play.png");
LoadImageFromFile(ref btnStop, "img_Stop.png");
//LoadImageFromFile(ref btnDropDownSep, "img_DropDownSep.png");

//LoadImageFromFile(ref texDropDownListBox, "tex_DropDownListBox.png");
//LoadImageFromFile(ref texDropDownListBoxUnity, "tex_DropDownListBoxUnity.png");

LoadImageFromFile(ref texResourceMove, "img_ResourceMove.png");

LoadImageFromFile(ref texBox, "tex_Box.png");
LoadImageFromFile(ref texBoxUnity, "tex_BoxUnity.png");

LoadImageFromFile(ref texSeparatorH, "img_SeparatorHorizontal.png");
LoadImageFromFile(ref texSeparatorV, "img_SeparatorVertical.png");

LoadImageFromFile(ref texAppLaunchIcon, "KSPARPaBig.png", PathPluginToolbarIcons);
}


Expand Down
3 changes: 2 additions & 1 deletion TestFlightCore/TestFlightCore/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public Settings(String FilePath) : base(FilePath) {
public double globalReliabilityModifier;
[Persistent]
public double masterStatusUpdateFrequency;
[Persistent] public int currentView;
[Persistent] public bool displaySettingsWindow;
[Persistent] public bool enableHUD;
}
}

102 changes: 22 additions & 80 deletions TestFlightCore/TestFlightCore/StylesAndSkins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using UnityEngine;
using KSPPluginFramework;

namespace KSPAlternateResourcePanel
namespace TestFlightCore
{
internal class Styles
{
Expand All @@ -32,24 +32,8 @@ internal class Styles

private static GUIStyle stylePanel;

internal static GUIStyle styleAlarmButton;

internal static GUIStyle styleBarName;
internal static GUIStyle styleBarDef;

internal static GUIStyle styleBarBlue;
internal static GUIStyle styleBarBlue_Back;
internal static GUIStyle styleBarBlue_Thin;
internal static GUIStyle styleBarGreen;
internal static GUIStyle styleBarGreen_Back;
internal static GUIStyle styleBarGreen_Thin;

internal static GUIStyle styleBarText;
internal static GUIStyle styleBarRateText;

internal static GUIStyle styleBarHighlight;
internal static GUIStyle styleBarHighlightGreen;
internal static GUIStyle styleBarHighlightRed;

internal static GUIStyle styleText;
internal static GUIStyle styleTextCenter;
Expand All @@ -59,9 +43,10 @@ internal class Styles
internal static GUIStyle styleTextYellow;
internal static GUIStyle styleTextYellowBold;

internal static GUIStyle styleStageText;
internal static GUIStyle styleStageTextHead;
//internal static GUIStyle styleStageButton;
internal static GUIStyle textStyleSafe;
internal static GUIStyle textStyleWarning;
internal static GUIStyle textStyleCritical;


internal static GUIStyle stylePartWindowPanel;
internal static GUIStyle stylePartWindowPanelUnity;
Expand All @@ -72,14 +57,12 @@ internal class Styles
internal static GUIStyle styleToggle;

internal static GUIStyle styleSettingsArea;
internal static GUIStyle styleResourceSettingsArea;

internal static GUIStyle styleDropDownGlyph;

internal static GUIStyle styleSeparatorV;
internal static GUIStyle styleSeparatorH;

internal static GUIStyle styleDragInsert;

/// <summary>
/// This one sets up the styles we use
Expand Down Expand Up @@ -184,34 +167,6 @@ internal static void InitStyles()
#endregion

#region Common Styles
styleAlarmButton = new GUIStyle();
styleAlarmButton.fixedWidth=16;
styleAlarmButton.fixedHeight=16;

styleBarName = new GUIStyle() { fixedHeight = 16, fixedWidth = 32 };
styleBarName.normal.textColor = Color.white;
//styleBarName.alignment = TextAnchor.MiddleCenter;

//styleBarDef = new GUIStyle(GUI.skin.box);
styleBarDef = new GUIStyle(SkinsLibrary.DefUnitySkin.box);
styleBarDef.border = new RectOffset(2, 2, 2, 2);
styleBarDef.normal.textColor = Color.white;
styleBarDef.fixedHeight = 15;
styleBarDef.alignment = TextAnchor.UpperCenter;

styleBarBlue = new GUIStyle(styleBarDef);
styleBarBlue.normal.background = TestFlight.Resources.texBarBlue;
styleBarBlue_Back = new GUIStyle(styleBarDef);
styleBarBlue_Back.normal.background = TestFlight.Resources.texBarBlue_Back;
styleBarBlue_Thin = new GUIStyle(styleBarBlue);
styleBarBlue_Thin.border = new RectOffset(0, 0, 0, 0);
styleBarGreen = new GUIStyle(styleBarDef);
styleBarGreen.normal.background = TestFlight.Resources.texBarGreen;
styleBarGreen_Back = new GUIStyle(styleBarDef);
styleBarGreen_Back.normal.background = TestFlight.Resources.texBarGreen_Back;
styleBarGreen_Thin = new GUIStyle(styleBarGreen);
styleBarGreen_Thin.border = new RectOffset(0, 0, 0, 0);

styleText = new GUIStyle(SkinsLibrary.DefUnitySkin.label);
styleText.fontSize = 12;
styleText.alignment = TextAnchor.MiddleLeft;
Expand All @@ -220,7 +175,7 @@ internal static void InitStyles()

styleTextGreen = new GUIStyle(styleText);
styleTextGreen.normal.textColor = new Color32(183, 254, 0, 255); ;
styleTextYellow = new GUIStyle(styleText);
styleTextYellow = new GUIStyle(styleText);
styleTextYellow.normal.textColor = Color.yellow;
styleTextYellowBold = new GUIStyle(styleTextYellow);
styleTextYellowBold.fontStyle = FontStyle.Bold;
Expand All @@ -234,28 +189,14 @@ internal static void InitStyles()
styleBarText.alignment = TextAnchor.MiddleCenter;
styleBarText.normal.textColor = new Color(255, 255, 255, 0.8f);

styleBarRateText = new GUIStyle(styleBarText);
styleBarRateText.alignment = TextAnchor.MiddleRight;

styleBarHighlight = new GUIStyle();
styleBarHighlight.normal.background = TestFlight.Resources.texBarHighlight;
styleBarHighlight.border = new RectOffset(3, 3, 3, 3);

styleBarHighlightGreen = new GUIStyle(styleBarHighlight);
styleBarHighlightGreen.normal.background = TestFlight.Resources.texBarHighlightGreen;
styleBarHighlightRed = new GUIStyle(styleBarHighlight);
styleBarHighlightRed.normal.background = TestFlight.Resources.texBarHighlightRed;

styleStageText = new GUIStyle(GUI.skin.label);
styleStageText.normal.textColor = new Color(207, 207, 207);
styleStageText.wordWrap = false;


styleStageTextHead = new GUIStyle(styleStageText);
styleStageTextHead.fontStyle = FontStyle.Bold;
styleStageTextHead.wordWrap = false;
textStyleSafe = new GUIStyle(styleText);
textStyleSafe.normal.textColor = new Color32(133, 153, 0, 255);

textStyleWarning = new GUIStyle(styleText);
textStyleWarning.normal.textColor = new Color32(203, 75, 22, 255);

textStyleCritical = new GUIStyle(styleText);
textStyleCritical.normal.textColor = new Color32(220, 50, 47, 255);

styleToggle = new GUIStyle(HighLogic.Skin.toggle);
styleToggle.normal.textColor = new Color(207, 207, 207);
Expand All @@ -265,10 +206,6 @@ internal static void InitStyles()
styleSettingsArea = new GUIStyle(HighLogic.Skin.textArea);
styleSettingsArea.padding = new RectOffset(0, 0, 0, 4);

styleResourceSettingsArea = new GUIStyle(styleSettingsArea);
styleResourceSettingsArea.padding = new RectOffset(1, 0, 0, 0);
styleResourceSettingsArea.margin.left = 0;

styleDropDownGlyph = new GUIStyle();
styleDropDownGlyph.alignment = TextAnchor.MiddleCenter;

Expand All @@ -282,11 +219,6 @@ internal static void InitStyles()
styleSeparatorH.border = new RectOffset(6, 6, 0, 0);
styleSeparatorH.fixedHeight = 2;

//the border determins which bit doesnt repeat
styleDragInsert = new GUIStyle();
styleDragInsert.normal.background = TestFlight.Resources.texResourceMove;
styleDragInsert.border = new RectOffset(8, 8, 3, 3);

#endregion
}
#endregion
Expand Down Expand Up @@ -317,6 +249,11 @@ internal static void InitSkins()
SkinsLibrary.AddStyle("Default", "DropDownListBox", styleDropDownListBox);
SkinsLibrary.AddStyle("Default", "DropDownListItem", styleDropDownListItem);

SkinsLibrary.AddStyle("Default", "SafeText", textStyleSafe);
SkinsLibrary.AddStyle("Default", "WarningText", textStyleWarning);
SkinsLibrary.AddStyle("Default", "CriticalText", textStyleCritical);


//Now a Unity Style one
GUISkin DefUnity = SkinsLibrary.CopySkin(SkinsLibrary.DefSkinType.Unity);
DefUnity.window = DefUnity.box;
Expand All @@ -341,6 +278,11 @@ internal static void InitSkins()
SkinsLibrary.AddStyle("Unity", "DropDownListBox", styleDropDownListBoxUnity);
SkinsLibrary.AddStyle("Unity", "DropDownListItem", styleDropDownListItem);

SkinsLibrary.AddStyle("Unity", "SafeText", textStyleSafe);
SkinsLibrary.AddStyle("Unity", "WarningText", textStyleWarning);
SkinsLibrary.AddStyle("Unity", "CriticalText", textStyleCritical);


////Now a Unity Style one with KSP buttons
GUISkin UnityWKSPButtons = SkinsLibrary.CopySkin("Unity");
UnityWKSPButtons.button = DefKSP.button;
Expand Down
2 changes: 1 addition & 1 deletion TestFlightCore/TestFlightCore/TestFlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public class TestFlightManagerScenario : ScenarioModule
public List<String> partsPackedStrings;
public Dictionary<Guid, double> knownVessels;

Settings settings = null;
internal Settings settings = null;
public double pollingInterval = 5.0f;
public bool processInactiveVessels = true;

Expand Down
2 changes: 1 addition & 1 deletion TestFlightCore/TestFlightCore/TestFlightCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace TestFlightCore
/// This is the core PartModule of the TestFlight system, and is the module that everything else plugins into.
/// All relevant data for working in the system, as well as all usable API methods live here.
/// </summary>
public class TestFlightCore : PartModule, ITestFlightCore
public class TestFlightCore : PartModuleExtended, ITestFlightCore
{
private float lastFailureCheck = 0f;
private float lastPolling = 0.0f;
Expand Down
1 change: 1 addition & 0 deletions TestFlightCore/TestFlightCore/TestFlightCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<Compile Include="TestFlightWindow.cs" />
<Compile Include="StylesAndSkins.cs" />
<Compile Include="Resources.cs" />
<Compile Include="Framework\PartModuleExtended.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
Expand Down
Loading

0 comments on commit 3fc2637

Please sign in to comment.