Skip to content

Commit

Permalink
Version 1.12 Release
Browse files Browse the repository at this point in the history
Add ability to show/hide keycode in flight
  • Loading branch information
SirDiazo committed Jul 29, 2014
1 parent 884eae2 commit 4d672fc
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 27 deletions.
18 changes: 8 additions & 10 deletions AGExt/AGExt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,31 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\0.24.1 dev\GameData\Diazo\AGExt\</OutputPath>
<OutputPath>..\..\..\0.24.2 dev\GameData\Diazo\AGExt\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\0.24.1 dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\0.24.2 dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\0.24.1 dev\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\..\0.24.2 dev\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\0.24.1 dev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
<Reference Include="UnityEngine">
<HintPath>..\..\..\0.24.2 dev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Button.cs" />
<Compile Include="CommonMethods.cs" />
<Compile Include="Instantly.cs" />
<Compile Include="Editor.cs" />
<Compile Include="External.cs" />
Expand Down
74 changes: 74 additions & 0 deletions AGExt/CommonMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using UnityEngine;


namespace ActionGroupsExtended
{

public class AGXMethods : PartModule
{


//public static void SettingsWindow(int WindowID)
//{
// if(GUI.Button(new Rect(10, 25, 130, 40), "Show KeyCodes in\nFlight Window"))
// {
// AGXFlight.FlightWinShowKeycodes = !AGXFlight.FlightWinShowKeycodes;
// }


// GUI.DragWindow();
//}
}//AGXMethods closing bracket

public class SettingsWindow : MonoBehaviour, IDrawable
{
public Rect SettingsWin = new Rect(0, 0, 150, 75);
public Vector2 Draw(Vector2 position)
{
var oldSkin = GUI.skin;
GUI.skin = HighLogic.Skin;

SettingsWin.x = position.x;
SettingsWin.y = position.y;

GUI.Window(2233452, SettingsWin, DrawSettingsWin, "AGX Settings", AGXFlight.AGXWinStyle);
//RCSlaWin = GUILayout.Window(42334567, RCSlaWin, DrawWin, (string)null, GUI.skin.box);
//GUI.skin = oldSkin;

return new Vector2(SettingsWin.width, SettingsWin.height);
}

public void DrawSettingsWin(int WindowID)
{

if (GUI.Button(new Rect(10, 25, 130, 40), "Show KeyCodes in\nFlight Window"))
{
AGXFlight.FlightWinShowKeycodes = !AGXFlight.FlightWinShowKeycodes;
if (AGXFlight.FlightWinShowKeycodes)
{
AGXFlight.AGExtNode.SetValue("FlightWinShowKeys", "1");
}
else
{
AGXFlight.AGExtNode.SetValue("FlightWinShowKeys", "0");
}
AGXFlight.AGExtNode.Save(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/AGExt.cfg");
}


//GUI.DragWindow();

}

public void Update()
{
//print("Test");
}
}
}//name space closing bracket
2 changes: 1 addition & 1 deletion AGExt/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ public void LoadGroupNames()


LoadNames = pm.AGXNames;

print("AGX Load Name: " + EditorLogic.startPod.partName+" "+ LoadNames);

if(LoadNames.Length > 0)
{
Expand Down
77 changes: 61 additions & 16 deletions AGExt/Flight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class AGXFlight : PartModule
private static int CurrentKeySet = 1;
private string CurrentKeySetName;
private Rect KeySetWin;
private ConfigNode AGExtNode;
public static ConfigNode AGExtNode;
string[] KeySetNames = new string[5];
//private bool TrapMouse = false;
private int LastPartCount = 0;
Expand Down Expand Up @@ -107,12 +107,15 @@ public class AGXFlight : PartModule
private int actionsCheckFrameCount = 0;

private static GUISkin AGXSkin;
private static GUIStyle AGXWinStyle = null;
public static GUIStyle AGXWinStyle = null;
//private static GUIStyle TWR1WinStyle = null; //window style
private static GUIStyle AGXLblStyle = null; //window style
private static GUIStyle AGXBtnStyle = null; //window style
public static GUIStyle AGXBtnStyle = null; //window style
private static GUIStyle AGXFldStyle = null; //window style
//private static GUIStyle AGXScrollStyle = null; //window style
private bool ShowSettingsWin = false;
private Rect SettingsWinRect;
public static bool FlightWinShowKeycodes = true;



Expand Down Expand Up @@ -172,9 +175,17 @@ public void Start()
KeyCodeWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltKeyCodeX")), Convert.ToInt32(AGExtNode.GetValue("FltKeyCodeY")), 410, 730);
KeySetWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltKeySetX")), Convert.ToInt32(AGExtNode.GetValue("FltKeySetY")), 185, 335);
CurActsWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltCurActsX")), Convert.ToInt32(AGExtNode.GetValue("FltCurActsY")), 345, 140);
FlightWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltMainX")), Convert.ToInt32(AGExtNode.GetValue("FltMainY")), 215, 100);
FlightWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltMainX")), Convert.ToInt32(AGExtNode.GetValue("FltMainY")), 235, 100);
GroupsInFlightWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("FltMainX")), Convert.ToInt32(AGExtNode.GetValue("FltMainY")), 80, 110);
ActiveGroups = new Dictionary<int, bool>();
if(AGExtNode.GetValue("FlightWinShowKeys") == "1")
{
FlightWinShowKeycodes = true;
}
else
{
FlightWinShowKeycodes = false;
}

UnbindDefaultKeys();

Expand All @@ -186,9 +197,31 @@ public void Start()
AGXBtn.TexturePath = "Diazo/AGExt/icon_button";
AGXBtn.ToolTip = "Action Groups Extended";
AGXBtn.OnClick += (e) =>
{
ShowAGXMod = !ShowAGXMod;
};
{
if (e.MouseButton == 0)
{
ShowAGXMod = !ShowAGXMod;
}
if (e.MouseButton == 1)
{
//ShowSettingsWin = !ShowSettingsWin;
if (ShowSettingsWin)
{
AGXBtn.Drawable = null;
ShowSettingsWin = false;
}
else
{
SettingsWindow Settings = new SettingsWindow();
AGXBtn.Drawable = Settings;
ShowSettingsWin = true;
}
}
};
//{
// ShowAGXMod = !ShowAGXMod;
//};
}

if (AGExtNode.GetValue("FltShow") == "0")
Expand Down Expand Up @@ -254,6 +287,7 @@ public void Start()
AGXBtnStyle.active.background = ButtonTexture;
AGXBtnStyle.focused.background = ButtonTexture;
AGXBtnStyle.hover.background = ButtonTexture;
SettingsWinRect = new Rect(500, 500, 150, 75);

}

Expand Down Expand Up @@ -435,11 +469,16 @@ public void AGXOnDraw()


//TestWin = GUI.Window(673467791, TestWin, TestingWindow, "Test", AGXWinStyle);
//if (ShowSettingsWin)
//{
// SettingsWinRect = GUI.Window(673467780, SettingsWinRect, AGXMethods.SettingsWindow, "AGX Settings", AGXWinStyle);
//}

if (ShowAGXMod)
{
if (ShowAGXFlightWin)
{
GroupsInFlightWin.x = FlightWin.x + 215;
GroupsInFlightWin.x = FlightWin.x + 235;
GroupsInFlightWin.y = FlightWin.y;
FlightWin = GUI.Window(673467788, FlightWin, FlightWindow, "Actions", AGXWinStyle);
//TrapMouse |= FlightWin.Contains(RealMousePos);
Expand Down Expand Up @@ -577,7 +616,7 @@ public void FlightWindow(int WindowID)
{
HighLogic.Skin.scrollView.normal.background = null;
AGXBtnStyle.alignment = TextAnchor.MiddleCenter;
if (GUI.Button(new Rect(140, 5, 70, 20), ShowGroupInFlightNames[ShowGroupInFlightCurrent], AGXBtnStyle))
if (GUI.Button(new Rect(160, 5, 70, 20), ShowGroupInFlightNames[ShowGroupInFlightCurrent], AGXBtnStyle))
{

ShowGroupsInFlightWindow = !ShowGroupsInFlightWindow;
Expand Down Expand Up @@ -645,9 +684,9 @@ public void FlightWindow(int WindowID)
//}

//GUI.Box(new Rect(5, 25, 190, Math.Min(410,10+(20*Math.Max(1,ActiveActions.Count)))), "");
GUI.Box(new Rect(5, 25, 190, Math.Min(410, 10 + (20 * Math.Max(1, ActiveActionsStateToShow.Count)))), "", AGXBtnStyle);
GUI.Box(new Rect(5, 25, 210, Math.Min(410, 10 + (20 * Math.Max(1, ActiveActionsStateToShow.Count)))), "", AGXBtnStyle);
//FlightWinScroll = GUI.BeginScrollView(new Rect(10, 30, 200, Math.Min(400,20+(20*(ActiveActions.Count-1)))), FlightWinScroll, new Rect(0, 0, 180, (20 * (ActiveActions.Count))));
FlightWinScroll = GUI.BeginScrollView(new Rect(10, 30, 200, Math.Min(400, 20 + (20 * (ActiveActionsStateToShow.Count - 1)))), FlightWinScroll, new Rect(0, 0, 180, (20 * (ActiveActionsStateToShow.Count))));
FlightWinScroll = GUI.BeginScrollView(new Rect(10, 30, 220, Math.Min(400, 20 + (20 * (ActiveActionsStateToShow.Count - 1)))), FlightWinScroll, new Rect(0, 0, 180, (20 * (ActiveActionsStateToShow.Count))));
//FlightWin.height = Math.Min( Math.Max(60,40+(20*ActiveActions.Count)),440);
Rect FlightWinOld = new Rect(FlightWin.x, FlightWin.y, FlightWin.width, FlightWin.height);
FlightWin.height = Math.Min(Math.Max(60, 40 + (20 * ActiveActionsStateToShow.Count)), 440);
Expand Down Expand Up @@ -700,19 +739,22 @@ public void FlightWindow(int WindowID)

AGXBtnStyle.alignment = TextAnchor.MiddleLeft;
//if (GUI.Button(new Rect(0, 0 + (20 * (i2 - 1)), 110, 20), ActiveActions.ElementAt((i2 - 1)) + ": " + AGXguiNames[ActiveActions.ElementAt((i2 - 1))]))
if (GUI.Button(new Rect(0, 0 + (20 * (i2 - 1)), 110, 20), ActiveActionsStateToShow.ElementAt((i2 - 1)).group + ": " + AGXguiNames[ActiveActionsStateToShow.ElementAt((i2 - 1)).group], AGXBtnStyle))
if (GUI.Button(new Rect(0, 0 + (20 * (i2 - 1)), FlightWinShowKeycodes? 110:200, 20), ActiveActionsStateToShow.ElementAt((i2 - 1)).group + ": " + AGXguiNames[ActiveActionsStateToShow.ElementAt((i2 - 1)).group], AGXBtnStyle))
{

//ActivateActionGroup(ActiveActions.ElementAt(i2 - 1));
ActivateActionGroup(ActiveActionsStateToShow.ElementAt(i2 - 1).group);
}
AGXBtnStyle.alignment = TextAnchor.MiddleCenter;
//if (GUI.Button(new Rect(110, 0 + (20 * (i2 - 1)), 70, 20), AGXguiKeys[ActiveActions.ElementAt((i2 - 1))].ToString()))
if (GUI.Button(new Rect(110, 0 + (20 * (i2 - 1)), 70, 20), AGXguiKeys[ActiveActionsStateToShow.ElementAt((i2 - 1)).group].ToString(), AGXBtnStyle))
if (FlightWinShowKeycodes)
{
if (GUI.Button(new Rect(110, 0 + (20 * (i2 - 1)), 90, 20), AGXguiKeys[ActiveActionsStateToShow.ElementAt((i2 - 1)).group].ToString(), AGXBtnStyle))
{

//ActivateActionGroup(ActiveActions.ElementAt(i2 - 1));
ActivateActionGroup(ActiveActionsStateToShow.ElementAt(i2 - 1).group);
//ActivateActionGroup(ActiveActions.ElementAt(i2 - 1));
ActivateActionGroup(ActiveActionsStateToShow.ElementAt(i2 - 1).group);
}
}
GUI.contentColor = TxtClr;
}
Expand Down Expand Up @@ -1935,6 +1977,8 @@ public void LoadGroupVisibility()
public void LoadGroupNames()
{



for (int i = 1; i <= 250; i = i + 1)
{
AGXguiNames[i] = "";
Expand All @@ -1951,7 +1995,7 @@ public void LoadGroupNames()


LoadNames = (string)pm.Fields.GetValue("AGXNames");

print("AGX Load Name: "+ p.partName+ " " + LoadNames);

if (LoadNames.Length > 0)
{
Expand Down Expand Up @@ -2219,6 +2263,7 @@ public void Update()
{
actionsCheckFrameCount = actionsCheckFrameCount + 1;
}
//print("test " + ShowSettingsWin + FlightWinShowKeycodes);
}


Expand Down

0 comments on commit 4d672fc

Please sign in to comment.