Restore the stable legacy Unity project
This commit is contained in:
parent
56a156ee87
commit
7006a6b0dd
2070 changed files with 180490 additions and 169303 deletions
|
|
@ -1,85 +1,18 @@
|
|||
using System.Collections.Generic;
|
||||
using JsonKnownTypes;using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class InputLayout
|
||||
{
|
||||
public InputLayoutRow[] Rows;
|
||||
|
||||
public static InputLayout CreateAnsi104()
|
||||
{
|
||||
return new InputLayout
|
||||
{
|
||||
Rows = new InputLayoutRow[]
|
||||
{
|
||||
Row(
|
||||
Key("Esc"), Spacer(1), Key("F1"), Key("F2"), Key("F3"), Key("F4"), Spacer(.5f),
|
||||
Key("F5"), Key("F6"), Key("F7"), Key("F8"), Spacer(.5f),
|
||||
Key("F9"), Key("F10"), Key("F11"), Key("F12"), Spacer(.25f),
|
||||
Key(""), Key(""), Key("")),
|
||||
RowSpacer(.5f),
|
||||
Row(
|
||||
Key("~\n`"), Key("!\n1"), Key("@\n2"), Key("#\n3"), Key("$\n4"), Key("%\n5"), Key("^\n6"),
|
||||
Key("&\n7"), Key("*\n8"), Key("(\n9"), Key(")\n0"), Key("_\n-"), Key("+\n="), Key("Backspace", 2),
|
||||
Spacer(.25f), Key("Insert"), Key("Home"), Key("PgUp"), Spacer(.25f), Key(""), Key("/"), Key("*"), Key("-")),
|
||||
Row(
|
||||
Key("Tab", 1.5f), Key("Q"), Key("W"), Key("E"), Key("R"), Key("T"), Key("Y"), Key("U"), Key("I"), Key("O"), Key("P"),
|
||||
Key("{\n["), Key("}\n]"), Key("|\n\\", 1.5f), Spacer(.25f),
|
||||
Key("Delete"), Key("End"), Key("PgDn"), Spacer(.25f), Key("Home\n7"), Key("Up\n8"), Key("PgUp\n9"), Key("+", 1, 2)),
|
||||
Row(
|
||||
Key("Caps Lock", 1.75f), Key("A"), Key("S"), Key("D"), Key("F"), Key("G"), Key("H"), Key("J"), Key("K"), Key("L"),
|
||||
Key(":\n;"), Key("\"\n'"), Key("Enter", 2.25f), Spacer(3.5f), Key("Left\n4"), Key("5"), Key("Right\n6")),
|
||||
Row(
|
||||
Key("Shift", 2.25f), Key("Z"), Key("X"), Key("C"), Key("V"), Key("B"), Key("N"), Key("M"),
|
||||
Key("<\n,"), Key(">\n."), Key("?\n/"), Key("Shift", 2.75f), Spacer(1.25f), Key("Up"), Spacer(1.25f),
|
||||
Key("End\n1"), Key("Down\n2"), Key("PgDn\n3"), Key("Enter", 1, 2)),
|
||||
Row(
|
||||
Key("Ctrl", 1.25f), Key("", 1.25f), Key("Alt", 1.25f), Key("Spacebar", 6.25f), Key("Alt", 1.25f),
|
||||
Key("", 1.25f), Key("", 1.25f), Key("Ctrl", 1.25f), Spacer(.25f),
|
||||
Key("Left"), Key("Down"), Key("Right"), Spacer(.25f), Key("Ins\n0", 2), Key("Del\n."))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static InputLayoutRowSpacer RowSpacer(float height)
|
||||
{
|
||||
return new InputLayoutRowSpacer {Height = height};
|
||||
}
|
||||
|
||||
private static InputLayoutKeyRow Row(params InputLayoutColumn[] columns)
|
||||
{
|
||||
return new InputLayoutKeyRow {Columns = columns};
|
||||
}
|
||||
|
||||
private static InputLayoutColumnSpacer Spacer(float width)
|
||||
{
|
||||
return new InputLayoutColumnSpacer {Width = width};
|
||||
}
|
||||
|
||||
private static InputLayoutKey Key(string label, float width = 1f, int height = 1)
|
||||
{
|
||||
InputLayoutKey key;
|
||||
var trimmedLabel = label.Trim();
|
||||
if (!string.IsNullOrEmpty(trimmedLabel))
|
||||
{
|
||||
var labels = trimmedLabel.Split('\n');
|
||||
key = height != 1 ? new InputLayoutMultiRowKey {Height = height} : new InputLayoutBindableKey();
|
||||
((InputLayoutBindableKey) key).MainLabel = labels.Length == 2 ? labels[1] : trimmedLabel;
|
||||
((InputLayoutBindableKey) key).AltLabel = labels.Length == 2 ? labels[0] : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
key = new InputLayoutKey();
|
||||
}
|
||||
|
||||
key.Width = width;
|
||||
return key;
|
||||
}
|
||||
[Key(0), JsonProperty("rows")] public InputLayoutRow[] Rows;
|
||||
|
||||
public IEnumerable<InputLayoutBindableKey> GetBindableKeys()
|
||||
{
|
||||
foreach (var row in Rows)
|
||||
{
|
||||
if (!(row is InputLayoutKeyRow keyRow)) continue;
|
||||
|
||||
|
||||
foreach (var column in keyRow.Columns)
|
||||
{
|
||||
if (column is InputLayoutBindableKey bindableKey)
|
||||
|
|
@ -91,33 +24,51 @@ public class InputLayout
|
|||
}
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(JsonKnownTypesConverter<InputLayoutRow>)),
|
||||
MessagePackObject,
|
||||
Union(0, typeof(InputLayoutRowSpacer)),
|
||||
Union(1, typeof(InputLayoutKeyRow))
|
||||
]
|
||||
public abstract class InputLayoutRow { }
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class InputLayoutRowSpacer : InputLayoutRow
|
||||
{
|
||||
public float Height;
|
||||
[Key(0), JsonProperty("height")] public float Height;
|
||||
}
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class InputLayoutKeyRow : InputLayoutRow
|
||||
{
|
||||
public InputLayoutColumn[] Columns;
|
||||
[Key(0), JsonProperty("columns")] public InputLayoutColumn[] Columns;
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(JsonKnownTypesConverter<InputLayoutColumn>)),
|
||||
MessagePackObject,
|
||||
Union(0, typeof(InputLayoutColumnSpacer)),
|
||||
Union(1, typeof(InputLayoutKey)),
|
||||
Union(2, typeof(InputLayoutBindableKey)),
|
||||
Union(3, typeof(InputLayoutMultiRowKey))
|
||||
]
|
||||
public abstract class InputLayoutColumn
|
||||
{
|
||||
public float Width;
|
||||
[Key(0), JsonProperty("width")] public float Width;
|
||||
}
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class InputLayoutColumnSpacer : InputLayoutColumn { }
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class InputLayoutKey : InputLayoutColumn { }
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class InputLayoutBindableKey : InputLayoutKey, IBindableButton
|
||||
{
|
||||
public string MainLabel;
|
||||
public string AltLabel;
|
||||
public string ShortPath;
|
||||
[Key(1), JsonProperty("mainLabel")] public string MainLabel;
|
||||
[Key(2), JsonProperty("altLabel")] public string AltLabel;
|
||||
[Key(3), JsonProperty("path")] public string ShortPath;
|
||||
|
||||
[IgnoreMember]
|
||||
public string InputSystemPath
|
||||
{
|
||||
get
|
||||
|
|
@ -133,7 +84,7 @@ public class InputLayoutBindableKey : InputLayoutKey, IBindableButton
|
|||
|
||||
public class InputLayoutMultiRowKey : InputLayoutBindableKey
|
||||
{
|
||||
public int Height;
|
||||
[Key(4), JsonProperty("height")] public int Height;
|
||||
}
|
||||
|
||||
public class InputLayoutMouseButton : IBindableButton
|
||||
|
|
@ -149,4 +100,4 @@ public class InputLayoutMouseButton : IBindableButton
|
|||
public interface IBindableButton
|
||||
{
|
||||
public string InputSystemPath { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue