- fix: borer ui
This commit is contained in:
@@ -44,6 +44,8 @@ public sealed class ReagentUIController : UIController, IOnSystemChanged<Actions
|
|||||||
CommandBinds.Builder
|
CommandBinds.Builder
|
||||||
.Bind(ContentKeyFunctions.OpenActionsMenu, InputCmdHandler.FromDelegate(_ => OpenWindow()))
|
.Bind(ContentKeyFunctions.OpenActionsMenu, InputCmdHandler.FromDelegate(_ => OpenWindow()))
|
||||||
.Register<ReagentWindow>();
|
.Register<ReagentWindow>();
|
||||||
|
|
||||||
|
_reagentsLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UnloadGui()
|
private void UnloadGui()
|
||||||
@@ -55,6 +57,7 @@ public sealed class ReagentUIController : UIController, IOnSystemChanged<Actions
|
|||||||
}
|
}
|
||||||
|
|
||||||
CommandBinds.Unregister<ReagentWindow>();
|
CommandBinds.Unregister<ReagentWindow>();
|
||||||
|
_reagentsLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInjectReagent(string protoId, int cost)
|
private void OnInjectReagent(string protoId, int cost)
|
||||||
@@ -68,24 +71,28 @@ public sealed class ReagentUIController : UIController, IOnSystemChanged<Actions
|
|||||||
if (_window == null || _window.IsOpen || !ent.HasValue)
|
if (_window == null || _window.IsOpen || !ent.HasValue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!_reagentsLoaded)
|
var entManager = IoCManager.Resolve<EntityManager>();
|
||||||
|
if (entManager.HasComponent<InfestedBorerComponent>(ent))
|
||||||
{
|
{
|
||||||
foreach (var reagent in _borerSystem.GetReagents(ent.Value))
|
if (!_reagentsLoaded)
|
||||||
{
|
{
|
||||||
var button = new Button();
|
foreach (var reagent in _borerSystem.GetReagents(ent.Value))
|
||||||
button.Text = Loc.GetString("borer-ui-secrete-inject-label",
|
{
|
||||||
("reagent", Loc.GetString("reagent-name-" +
|
var button = new Button();
|
||||||
reagent.Key.ToLower().Replace("spacedrugs", "space-drugs"))),
|
button.Text = Loc.GetString("borer-ui-secrete-inject-label",
|
||||||
("cost", reagent.Value));
|
("reagent", Loc.GetString("reagent-name-" +
|
||||||
|
reagent.Key.ToLower().Replace("spacedrugs", "space-drugs"))),
|
||||||
|
("cost", reagent.Value));
|
||||||
|
|
||||||
button.OnPressed += _ => OnInjectReagent(reagent.Key, reagent.Value);
|
button.OnPressed += _ => OnInjectReagent(reagent.Key, reagent.Value);
|
||||||
_window.MainContainer.AddChild(button);
|
_window.MainContainer.AddChild(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
_reagentsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_reagentsLoaded = true;
|
_window.Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
_window.Open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSystemLoaded(ActionsSystem system)
|
public void OnSystemLoaded(ActionsSystem system)
|
||||||
|
|||||||
Reference in New Issue
Block a user