Skip to content

Commit

Permalink
Version 1.22a
Browse files Browse the repository at this point in the history
Add window location reset
  • Loading branch information
SirDiazo committed Nov 17, 2014
1 parent fa80f7a commit d36c6be
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 77 deletions.
61 changes: 3 additions & 58 deletions AGExt/CommonMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,64 +26,9 @@ public class AGXMethods : PartModule
//}
}//AGXMethods closing bracket

public class SettingsWindow : MonoBehaviour, IDrawable
{
public Rect SettingsWin = new Rect(0, 0, 150, 80);
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, 25), "Show KeyCodes"))
{
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");
}

if (GUI.Button(new Rect(10, 50, 130, 25), "Edit Actions"))
{
AGXFlight.ClickEditButton();
//if (AGXFlight.ShowSelectedWin || ShowKeySetWin)
//{

// SaveEverything();
// ShowSelectedWin = false;
// ShowKeySetWin = false;
//}
//else if (!ShowSelectedWin)
//{
// ShowSelectedWin = true;
//}
}

//GUI.DragWindow();


}

public void Update()
{
//print("Test");
}
}


}//name space closing bracket
99 changes: 81 additions & 18 deletions AGExt/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace ActionGroupsExtended
[KSPAddon(KSPAddon.Startup.EditorAny, false)]
public class AGXEditor : PartModule
{


bool EditorShowToolbarPopout = false;
bool defaultShowingNonNumeric = false; //are we in non-numeric (abort/brakes/gear/list) mode?
List<BaseAction> defaultActionsListThisType; //list of default actions showing in group win when non-numeric
List<BaseAction> defaultActionsListAll; //list of all default actions on vessel, only used in non-numeric mode when going to other mode
Expand Down Expand Up @@ -104,7 +105,7 @@ public class AGXEditor : PartModule
public static Dictionary<int, KSPActionGroup> KSPActs = new Dictionary<int, KSPActionGroup>();
private bool AGXShow = false;
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
Expand All @@ -129,8 +130,50 @@ public class AGXEditor : PartModule
//static Part.HighlightType partHighlightLastType;
//static Material[] partHighlightLastMaterial;




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

SettingsWinEditor.x = position.x;
SettingsWinEditor.y = position.y;

GUI.Window(2233452, SettingsWinEditor, DrawSettingsWinEditor, "AGX Settings", AGXEditor.AGXWinStyle);
//RCSlaWin = GUILayout.Window(42334567, RCSlaWin, DrawWin, (string)null, GUI.skin.box);
//GUI.skin = oldSkin;

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

public void DrawSettingsWinEditor(int WindowID)
{

if (GUI.Button(new Rect(10, 25, 130, 25), "Reset Windows"))
{
KeySetWin.x = 250;
KeySetWin.y = 250;
GroupsWin.x = 350;
GroupsWin.y = 350;
SelPartsWin.x = 200;
SelPartsWin.y = 200;
KeyCodeWin.x = 300;
KeyCodeWin.y = 300;
CurActsWin.x = 150;
CurActsWin.y = 150;


}

}
public void Update()
{

}
}

public void Start()
{
Expand Down Expand Up @@ -239,28 +282,48 @@ public void Start()
{
//List<UnityEngine.Transform> UIPanelList = new List<UnityEngine.Transform>(); //setup list to find Editor Actions UI transform into a list. Could not figure out how to find just a transform
//UIPanelList.AddRange(FindObjectsOfType<UnityEngine.Transform>().Where(n => n.name == "PanelActionGroups")); //actual find command
if (EditorLogic.fetch.editorScreen == EditorLogic.EditorScreen.Actions)
if (e.MouseButton == 0)
{
if (AGXShow)
if (EditorLogic.fetch.editorScreen == EditorLogic.EditorScreen.Actions)
{
//UIPanelList.First().Translate(new Vector3(500f, 0, 0), UIPanelList.First().parent.transform); //hide UI panel
AGXShow = false;
AGExtNode.SetValue("EditShow", "0");
EditorPanels.Instance.panelManager.BringIn(EditorPanels.Instance.actions);
if (AGXShow)
{
//UIPanelList.First().Translate(new Vector3(500f, 0, 0), UIPanelList.First().parent.transform); //hide UI panel
AGXShow = false;
AGExtNode.SetValue("EditShow", "0");
EditorPanels.Instance.panelManager.BringIn(EditorPanels.Instance.actions);
}
else
{
// UIPanelList.First().Translate(new Vector3(-500f, 0, 0), UIPanelList.First().parent.transform); //show UI panel
AGXShow = true;
AGExtNode.SetValue("EditShow", "1");
EditorPanels.Instance.panelManager.Dismiss();
}
AGExtNode.Save(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/AGExt.cfg");
}
else
{
// UIPanelList.First().Translate(new Vector3(-500f, 0, 0), UIPanelList.First().parent.transform); //show UI panel
AGXShow = true;
AGExtNode.SetValue("EditShow", "1");
EditorPanels.Instance.panelManager.Dismiss();
EditorLogic.fetch.SelectPanelActions();
}
AGExtNode.Save(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/AGExt.cfg");
}
else
if (e.MouseButton == 1)
{
EditorLogic.fetch.SelectPanelActions();
if (EditorLogic.fetch.editorScreen == EditorLogic.EditorScreen.Actions)
{
if (EditorShowToolbarPopout)
{
AGXBtn.Drawable = null;
EditorShowToolbarPopout = false;
}
else
{
SettingsWindowEditor SettingsEditor = new SettingsWindowEditor();
AGXBtn.Drawable = SettingsEditor;
EditorShowToolbarPopout = true;
}
}
}
};
}
Expand Down Expand Up @@ -1928,7 +1991,7 @@ public void GroupsWindow(int WindowID)
AGXBtnStyle.normal.background = AutoHideGroupsWin ? ButtonTextureRed : ButtonTexture;
//AGXBtnStyle.onHover.background = AutoHideGroupsWin ? ButtonTextureRed : ButtonTexture;
AGXBtnStyle.hover.background = AutoHideGroupsWin ? ButtonTextureRed : ButtonTexture;
if (GUI.Button(new Rect(5, 3, 80, 20), "Auto-Hide", AGXBtnStyle))
if (GUI.Button(new Rect(15, 3, 70, 20), "Auto-Hide", AGXBtnStyle))
{
AutoHideGroupsWin = !AutoHideGroupsWin;

Expand Down
65 changes: 65 additions & 0 deletions AGExt/Flight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,71 @@ public void Start()
}


public class SettingsWindow : MonoBehaviour, IDrawable
{
public Rect SettingsWin = new Rect(0, 0, 150, 105);
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", 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, 25), "Show KeyCodes"))
{
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");
}

if (GUI.Button(new Rect(10, 50, 130, 25), "Edit Actions"))
{
AGXFlight.ClickEditButton();

}
if (GUI.Button(new Rect(10, 75, 130, 25), "Reset Windows"))
{
KeySetWin.x = 250;
KeySetWin.y = 250;
GroupsWin.x = 350;
GroupsWin.y = 350;
SelPartsWin.x = 200;
SelPartsWin.y = 200;
KeyCodeWin.x = 300;
KeyCodeWin.y = 300;
CurActsWin.x = 150;
CurActsWin.y = 150;
FlightWin.x = 400;
FlightWin.y = 400;
}

//GUI.DragWindow();

}
public void Update()
{

}
}

public bool IsVesselLoaded(uint flightID) //is vessel loaded, wrapper to convert from flightID to vsl
{
try
Expand Down
2 changes: 1 addition & 1 deletion AGExt/Instantly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class AGXMainMenu :PartModule

public void Start()
{
print("AGExt Ver. 1.22 loaded");
print("AGExt Ver. 1.22a loaded");
//below no longer needed with InputLockManager
//AGXguiKeys = new Dictionary<int, KeyCode>();
//AGExtNode = ConfigNode.Load(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/AGExt.cfg");
Expand Down

0 comments on commit d36c6be

Please sign in to comment.