1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-02-04 13:12:17 +08:00

minor fix

This commit is contained in:
2026-01-27 23:31:16 +08:00
parent aa775bd05f
commit 71c0fe75db
3 changed files with 61 additions and 48 deletions

View File

@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Newtonsoft.Json.Linq;
using NLua;
using OBSWebsocketDotNet;
@@ -50,6 +48,7 @@ public class LuaScriptEngine : BaseUnityPlugin
private readonly long _repeatInterval = repeatInterval;
private long _nextTick = GameMain.gameTick + startInterval;
}
public new static readonly ManualLogSource Logger =
BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME);
@@ -98,31 +97,30 @@ public class LuaScriptEngine : BaseUnityPlugin
break;
}
};
LuaState["add_timer"] = Timer(LuaFunction func, long firstInterval, long repeatInterval) =>
LuaState["add_timer"] = Timer (LuaFunction func, long firstInterval, long repeatInterval) =>
{
var timer = new Timer(func, firstInterval, repeatInterval);
Timers.Add(timer);
return timer;
};
LuaState["remove_timer"] = void (Timer timer) =>
{
Timers.Remove(timer);
};
LuaState["remove_timer"] = void (Timer timer) => { Timers.Remove(timer); };
LuaState["obs_connect"] = void (string server, string password) =>
{
_obs.Connected += (sender, e) =>
_obs.Connected += (_, _) =>
{
Logger.LogDebug("Connected to OBS");
foreach (var (sourceName, text) in _scheduledText)
{
_obs.SetInputSettings(sourceName,
new JObject {
{"text", text}
new JObject
{
{ "text", text }
});
}
_scheduledText.Clear();
};
_obs.Disconnected += (sender, e) =>
_obs.Disconnected += (_, _) =>
{
Logger.LogDebug("Disconnected from OBS");
_obs.ConnectAsync(server, password);
@@ -135,8 +133,9 @@ public class LuaScriptEngine : BaseUnityPlugin
{
try
{
_obs.SetInputSettings(sourceName, new JObject {
{"text", text}
_obs.SetInputSettings(sourceName, new JObject
{
{ "text", text }
});
}
catch (Exception e)
@@ -162,6 +161,7 @@ public class LuaScriptEngine : BaseUnityPlugin
Logger.LogInfo($"Loading Lua script: {file}");
LuaState.DoFile(file);
}
_harmony = Harmony.CreateAndPatchAll(typeof(Patches));
}
@@ -215,12 +215,14 @@ public class LuaScriptEngine : BaseUnityPlugin
if (timer == null || !timer.Check(gameTick)) continue;
TimersToRemove.Add(timer);
}
if (TimersToRemove.Count > 0)
{
foreach (var timer in TimersToRemove)
{
Timers.Remove(timer);
}
TimersToRemove.Clear();
}
}
@@ -247,14 +249,17 @@ public class LuaScriptEngine : BaseUnityPlugin
TimersToRemove.Add(timer);
}
}
if (TimersToRemove.Count > 0)
{
foreach (var timer in TimersToRemove)
{
Timers.Remove(timer);
}
TimersToRemove.Clear();
}
LoopCall(PreGameBeginFuncs);
}

View File

@@ -464,6 +464,16 @@ public class GamePatch : PatchImpl<GamePatch>
_needConvert = true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameHistoryData), nameof(GameHistoryData.Import))]
private static void GameHistoryData_Import_Postfix(GameHistoryData __instance)
{
if (_needConvert)
{
__instance.combatSettings = UIRoot.instance.galaxySelect.uiCombat.combatSettings;
}
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(GameData), nameof(GameData.Import))]
private static IEnumerable<CodeInstruction> GameData_Import_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)

View File

@@ -12,35 +12,25 @@ public class MyKeyBinder : MonoBehaviour
private ConfigEntry<KeyboardShortcut> _config;
protected event Action OnFree;
[SerializeField]
public Text functionText;
[SerializeField] public Text functionText;
[SerializeField]
public Text keyText;
[SerializeField] public Text keyText;
[SerializeField]
public InputField setTheKeyInput;
[SerializeField] public InputField setTheKeyInput;
[SerializeField]
public Toggle setTheKeyToggle;
[SerializeField] public Toggle setTheKeyToggle;
[SerializeField]
public RectTransform rectTrans;
[SerializeField] public RectTransform rectTrans;
[SerializeField]
public UIButton inputUIButton;
[SerializeField] public UIButton inputUIButton;
[SerializeField]
public Text conflictText;
[SerializeField] public Text conflictText;
[SerializeField]
public Text waitingText;
[SerializeField] public Text waitingText;
[SerializeField]
public UIButton setDefaultUIButton;
[SerializeField] public UIButton setDefaultUIButton;
[SerializeField]
public UIButton setNoneKeyUIButton;
[SerializeField] public UIButton setNoneKeyUIButton;
private bool _nextNotOn;
@@ -135,10 +125,12 @@ public class MyKeyBinder : MonoBehaviour
VFInput.UseEscape();
return true;
}
if (Input.GetKey(KeyCode.Mouse0) || Input.GetKey(KeyCode.Mouse1))
{
return true;
}
var anyKey = GetIunptKeys();
if (anyKey || _lastKey == KeyCode.None) return false;
var k = GetPressedKey();
@@ -146,20 +138,24 @@ public class MyKeyBinder : MonoBehaviour
{
return false;
}
_lastKey = KeyCode.None;
_config.Value = KeyboardShortcut.Deserialize(k);
//keyText.text = k;
return true;
}
private KeyCode _lastKey;
private static readonly KeyCode[] ModKeys = { KeyCode.RightShift, KeyCode.LeftShift,
private static readonly KeyCode[] ModKeys =
[
KeyCode.RightShift, KeyCode.LeftShift,
KeyCode.RightControl, KeyCode.LeftControl,
KeyCode.RightAlt, KeyCode.LeftAlt,
KeyCode.LeftCommand, KeyCode.LeftApple, KeyCode.LeftWindows,
KeyCode.RightCommand, KeyCode.RightApple, KeyCode.RightWindows };
KeyCode.RightCommand, KeyCode.RightApple, KeyCode.RightWindows
];
private string GetPressedKey()
{
@@ -168,6 +164,7 @@ public class MyKeyBinder : MonoBehaviour
{
return null;
}
var mod = "";
foreach (var modKey in ModKeys)
{
@@ -181,6 +178,7 @@ public class MyKeyBinder : MonoBehaviour
{
key += mod;
}
return key;
}
@@ -195,8 +193,8 @@ public class MyKeyBinder : MonoBehaviour
_lastKey = item;
anyKey = true;
}
return anyKey;
return anyKey;
}
public void Reset()