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

Lgg dev branch #19

Merged
merged 4 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/InSituation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ internal static bool InRange(Vessel vessel)
double distance = directionToTarget.magnitude;

//Log.dbg("Angle " + angle);
Log.dbg("{0} Range {1}", vessel.name, distance);
// LGG commented out the following to avoid compile error
//Log.dbg("{0} Range {1}", vessel.name, distance);

// if (Mathf.Abs(angle) < 35 && distance < range) return true;
if (distance < HighLogic.CurrentGame.Parameters.CustomParams<SimpleLogistics_Options>().maxRange) return true;
Expand Down
8 changes: 6 additions & 2 deletions Source/LogisticsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,22 @@ public override string GetInfo()
public override void OnStart(PartModule.StartState state) {
}

public void Load(ConfigNode node)
// LGG
public new void Load(ConfigNode node)
{
bool b;
if (node.HasValue("IsActive") && bool.TryParse(node.GetValue("IsActive"), out b))
{
isActive = b;
}
base.Load(node); // LGG
}

public void Save(ConfigNode node)
// LGG
public new void Save(ConfigNode node)
{
node.AddValue("IsActive", isActive);
base.Save(node); // LGG
}

public override string ToString()
Expand Down
1 change: 1 addition & 0 deletions Source/RegisterToolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class RegisterToolbar : MonoBehaviour
{
void Start()
{
Debug.Log("SimpleLogistics.RegisterToolbar");
ToolbarControl.RegisterMod(SimpleLogistics.MODID, SimpleLogistics.MODNAME);
}
}
Expand Down
39 changes: 21 additions & 18 deletions Source/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,94 +25,97 @@ public class SimpleLogistics_Options : GameParameters.CustomParameterNode
public override string DisplaySection { get { return "[WIP] SimpleLogistics"; } }
public override int SectionOrder { get { return 1; } }

[GameParameters.CustomParameterUI("Use alternate skin",
toolTip = "Use a more minimiliast skin")]
public bool useAlternateSkin = false;

[GameParameters.CustomParameterUI("SimpleLogistics! enabled?",
toolTip = "enables and disables entire network (ON/off).",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool enabled = true;
public bool enabled = true;


[GameParameters.CustomParameterUI("Landed vessels may connect to SimpleLogistics network",
toolTip = "if yes, landed vessels connect to and use the SimpleLogistics Network?",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool yesLanded = true;
public bool yesLanded = true;


[GameParameters.CustomParameterUI("Splashed vessels may connect to SimpleLogistics network",
toolTip = "if yes, allow splashed vessels to access the SimpleLogistics network.",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool yesSplashed = true;
public bool yesSplashed = true;


[GameParameters.CustomParameterUI("Pre-Launch vessels may connect to SimpleLogistics network",
toolTip = "if yes, allow pre-launch vessels to access the SimpleLogistics network.",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool yesPreLaunch = true;
public bool yesPreLaunch = true;


[GameParameters.CustomParameterUI("Orbiting vessels may connect to SimpleLogistics network",
toolTip = "if yes, allow Orbiting vessels to access the SimpleLogistics network.",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool yesOrbiting = false;
public bool yesOrbiting = false;


[GameParameters.CustomParameterUI("Flying vessels may connect to SimpleLogistics network",
toolTip = "if yes, allow Flying vessels to access the SimpleLogistics network.",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool yesFlying = false;
public bool yesFlying = false;


[GameParameters.CustomParameterUI("SubOrbital vessels may connect to SimpleLogistics network",
toolTip = "if yes, allow SubOrbital vessels to access the SimpleLogistics network.",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool yesSubOrbital = false;
public bool yesSubOrbital = false;


[GameParameters.CustomParameterUI("Escaping vessels may connect to SimpleLogistics network",
toolTip = "if yes, allow Escaping vessels to access the SimpleLogistics network.",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool yesEscaping = false;
public bool yesEscaping = false;


[GameParameters.CustomParameterUI("Docked vessels may connect to SimpleLogistics network",
toolTip = "if yes, allow Docked vessels to access the SimpleLogistics network.",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool yesDocked = false;
public bool yesDocked = false;


[GameParameters.CustomParameterUI("Control: Full",
toolTip = "allow logisics network access from vessels with full control.",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool yesFull = true;
public bool yesFull = true;

[GameParameters.CustomParameterUI("Control: Partial Manned",
toolTip = "allow logisics network access from vessels with Partial Manned control.",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool yesPartialManned = true;
public bool yesPartialManned = true;

[GameParameters.CustomParameterUI("Control: Partial Unmanned",
toolTip = "allow logisics network access from vessels with Partial Unmanned control.",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool yesPartialUnmaned = true;
public bool yesPartialUnmaned = true;


[GameParameters.CustomParameterUI("Control: None (debris)",
toolTip = "allow logisics network access from vessels with no control.",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool yesNone = false;
public bool yesNone = false;

/// <summary>
/// The colored paw
Expand All @@ -121,7 +124,7 @@ public class SimpleLogistics_Options : GameParameters.CustomParameterNode
toolTip = "allow color coding in PAW (part action window) / part RMB (right menu button).",
newGameOnly = false,
unlockedDuringMission = true)]
internal bool coloredPAW = true;
public bool coloredPAW = true;

[GameParameters.CustomFloatParameterUI("Global Range Max (0 for limitied only by game physics range",
toolTip = "Max range of Logistics Network (in meters).",
Expand All @@ -132,7 +135,7 @@ public class SimpleLogistics_Options : GameParameters.CustomParameterNode
stepCount = 100,
displayFormat = "F2",
asPercentage = false)]
internal float maxRange = 1000.0f; // 0 for physics range ~2400
public float maxRange = 1000.0f; // 0 for physics range ~2400

[GameParameters.CustomFloatParameterUI("Global Range",
toolTip = "Max range of Logistics Network (in meters).",
Expand All @@ -143,7 +146,7 @@ public class SimpleLogistics_Options : GameParameters.CustomParameterNode
stepCount = 10,
displayFormat = "F2",
asPercentage = false)]
internal float maxAltitude = 500.0f;
public float maxAltitude = 500.0f;

[GameParameters.CustomFloatParameterUI("Global Range",
toolTip = "Max range of Logistics Network (in meters).",
Expand All @@ -154,13 +157,13 @@ public class SimpleLogistics_Options : GameParameters.CustomParameterNode
stepCount = 1,
displayFormat = "F2",
asPercentage = false)]
internal float maxGroundSpeed = 20.0f;
public float maxGroundSpeed = 20.0f;

// If you want to have some of the game settings default to enabled, change
// the "if false" to "if true" and set the values as you like


#if true
#if false
/// <summary>
/// Gets a value indicating whether this instance has presets.
/// </summary>
Expand Down
88 changes: 55 additions & 33 deletions Source/SimpleLogistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private void CreateLauncher()
null,
null,
ApplicationLauncher.AppScenes.FLIGHT,
GameDatabase.Instance.GetTexture("SimpleLogistics/Plugins/Textures/simple-logistics-icon", false)
GameDatabase.Instance.GetTexture("SimpleLogistics/Plugins/PluginData/Textures/simple-logistics-icon", false)
);
}
#endif
Expand Down Expand Up @@ -201,8 +201,12 @@ public void OnGUI()
windowRect.height = 0;
refresh = false;
}
// LGG The following uses the KSP stock skin. Comment it out to use
// the Unity stock skin
GUI.skin = HighLogic.Skin;
// windowRect = Layout.Window(
windowRect = GUILayout.Window(

windowRect = Layout.Window(
windowId,
windowRect,
DrawGUI,
Expand All @@ -220,22 +224,29 @@ public void OnGUI()
// It's a mess
private void DrawGUI(int windowId) {
GUILayout.BeginVertical ();

Layout.LabelAndText(Localizer.Format("#SimpleLogistics_Label1"), Localizer.Format(FlightGlobals.ActiveVessel.RevealName())); //"Current Vessel"
#if false
Layout.LabelAndText(Localizer.Format("#SimpleLogistics_Label1"), Localizer.Format(FlightGlobals.ActiveVessel.RevealName())); //"Current Vessel"
#endif
GUILayout.BeginHorizontal();
GUILayout.Label(Localizer.Format("#SimpleLogistics_Label1" + ": "));
GUILayout.Label(Localizer.Format(FlightGlobals.ActiveVessel.RevealName()));
GUILayout.EndHorizontal();

bool ableToRequest = false;

LogisticsModule lm = FlightGlobals.ActiveVessel.FindPartModuleImplementing<LogisticsModule> ();
if (lm != null) {
Layout.Label(
lm.IsActive ? Localizer.Format("#SimpleLogistics_Label2") : Localizer.Format("#SimpleLogistics_Label3"), //"Pluged In""Unplugged"
lm.IsActive ? Palette.green : Palette.red
// Layout.Label(
GUILayout.Label(
lm.IsActive ? Localizer.Format("#SimpleLogistics_Label2") : Localizer.Format("#SimpleLogistics_Label3") //, //"Pluged In""Unplugged"
// lm.IsActive ? Palette.green : Palette.red
);

// "Toggle Plug"
if (Layout.Button(Localizer.Format("#SimpleLogistics_Label4"), Palette.yellow))
{
lm.Set (!lm.IsActive);
// "Toggle Plug"
//if (Layout.Button(Localizer.Format("#SimpleLogistics_Label4"), Palette.yellow))
if (GUILayout.Button(Localizer.Format("#SimpleLogistics_Label4")))
{
lm.Set (!lm.IsActive);
refresh = true;
}
ableToRequest = !lm.IsActive;
Expand All @@ -244,52 +255,63 @@ private void DrawGUI(int windowId) {
if (ableToRequest)
GetVesselSpareSpace ();

Layout.LabelCentered(Localizer.Format("#SimpleLogistics_Label5"), Palette.yellow); //"Resource Pool:"

foreach (var resource in resourcePool) {
//Layout.LabelCentered(Localizer.Format("#SimpleLogistics_Label5"), Palette.yellow); //"Resource Pool:"
GUILayout.FlexibleSpace();
GUILayout.Label(Localizer.Format("#SimpleLogistics_Label5")); //"Resource Pool:"
GUILayout.FlexibleSpace();
foreach (var resource in resourcePool) {
GUILayout.BeginHorizontal ();
Layout.Label (resource.Key, Palette.yellow, GUILayout.Width(170));
//Layout.Label(resource.Key, Palette.yellow, GUILayout.Width(170));
GUILayout.Label(resource.Key, GUILayout.Width(170));
if (ableToRequest && requestPool.ContainsKey (resource.Key)) {
Layout.Label (requestPool[resource.Key].ToString("0.00") + " / " +
//Layout.Label(requestPool[resource.Key].ToString("0.00") + " / " +
GUILayout.Label(requestPool[resource.Key].ToString("0.00") + " / " +
resource.Value.ToString ("0.00"));
} else
Layout.Label (resource.Value.ToString ("0.00"));

// Layout.Label(resource.Value.ToString("0.00"));
GUILayout.Label(resource.Value.ToString("0.00"));

GUILayout.EndHorizontal ();
if (ableToRequest && requestPool.ContainsKey(resource.Key)) {
GUILayout.BeginHorizontal ();
if (Layout.Button ("0", GUILayout.Width (20)))
requestPool [resource.Key] = 0;

requestPool [resource.Key] = Layout.HorizontalSlider (
requestPool [resource.Key],
//if (Layout.Button("0", GUILayout.Width(20)))
if (GUILayout.Button("0", GUILayout.Width(20)))
requestPool[resource.Key] = 0;

//requestPool[resource.Key] = Layout.HorizontalSlider(
requestPool[resource.Key] = GUILayout.HorizontalSlider(
(float)requestPool[resource.Key],
0,
Math.Min (vesselSpareSpace [resource.Key], resource.Value),
(float)Math.Min (vesselSpareSpace [resource.Key], resource.Value),
GUILayout.Width (280)
);
if (Layout.Button (vesselSpareSpace [resource.Key].ToString ("0.00")))
requestPool [resource.Key] = Math.Min (vesselSpareSpace [resource.Key], resource.Value);
//if (Layout.Button(vesselSpareSpace[resource.Key].ToString("0.00")))
if (GUILayout.Button(vesselSpareSpace[resource.Key].ToString("0.00")))
requestPool[resource.Key] = Math.Min (vesselSpareSpace [resource.Key], resource.Value);

GUILayout.EndHorizontal ();
}
}

if (ableToRequest)
// "Request Resources"
if(Layout.Button(Localizer.Format("#SimpleLogistics_Label6"))) {
requested = true;
// "Request Resources"
//if(Layout.Button(Localizer.Format("#SimpleLogistics_Label6"))) {
if (GUILayout.Button(Localizer.Format("#SimpleLogistics_Label6")))
{
requested = true;
}

//"Close"
if (Layout.Button(Localizer.Format("#SimpleLogistics_Label7"), Palette.red))
{
//"Close"
//if (Layout.Button(Localizer.Format("#SimpleLogistics_Label7"), Palette.red))
if (GUILayout.Button(Localizer.Format("#SimpleLogistics_Label7")))
{
#if false
if (appLauncherButton != null)
appLauncherButton.SetFalse ();
else
onToggle ();
#endif
toolbarControl.SetFalse();
toolbarControl.SetFalse();
}

GUILayout.EndVertical ();
Expand Down
32 changes: 0 additions & 32 deletions Source/SimpleLogistics19.sln

This file was deleted.

2 changes: 2 additions & 0 deletions Source/UIFramework/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public void OnGUI() {
return;
Palette.InitPalette ();
Palette.LoadTextures ();
#if false
Styles.InitStyles ();
#endif
skinInitialized = true;
Destroy (this); // Quit after initialized
}
Expand Down
Loading