This commit is contained in:
Gurge44 committed 2024-06-21 21:37:35 +02:00
1 parent 9f0837163a
commit 7609876f3e
46 files changed
+569 -74

No files matched your search

+3
View File
@@ -15,12 +15,15 @@
<ItemGroup>
<EmbeddedResource Include=".\Resources\**" />
<EmbeddedResource Remove="SUI\**"/>
</ItemGroup>
<ItemGroup>
<Compile Remove="CTA\**" />
<EmbeddedResource Remove="CTA\**" />
<None Remove="CTA\**" />
<Compile Remove="SUI\**"/>
<None Remove="SUI\**"/>
</ItemGroup>
<ItemGroup>
+2 -4
View File
@@ -1,18 +1,16 @@
using System;
using BepInEx.Configuration;
using UnityEngine;
using Object = UnityEngine.Object;
namespace EHR;
//来源:https://github.com/tukasa0001/TownOfHost/pull/1265
public class ClientOptionItem
{
public ConfigEntry<bool> Config;
public ToggleButtonBehaviour ToggleButton;
public static SpriteRenderer CustomBackground;
private static int numOptions;
public ConfigEntry<bool> Config;
public ToggleButtonBehaviour ToggleButton;
private ClientOptionItem(
string name,
+1 -1
View File
@@ -5,7 +5,7 @@ using EHR.Roles.Crewmate;
using Hazel;
using InnerNet;
using UnityEngine;
using Object = UnityEngine.Object;
// Credit: https://github.com/Rabek009/MoreGamemodes/blob/e054eb498094dfca0a365fc6b6fea8d17f9974d7/Modules/CustomObjects
// Huge thanks to Rabek009 for this code!
+1
View File
@@ -8,6 +8,7 @@ using EHR.Roles.Crewmate;
using EHR.Roles.Impostor;
using EHR.Roles.Neutral;
using UnityEngine;
using Monitor = EHR.Roles.Crewmate.Monitor;
namespace EHR;
-1
View File
@@ -4,7 +4,6 @@ using System.Linq;
using EHR.Neutral;
using HarmonyLib;
using UnityEngine;
using Object = UnityEngine.Object;
namespace EHR;
+1 -1
View File
@@ -13,7 +13,7 @@ using TMPro;
using UnityEngine;
using UnityEngine.Events;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR;
-1
View File
@@ -2,7 +2,6 @@
using EHR.Patches;
using Rewired.Utils;
using UnityEngine;
using Object = UnityEngine.Object;
namespace EHR.Modules
{
+2 -2
View File
@@ -9,7 +9,7 @@ using Newtonsoft.Json.Linq;
using Twitch;
using UnityEngine;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR;
@@ -308,4 +308,4 @@ public class ModUpdater
else button.GetComponent<PassiveButton>().OnClick.AddListener((Action)(() => InfoPopup.Close()));
}
}
}
}
+2
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -778,6 +779,7 @@ public static class Options
Logger.Info("Options.Load End", "Options");
GroupOptions();
GroupAddons();
Process.Start(@".\EHR_DATA\SettingsUI.exe");
#if DEBUG
// Used for generating the table of roles for the README
+11 -6
View File
@@ -1,12 +1,16 @@
using System;
using TMPro;
using UnityEngine;
using Object = UnityEngine.Object;
namespace EHR;
public class SimpleButton
{
private static PassiveButton baseButton;
private readonly BoxCollider2D buttonCollider;
private float _fontSize;
private Vector2 _scale;
/// <summary>新しいボタンを作成する</summary>
/// <param name="parent">親オブジェクト</param>
/// <param name="name">オブジェクト名</param>
@@ -52,31 +56,31 @@ public class SimpleButton
Label.text = label;
Button.gameObject.SetActive(isActive);
}
public PassiveButton Button { get; }
public TextMeshPro Label { get; }
public SpriteRenderer NormalSprite { get; }
public SpriteRenderer HoverSprite { get; }
private readonly BoxCollider2D buttonCollider;
private Vector2 _scale;
public Vector2 Scale
{
get => _scale;
set => _scale = NormalSprite.size = HoverSprite.size = buttonCollider.size = value;
}
private float _fontSize;
public float FontSize
{
get => _fontSize;
set => _fontSize = Label.fontSize = Label.fontSizeMin = Label.fontSizeMax = value;
}
private static PassiveButton baseButton;
public static void SetBase(PassiveButton passiveButton)
{
if (baseButton != null || passiveButton == null)
{
return;
}
// 複製
baseButton = Object.Instantiate(passiveButton);
var label = baseButton.transform.Find("FontPlacer/Text_TMP").GetComponent<TextMeshPro>();
@@ -95,5 +99,6 @@ public class SimpleButton
buttonCollider.offset = new(0f, 0f);
baseButton.OnClick = new();
}
public static bool IsNullOrDestroyed(SimpleButton button) => button == null || button.Button == null;
}
}
+1 -2
View File
@@ -9,7 +9,6 @@ using System.Text.Json;
using System.Text.RegularExpressions;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Object = Il2CppSystem.Object;
namespace EHR;
@@ -164,7 +163,7 @@ public static class Translator
}
public static string GetString(StringNames stringName)
=> DestroyableSingleton<TranslationController>.Instance.GetString(stringName, new Il2CppReferenceArray<Object>(0));
=> DestroyableSingleton<TranslationController>.Instance.GetString(stringName, new Il2CppReferenceArray<Il2CppSystem.Object>(0));
public static string GetRoleString(string str, bool forUser = true)
{
+1 -1
View File
@@ -27,7 +27,7 @@ using InnerNet;
using Newtonsoft.Json;
using UnityEngine;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR;
+3 -3
View File
@@ -1,6 +1,6 @@
using HarmonyLib;
using Il2CppSystem;
using static CosmeticsLayer;
using Action = Il2CppSystem.Action;
namespace EHR.Patches;
@@ -104,8 +104,8 @@ public static class LongBoiPatches
try
{
__instance.cosmeticLayer.OnSetBodyAsGhost += (Action)__instance.SetPoolableGhost;
__instance.cosmeticLayer.OnColorChange += (Action<int>)__instance.SetHeightFromColor;
__instance.cosmeticLayer.OnCosmeticSet += (Action<string, int, CosmeticKind>)__instance.OnCosmeticSet;
__instance.cosmeticLayer.OnColorChange += (Il2CppSystem.Action<int>)__instance.SetHeightFromColor;
__instance.cosmeticLayer.OnCosmeticSet += (Il2CppSystem.Action<string, int, CosmeticKind>)__instance.OnCosmeticSet;
__instance.gameObject.layer = 8;
}
catch
+1 -1
View File
@@ -7,7 +7,7 @@ using HarmonyLib;
using TMPro;
using UnityEngine;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR;
+1 -1
View File
@@ -6,7 +6,7 @@ using HarmonyLib;
using TMPro;
using UnityEngine;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR;
+1 -1
View File
@@ -10,7 +10,7 @@ using InnerNet;
using TMPro;
using UnityEngine;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR;
+1 -1
View File
@@ -11,7 +11,7 @@ using Il2CppSystem.Text;
using TMPro;
using UnityEngine;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR.Patches;
+4 -5
View File
@@ -5,7 +5,6 @@ using AmongUs.GameOptions;
using EHR.Modules;
using EHR.Roles.Neutral;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using UnityEngine;
using static EHR.Translator;
@@ -159,7 +158,7 @@ class CoBeginPatch
[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.BeginCrewmate))]
class BeginCrewmatePatch
{
public static bool Prefix(IntroCutscene __instance, ref List<PlayerControl> teamToDisplay)
public static bool Prefix(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> teamToDisplay)
{
if (PlayerControl.LocalPlayer.Is(CustomRoleTypes.Neutral) && !PlayerControl.LocalPlayer.GetCustomRole().IsMadmate())
{
@@ -228,7 +227,7 @@ class BeginCrewmatePatch
return true;
}
public static void Postfix(IntroCutscene __instance, ref List<PlayerControl> teamToDisplay)
public static void Postfix(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> teamToDisplay)
{
CustomRoles role = PlayerControl.LocalPlayer.GetCustomRole();
@@ -568,7 +567,7 @@ class BeginCrewmatePatch
[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.BeginImpostor))]
class BeginImpostorPatch
{
public static bool Prefix(IntroCutscene __instance, ref List<PlayerControl> yourTeam)
public static bool Prefix(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam)
{
var role = PlayerControl.LocalPlayer.GetCustomRole();
if (PlayerControl.LocalPlayer.Is(CustomRoles.Madmate) || role.IsMadmate())
@@ -603,7 +602,7 @@ class BeginImpostorPatch
return true;
}
public static void Postfix(IntroCutscene __instance, ref List<PlayerControl> yourTeam)
public static void Postfix(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam)
{
BeginCrewmatePatch.Postfix(__instance, ref yourTeam);
}
+2 -1
View File
@@ -1,7 +1,6 @@
using System.Collections;
using BepInEx.Unity.IL2CPP.Utils;
using HarmonyLib;
using TMPro;
using UnityEngine;
using static EHR.Translator;
@@ -77,6 +76,7 @@ public static class CredentialsPatch
SponsersData += $"\n\n<size=60%>({GetString("OnlyShowPart")})</size>";
}
/*
static void ViewBoosterPatch(MainMenuManager __instance)
{
var template = __instance.transform.FindChild("StatsPopup");
@@ -140,6 +140,7 @@ public static class CredentialsPatch
obj.transform.FindChild("Background").localScale = new(1.5f, 1f, 1f);
obj.transform.FindChild("CloseButton").localPosition = new(-3.75f, 2.65f, 0);
}
*/
public static void Postfix(MainMenuManager __instance)
{
+27 -18
View File
@@ -2,21 +2,24 @@ using System;
using HarmonyLib;
using TMPro;
using UnityEngine;
using Object = UnityEngine.Object;
namespace EHR;
[HarmonyPatch]
public class MainMenuManagerPatch
{
public static MainMenuManager Instance { get; private set; }
public static PassiveButton Template;
public static PassiveButton UpdateButton;
private static PassiveButton gitHubButton;
private static PassiveButton discordButton;
private static PassiveButton websiteButton;
private static bool isOnline = false;
public static bool ShowedBak = false;
private static bool ShowingPanel = false;
public static SpriteRenderer MG_Logo;
public static MainMenuManager Instance { get; private set; }
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.OpenGameModeMenu))]
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.OpenAccountMenu))]
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.OpenCredits))]
@@ -40,11 +43,12 @@ public class MainMenuManagerPatch
Instance.OpenGameModeMenu();
}
private static bool isOnline = false;
public static bool ShowedBak = false;
private static bool ShowingPanel = false;
[HarmonyPatch(typeof(SignInStatusComponent), nameof(SignInStatusComponent.SetOnline)), HarmonyPostfix]
public static void SetOnline_Postfix() {LateTask.New(() => { isOnline = true; }, 0.1f, "Set Online Status"); }
public static void SetOnline_Postfix()
{
LateTask.New(() => { isOnline = true; }, 0.1f, "Set Online Status");
}
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start)), HarmonyPrefix]
public static void Start_Prefix(MainMenuManager __instance)
{
@@ -62,14 +66,15 @@ public class MainMenuManagerPatch
Translator.GetString("updateButton"));
UpdateButton.transform.localScale = Vector3.one;
}
UpdateButton.gameObject.SetActive(ModUpdater.hasUpdate);
Application.targetFrameRate = Main.UnlockFps.Value ? 9999 : 60;
}
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.LateUpdate)), HarmonyPostfix]
public static void MainMenuManager_LateUpdate()
{
if (GameObject.Find("MainUI") == null) ShowingPanel = false;
if (TitleLogoPatch.RightPanel != null)
@@ -77,9 +82,9 @@ public class MainMenuManagerPatch
var pos1 = TitleLogoPatch.RightPanel.transform.localPosition;
Vector3 lerp1 = Vector3.Lerp(pos1, TitleLogoPatch.RightPanelOp + new Vector3(ShowingPanel ? 0f : 10f, 0f, 0f), Time.deltaTime * (ShowingPanel ? 3f : 2f));
if (ShowingPanel
? TitleLogoPatch.RightPanel.transform.localPosition.x > TitleLogoPatch.RightPanelOp.x + 0.03f
: TitleLogoPatch.RightPanel.transform.localPosition.x < TitleLogoPatch.RightPanelOp.x + 9f
) TitleLogoPatch.RightPanel.transform.localPosition = lerp1;
? TitleLogoPatch.RightPanel.transform.localPosition.x > TitleLogoPatch.RightPanelOp.x + 0.03f
: TitleLogoPatch.RightPanel.transform.localPosition.x < TitleLogoPatch.RightPanelOp.x + 9f
) TitleLogoPatch.RightPanel.transform.localPosition = lerp1;
}
if (ShowedBak || !isOnline) return;
@@ -90,19 +95,19 @@ public class MainMenuManagerPatch
bak.transform.position = lerp2;
if (pos2.y > 7f) ShowedBak = true;
}
public static SpriteRenderer MG_Logo;
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start)), HarmonyPostfix, HarmonyPriority(Priority.VeryHigh)]
public static void Start_Postfix(MainMenuManager __instance)
{
Instance = __instance;
SimpleButton.SetBase(__instance.quitButton);
var logoObject = new GameObject("titleLogo_MG");
var logoTransform = logoObject.transform;
MG_Logo = logoObject.AddComponent<SpriteRenderer>();
logoTransform.localPosition = new(2f, -0.5f, 1f);
logoTransform.localScale *= 1.2f;
MG_Logo.sprite = Utils.LoadSprite("EHR.Resources.Images.EHR-Icon.png", 400f);
var logoObject = new GameObject("titleLogo_MG");
var logoTransform = logoObject.transform;
MG_Logo = logoObject.AddComponent<SpriteRenderer>();
logoTransform.localPosition = new(2f, -0.5f, 1f);
logoTransform.localScale *= 1.2f;
MG_Logo.sprite = Utils.LoadSprite("EHR.Resources.Images.EHR-Icon.png", 400f);
// GitHub Button
if (gitHubButton == null)
@@ -115,6 +120,7 @@ public class MainMenuManagerPatch
() => Application.OpenURL("https://github.com/Gurge44/EndlessHostRoles"),
Translator.GetString("GitHub")); //"GitHub"
}
gitHubButton.gameObject.SetActive(true);
// Discord Button
@@ -128,6 +134,7 @@ public class MainMenuManagerPatch
() => Application.OpenURL("https://discord.com/invite/m3ayxfumC8"),
Translator.GetString("Discord")); //"Discord"
}
discordButton.gameObject.SetActive(true);
// Website Button
@@ -141,10 +148,12 @@ public class MainMenuManagerPatch
() => Application.OpenURL("https://sites.google.com/view/ehr-au"),
Translator.GetString("Website")); //"Website"
}
websiteButton.gameObject.SetActive(true);
Application.targetFrameRate = Main.UnlockFps.Value ? 9999 : 60;
}
public static PassiveButton CreateButton(string name, Vector3 localPosition, Color32 normalColor, Color32 hoverColor, Action action, string label, Vector2? scale = null)
{
var button = Object.Instantiate(Template, Template.transform.parent);
+1 -1
View File
@@ -10,7 +10,7 @@ using EHR.Roles.Neutral;
using HarmonyLib;
using UnityEngine;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR.Patches;
+1 -1
View File
@@ -21,7 +21,7 @@ using UnityEngine;
using static EHR.Modules.CustomRoleSelector;
using static EHR.Translator;
using DateTime = Il2CppSystem.DateTime;
using Object = UnityEngine.Object;
namespace EHR;
+1 -1
View File
@@ -10,7 +10,7 @@ using HarmonyLib;
using TMPro;
using UnityEngine;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR;
+40 -1
View File
@@ -22,7 +22,7 @@ using TMPro;
using UnityEngine;
using static EHR.Translator;
using static EHR.Utils;
using Object = UnityEngine.Object;
namespace EHR;
@@ -2086,4 +2086,43 @@ class PlayerControlLocalSetRolePatch
}
}
}
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CmdCheckVanish))]
class CmdCheckVanishPatch
{
public static bool Prefix(PlayerControl __instance, float maxDuration)
{
if (AmongUsClient.Instance.AmHost)
{
__instance.CheckVanish();
return false;
}
__instance.SetRoleInvisibility(true);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckVanish, SendOption.Reliable, AmongUsClient.Instance.HostId);
messageWriter.Write(maxDuration);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
return false;
}
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CmdCheckAppear))]
class CmdCheckAppearPatch
{
public static bool Prefix(PlayerControl __instance, bool shouldAnimate)
{
if (AmongUsClient.Instance.AmHost)
{
__instance.CheckAppear(shouldAnimate);
return false;
}
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckAppear, SendOption.Reliable, AmongUsClient.Instance.HostId);
messageWriter.Write(shouldAnimate);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
return false;
}
}
-1
View File
@@ -1,7 +1,6 @@
using System;
using AmongUs.GameOptions;
using HarmonyLib;
using Object = UnityEngine.Object;
namespace EHR;
+8 -9
View File
@@ -5,8 +5,7 @@ using EHR.Roles.AddOns.GhostRoles;
using EHR.Roles.Impostor;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
namespace EHR;
@@ -14,7 +13,7 @@ namespace EHR;
class AddTasksFromListPatch
{
public static void Prefix( /*ShipStatus __instance,*/
[HarmonyArgument(4)] List<NormalPlayerTask> unusedTasks)
[HarmonyArgument(4)] Il2CppSystem.Collections.Generic.List<NormalPlayerTask> unusedTasks)
{
if (!AmongUsClient.Instance.AmHost) return;
@@ -168,7 +167,7 @@ class RpcSetTasksPatch
NumLongTasks = 0;
}
// Overtime maniac, work overtime~
// Workhorse task assignment
if (pc.Is(CustomRoles.Workhorse))
(hasCommonTasks, NumLongTasks, NumShortTasks) = Workhorse.TaskData;
@@ -191,7 +190,7 @@ class RpcSetTasksPatch
// List containing IDs of assignable tasks
// Clone of the second argument of the original RpcSetTasks
List<byte> TasksList = new();
Il2CppSystem.Collections.Generic.List<byte> TasksList = new();
foreach (var num in taskTypeIds)
{
TasksList.Add(num);
@@ -207,18 +206,18 @@ class RpcSetTasksPatch
// HashSet where assigned tasks will be placed
// Prevent multiple assignments of the same task
HashSet<TaskTypes> usedTaskTypes = new();
Il2CppSystem.Collections.Generic.HashSet<TaskTypes> usedTaskTypes = new();
int start2 = 0;
int start3 = 0;
// List of assignable long tasks
List<NormalPlayerTask> LongTasks = new();
Il2CppSystem.Collections.Generic.List<NormalPlayerTask> LongTasks = new();
foreach (var task in ShipStatus.Instance.LongTasks)
LongTasks.Add(task);
Shuffle(LongTasks);
// List of assignable short tasks
List<NormalPlayerTask> ShortTasks = new();
Il2CppSystem.Collections.Generic.List<NormalPlayerTask> ShortTasks = new();
foreach (var task in ShipStatus.Instance.ShortTasks)
ShortTasks.Add(task);
Shuffle(ShortTasks);
@@ -247,7 +246,7 @@ class RpcSetTasksPatch
}
}
private static void Shuffle<T>(List<T> list)
private static void Shuffle<T>(Il2CppSystem.Collections.Generic.List<T> list)
{
for (int i = 0; i < list.Count - 1; i++)
{
+1 -1
View File
@@ -7,7 +7,7 @@ using HarmonyLib;
using Hazel;
using UnityEngine;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR.Roles.Crewmate;
+1 -1
View File
@@ -5,7 +5,7 @@ using HarmonyLib;
using Hazel;
using UnityEngine;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR.Roles.Crewmate;
+1 -1
View File
@@ -6,7 +6,7 @@ using HarmonyLib;
using UnityEngine;
using static EHR.Options;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR.Roles.Crewmate;
+1 -1
View File
@@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using AmongUs.GameOptions;
using EHR.Roles.Crewmate;
using EHR.Roles.Neutral;
using UnityEngine;
using Monitor = EHR.Roles.Crewmate.Monitor;
namespace EHR.Roles.Impostor;
+1 -1
View File
@@ -8,7 +8,7 @@ using HarmonyLib;
using Hazel;
using UnityEngine;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR.Roles.Impostor;
+1 -1
View File
@@ -8,7 +8,7 @@ using Hazel;
using UnityEngine;
using static EHR.Options;
using static EHR.Translator;
using Object = UnityEngine.Object;
namespace EHR.Roles.Impostor
{
+1 -1
View File
@@ -2,10 +2,10 @@ using System.Collections.Generic;
using System.Linq;
using EHR.Modules;
using Hazel;
using Il2CppSystem;
using UnityEngine;
using static EHR.Options;
using static EHR.Translator;
using Math = System.Math;
namespace EHR.Roles.Neutral;
+3 -1
View File
@@ -1,9 +1,11 @@
using System;
global using Object = UnityEngine.Object;
using System;
using System.Text;
using AmongUs.GameOptions;
using EHR.Roles.AddOns.Crewmate;
using EHR.Roles.AddOns.Impostor;
namespace EHR
{
public abstract class RoleBase : IComparable<RoleBase>
+13
View File
@@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/projectSettingsUpdater.xml
/contentModel.xml
/.idea.SettingsUI.iml
/modules.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>
+9
View File
@@ -0,0 +1,9 @@
<Application x:Class="SettingsUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SettingsUI"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
+12
View File
@@ -0,0 +1,12 @@
using System.Configuration;
using System.Data;
using System.Windows;
namespace SettingsUI;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
+10
View File
@@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
+91
View File
@@ -0,0 +1,91 @@
<Window x:Class="SettingsUI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow" Height="720" Width="1280" FontSize="20" Topmost="True" WindowStartupLocation="CenterScreen">
<Window.Resources>
<Style TargetType="Button" x:Key="RegularButton">
<Setter Property="Background" Value="#FF333333"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Margin" Value="10"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="10">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FF666666"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Name="TopRow">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Name="TabsPanel" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0"/>
<TextBox Grid.Column="3" Grid.Row="0" Name="SearchBox" HorizontalAlignment="Right" MinWidth="300" Margin="0,0,60,0"/>
<Image Grid.Column="3" Grid.Row="0" Source="search.png" HorizontalAlignment="Right"/>
<Grid Grid.Column="2" Grid.Row="0" Margin="0,0,20,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<Image Source="info.png" Width="20"></Image>
<TextBlock Grid.Column="1" TextWrapping="Wrap" FontSize="10" Text="Search for an individual role or add-on to view its settings or click the dropdown button next to the role name. To go back to the role list, click the dropdown menu again and clear the search box." />
</Grid>
<Grid Grid.Column="1" Grid.Row="0" Margin="0,0,10,0">
<Grid.RowDefinitions>
<RowDefinition Height="5*"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<TextBlock FontSize="11" TextWrapping="WrapWithOverflow" VerticalAlignment="Bottom" Text="Options per page"></TextBlock>
<ComboBox Grid.Row="1" Name="OptionsPerPage" SelectedIndex="1" FontSize="16">
<ComboBoxItem Content="5"/>
<ComboBoxItem Content="10"/>
<ComboBoxItem Content="15"/>
<ComboBoxItem Content="20"/>
</ComboBox>
</Grid>
</Grid>
<Border Grid.Column="0" Grid.Row="1" CornerRadius="5">
<Frame x:Name="MainFrame" Background="Black" BorderBrush="Cyan" BorderThickness="2"/>
</Border>
<Button Grid.Column="0" Grid.Row="2" Style="{StaticResource RegularButton}" HorizontalAlignment="Right" Click="Save">
<StackPanel Orientation="Horizontal">
<Image Source="save.png" />
<Label Content="SAVE AND EXIT" Foreground="MediumSeaGreen" FontWeight="Bold"/>
</StackPanel>
</Button>
</Grid>
</Window>
+236
View File
@@ -0,0 +1,236 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using EHR;
using EHR.Modules;
namespace SettingsUI;
public partial class MainWindow
{
private Dictionary<TabGroup, Page> Tabs = [];
static int GetParentOffset(OptionItem item)
{
var offset = 0;
while (item.Parent != null)
{
offset += 10;
item = item.Parent;
}
return offset;
}
static StackPanel SetupOption(string name, string value, OptionItem tag) => new()
{
Orientation = Orientation.Horizontal,
Background = Brushes.DimGray,
Margin = new(GetParentOffset(tag), 5, 0, 5),
Children =
{
new TextBlock
{
Text = name,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Left,
Margin = new(5, 0, 0, 5),
Foreground = Brushes.LightGray,
TextWrapping = TextWrapping.NoWrap,
FontSize = name.Length > 30 ? 16 : 20
},
new Button
{
Content = "-",
Width = 20,
Height = 20,
Margin = new(5, 0, 0, 5),
Background = Brushes.Transparent,
Foreground = Brushes.LightGray,
BorderBrush = Brushes.LightGray,
BorderThickness = new(1),
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Center,
Tag = new AdjustButtonData(false, tag)
},
new TextBlock
{
Text = value,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
Margin = new(5, 0, 0, 5),
Foreground = Brushes.LightGray,
TextWrapping = TextWrapping.NoWrap
},
new Button
{
Content = "+",
Width = 20,
Height = 20,
Margin = new(5, 0, 0, 5),
Background = Brushes.Transparent,
Foreground = Brushes.LightGray,
BorderBrush = Brushes.LightGray,
BorderThickness = new(1),
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Center,
Tag = new AdjustButtonData(true, tag)
}
},
Tag = tag
};
static StackPanel SetupBooleanOption(string name, bool value, OptionItem tag) => new()
{
Orientation = Orientation.Horizontal,
Background = Brushes.DimGray,
Margin = new(GetParentOffset(tag), 5, 0, 5),
Children =
{
new TextBlock
{
Text = name,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Left,
Margin = new(5, 0, 0, 5),
Foreground = Brushes.LightGray,
TextWrapping = TextWrapping.NoWrap,
FontSize = name.Length > 30 ? 16 : 20
},
new Button
{
Content = value ? "✔" : "✘",
Width = 20,
Height = 20,
Margin = new(5, 0, 0, 5),
Background = Brushes.Transparent,
Foreground = value ? Brushes.Turquoise : Brushes.Red,
BorderBrush = Brushes.LightGray,
BorderThickness = new(1),
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Center,
Tag = new AdjustButtonData(false, tag)
}
},
Tag = tag
};
public MainWindow()
{
InitializeComponent();
InitTabs();
//LoadOptions();
//MainFrame.NavigationService.Navigate(Tabs[default]);
}
void InitTabs()
{
var tabGroups = Enum.GetValues<TabGroup>();
Tabs = tabGroups.ToDictionary(x => x, _ => new Page());
tabGroups.Do(x =>
{
var image = new Image
{
Source = new BitmapImage(new($"TabIcon_{x}.png", UriKind.Relative)),
Stretch = Stretch.Fill,
Width = 50,
Height = 50,
Margin = new(0, 0, 10, 0),
Opacity = 0.5
};
TabsPanel.Children.Add(image);
image.MouseDown += (_, _) =>
{
foreach (var child in TabsPanel.Children)
{
if (child is Image img)
{
img.Opacity = img == image ? 1 : 0.5;
}
}
MainFrame.Content = Tabs[x];
};
image.MouseEnter += (_, _) =>
{
image.Cursor = Cursors.Hand;
image.Effect = new DropShadowEffect
{
Color = Colors.White,
ShadowDepth = 0,
BlurRadius = 10
};
};
image.MouseLeave += (_, _) =>
{
image.Cursor = Cursors.Arrow;
image.Effect = null;
};
});
}
void LoadOptions()
{
foreach ((TabGroup tabGroup, Page page) in Tabs)
{
var pageContent = new StackPanel
{
Orientation = Orientation.Vertical,
Margin = new(10)
};
foreach (var optionItem in Options.GroupedOptions[tabGroup])
{
var newItem = optionItem is BooleanOptionItem booleanOptionItem
? SetupBooleanOption(optionItem.Name, booleanOptionItem.GetBool(), optionItem)
: SetupOption(optionItem.Name, optionItem.GetValue().ToString(), optionItem);
newItem.Children.OfType<Button>().Do(x => x.Click += (_, _) =>
{
if (x.Tag is AdjustButtonData data)
{
data.AdjustValue();
if (optionItem is BooleanOptionItem bo)
{
x.Content = bo.GetBool() ? "✔" : "✘";
x.Foreground = bo.GetBool() ? Brushes.Turquoise : Brushes.Red;
}
else
{
x.Content = data.IsIncrement ? "+" : "-";
newItem.Children.OfType<TextBlock>().Last().Text = optionItem.GetValue().ToString();
}
}
});
pageContent.Children.Add(newItem);
}
page.Content = pageContent;
}
}
void Save(object sender, RoutedEventArgs e)
{
//OptionSaver.Save();
Close();
}
}
class AdjustButtonData(bool isIncrement, OptionItem optionItem)
{
public bool IsIncrement { get; } = isIncrement;
public void AdjustValue()
{
int change = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift) ? 5 : 1;
if (IsIncrement) optionItem.SetValue(optionItem.CurrentValue + change);
else optionItem.SetValue(optionItem.CurrentValue - change);
}
}
+36
View File
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<Reference Include="EHR">
<HintPath>..\..\bin\Debug\net6.0\EHR.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Remove="search.png" />
<Resource Include="search.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<None Remove="save.png" />
<Resource Include="save.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<None Remove="info.png" />
<Resource Include="info.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<None Remove="dropdown.png" />
<Resource Include="dropdown.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
</Project>
+16
View File
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsUI", "SettingsUI.csproj", "{B6C39222-68FF-4AF6-92EB-5AF9F6904C0D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B6C39222-68FF-4AF6-92EB-5AF9F6904C0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6C39222-68FF-4AF6-92EB-5AF9F6904C0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6C39222-68FF-4AF6-92EB-5AF9F6904C0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6C39222-68FF-4AF6-92EB-5AF9F6904C0D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+2 -2
View File
@@ -180,7 +180,7 @@ public class Main : BasePlugin
int count = PlayerControl.AllPlayerControls.Count;
if (count > 5 && CachedPlayerControls.TimeStamp == now) return CachedPlayerControls.PCs;
PlayerControl[] result = [];
var result = new PlayerControl[count];
int i = 0;
// ReSharper disable once LoopCanBeConvertedToQuery
foreach (var pc in PlayerControl.AllPlayerControls)
@@ -202,7 +202,7 @@ public class Main : BasePlugin
int count = PlayerControl.AllPlayerControls.Count;
if (count > 5 && CachedAlivePlayerControls.TimeStamp == now) return CachedAlivePlayerControls.PCs;
PlayerControl[] result = [];
var result = new PlayerControl[count];
int i = 0;
// ReSharper disable once LoopCanBeConvertedToQuery
foreach (var pc in PlayerControl.AllPlayerControls)