Skip to content

Commit

Permalink
Add backend-specific window title colors
Browse files Browse the repository at this point in the history
  • Loading branch information
karashiiro committed Jul 2, 2021
1 parent 2162505 commit 7e9e948
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions TextToTalk/Backends/Polly/AmazonPollyBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class AmazonPollyBackend : VoiceBackend

public AmazonPollyBackend(PluginConfiguration config)
{
TitleBarColor = ImGui.ColorConvertU32ToFloat4(0xFF0099FF);

var credentials = CredentialManager.GetCredentials(CredentialsTarget);

if (credentials != null)
Expand Down
3 changes: 3 additions & 0 deletions TextToTalk/Backends/VoiceBackend.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System;
using System.Numerics;
using TextToTalk.GameEnums;

namespace TextToTalk.Backends
{
public abstract class VoiceBackend : IDisposable
{
public Vector4 TitleBarColor { get; protected set; }

public abstract void Say(Gender gender, string text);

public abstract void CancelSay();
Expand Down
6 changes: 6 additions & 0 deletions TextToTalk/Backends/VoiceBackendManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Numerics;
using TextToTalk.Backends.Polly;
using TextToTalk.Backends.System;
using TextToTalk.Backends.Websocket;
Expand Down Expand Up @@ -39,6 +40,11 @@ public void SetBackend(TTSBackend backendKind)
this.backend = CreateBackendFor(backendKind);
}

public Vector4 GetBackendTitleBarColor()
{
return this.backend.TitleBarColor;
}

private VoiceBackend CreateBackendFor(TTSBackend backendKind)
{
return backendKind switch
Expand Down
7 changes: 7 additions & 0 deletions TextToTalk/UI/ConfigurationWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public ConfigurationWindow()

public override void Draw(ref bool visible)
{
var titleBarColor = BackendManager.GetBackendTitleBarColor();
ImGui.PushStyleColor(ImGuiCol.TitleBgActive, titleBarColor != default
? titleBarColor
: ImGui.ColorConvertU32ToFloat4(ImGui.GetColorU32(ImGuiCol.TitleBgActive)));

ImGui.SetNextWindowSize(new Vector2(520, 480));
ImGui.Begin("TextToTalk Configuration", ref visible, ImGuiWindowFlags.NoResize);
{
Expand Down Expand Up @@ -56,6 +61,8 @@ public override void Draw(ref bool visible)
ImGui.EndTabBar();
}
ImGui.End();

ImGui.PopStyleColor();
}

private void DrawSynthesizerSettings()
Expand Down

0 comments on commit 7e9e948

Please sign in to comment.