Progression And Cleanup
This commit is contained in:
parent
012cc02352
commit
0918ac5a80
@ -10,27 +10,45 @@ namespace FakeeDeck.ButtonType
|
|||||||
{
|
{
|
||||||
class HelldiversTwoMacro : Button
|
class HelldiversTwoMacro : Button
|
||||||
{
|
{
|
||||||
|
const uint Key_Up = 0x68;
|
||||||
|
const uint Key_Down = 0x62;
|
||||||
|
const uint Key_Left = 0x64;
|
||||||
|
const uint Key_Right = 0x66;
|
||||||
|
|
||||||
//https://helldivers.wiki.gg/wiki/Stratagems
|
//https://helldivers.wiki.gg/wiki/Stratagems
|
||||||
//https://helldivers.fandom.com/wiki/Stratagems_(Helldivers_2)
|
//https://helldivers.fandom.com/wiki/Stratagems_(Helldivers_2)
|
||||||
|
|
||||||
public static Dictionary<string, uint[]> stratogems = new Dictionary<string, uint[]>
|
public static Dictionary<string, uint[]> stratogems = new Dictionary<string, uint[]>
|
||||||
{
|
{
|
||||||
{ "reinforce", new uint[] { 0x65, 0x68, 0x62, 0x66, 0x64, 0x68}},
|
//Mission
|
||||||
{ "resupply", new uint[] { 0x65, 0x62, 0x62, 0x68, 0x66 }},
|
{ "reinforce", new uint[] { 0x65, Key_Up, Key_Down, Key_Right, Key_Left, Key_Up}},
|
||||||
//Patriotic Administration Center
|
{ "resupply", new uint[] { 0x65, Key_Down, Key_Down, Key_Up, Key_Right }},
|
||||||
{ "anti-material", new uint[] { 0x65, 0x62, 0x64, 0x66, 0x68, 0x62}},
|
|
||||||
{ "flamethrower", new uint[] { 0x65, 0x62, 0x64, 0x68, 0x62, 0x68}},
|
//Support Weapons
|
||||||
{ "autocannon", new uint[] { 0x65, 0x62, 0x64, 0x62, 0x68, 0x68, 0x66}},
|
{ "anti-material", new uint[] { 0x65, Key_Down, Key_Left, Key_Right, Key_Up, Key_Down}},
|
||||||
{ "grenade-launcher", new uint[] { 0x65, 0x62, 0x64, 0x68, 0x64, 0x62}},
|
{ "flamethrower", new uint[] { 0x65, Key_Down, Key_Left, Key_Up, Key_Down, Key_Up}},
|
||||||
|
{ "autocannon", new uint[] { 0x65, Key_Down, Key_Left, Key_Down, Key_Up, Key_Up, Key_Right}},
|
||||||
|
{ "grenade-launcher", new uint[] { 0x65, Key_Down, Key_Left, Key_Up, Key_Left, Key_Down}},
|
||||||
|
|
||||||
|
//Offensive: Orbital Strikes
|
||||||
|
{ "orbital-precision-strike", new uint[] { 0x65, Key_Right, Key_Right, Key_Up}},
|
||||||
|
|
||||||
|
//Defensive
|
||||||
|
{ "mortar-sentry", new uint[] { 0x65, Key_Down, Key_Up, Key_Right, Key_Down}},
|
||||||
|
{ "gatling-sentry", new uint[] { 0x65, Key_Down, Key_Up, Key_Right, Key_Left}},
|
||||||
|
|
||||||
|
|
||||||
|
//Supply: Backpacks
|
||||||
|
|
||||||
|
//Offensive: Eagle
|
||||||
|
{ "strafing-run", new uint[] { 0x65, Key_Up, Key_Right, Key_Right}},
|
||||||
|
{ "airstrike", new uint[] { 0x65, Key_Up, Key_Right, Key_Down, Key_Right}},
|
||||||
|
{ "cluster-bomb", new uint[] { 0x65, Key_Up, Key_Right, Key_Down, Key_Down, Key_Right}},
|
||||||
|
{ "napalm-airstrike", new uint[] { 0x65, Key_Up, Key_Right, Key_Down, Key_Up}},
|
||||||
|
{ "smoke-strike", new uint[] { 0x65, Key_Up, Key_Right, Key_Up, Key_Down}},
|
||||||
|
{ "rocket-pods", new uint[] { 0x65, Key_Up, Key_Right, Key_Up, Key_Left}},
|
||||||
|
{ "bomb", new uint[] { 0x65, Key_Up, Key_Right, Key_Up, Key_Right}},
|
||||||
|
|
||||||
//Orbital Cannons
|
|
||||||
{ "orbital-precision-strike", new uint[] { 0x65, 0x66, 0x66, 0x68}},
|
|
||||||
//Robotics Workshop
|
|
||||||
{ "mortar-sentry", new uint[] { 0x65, 0x62, 0x68, 0x66, 0x62}},
|
|
||||||
{ "gatling-sentry", new uint[] { 0x65, 0x62, 0x68, 0x66, 0x64}},
|
|
||||||
//Hangar
|
|
||||||
{ "rocket-pods", new uint[] { 0x65, 0x68, 0x66, 0x68, 0x64}},
|
|
||||||
{ "bomb", new uint[] { 0x65, 0x68, 0x66, 0x68, 0x64}},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Dictionary<string, string> stratogemsIcons = new Dictionary<string, string>
|
public static Dictionary<string, string> stratogemsIcons = new Dictionary<string, string>
|
||||||
@ -44,6 +62,13 @@ namespace FakeeDeck.ButtonType
|
|||||||
{ "orbital-precision-strike", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/4/47/Orbital_Precision_Strike_Icon.png"},
|
{ "orbital-precision-strike", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/4/47/Orbital_Precision_Strike_Icon.png"},
|
||||||
{ "mortar-sentry", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/1/1d/A_M-12_Mortar_Sentry_Icon.png"},
|
{ "mortar-sentry", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/1/1d/A_M-12_Mortar_Sentry_Icon.png"},
|
||||||
{ "gatling-sentry","https://static.wikia.nocookie.net/helldivers_gamepedia/images/4/48/A_G-16_Gatling_Sentry_Icon.png"},
|
{ "gatling-sentry","https://static.wikia.nocookie.net/helldivers_gamepedia/images/4/48/A_G-16_Gatling_Sentry_Icon.png"},
|
||||||
|
|
||||||
|
//Offensive: Eagle
|
||||||
|
{ "strafing-run","https://static.wikia.nocookie.net/helldivers_gamepedia/images/3/33/Eagle_Strafing_Run_Icon.png"},
|
||||||
|
{ "airstrike","https://static.wikia.nocookie.net/helldivers_gamepedia/images/7/7e/Eagle_Airstrike_Icon.png"},
|
||||||
|
{ "cluster-bomb","https://static.wikia.nocookie.net/helldivers_gamepedia/images/8/89/Eagle_Cluster_Bomb_Icon.png"},
|
||||||
|
{ "napalm-airstrike","https://static.wikia.nocookie.net/helldivers_gamepedia/images/d/d4/Eagle_Napalm_Airstrike_Icon.png"},
|
||||||
|
{ "smoke-strike","https://static.wikia.nocookie.net/helldivers_gamepedia/images/1/1a/Eagle_Smoke_Strike_Icon.png"},
|
||||||
{ "rocket-pods","https://static.wikia.nocookie.net/helldivers_gamepedia/images/e/e3/Eagle_110MM_Rocket_Pods_Icon.png"},
|
{ "rocket-pods","https://static.wikia.nocookie.net/helldivers_gamepedia/images/e/e3/Eagle_110MM_Rocket_Pods_Icon.png"},
|
||||||
{ "bomb","https://static.wikia.nocookie.net/helldivers_gamepedia/images/5/5a/Eagle_500KG_Bomb_Icon.png"},
|
{ "bomb","https://static.wikia.nocookie.net/helldivers_gamepedia/images/5/5a/Eagle_500KG_Bomb_Icon.png"},
|
||||||
};
|
};
|
||||||
|
41
FakeeDeck/Class/AbstractionHelper.cs
Normal file
41
FakeeDeck/Class/AbstractionHelper.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FakeeDeck.Class
|
||||||
|
{
|
||||||
|
internal class AbstractionHelper
|
||||||
|
{
|
||||||
|
public static Type? resolvType(string className)
|
||||||
|
{
|
||||||
|
string cleanClass = "FakeeDeck.ButtonType." + className.Trim('/');
|
||||||
|
|
||||||
|
Type? buttonClass = Type.GetType(cleanClass, true);
|
||||||
|
|
||||||
|
if (buttonClass is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return buttonClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string getButtonVisual(JsonElement button)
|
||||||
|
{
|
||||||
|
string calssName = button.GetProperty("function").ToString();
|
||||||
|
MethodInfo? renderMethod = AbstractionHelper.resolvType(calssName).GetMethod("getButton");
|
||||||
|
ParameterInfo[] pars = renderMethod.GetParameters();
|
||||||
|
List<object> parameters = new List<object>();
|
||||||
|
|
||||||
|
foreach (ParameterInfo p in pars)
|
||||||
|
{
|
||||||
|
JsonElement parameter = button.GetProperty("parameters").EnumerateArray().SingleOrDefault(item => item.GetProperty("name").ToString() == p.Name);
|
||||||
|
parameters.Insert(p.Position, parameter.GetProperty("value").ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return renderMethod.Invoke(null, [.. parameters]).ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ using System.IO;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using FakeeDeck.ButtonType;
|
using FakeeDeck.ButtonType;
|
||||||
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
namespace FakeeDeck.Class
|
||||||
{
|
{
|
||||||
@ -17,9 +18,20 @@ namespace FakeeDeck.Class
|
|||||||
{
|
{
|
||||||
public FakeDeck()
|
public FakeDeck()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
YamlHelper yaml = new YamlHelper();
|
||||||
HttpServer server = new HttpServer();
|
HttpServer server = new HttpServer();
|
||||||
|
|
||||||
foreach (var stratogem in HelldiversTwoMacro.stratogems)
|
foreach (JsonElement item in yaml.getData().GetProperty("pages").EnumerateArray())
|
||||||
|
{
|
||||||
|
Debug.WriteLine("PAGE: " + item.GetProperty("page"));
|
||||||
|
foreach (JsonElement button in item.GetProperty("buttons").EnumerateArray())
|
||||||
|
{
|
||||||
|
server.pageData += AbstractionHelper.getButtonVisual(button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*foreach (var stratogem in HelldiversTwoMacro.stratogems)
|
||||||
{
|
{
|
||||||
server.pageData += HelldiversTwoMacro.getButton(stratogem.Key);
|
server.pageData += HelldiversTwoMacro.getButton(stratogem.Key);
|
||||||
}
|
}
|
||||||
@ -27,9 +39,11 @@ namespace FakeeDeck.Class
|
|||||||
foreach (var control in MediaMacro.mediaControls)
|
foreach (var control in MediaMacro.mediaControls)
|
||||||
{
|
{
|
||||||
server.pageData += MediaMacro.getButton(control.Key);
|
server.pageData += MediaMacro.getButton(control.Key);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
server.serv();
|
server.serv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ using System.Reflection.Metadata;
|
|||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
namespace FakeeDeck.Class
|
||||||
{
|
{
|
||||||
@ -118,7 +119,7 @@ namespace FakeeDeck.Class
|
|||||||
" </body>" +
|
" </body>" +
|
||||||
"</html>";
|
"</html>";
|
||||||
public string pageData = "";
|
public string pageData = "";
|
||||||
|
private Dictionary<string, Dictionary<string, Action>> routes;
|
||||||
public async Task HandleIncomingConnections()
|
public async Task HandleIncomingConnections()
|
||||||
{
|
{
|
||||||
bool runServer = true;
|
bool runServer = true;
|
||||||
|
28
FakeeDeck/Class/YamlHelper.cs
Normal file
28
FakeeDeck/Class/YamlHelper.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
|
namespace FakeeDeck.Class
|
||||||
|
{
|
||||||
|
internal class YamlHelper
|
||||||
|
{
|
||||||
|
JsonDocument jsonObjecz;
|
||||||
|
public YamlHelper()
|
||||||
|
{
|
||||||
|
var r = new StreamReader("./configuration.yaml");
|
||||||
|
var deserializer = new Deserializer();
|
||||||
|
object yamlObject = deserializer.Deserialize(r);
|
||||||
|
string json = System.Text.Json.JsonSerializer.Serialize(yamlObject);
|
||||||
|
jsonObjecz = JsonDocument.Parse(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonElement getData()
|
||||||
|
{
|
||||||
|
return jsonObjecz.RootElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,8 +3,58 @@ server:
|
|||||||
port: 8000
|
port: 8000
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
- page: helldivers,
|
- page: helldivers
|
||||||
buttons:
|
buttons:
|
||||||
- button: reinforce,
|
- button: reinforce
|
||||||
name: reinforce,
|
function: HelldiversTwoMacro
|
||||||
type: HelldiversTwoMacro,
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "reinforce"
|
||||||
|
|
||||||
|
- button: strafing-run
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: strafing-run
|
||||||
|
|
||||||
|
- button: airstrike
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: airstrike
|
||||||
|
|
||||||
|
- button: cluster-bomb
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: cluster-bomb
|
||||||
|
|
||||||
|
- button: napalm-airstrike
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: napalm-airstrike
|
||||||
|
|
||||||
|
- button: smoke-strike
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: smoke-strike
|
||||||
|
|
||||||
|
- button: rocket-pods
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: rocket-pods
|
||||||
|
|
||||||
|
- button: bomb
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: bomb
|
||||||
|
|
||||||
|
- button: mute
|
||||||
|
function: MediaMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "mute"
|
Loading…
Reference in New Issue
Block a user