Skip to content

Commit

Permalink
Merge branch 'fixes_2838_reread_boot_button' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunbaratu committed Jan 15, 2021
2 parents 1e46126 + 2b9d3c3 commit ae80f85
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/kOS/Module/kOSProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class kOSProcessor : PartModule, IProcessor, IPartCostModifier, IPartMass

public MessageQueue Messages { get; private set; }

private static bool bootListDirty;

public string Tag
{
get
Expand Down Expand Up @@ -337,12 +339,18 @@ public override void OnStart(StartState state)

SafeHouse.Logger.Log(string.Format("OnStart: {0} {1}", state, ProcessorMode));
InitObjects();
} catch (Exception e)
}
catch (Exception e)
{
SafeHouse.Logger.LogException(e);
}
}

public static void SetBootListDirty()
{
bootListDirty = true;
}

private void InitUI()
{
//Populate selector for boot scripts
Expand Down Expand Up @@ -415,6 +423,9 @@ private void InitUI()
options.options = availableOptions.ToArray();
options.display = availableDisplays.ToArray();

bootListDirty = false;
ForcePAWRefresh();

//populate diskSpaceUI selector
diskSpaceUI = diskSpace.ToString();
field = Fields["diskSpaceUI"];
Expand All @@ -426,6 +437,18 @@ private void InitUI()
options.options = sizeOptions;
}

public void ForcePAWRefresh()
{
// Thanks to https://github.com/blowfishpro for finding this API call for me:
UIPartActionWindow paw = UIPartActionController.Instance?.GetItem(part, false);

if (paw != null)
{
paw.ClearList();
paw.displayDirty = true;
}
}

private IEnumerable<VolumePath> BootDirectoryFiles()
{
var result = new List<VolumePath>();
Expand Down Expand Up @@ -695,6 +718,10 @@ public void Update()
{
if (HighLogic.LoadedScene == GameScenes.EDITOR && EditorLogic.fetch != null)
{
if (bootListDirty)
{
InitUI();
}
if (diskSpace != Convert.ToInt32(diskSpaceUI))
{
diskSpace = Convert.ToInt32(diskSpaceUI);
Expand Down
26 changes: 26 additions & 0 deletions src/kOS/Screen/KOSToolbarWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,11 @@ private void DrawActiveCPUsOnPanel()
"There are either no kOS CPU's\n" +
"in this universe, or there are\n " +
"but they are all \"on rails\".", panelSkin.label);

if (HighLogic.LoadedSceneIsEditor)
{
DrawRereadBootButton();
}
CountEndVertical();

GUILayout.EndScrollView();
Expand Down Expand Up @@ -801,6 +806,27 @@ private void DrawPart(Part part)
GUILayout.Box(new GUIContent(labelText, "This is the currently highlighted part on the vessel"), partNameStyle);
}

private void DrawRereadBootButton()
{
CountBeginVertical();
GUILayout.Box(" "); // just putting a bar above the button and text.
CountBeginHorizontal();
bool clicked = GUILayout.Button("Reread\nBoot\nFolder", panelSkin.button);
GUILayout.Label(
"If you added new files to the archive\n" +
"boot folder after entering this\n" +
"Editor scene, they won't show up in the\n" +
"part window unless you click here.\n", panelSkin.label);

if (clicked)
{
kOSProcessor.SetBootListDirty();
}
CountEndHorizontal();
GUILayout.Box(" "); // just putting a bar below the button and text.
CountEndVertical();
}

public void BeginHoverHousekeeping()
{
// OnGUI() gets called many times in different modes for different reasons.
Expand Down

0 comments on commit ae80f85

Please sign in to comment.