Skip to content

Commit

Permalink
Add config option ChatWindowOpacity
Browse files Browse the repository at this point in the history
  • Loading branch information
starfi5h committed Dec 14, 2023
1 parent dd2cc40 commit 35b4dc2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions NebulaModel/MultiplayerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public class MultiplayerOptions : ICloneable
[Description("Configure which type of IP should be used by Discord RPC")]
public IPUtils.IPConfiguration IPConfiguration { get; set; }

[DisplayName("Cleanup inactive sessions"), Category("Network")]
[Description("If disabled the underlying networking library will not cleanup inactive connections. This might solve issues with clients randomly disconnecting and hosts having a 'System.ObjectDisposedException'.")]
public bool CleanupInactiveSessions { get; set; } = false;

[DisplayName("Show Lobby Hints")]
public bool ShowLobbyHints { get; set; } = true;

Expand Down Expand Up @@ -111,11 +115,12 @@ public bool StreamerMode {
public ChatSize DefaultChatSize { get; set; } = ChatSize.Medium;

[DisplayName("Notification duration"), Category("Chat")]
[Description("How long should the active message stay on the screen in seconds")]
public int NotificationDuration { get; set; } = 15;

[DisplayName("Cleanup inactive sessions"), Category("Network")]
[Description("If disabled the underlying networking library will not cleanup inactive connections. This might solve issues with clients randomly disconnecting and hosts having a 'System.ObjectDisposedException'.")]
public bool CleanupInactiveSessions { get; set; } = true;
[DisplayName("Chat Window Opacity"), Category("Chat")]
[UIRange(0f, 1.0f, true)]
public float ChatWindowOpacity { get; set; } = 0.8f;

// Detail function group buttons
public bool PowerGridEnabled { get; set; } = false;
Expand Down
9 changes: 9 additions & 0 deletions NebulaWorld/MonoBehaviours/Local/Chat/ChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
using NebulaModel.Utils;
using System;
using UnityEngine;
using UnityEngine.UI;

namespace NebulaWorld.MonoBehaviours.Local
{
public class ChatManager : MonoBehaviour
{
private ChatWindow chatWindow;
private Image backgroundImage;
public static ChatManager Instance;

private void Awake()
Expand All @@ -33,6 +35,12 @@ private void Awake()

trans.sizeDelta = defaultSize;
trans.anchoredPosition = defaultPos;

// TODO: Fix ChatV2.prefab to get rid of warnings
GameObject backgroundGo = chatGo.transform.Find("Main/background").gameObject;
DestroyImmediate(backgroundGo.GetComponent<TranslucentImage>());
backgroundImage = backgroundGo.AddComponent<Image>();
backgroundImage.color = new Color(0f, 0f, 0f, options.ChatWindowOpacity);
}

chatWindow = chatGo.transform.GetComponentInChildren<ChatWindow>();
Expand All @@ -56,6 +64,7 @@ public static void UpdateChatPosition()
RectTransform trans = (RectTransform)Instance.chatWindow.transform;
trans.anchoredPosition = defaultPos;
trans.sizeDelta = defaultSize;
Instance.backgroundImage.color = new Color(0f, 0f, 0f, options.ChatWindowOpacity);
}

void Update()
Expand Down

0 comments on commit 35b4dc2

Please sign in to comment.