Skip to content

Commit

Permalink
Allow creating new plans from module viewer.
Browse files Browse the repository at this point in the history
  • Loading branch information
awgil committed Jul 6, 2024
1 parent 929b062 commit a535681
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion BossMod/Config/ConfigUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ConfigUI(ConfigRoot config, WorldState ws, RotationDatabase? rotationDB)
{
_root = config;
_ws = ws;
_mv = new(rotationDB?.Plans);
_mv = new(rotationDB?.Plans, ws);
_presets = rotationDB != null ? new(rotationDB.Presets) : null;
_tabs.Add("Configs", () => DrawNodes(_roots));
_tabs.Add("Modules", () => _mv.Draw(_tree, _ws));
Expand Down
19 changes: 16 additions & 3 deletions BossMod/Config/ModuleViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ private record struct ModuleGroupInfo(string Name, uint Id, uint SortOrder, uint
private record struct ModuleGroup(ModuleGroupInfo Info, List<ModuleInfo> Modules);

private readonly PlanDatabase? _planDB;
private readonly WorldState _ws; // TODO: reconsider...

private BitMask _filterExpansions;
private BitMask _filterCategories;
Expand All @@ -29,9 +30,10 @@ private record struct ModuleGroup(ModuleGroupInfo Info, List<ModuleInfo> Modules
private readonly List<ModuleGroup>[,] _groups;
private readonly Vector2 _iconSize = new(30, 30);

public ModuleViewer(PlanDatabase? planDB)
public ModuleViewer(PlanDatabase? planDB, WorldState ws)
{
_planDB = planDB;
_ws = ws;

uint defaultIcon = 61762;
_expansions = Enum.GetNames<BossModuleInfo.Expansion>().Take((int)BossModuleInfo.Expansion.Count).Select(n => (n, defaultIcon)).ToArray();
Expand Down Expand Up @@ -308,9 +310,10 @@ private string ModuleHelpText(ModuleInfo info)

private void ModulePlansPopup(ModuleRegistry.Info info)
{
if (_planDB == null || !_planDB.Plans.TryGetValue(info.ModuleType, out var mplans))
if (_planDB == null)
return;

var mplans = _planDB.Plans.GetOrAdd(info.ModuleType);
foreach (var (cls, plans) in mplans)
{
foreach (var plan in plans.Plans)
Expand All @@ -322,6 +325,16 @@ private void ModulePlansPopup(ModuleRegistry.Info info)
}
}

// TODO: new plan ui
var player = _ws.Party.Player();
if (player != null)
{
if (ImGui.Selectable($"New plan for {player.Class}..."))
{
var plans = mplans.GetOrAdd(player.Class);
var plan = new Plan($"New {plans.Plans.Count + 1}", info.ModuleType) { Guid = Guid.NewGuid().ToString(), Class = player.Class, Level = info.PlanLevel };
_planDB.ModifyPlan(null, plan);
UIPlanDatabaseEditor.StartPlanEditor(_planDB, plan);
}
}
}
}

0 comments on commit a535681

Please sign in to comment.