Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: KSP-RO/RP-1
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1130256cfe93
Choose a base ref
...
head repository: KSP-RO/RP-1
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7bf093152c2e
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Aug 14, 2017

  1. Add UI to display unlocked toolings

    Currently it's part of the Maintenance UI, so only accessible in the Space
     Centre (not the VAB/SPH).  We should probably do something about that.
    ec429 committed Aug 14, 2017
    Copy the full SHA
    d8cfbc8 View commit details

Commits on Aug 15, 2017

  1. Merge pull request #752 from ec429/maintUI

    Add UI to display unlocked toolings
    NathanKell authored Aug 15, 2017
    Copy the full SHA
    7bf0931 View commit details
Showing with 90 additions and 3 deletions.
  1. BIN GameData/RP-0/Plugins/RP0.dll
  2. +89 −2 Source/Maintenance/MaintenanceWindow.cs
  3. +1 −1 Source/Tooling/ToolingDatabase.cs
Binary file modified GameData/RP-0/Plugins/RP0.dll
100644 → 100755
Binary file not shown.
91 changes: 89 additions & 2 deletions Source/Maintenance/MaintenanceWindow.cs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ class MaintenanceWindow : MonoBehaviour
static bool guiEnabled = false;
private ApplicationLauncherButton button;
private GUIStyle rightLabel, boldLabel, boldRightLabel, pressedButton;
private Vector2 nautListScroll = new Vector2();
private Vector2 nautListScroll = new Vector2(), toolingTypesScroll = new Vector2();

protected void Awake()
{
@@ -88,8 +88,9 @@ public void OnGUI()
}
}

private enum tabs { SUMMARY, Facilities, Integration, Astronauts };
private enum tabs { SUMMARY, Facilities, Integration, Astronauts, Tooling, ToolingType };
private tabs currentTab;
private string currentToolingType;
private enum per { DAY, MONTH, YEAR };
private per displayPer = per.YEAR;

@@ -128,6 +129,10 @@ private void tabSelector()
currentTab = tabs.Integration;
if (toggleButton("Astronauts", currentTab == tabs.Astronauts))
currentTab = tabs.Astronauts;
if (toggleButton("Tooling", currentTab == tabs.Tooling)) {
currentTab = tabs.Tooling;
currentToolingType = null;
}
} finally {
GUILayout.EndHorizontal();
}
@@ -384,6 +389,82 @@ private void astronautsTab()
}
}

private void toolingTab()
{
GUILayout.BeginHorizontal();
try {
GUILayout.FlexibleSpace();
GUILayout.Label("Tooling Types", HighLogic.Skin.label);
GUILayout.FlexibleSpace();
} finally {
GUILayout.EndHorizontal();
}
int counter = 0;
GUILayout.BeginHorizontal();
try {
foreach (string type in ToolingDatabase.toolings.Keys) {
if (counter % 3 == 0 && counter != 0) {
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
}
counter++;
if (GUILayout.Button(type)) {
currentToolingType = type;
currentTab = tabs.ToolingType;
}
}
} finally {
GUILayout.EndHorizontal();
}
}

private void toolingTypesHeading()
{
GUILayout.BeginHorizontal();
try {
GUILayout.Label("Diameter", HighLogic.Skin.label, GUILayout.Width(80));
GUILayout.Label("×", HighLogic.Skin.label);
GUILayout.Label("Length", rightLabel, GUILayout.Width(80));
} finally {
GUILayout.EndHorizontal();
}
}

private void toolingTypeRow(float diameter, float length)
{
GUILayout.BeginHorizontal();
try {
GUILayout.Label(diameter.ToString("F2") + "m", HighLogic.Skin.label, GUILayout.Width(80));
GUILayout.Label("×", HighLogic.Skin.label);
GUILayout.Label(length.ToString("F2") + "m", rightLabel, GUILayout.Width(80));
} finally {
GUILayout.EndHorizontal();
}
}

private void toolingTypeTab()
{
GUILayout.BeginHorizontal();
try {
GUILayout.FlexibleSpace();
GUILayout.Label("Toolings for type "+currentToolingType, HighLogic.Skin.label);
GUILayout.FlexibleSpace();
} finally {
GUILayout.EndHorizontal();
}
toolingTypesHeading();
toolingTypesScroll = GUILayout.BeginScrollView(toolingTypesScroll, GUILayout.Width(200), GUILayout.Height(240));
try {
foreach (ToolingDiameter td in ToolingDatabase.toolings[currentToolingType]) {
foreach (float length in td.lengths) {
toolingTypeRow(td.diameter, length);
}
}
} finally {
GUILayout.EndScrollView();
}
}

public void DrawWindow(int windowID)
{
try {
@@ -407,6 +488,12 @@ public void DrawWindow(int windowID)
case tabs.Astronauts:
astronautsTab();
break;
case tabs.Tooling:
toolingTab();
break;
case tabs.ToolingType:
toolingTypeTab();
break;
default: // can't happen
break;
}
2 changes: 1 addition & 1 deletion Source/Tooling/ToolingDatabase.cs
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ protected static int EpsilonCompare(float a, float b)
return a.CompareTo(b);
}

protected static Dictionary<string, List<ToolingDiameter>> toolings = new Dictionary<string, List<ToolingDiameter>>();
public static Dictionary<string, List<ToolingDiameter>> toolings = new Dictionary<string, List<ToolingDiameter>>();

protected static int DiamIndex(float diam, List<ToolingDiameter> lst, out int min)
{