feat: add opacity slider
This commit is contained in:
parent
d669ba8db0
commit
2d7039deae
@ -16,6 +16,7 @@ internal class Configuration : IPluginConfiguration {
|
|||||||
public bool CanResize = true;
|
public bool CanResize = true;
|
||||||
public bool ShowTitleBar;
|
public bool ShowTitleBar;
|
||||||
public float FontSize = 17f;
|
public float FontSize = 17f;
|
||||||
|
public float WindowAlpha = 1f;
|
||||||
public Dictionary<ChatType, uint> ChatColours = new();
|
public Dictionary<ChatType, uint> ChatColours = new();
|
||||||
public List<Tab> Tabs = new();
|
public List<Tab> Tabs = new();
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ internal class Configuration : IPluginConfiguration {
|
|||||||
this.CanResize = other.CanResize;
|
this.CanResize = other.CanResize;
|
||||||
this.ShowTitleBar = other.ShowTitleBar;
|
this.ShowTitleBar = other.ShowTitleBar;
|
||||||
this.FontSize = other.FontSize;
|
this.FontSize = other.FontSize;
|
||||||
|
this.WindowAlpha = other.WindowAlpha;
|
||||||
this.ChatColours = other.ChatColours.ToDictionary(entry => entry.Key, entry => entry.Value);
|
this.ChatColours = other.ChatColours.ToDictionary(entry => entry.Key, entry => entry.Value);
|
||||||
this.Tabs = other.Tabs.Select(t => t.Clone()).ToList();
|
this.Tabs = other.Tabs.Select(t => t.Clone()).ToList();
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,8 @@ internal sealed class ChatLog : IUiComponent {
|
|||||||
- ImGui.GetStyle().ItemSpacing.Y * 4;
|
- ImGui.GetStyle().ItemSpacing.Y * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private unsafe ImGuiViewport* _lastViewport;
|
||||||
|
|
||||||
public unsafe void Draw() {
|
public unsafe void Draw() {
|
||||||
var flags = ImGuiWindowFlags.None;
|
var flags = ImGuiWindowFlags.None;
|
||||||
if (!this.Ui.Plugin.Config.CanMove) {
|
if (!this.Ui.Plugin.Config.CanMove) {
|
||||||
@ -110,11 +112,18 @@ internal sealed class ChatLog : IUiComponent {
|
|||||||
flags |= ImGuiWindowFlags.NoTitleBar;
|
flags |= ImGuiWindowFlags.NoTitleBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._lastViewport == ImGuiHelpers.MainViewport.NativePtr) {
|
||||||
|
ImGui.SetNextWindowBgAlpha(this.Ui.Plugin.Config.WindowAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ImGui.Begin($"{this.Ui.Plugin.Name}##chat", flags)) {
|
if (!ImGui.Begin($"{this.Ui.Plugin.Name}##chat", flags)) {
|
||||||
|
this._lastViewport = ImGui.GetWindowViewport().NativePtr;
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._lastViewport = ImGui.GetWindowViewport().NativePtr;
|
||||||
|
|
||||||
var currentTab = this.Ui.Plugin.Config.SidebarTabView
|
var currentTab = this.Ui.Plugin.Config.SidebarTabView
|
||||||
? this.DrawTabSidebar()
|
? this.DrawTabSidebar()
|
||||||
: this.DrawTabBar();
|
: this.DrawTabBar();
|
||||||
|
@ -21,7 +21,18 @@ internal sealed class Display : ISettingsTab {
|
|||||||
ImGui.Checkbox("More compact modern layout", ref this.Mutable.MoreCompactPretty);
|
ImGui.Checkbox("More compact modern layout", ref this.Mutable.MoreCompactPretty);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.DragFloat("Font size", ref this.Mutable.FontSize, .0125f, 12f, 36f, "%.1f");
|
ImGui.DragFloat("Font size", ref this.Mutable.FontSize, .0125f, 12f, 36f, $"{this.Mutable.FontSize:N1}");
|
||||||
|
if (ImGui.DragFloat("Window opacity", ref this.Mutable.WindowAlpha, .0025f, 0f, 1f, $"{this.Mutable.WindowAlpha * 100f:N2}%%")) {
|
||||||
|
switch (this.Mutable.WindowAlpha) {
|
||||||
|
case > 1f and <= 100f:
|
||||||
|
this.Mutable.WindowAlpha /= 100f;
|
||||||
|
break;
|
||||||
|
case < 0f or > 100f:
|
||||||
|
this.Mutable.WindowAlpha = 1f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.Checkbox("Allow moving main window", ref this.Mutable.CanMove);
|
ImGui.Checkbox("Allow moving main window", ref this.Mutable.CanMove);
|
||||||
ImGui.Checkbox("Allow resizing main window", ref this.Mutable.CanResize);
|
ImGui.Checkbox("Allow resizing main window", ref this.Mutable.CanResize);
|
||||||
ImGui.Checkbox("Show title bar for main window", ref this.Mutable.ShowTitleBar);
|
ImGui.Checkbox("Show title bar for main window", ref this.Mutable.ShowTitleBar);
|
||||||
|
Loading…
Reference in New Issue
Block a user