Highlight loops

master
D4VID 7 months ago
parent 90690ff397
commit bad72aeb71

@ -1,6 +1,8 @@
CriticalPathAnalyzer.CriticalPathAnalyzer:
InjectTriggersInto:
- MHG.BuildActions
Triggers:
- CriticalPathAnalyzer.AnalyzePathStart
- CriticalPathAnalyzer.AnalyzePathEnd
InjectTriggersInto:
- MHG.BuildActions
Triggers:
- CriticalPathAnalyzer.OpenPathAnalyzer
- CriticalPathAnalyzer.AnalyzePathStart
- CriticalPathAnalyzer.AnalyzePathEnd
- CriticalPathAnalyzer.DisplayLoop

@ -1,11 +1,23 @@
CriticalPathAnalyzer.OpenPathAnalyzer:
Heading: "CriticalPathAnalyzer"
DefaultBinding:
Options:
- I
CriticalPathAnalyzer.AnalyzePathStart:
Heading: "CriticalPathAnalyzer"
DefaultBinding:
Options:
- I
Heading: "CriticalPathAnalyzer"
DefaultBinding:
Options:
- I
CriticalPathAnalyzer.AnalyzePathEnd:
Heading: "CriticalPathAnalyzer"
DefaultBinding:
Options:
- O
Heading: "CriticalPathAnalyzer"
DefaultBinding:
Options:
- O
CriticalPathAnalyzer.DisplayLoop:
Heading: "CriticalPathAnalyzer"
DefaultBinding:
Options:
- P

@ -1,5 +1,10 @@
MHG.SettingsMenu.Pages.Controls.Headings.CriticalPathAnalyzer: "Mod: Critical Path Analyzer"
FancyInput.Trigger.CriticalPathAnalyzer.OpenPathAnalyzer: "Open the path analyzer tool"
FancyInput.Trigger.CriticalPathAnalyzer.OpenPathAnalyzer.Description : """
Transitions into the CriticalPathAnalyzer state.
"""
FancyInput.Trigger.CriticalPathAnalyzer.AnalyzePathStart: "Select start of path"
FancyInput.Trigger.CriticalPathAnalyzer.AnalyzePathStart.Description : """
Press to select the start of the path to be analyzed.
@ -9,3 +14,8 @@ FancyInput.Trigger.CriticalPathAnalyzer.AnalyzePathEnd: "Select end of path"
FancyInput.Trigger.CriticalPathAnalyzer.AnalyzePathEnd.Description : """
Press to select the end of the path to be analyzed.
"""
FancyInput.Trigger.CriticalPathAnalyzer.DisplayLoop: "Display loop"
FancyInput.Trigger.CriticalPathAnalyzer.DisplayLoop.Description : """
Highlights only clusters that are causing a loop.
"""

@ -34,7 +34,7 @@ namespace CriticalPathAnalyzer.Client {
public static void OnAnalyzePathResponse(AnalyzePathResponse response) {
LoggerInstance.Info($"Got response from server");
CriticalPathAnalyzerTool.Highlight(response);
CriticalPathAnalyzerTool.HandleResponse(response);
}
}
}

@ -16,6 +16,7 @@ namespace CriticalPathAnalyzer.Client {
UITrigger.Back,
CriticalPathAnalyzerTrigger.AnalyzePathStart,
CriticalPathAnalyzerTrigger.AnalyzePathEnd,
CriticalPathAnalyzerTrigger.DisplayLoop,
};
public override void OnEnter() {
@ -29,6 +30,8 @@ namespace CriticalPathAnalyzer.Client {
CriticalPathAnalyzerTool.SelectPathStart();
} else if (CustomInput.DownThisFrame(CriticalPathAnalyzerTrigger.AnalyzePathEnd)) {
CriticalPathAnalyzerTool.SelectPathEnd();
} else if (CustomInput.DownThisFrame(CriticalPathAnalyzerTrigger.DisplayLoop)) {
CriticalPathAnalyzerTool.DisplayLoop();
}
}

@ -17,7 +17,7 @@ namespace CriticalPathAnalyzer.Client {
}
private static bool Hook(out bool deletedWire) {
if (CustomInput.DownThisFrame(CriticalPathAnalyzerTrigger.AnalyzePathStart)) {
if (CustomInput.DownThisFrame(CriticalPathAnalyzerTrigger.OpenPathAnalyzer)) {
GameStateManager.TransitionTo(CriticalPathAnalyzerGameState.Id);
deletedWire = true; // True = Cancel remaining keybinding handling.

@ -1,7 +1,9 @@
namespace CriticalPathAnalyzer.Client.Keybindings {
public enum CriticalPathAnalyzerTrigger {
None,
OpenPathAnalyzer,
AnalyzePathStart,
AnalyzePathEnd,
DisplayLoop,
}
}

@ -17,6 +17,7 @@ namespace CriticalPathAnalyzer.Client.Tool {
private static PegAddress? _endPegAddress;
private static Guid _currentRequestGuid = Guid.NewGuid();
private static AnalyzePathResponse _response;
public static void Init(ILogicLogger logger) {
_logger = logger;
@ -74,6 +75,15 @@ namespace CriticalPathAnalyzer.Client.Tool {
}
}
public static void DisplayLoop() {
if (_response == null) {
_logger.Error("Got no response - cannot display loop");
return;
}
PathHighLighter.RemoveHighLighting();
PathHighLighter.HighlightWires(_response.LoopingClusters);
}
private static void CalculateCriticalPath() {
if (_startPegAddress == null || _endPegAddress == null) {
_logger.Error("Invalid pegs");
@ -88,17 +98,19 @@ namespace CriticalPathAnalyzer.Client.Tool {
});
}
public static void Highlight(AnalyzePathResponse response) {
public static void HandleResponse(AnalyzePathResponse response) {
if (_currentRequestGuid != response.RequestGuid) {
// Not matching Guid, old or wrong request, discard.
_logger.Warn("Got response to wrong request, discarding");
return;
}
_logger.Info($"Critical path length is: {response.CriticalPathLength}");
_response = response;
_logger.Info($"Critical path length is: {_response.CriticalPathLength}");
PathHighLighter.RemoveHighLighting();
PathHighLighter.HighlightWires(response);
PathHighLighter.HighlightWires(_response.Clusters);
}
}
}

@ -16,8 +16,8 @@ namespace CriticalPathAnalyzer.Client.Tool {
private static List<ComponentAddress> _highlightedComponents = new List<ComponentAddress>();
private static List<WireAddress> _highlightedWires = new List<WireAddress>();
public static void HighlightWires(AnalyzePathResponse response) {
_clusters = response.Clusters;
public static void HighlightWires(List<ClusterDetails> clusters) {
_clusters = clusters;
foreach (ClusterDetails clusterDetails in _clusters) {
HighlightCluster(clusterDetails, Color);

@ -11,8 +11,9 @@ namespace CriticalPathAnalyzer.Shared.Packets.S2C {
[Key(1)] public List<ClusterDetails> Clusters;
[Key(2)] public int CriticalPathLength;
// [Key(3)] public List<ComponentAddress> PerimeterComponents;
// [Key(4)] public List<ClusterDetails> NextClusters;
[Key(3)] public List<ClusterDetails> LoopingClusters;
// [Key(4)] public List<ComponentAddress> PerimeterComponents;
// [Key(5)] public List<ClusterDetails> NextClusters;
}
[MessagePackObject]

Loading…
Cancel
Save