mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-14 20:54:17 +01:00
Add experimental automation condition for gearsets.
This commit is contained in:
parent
c11bd629da
commit
dd42b7ab7f
7 changed files with 185 additions and 32 deletions
|
|
@ -306,6 +306,7 @@ public class AutoDesignManager : ISavable, IReadOnlyList<AutoDesignSet>, IDispos
|
|||
return;
|
||||
|
||||
var design = set.Designs[which];
|
||||
|
||||
if (design.Jobs.Id == jobs.Id)
|
||||
return;
|
||||
|
||||
|
|
@ -316,6 +317,22 @@ public class AutoDesignManager : ISavable, IReadOnlyList<AutoDesignSet>, IDispos
|
|||
_event.Invoke(AutomationChanged.Type.ChangedConditions, set, (which, old, jobs));
|
||||
}
|
||||
|
||||
public void ChangeGearsetCondition(AutoDesignSet set, int which, short index)
|
||||
{
|
||||
if (which >= set.Designs.Count || which < 0)
|
||||
return;
|
||||
|
||||
var design = set.Designs[which];
|
||||
if (design.GearsetIndex == index)
|
||||
return;
|
||||
|
||||
var old = design.GearsetIndex;
|
||||
design.GearsetIndex = index;
|
||||
Save();
|
||||
Glamourer.Log.Debug($"Changed gearset condition from {old} to {index} for associated design {which + 1} in design set.");
|
||||
_event.Invoke(AutomationChanged.Type.ChangedConditions, set, (which, old, index));
|
||||
}
|
||||
|
||||
public void ChangeApplicationType(AutoDesignSet set, int which, AutoDesign.Type type)
|
||||
{
|
||||
if (which >= set.Designs.Count || which < 0)
|
||||
|
|
@ -338,10 +355,8 @@ public class AutoDesignManager : ISavable, IReadOnlyList<AutoDesignSet>, IDispos
|
|||
|
||||
public void Save(StreamWriter writer)
|
||||
{
|
||||
using var j = new JsonTextWriter(writer)
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
};
|
||||
using var j = new JsonTextWriter(writer);
|
||||
j.Formatting = Formatting.Indented;
|
||||
Serialize().WriteTo(j);
|
||||
}
|
||||
|
||||
|
|
@ -456,13 +471,16 @@ public class AutoDesignManager : ISavable, IReadOnlyList<AutoDesignSet>, IDispos
|
|||
{
|
||||
if (designIdentifier.Length == 0)
|
||||
{
|
||||
Glamourer.Messager.NotificationMessage($"Error parsing automatically applied design for set {setName}: No design specified.", NotificationType.Warning);
|
||||
Glamourer.Messager.NotificationMessage($"Error parsing automatically applied design for set {setName}: No design specified.",
|
||||
NotificationType.Warning);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Guid.TryParse(designIdentifier, out var guid))
|
||||
{
|
||||
Glamourer.Messager.NotificationMessage($"Error parsing automatically applied design for set {setName}: {designIdentifier} is not a valid GUID.", NotificationType.Warning);
|
||||
Glamourer.Messager.NotificationMessage(
|
||||
$"Error parsing automatically applied design for set {setName}: {designIdentifier} is not a valid GUID.",
|
||||
NotificationType.Warning);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
@ -471,7 +489,8 @@ public class AutoDesignManager : ISavable, IReadOnlyList<AutoDesignSet>, IDispos
|
|||
if (design == null)
|
||||
{
|
||||
Glamourer.Messager.NotificationMessage(
|
||||
$"Error parsing automatically applied design for set {setName}: The specified design {guid} does not exist.", NotificationType.Warning);
|
||||
$"Error parsing automatically applied design for set {setName}: The specified design {guid} does not exist.",
|
||||
NotificationType.Warning);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -483,24 +502,31 @@ public class AutoDesignManager : ISavable, IReadOnlyList<AutoDesignSet>, IDispos
|
|||
Design = design,
|
||||
ApplicationType = applicationType & AutoDesign.Type.All,
|
||||
};
|
||||
return ParseConditions(setName, jObj, ret) ? ret : null;
|
||||
}
|
||||
|
||||
private bool ParseConditions(string setName, JObject jObj, AutoDesign ret)
|
||||
{
|
||||
var conditions = jObj["Conditions"];
|
||||
if (conditions == null)
|
||||
return ret;
|
||||
return true;
|
||||
|
||||
var jobs = conditions["JobGroup"]?.ToObject<int>() ?? -1;
|
||||
if (jobs >= 0)
|
||||
{
|
||||
if (!_jobs.JobGroups.TryGetValue((ushort)jobs, out var jobGroup))
|
||||
{
|
||||
Glamourer.Messager.NotificationMessage($"Error parsing automatically applied design for set {setName}: The job condition {jobs} does not exist.", NotificationType.Warning);
|
||||
return null;
|
||||
Glamourer.Messager.NotificationMessage(
|
||||
$"Error parsing automatically applied design for set {setName}: The job condition {jobs} does not exist.",
|
||||
NotificationType.Warning);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret.Jobs = jobGroup;
|
||||
}
|
||||
|
||||
return ret;
|
||||
ret.GearsetIndex = conditions["Gearset"]?.ToObject<short>() ?? -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Save()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue