Skip to content

Commit d7512e5

Browse files
committed
Add Manager
1 parent a3e077f commit d7512e5

File tree

7 files changed

+448
-1
lines changed

7 files changed

+448
-1
lines changed

LiveSplit.OriWotW.csproj

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@
5656
<PropertyGroup>
5757
<ApplicationIcon>Resources\icon.ico</ApplicationIcon>
5858
</PropertyGroup>
59+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Manager|AnyCPU'">
60+
<DebugSymbols>true</DebugSymbols>
61+
<OutputPath>bin\</OutputPath>
62+
<OutputType>WinExe</OutputType>
63+
<DefineConstants>TRACE;DEBUG;Console;Manager</DefineConstants>
64+
<DebugType>full</DebugType>
65+
<PlatformTarget>AnyCPU</PlatformTarget>
66+
<LangVersion>7.3</LangVersion>
67+
<ErrorReport>prompt</ErrorReport>
68+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
69+
<Optimize>true</Optimize>
70+
<Prefer32Bit>false</Prefer32Bit>
71+
</PropertyGroup>
5972
<ItemGroup>
6073
<Reference Include="LiveSplit.Core">
6174
<HintPath>..\..\LiveSplit\LiveSplit.Core.dll</HintPath>
@@ -130,6 +143,12 @@
130143
<Compile Include="UI\LogViewer.Designer.cs">
131144
<DependentUpon>LogViewer.cs</DependentUpon>
132145
</Compile>
146+
<Compile Include="UI\Manager.cs">
147+
<SubType>Form</SubType>
148+
</Compile>
149+
<Compile Include="UI\Manager.Designer.cs">
150+
<DependentUpon>Manager.cs</DependentUpon>
151+
</Compile>
133152
<Compile Include="UI\UserSplitSettings.cs">
134153
<SubType>UserControl</SubType>
135154
</Compile>
@@ -155,10 +174,14 @@
155174
<EmbeddedResource Include="Properties\Resources.resx">
156175
<Generator>ResXFileCodeGenerator</Generator>
157176
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
177+
<SubType>Designer</SubType>
158178
</EmbeddedResource>
159179
<EmbeddedResource Include="UI\LogViewer.resx">
160180
<DependentUpon>LogViewer.cs</DependentUpon>
161181
</EmbeddedResource>
182+
<EmbeddedResource Include="UI\Manager.resx">
183+
<DependentUpon>Manager.cs</DependentUpon>
184+
</EmbeddedResource>
162185
<EmbeddedResource Include="UI\UserSplitSettings.resx">
163186
<DependentUpon>UserSplitSettings.cs</DependentUpon>
164187
</EmbeddedResource>

LiveSplit.OriWotW.sln

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ Global
1414
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1515
Console|Any CPU = Console|Any CPU
1616
Debug|Any CPU = Debug|Any CPU
17+
Manager|Any CPU = Manager|Any CPU
1718
Release|Any CPU = Release|Any CPU
1819
EndGlobalSection
1920
GlobalSection(ProjectConfigurationPlatforms) = postSolution
2021
{B3294E28-2BD4-4E39-92FA-E04A620C7E7F}.Console|Any CPU.ActiveCfg = Console|Any CPU
2122
{B3294E28-2BD4-4E39-92FA-E04A620C7E7F}.Console|Any CPU.Build.0 = Console|Any CPU
2223
{B3294E28-2BD4-4E39-92FA-E04A620C7E7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2324
{B3294E28-2BD4-4E39-92FA-E04A620C7E7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{B3294E28-2BD4-4E39-92FA-E04A620C7E7F}.Manager|Any CPU.ActiveCfg = Manager|Any CPU
26+
{B3294E28-2BD4-4E39-92FA-E04A620C7E7F}.Manager|Any CPU.Build.0 = Manager|Any CPU
2427
{B3294E28-2BD4-4E39-92FA-E04A620C7E7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
2528
{B3294E28-2BD4-4E39-92FA-E04A620C7E7F}.Release|Any CPU.Build.0 = Release|Any CPU
2629
EndGlobalSection

Memory/Vector2.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Runtime.InteropServices;
23
namespace LiveSplit.OriWotW {
34
[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 1)]
45
public struct Vector2 {
@@ -7,6 +8,24 @@ public struct Vector2 {
78
[FieldOffset(4)]
89
public float Y;
910

11+
public static Vector2 operator -(Vector2 one, Vector2 two) {
12+
return new Vector2() { X = one.X - two.X, Y = one.Y - two.Y };
13+
}
14+
public static Vector2 operator +(Vector2 one, Vector2 two) {
15+
return new Vector2() { X = one.X + two.X, Y = one.Y + two.Y };
16+
}
17+
public static Vector2 operator *(Vector2 one, Vector2 two) {
18+
return new Vector2() { X = one.X * two.X, Y = one.Y * two.Y };
19+
}
20+
public static Vector2 operator *(Vector2 one, int two) {
21+
return new Vector2() { X = one.X * two, Y = one.Y * two };
22+
}
23+
public static Vector2 operator *(int two, Vector2 one) {
24+
return new Vector2() { X = one.X * two, Y = one.Y * two };
25+
}
26+
public static float operator !(Vector2 one) {
27+
return (float)Math.Sqrt(one.X * one.X + one.Y * one.Y);
28+
}
1029
public override string ToString() {
1130
return $"{X:0.00}, {Y:0.00}";
1231
}

UI/Component.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ public class Component : IComponent {
2121
private bool isAutosplitting = false;
2222
private TextComponent infoComponent;
2323
private DateTime lastInfoCheck = DateTime.MinValue;
24+
#if !Manager
2425
public static void Main(string[] args) {
2526
Component component = new Component(null);
2627
component.log.EnableLogging = true;
2728
component.userSettings.Settings.NoPause = true;
2829
component.userSettings.Settings.FPSLock = false;
2930
Application.Run();
3031
}
32+
#endif
3133
public Component(LiveSplitState state) {
3234
log = new LogManager();
3335
userSettings = new UserSettings(state, log);

UI/Manager.Designer.cs

Lines changed: 182 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UI/Manager.cs

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
using System;
2+
using System.Drawing;
3+
using System.Threading;
4+
using System.Windows.Forms;
5+
namespace LiveSplit.OriWotW {
6+
public partial class Manager : Form {
7+
public MemoryManager Memory { get; set; }
8+
private Thread timerLoop;
9+
private bool useLivesplitColors = true;
10+
private Vector2 lastPosition;
11+
#if Manager
12+
public static void Main(string[] args) {
13+
try {
14+
Application.EnableVisualStyles();
15+
Application.SetCompatibleTextRenderingDefault(false);
16+
Application.Run(new Manager());
17+
} catch (Exception ex) {
18+
Console.WriteLine(ex.ToString());
19+
}
20+
}
21+
#endif
22+
public Manager() {
23+
this.DoubleBuffered = true;
24+
InitializeComponent();
25+
Memory = new MemoryManager();
26+
StartUpdateLoop();
27+
}
28+
public void StartUpdateLoop() {
29+
if (timerLoop != null) { return; }
30+
31+
timerLoop = new Thread(UpdateLoop);
32+
timerLoop.IsBackground = true;
33+
timerLoop.Priority = ThreadPriority.AboveNormal;
34+
timerLoop.Start();
35+
}
36+
private void UpdateLoop() {
37+
bool lastHooked = false;
38+
while (timerLoop != null) {
39+
try {
40+
bool hooked = Memory.HookProcess();
41+
if (hooked) {
42+
UpdateValues();
43+
}
44+
if (lastHooked != hooked) {
45+
lastHooked = hooked;
46+
this.Invoke((Action)delegate () { lblNote.Visible = !hooked; });
47+
}
48+
} catch { }
49+
Thread.Sleep(7);
50+
}
51+
}
52+
public void UpdateValues() {
53+
if (this.InvokeRequired) { this.Invoke((Action)UpdateValues); return; }
54+
55+
GameState gameState = Memory.GameState();
56+
Vector2 position = Memory.Position();
57+
Vector2 speed = (position - lastPosition) * 120;
58+
lastPosition = position;
59+
Stats stats = Memory.PlayerStats();
60+
AreaType area = Memory.PlayerArea();
61+
float mapCompletion = Memory.MapCompletion();
62+
float areaCompletion = Memory.MapCompletion(area);
63+
string scene = Memory.CurrentScene();
64+
if (string.IsNullOrEmpty(scene)) { scene = "N/A"; }
65+
66+
lblMap.Text = $"Total: {mapCompletion:0.00}%";
67+
lblArea.Text = $"Area: {area} - {areaCompletion:0.00}%";
68+
lblScene.Text = $"Scene: {scene}";
69+
lblPos.Text = $"Pos: {position}";
70+
lblSpeed.Text = $"Speed: {speed} ({!speed:0.00})";
71+
72+
73+
if (gameState == GameState.Game) {
74+
lblHP.Text = $"HP: {stats.Health:0} / {stats.MaxHealth}";
75+
lblEN.Text = $"EN: {stats.Energy:0.0} / {stats.MaxEnergy:0}";
76+
lblOre.Text = $"Ore: {Memory.Ore()}";
77+
lblKeys.Text = $"Keys: {Memory.Keystones()}";
78+
} else {
79+
lblHP.Text = "HP: N/A";
80+
lblEN.Text = "EN: N/A";
81+
lblOre.Text = "Ore: N/A";
82+
lblKeys.Text = "Keys: N/A";
83+
}
84+
}
85+
private void Manager_KeyDown(object sender, KeyEventArgs e) {
86+
if (e.Control && e.KeyCode == Keys.L) {
87+
useLivesplitColors = !useLivesplitColors;
88+
if (useLivesplitColors) {
89+
this.BackColor = Color.White;
90+
this.ForeColor = Color.Black;
91+
} else {
92+
this.BackColor = Color.Black;
93+
this.ForeColor = Color.White;
94+
}
95+
}
96+
}
97+
}
98+
}

0 commit comments

Comments
 (0)