Skip to content

Commit

Permalink
Remove dependency of CommonAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
starfi5h committed Dec 14, 2023
1 parent 525ffac commit 40e687d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 27 deletions.
7 changes: 6 additions & 1 deletion NebulaModel/MultiplayerOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NebulaAPI;
using BepInEx.Configuration;
using NebulaAPI;
using NebulaModel.Attributes;
using NebulaModel.DataStructures;
using NebulaModel.Utils;
Expand Down Expand Up @@ -89,6 +90,10 @@ public bool StreamerMode {
}
}

[DisplayName("Chat Hotkey"), Category("Chat")]
[Description("Keyboard shortcut to toggle the chat window")]
public KeyboardShortcut ChatHotkey { get; set; } = new KeyboardShortcut(KeyCode.BackQuote, KeyCode.LeftAlt);

[DisplayName("Auto Open Chat"), Category("Chat")]
[Description("Auto open chat window when receiving message from other players")]
public bool AutoOpenChat { get; set; } = true;
Expand Down
3 changes: 1 addition & 2 deletions NebulaPatcher/MonoBehaviours/NebulaBootstrapper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommonAPI.Systems;
using NebulaWorld;
using NebulaWorld;
using UnityEngine;

namespace NebulaPatcher.MonoBehaviours
Expand Down
19 changes: 1 addition & 18 deletions NebulaPatcher/NebulaPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using BepInEx;
using CommonAPI;
using CommonAPI.Systems;
using HarmonyLib;
using NebulaAPI;
using NebulaModel.Logger;
Expand All @@ -20,8 +18,7 @@
namespace NebulaPatcher
{
[BepInPlugin(PluginInfo.PLUGIN_ID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
[BepInDependency(CommonAPIPlugin.GUID)]
[CommonAPISubmoduleDependency(nameof(ProtoRegistry), nameof(CustomKeyBindSystem))]
[BepInDependency("dsp.common - api.CommonAPI", BepInDependency.DependencyFlags.SoftDependency)]
public class NebulaPlugin : BaseUnityPlugin, IMultiplayerMod
{
static int command_ups = 0;
Expand Down Expand Up @@ -176,7 +173,6 @@ private static void Initialize()
{
InitPatches();
AddNebulaBootstrapper();
RegisterKeyBinds();
DiscordManager.Setup(ActivityManager_OnActivityJoin);
}

Expand Down Expand Up @@ -285,19 +281,6 @@ private void Update()
}
}

private static void RegisterKeyBinds()
{
CustomKeyBindSystem.RegisterKeyBind<PressKeyBind>(new BuiltinKey
{
id = 212,
key = new CombineKey((int)KeyCode.BackQuote, CombineKey.ALT_COMB, ECombineKeyAction.OnceClick, false),
conflictGroup = 2052,
name = "NebulaChatWindow",
canOverride = true
});
ProtoRegistry.RegisterString("KEYNebulaChatWindow", "Show or Hide Chat Window");
}

private static void InitPatches()
{
Log.Info("Patching Dyson Sphere Program...");
Expand Down
8 changes: 2 additions & 6 deletions NebulaWorld/MonoBehaviours/Local/Chat/ChatManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using CommonAPI;
using CommonAPI.Systems;
using NebulaModel;
using NebulaModel;
using NebulaModel.DataStructures;
using NebulaModel.Logger;
using NebulaModel.Packets.Players;
Expand Down Expand Up @@ -35,8 +33,6 @@ private void Awake()

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

chatGo.GetComponent<UIWindowResize>().minSize = ChatUtils.GetDefaultSize(ChatSize.Small);
}

chatWindow = chatGo.transform.GetComponentInChildren<ChatWindow>();
Expand Down Expand Up @@ -64,7 +60,7 @@ public static void UpdateChatPosition()

void Update()
{
if (CustomKeyBindSystem.GetKeyBind("NebulaChatWindow").keyValue)
if (Config.Options.ChatHotkey.IsDown())
{
chatWindow.Toggle();
}
Expand Down

0 comments on commit 40e687d

Please sign in to comment.