mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
I give up
This commit is contained in:
1 parent
7609876f3e
commit
8a316891b1
17 files changed
+56
-462
No files matched your search
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -779,7 +778,7 @@ public static class Options
|
||||
Logger.Info("Options.Load End", "Options");
|
||||
GroupOptions();
|
||||
GroupAddons();
|
||||
Process.Start(@".\EHR_DATA\SettingsUI.exe");
|
||||
//Process.Start(@".\EHR_DATA\SettingsUI.exe");
|
||||
|
||||
#if DEBUG
|
||||
// Used for generating the table of roles for the README
|
||||
|
||||
+12
-3
@@ -47,11 +47,20 @@ public static class OptionShower
|
||||
{
|
||||
sb.Append($"<color={Utils.GetRoleColorCode(CustomRoles.GM)}>{Utils.GetRoleName(CustomRoles.GM)}:</color> {(Main.GM.Value ? GetString("RoleRate") : GetString("RoleOff"))}\n\n");
|
||||
sb.Append(GetString("ActiveRolesList")).Append('\n');
|
||||
int count = 4;
|
||||
foreach (var kvp in Options.CustomRoleSpawnChances)
|
||||
{
|
||||
if (kvp.Value.GameMode is CustomGameMode.Standard or CustomGameMode.All && kvp.Value.GetBool())
|
||||
{
|
||||
sb.Append($"{Utils.ColorString(Utils.GetRoleColor(kvp.Key), Utils.GetRoleName(kvp.Key))}: {kvp.Value.GetString()}×{kvp.Key.GetCount()}\n");
|
||||
sb.Append($"{Utils.ColorString(Utils.GetRoleColor(kvp.Key), Utils.GetRoleName(kvp.Key))}: {kvp.Value.GetString()} ×{kvp.Key.GetCount()}\n");
|
||||
count++;
|
||||
|
||||
if (count > 44)
|
||||
{
|
||||
count = 0;
|
||||
Pages.Add(sb + "\n\n");
|
||||
sb.Clear().Append(GetString("ActiveRolesList")).Append('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +76,7 @@ public static class OptionShower
|
||||
{
|
||||
if (!kvp.Key.IsEnable() || kvp.Value.IsHiddenOn(Options.CurrentGameMode)) continue;
|
||||
sb.Append('\n');
|
||||
sb.Append($"{Utils.ColorString(Utils.GetRoleColor(kvp.Key), Utils.GetRoleName(kvp.Key))}: {kvp.Value.GetString()}×{kvp.Key.GetCount()}\n");
|
||||
sb.Append($"{Utils.ColorString(Utils.GetRoleColor(kvp.Key), Utils.GetRoleName(kvp.Key))}: {kvp.Value.GetString()} ×{kvp.Key.GetCount()}\n");
|
||||
ShowChildren(kvp.Value, ref sb, Utils.GetRoleColor(kvp.Key).ShadeColor(-0.5f), 1);
|
||||
}
|
||||
}
|
||||
@@ -86,7 +95,7 @@ public static class OptionShower
|
||||
string[] tmp = sb.ToString().Split("\n\n");
|
||||
foreach (var str in tmp)
|
||||
{
|
||||
if (Pages[^1].Count(c => c == '\n') + 1 + str.Count(c => c == '\n') + 1 > 35)
|
||||
if (Pages[^1].Count(c => c == '\n') + 1 + str.Count(c => c == '\n') + 1 > 44)
|
||||
Pages.Add(str + "\n\n");
|
||||
else Pages[^1] += str + "\n\n";
|
||||
}
|
||||
|
||||
@@ -14,12 +14,15 @@ namespace EHR;
|
||||
[HarmonyPatch(typeof(PingTracker), nameof(PingTracker.Update))]
|
||||
internal class PingTrackerUpdatePatch
|
||||
{
|
||||
public static PingTracker Instance;
|
||||
private static readonly StringBuilder Sb = new();
|
||||
private static long LastUpdate;
|
||||
private static int Delay => GameStates.IsInTask ? 8 : 1;
|
||||
|
||||
private static void Postfix(PingTracker __instance)
|
||||
{
|
||||
Instance = __instance;
|
||||
|
||||
__instance.text.alignment = TextAlignmentOptions.Center;
|
||||
__instance.text.text = Sb.ToString();
|
||||
|
||||
@@ -219,7 +222,7 @@ internal class ModManagerLateUpdatePatch
|
||||
__instance.localCamera = !DestroyableSingleton<HudManager>.InstanceExists ? Camera.main : DestroyableSingleton<HudManager>.Instance.GetComponentInChildren<Camera>();
|
||||
if (__instance.localCamera != null)
|
||||
{
|
||||
var offsetY = HudManager.InstanceExists ? 1.6f : 0.9f;
|
||||
var offsetY = HudManager.InstanceExists ? 1.1f : 0.9f;
|
||||
__instance.ModStamp.transform.position = AspectPosition.ComputeWorldPosition(
|
||||
__instance.localCamera, AspectPosition.EdgeAlignments.RightTop,
|
||||
new(0.4f, offsetY, __instance.localCamera.nearClipPlane + 0.1f));
|
||||
|
||||
@@ -3,6 +3,18 @@ using UnityEngine;
|
||||
|
||||
namespace EHR;
|
||||
|
||||
[HarmonyPatch(typeof(GameStartManager))]
|
||||
class AllMapIconsPatch
|
||||
{
|
||||
[HarmonyPatch(nameof(GameStartManager.Start)), HarmonyPostfix]
|
||||
public static void Postfix_AllMapIcons(GameStartManager __instance)
|
||||
{
|
||||
MapIconByName dleksIcon = Object.Instantiate(__instance, __instance.gameObject.transform).AllMapIcons[0];
|
||||
dleksIcon.Name = MapNames.Dleks;
|
||||
__instance.AllMapIcons.Add(dleksIcon);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AmongUsClient._CoStartGameHost_d__32), nameof(AmongUsClient._CoStartGameHost_d__32.MoveNext))]
|
||||
public static class DleksPatch
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ using static EHR.Translator;
|
||||
|
||||
namespace EHR;
|
||||
|
||||
/*
|
||||
[HarmonyPatch(typeof(GameSettingMenu), nameof(GameSettingMenu.Start))]
|
||||
public static class GameSettingMenuPatch
|
||||
{
|
||||
@@ -34,9 +35,6 @@ public static class GameSettingMenuPatch
|
||||
|
||||
GameObject template = gamepreset.gameObject;
|
||||
GameObject targetBox = Object.Instantiate(template, gamepreset.transform);
|
||||
targetBox.name = "System Settings";
|
||||
targetBox.transform.localScale = new(0.59f, 0.59f, 1f);
|
||||
targetBox.transform.localPosition = new(targetBox.transform.localPosition.x + 2.95f, rolesettings.transform.localPosition.y - 0.1f, targetBox.transform.localPosition.z);
|
||||
|
||||
LateTask.New(() =>
|
||||
{
|
||||
@@ -60,6 +58,7 @@ public static class GameSettingMenuPatch
|
||||
targetBox = Object.Instantiate(template, targetBox.transform);
|
||||
targetBox.name = name;
|
||||
targetBox.transform.localScale = new(1f, 1f, 1f);
|
||||
targetBox.transform.localPosition = new(targetBox.transform.localPosition.x, targetBox.transform.localPosition.y - 0.6f, targetBox.transform.localPosition.z);
|
||||
|
||||
PassiveButton button = targetBox.GetComponent<PassiveButton>();
|
||||
button.OnClick.RemoveAllListeners();
|
||||
@@ -108,7 +107,7 @@ public static class RolesSettingsMenuAwakePatch
|
||||
ehrRoleSettings.name = "EHR Role Settings";
|
||||
ehrRoleSettings.enabled = true;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.Awake))]
|
||||
[HarmonyPriority(Priority.First)]
|
||||
@@ -280,7 +279,8 @@ public static class GameOptionsMenuPatch
|
||||
}
|
||||
}
|
||||
|
||||
// [HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.Update))]
|
||||
/*
|
||||
[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.Update))]
|
||||
public static class GameOptionsMenuUpdatePatch
|
||||
{
|
||||
private static float Timer = 1f;
|
||||
@@ -381,7 +381,7 @@ public static class GameOptionsMenuUpdatePatch
|
||||
}
|
||||
}
|
||||
|
||||
// [HarmonyPatch(typeof(StringOption), nameof(StringOption.Start))]
|
||||
[HarmonyPatch(typeof(StringOption), nameof(StringOption.Start))]
|
||||
public class StringOptionEnablePatch
|
||||
{
|
||||
public static bool Prefix(StringOption __instance)
|
||||
@@ -405,7 +405,7 @@ public class StringOptionEnablePatch
|
||||
}
|
||||
}
|
||||
|
||||
// [HarmonyPatch(typeof(StringOption), nameof(StringOption.Increase))]
|
||||
[HarmonyPatch(typeof(StringOption), nameof(StringOption.Increase))]
|
||||
public class StringOptionIncreasePatch
|
||||
{
|
||||
public static bool Prefix(StringOption __instance)
|
||||
@@ -417,10 +417,10 @@ public class StringOptionIncreasePatch
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void Postfix( /*StringOption __instance*/) => OptionShower.GetText();
|
||||
public static void Postfix() => OptionShower.GetText();
|
||||
}
|
||||
|
||||
// [HarmonyPatch(typeof(StringOption), nameof(StringOption.Decrease))]
|
||||
[HarmonyPatch(typeof(StringOption), nameof(StringOption.Decrease))]
|
||||
public class StringOptionDecreasePatch
|
||||
{
|
||||
public static bool Prefix(StringOption __instance)
|
||||
@@ -432,8 +432,8 @@ public class StringOptionDecreasePatch
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void Postfix( /*StringOption __instance*/) => OptionShower.GetText();
|
||||
}
|
||||
public static void Postfix() => OptionShower.GetText();
|
||||
}*/
|
||||
|
||||
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.RpcSyncSettings))]
|
||||
public class RpcSyncSettingsPatch
|
||||
|
||||
+16
-4
@@ -20,6 +20,7 @@ class HudManagerPatch
|
||||
{
|
||||
private static TextMeshPro LowerInfoText;
|
||||
private static TextMeshPro OverriddenRolesText;
|
||||
private static TextMeshPro SettingsText;
|
||||
private static long LastNullError;
|
||||
|
||||
public static bool Prefix(HudManager __instance)
|
||||
@@ -63,10 +64,21 @@ class HudManagerPatch
|
||||
|
||||
if (GameStates.IsLobby)
|
||||
{
|
||||
// var POM = GameObject.Find("PlayerOptionsMenu(Clone)");
|
||||
// __instance.GameSettings.text = POM != null ? string.Empty : OptionShower.GetTextNoFresh();
|
||||
// __instance.GameSettings.fontSizeMin =
|
||||
// __instance.GameSettings.fontSizeMax = 1f;
|
||||
if (PingTrackerUpdatePatch.Instance != null)
|
||||
{
|
||||
if (SettingsText != null) Object.Destroy(SettingsText.gameObject);
|
||||
SettingsText = Object.Instantiate(PingTrackerUpdatePatch.Instance.text, __instance.transform, true);
|
||||
SettingsText.alignment = TextAlignmentOptions.TopLeft;
|
||||
SettingsText.verticalAlignment = VerticalAlignmentOptions.Top;
|
||||
SettingsText.transform.localPosition = new(-4.9f, 2.9f, 0);
|
||||
SettingsText.fontSize = SettingsText.fontSizeMin = SettingsText.fontSizeMax = 1.5f;
|
||||
}
|
||||
|
||||
if (SettingsText != null)
|
||||
{
|
||||
SettingsText.text = OptionShower.GetTextNoFresh();
|
||||
SettingsText.enabled = SettingsText.text != string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
if (AmongUsClient.Instance.AmHost)
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
# 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
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,9 +0,0 @@
|
||||
<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>
|
||||
@@ -1,12 +0,0 @@
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
|
||||
namespace SettingsUI;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
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)
|
||||
)]
|
||||
@@ -1,91 +0,0 @@
|
||||
<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>
|
||||
@@ -1,236 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<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>
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
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
|
||||
Reference in new issue
Block a user