refactor: store alpha as [0, 100]
This commit is contained in:
@@ -8,7 +8,7 @@ namespace ChatTwo;
|
|||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
internal class Configuration : IPluginConfiguration {
|
internal class Configuration : IPluginConfiguration {
|
||||||
private const int LatestVersion = 3;
|
private const int LatestVersion = 4;
|
||||||
|
|
||||||
public int Version { get; set; } = LatestVersion;
|
public int Version { get; set; } = LatestVersion;
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ internal class Configuration : IPluginConfiguration {
|
|||||||
public string GlobalFont = Fonts.GlobalFonts[0].Name;
|
public string GlobalFont = Fonts.GlobalFonts[0].Name;
|
||||||
public string JapaneseFont = Fonts.JapaneseFonts[0].Item1;
|
public string JapaneseFont = Fonts.JapaneseFonts[0].Item1;
|
||||||
|
|
||||||
public float WindowAlpha = 1f;
|
public float WindowAlpha = 100f;
|
||||||
public Dictionary<ChatType, uint> ChatColours = new();
|
public Dictionary<ChatType, uint> ChatColours = new();
|
||||||
public List<Tab> Tabs = new();
|
public List<Tab> Tabs = new();
|
||||||
|
|
||||||
@@ -97,6 +97,11 @@ internal class Configuration : IPluginConfiguration {
|
|||||||
this.JapaneseFontSize = this.FontSize;
|
this.JapaneseFontSize = this.FontSize;
|
||||||
this.SymbolsFontSize = this.FontSize;
|
this.SymbolsFontSize = this.FontSize;
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
|
this.Version = 4;
|
||||||
|
|
||||||
|
this.WindowAlpha *= 100f;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
PluginLog.Warning($"Couldn't migrate config version {this.Version}");
|
PluginLog.Warning($"Couldn't migrate config version {this.Version}");
|
||||||
loop = false;
|
loop = false;
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ internal sealed class ChatLog : IUiComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this._lastViewport == ImGuiHelpers.MainViewport.NativePtr) {
|
if (this._lastViewport == ImGuiHelpers.MainViewport.NativePtr) {
|
||||||
ImGui.SetNextWindowBgAlpha(this.Ui.Plugin.Config.WindowAlpha);
|
ImGui.SetNextWindowBgAlpha(this.Ui.Plugin.Config.WindowAlpha / 100f);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SetNextWindowSize(new Vector2(500, 250) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver);
|
ImGui.SetNextWindowSize(new Vector2(500, 250) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver);
|
||||||
@@ -880,8 +880,8 @@ internal sealed class ChatLog : IUiComponent {
|
|||||||
flags |= ImGuiWindowFlags.NoTitleBar;
|
flags |= ImGuiWindowFlags.NoTitleBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
var alpha = tab.IndependentOpacity ? tab.Opacity / 100f : this.Ui.Plugin.Config.WindowAlpha;
|
var alpha = tab.IndependentOpacity ? tab.Opacity : this.Ui.Plugin.Config.WindowAlpha;
|
||||||
ImGui.SetNextWindowBgAlpha(alpha);
|
ImGui.SetNextWindowBgAlpha(alpha / 100f);
|
||||||
ImGui.SetNextWindowSize(new Vector2(350, 350) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver);
|
ImGui.SetNextWindowSize(new Vector2(350, 350) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver);
|
||||||
if (!ImGui.Begin($"{tab.Name}##popout", ref tab.PopOut, flags)) {
|
if (!ImGui.Begin($"{tab.Name}##popout", ref tab.PopOut, flags)) {
|
||||||
goto End;
|
goto End;
|
||||||
|
|||||||
@@ -68,16 +68,8 @@ internal sealed class Display : ISettingsTab {
|
|||||||
ImGuiUtil.OptionCheckbox(ref this.Mutable.ShowNoviceNetwork, Language.Options_ShowNoviceNetwork_Name, Language.Options_ShowNoviceNetwork_Description);
|
ImGuiUtil.OptionCheckbox(ref this.Mutable.ShowNoviceNetwork, Language.Options_ShowNoviceNetwork_Name, Language.Options_ShowNoviceNetwork_Description);
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
if (ImGuiUtil.DragFloatVertical(Language.Options_WindowOpacity_Name, ref this.Mutable.WindowAlpha, .0025f, 0f, 1f, $"{this.Mutable.WindowAlpha * 100f:N2}%%")) {
|
ImGuiUtil.DragFloatVertical(Language.Options_WindowOpacity_Name, ref this.Mutable.WindowAlpha, .25f, 0f, 100f, $"{this.Mutable.WindowAlpha:N2}%%", ImGuiSliderFlags.AlwaysClamp);
|
||||||
switch (this.Mutable.WindowAlpha) {
|
ImGui.Spacing();
|
||||||
case > 1f and <= 100f:
|
|
||||||
this.Mutable.WindowAlpha /= 100f;
|
|
||||||
break;
|
|
||||||
case < 0f or > 100f:
|
|
||||||
this.Mutable.WindowAlpha = 1f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGuiUtil.OptionCheckbox(ref this.Mutable.CanMove, Language.Options_CanMove_Name);
|
ImGuiUtil.OptionCheckbox(ref this.Mutable.CanMove, Language.Options_CanMove_Name);
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ internal sealed class Tabs : ISettingsTab {
|
|||||||
if (tab.PopOut) {
|
if (tab.PopOut) {
|
||||||
ImGui.Checkbox(Language.Options_Tabs_IndependentOpacity, ref tab.IndependentOpacity);
|
ImGui.Checkbox(Language.Options_Tabs_IndependentOpacity, ref tab.IndependentOpacity);
|
||||||
if (tab.IndependentOpacity) {
|
if (tab.IndependentOpacity) {
|
||||||
ImGuiUtil.DragFloatVertical(Language.Options_Tabs_Opacity, ref tab.Opacity, 0.1f, 0f, 100f);
|
ImGuiUtil.DragFloatVertical(Language.Options_Tabs_Opacity, ref tab.Opacity, 0.25f, 0f, 100f, $"{tab.Opacity:N2}%%", ImGuiSliderFlags.AlwaysClamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user