Add new draw events.

This commit is contained in:
Ottermandias 2024-03-22 00:45:52 +01:00
parent 8fded88813
commit 5ea140db98
8 changed files with 88 additions and 7 deletions

View file

@ -32,9 +32,14 @@ public class ModPanelHeader : IDisposable
/// </summary>
public void Draw()
{
var offset = DrawModName();
DrawVersion(offset);
DrawSecondRow(offset);
using (ImRaii.Group())
{
var offset = DrawModName();
DrawVersion(offset);
DrawSecondRow(offset);
}
_communicator.PreSettingsTabBarDraw.Invoke(_mod.Identifier, ImGui.GetItemRectSize().X, _nameWidth);
}
/// <summary>
@ -43,6 +48,7 @@ public class ModPanelHeader : IDisposable
/// </summary>
public void UpdateModData(Mod mod)
{
_mod = mod;
// Name
var name = $" {mod.Name} ";
if (name != _modName)
@ -90,6 +96,7 @@ public class ModPanelHeader : IDisposable
}
// Header data.
private Mod _mod = null!;
private string _modName = string.Empty;
private string _modAuthor = string.Empty;
private string _modVersion = string.Empty;
@ -103,6 +110,8 @@ public class ModPanelHeader : IDisposable
private float _modWebsiteButtonWidth;
private float _secondRowWidth;
private float _nameWidth;
/// <summary>
/// Draw the mod name in the game font with a 2px border, centered,
/// with at least the width of the version space to each side.
@ -124,6 +133,7 @@ public class ModPanelHeader : IDisposable
using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, 2 * UiHelpers.Scale);
using var f = _nameFont.Push();
ImGuiUtil.DrawTextButton(_modName, Vector2.Zero, 0);
_nameWidth = ImGui.GetItemRectSize().X;
return offset;
}

View file

@ -61,7 +61,7 @@ public class ModPanelSettingsTab : ITab
DrawInheritedWarning();
UiHelpers.DefaultLineSpace();
_communicator.PreSettingsPanelDraw.Invoke(_selector.Selected!.ModPath.Name);
_communicator.PreSettingsPanelDraw.Invoke(_selector.Selected!.Identifier);
DrawEnabledInput();
_tutorial.OpenTutorial(BasicTutorialSteps.EnablingMods);
ImGui.SameLine();
@ -69,6 +69,8 @@ public class ModPanelSettingsTab : ITab
_tutorial.OpenTutorial(BasicTutorialSteps.Priority);
DrawRemoveSettings();
_communicator.PostEnabledDraw.Invoke(_selector.Selected!.Identifier);
if (_selector.Selected!.Groups.Count > 0)
{
var useDummy = true;
@ -98,7 +100,7 @@ public class ModPanelSettingsTab : ITab
}
UiHelpers.DefaultLineSpace();
_communicator.PostSettingsPanelDraw.Invoke(_selector.Selected!.ModPath.Name);
_communicator.PostSettingsPanelDraw.Invoke(_selector.Selected!.Identifier);
}
/// <summary> Draw a big red bar if the current setting is inherited. </summary>