Skip to content

Commit

Permalink
fix titles and icons for combined items
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjay900 committed Mar 22, 2023
1 parent fac51e4 commit f4ac989
Show file tree
Hide file tree
Showing 34 changed files with 107 additions and 138 deletions.
2 changes: 2 additions & 0 deletions Configuration/Conversions/AnalogToDigital.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public override string GetImagePath()
return Child.GetImagePath();
}

public override string Title => Child.Title;

public override IReadOnlyList<string> RequiredDefines()
{
return Child.RequiredDefines();
Expand Down
3 changes: 3 additions & 0 deletions Configuration/Conversions/AnalogToDigitalType.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System.ComponentModel;

namespace GuitarConfigurator.NetCore.Configuration.Conversions;

public enum AnalogToDigitalType
{
JoyLow,
JoyHigh,
[Description("Trigger / Button")]
Trigger
}
1 change: 1 addition & 0 deletions Configuration/Conversions/DigitalToAnalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public override Input InnermostInput()
{
return Child;
}
public override string Title => Child.Title;

public override void Update(List<Output> modelBindings, Dictionary<int, int> analogRaw,
Dictionary<int, bool> digitalRaw, byte[] ps2Raw,
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Inputs/DJInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public override string GenerateAll(List<Output> allBindings, List<Tuple<Input, s
{right}
}}";
}

public override string Title => EnumToStringConverter.Convert(Input);
public override string GetImagePath()
{
return $"DJ/{Input}.png";
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Inputs/DirectInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private IEnumerable<DevicePinMode> GetPinModes()
? modes.Where(mode => mode is not (DevicePinMode.BusKeep or DevicePinMode.PullDown))
: modes;
}

public override string Title => "Direct";

public override SerializedInput Serialise()
{
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Inputs/FixedInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override SerializedInput Serialise()
{
throw new NotImplementedException();
}

public override string Title => "Fixed";
public override void Update(List<Output> modelBindings, Dictionary<int, int> analogRaw,
Dictionary<int, bool> digitalRaw, byte[] ps2Raw, byte[] wiiRaw,
byte[] djLeftRaw, byte[] djRightRaw, byte[] gh5Raw, byte[] ghWtRaw, byte[] ps2ControllerType,
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Inputs/Gh5NeckInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Gh5NeckInput(Gh5NeckInputType input, ConfigViewModel model, int? sda = nu
Input = input;
IsAnalog = Input == Gh5NeckInputType.TapBar;
}

public override string Title => EnumToStringConverter.Convert(Input);
public bool Combined { get; }

public bool BindableTwi { get; }
Expand Down
1 change: 1 addition & 0 deletions Configuration/Inputs/GhWtTapInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public int Sensitivity
get => 60 - Model.WtSensitivity;
set => Model.WtSensitivity = (byte) (60 - value);
}
public override string Title => EnumToStringConverter.Convert(Input);

public override InputType? InputType => Types.InputType.WtNeckInput;
public override bool IsUint => true;
Expand Down
11 changes: 2 additions & 9 deletions Configuration/Inputs/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ public bool IsAnalog
get => _analog;
set => this.RaiseAndSetIfChanged(ref _analog, value);
}

private Output? _output;

public Output? Output
{
get => _output;
set => this.RaiseAndSetIfChanged(ref _output, value);
}

public abstract bool IsUint { get; }

public int RawValue
Expand Down Expand Up @@ -84,6 +75,8 @@ public abstract string GenerateAll(List<Output> allBindings, List<Tuple<Input, s

public abstract string GetImagePath();

public abstract string Title { get; }

private Bitmap GetImage()
{
if (_image != null) return _image;
Expand Down
1 change: 1 addition & 0 deletions Configuration/Inputs/MacroInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public override string Generate(ConfigField mode)
{
return $"{Child1.Generate(mode)} && {Child2.Generate(mode)}";
}
public override string Title => "Macro";

public override SerializedInput Serialise()
{
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Inputs/Ps2Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public static string GeneratePs2Pressures(List<Input> bindings)

return retDs2;
}

public override string Title => EnumToStringConverter.Convert(Input);
public override void Update(List<Output> modelBindings, Dictionary<int, int> analogRaw,
Dictionary<int, bool> digitalRaw, byte[] ps2Data,
byte[] wiiRaw, byte[] djLeftRaw,
Expand Down
1 change: 1 addition & 0 deletions Configuration/Inputs/WiiInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ public override string GenerateAll(List<Output> allBindings, List<Tuple<Input, s
}}
}}";
}
public override string Title => EnumToStringConverter.Convert(Input);

public override string GetImagePath()
{
Expand Down
4 changes: 2 additions & 2 deletions Configuration/Other/EmulationMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace GuitarConfigurator.NetCore.Configuration.Other;
public class EmulationMode : Output
{
public EmulationMode(ConfigViewModel model, Input input, EmulationModeType type) : base(
model, input, Colors.Black, Colors.Black, Array.Empty<byte>(), false)
model, input, Colors.Black, Colors.Black, Array.Empty<byte>())
{
Type = type;
}
Expand Down Expand Up @@ -50,7 +50,7 @@ private string GetDefinition()
public override bool IsStrum => false;

public override bool IsKeyboard => false;
public override bool IsController => false;
public virtual bool IsController => false;

public override bool Valid => true;
public override string LedOnLabel => "";
Expand Down
17 changes: 13 additions & 4 deletions Configuration/Other/JoystickToDpad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@

namespace GuitarConfigurator.NetCore.Configuration.Other;

public class JoystickToDpadInput : FixedInput
{
public override string Title => "Map joystick to Dpad";

public JoystickToDpadInput(ConfigViewModel model) : base(model, 0)
{
}
}

public class JoystickToDpad : Output
{
private int _threshold;
Expand Down Expand Up @@ -70,7 +79,7 @@ public bool Right
private List<ControllerButton> _outputs = new();

public JoystickToDpad(ConfigViewModel model, int threshold, bool wii) : base(
model, new FixedInput(model, 0), Colors.Black, Colors.Black, Array.Empty<byte>(), false)
model, new JoystickToDpadInput(model), Colors.Black, Colors.Black, Array.Empty<byte>())
{
Threshold = threshold;
Wii = wii;
Expand All @@ -95,6 +104,7 @@ public JoystickToDpad(ConfigViewModel model, int threshold, bool wii) : base(
new AnalogToDigital(new WiiInput(wiiInputType, model), AnalogToDigitalType.JoyLow, Threshold,
model), Colors.Black, Colors.Black, Array.Empty<byte>(), 10, StandardButtonType.DpadDown));
}

UpdateDetails();
return;
}
Expand All @@ -118,13 +128,11 @@ public JoystickToDpad(ConfigViewModel model, int threshold, bool wii) : base(
public override bool IsStrum => false;

public override bool IsKeyboard => false;
public override bool IsController => false;

public override bool Valid => true;
public override string LedOnLabel => "";
public override string LedOffLabel => "";




public override IEnumerable<Output> ValidOutputs()
{
Expand Down Expand Up @@ -177,6 +185,7 @@ public override void Update(List<Output> modelBindings, Dictionary<int, int> ana
output.Update(modelBindings, analogRaw, digitalRaw, ps2Raw, wiiRaw, djLeftRaw, djRightRaw, gh5Raw, ghWtRaw,
ps2ControllerType, wiiControllerType);
}

Up = _outputs.Where(s => s.Type is StandardButtonType.DpadUp)
.Any(x => x.ValueRaw != 0);
Down = _outputs.Where(s => s.Type is StandardButtonType.DpadDown)
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Other/Led.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public override string LedOnLabel
public override bool SupportsLedOff => !Command.IsAuth() && !Command.IsPlayer();

public override bool IsKeyboard => false;
public override bool IsController => false;
public virtual bool IsController => false;

public override bool Valid => true;

Expand Down
2 changes: 1 addition & 1 deletion Configuration/Other/Rumble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public RumbleMotorType RumbleMotorType
public override bool SupportsLedOff => false;

public override bool IsKeyboard => false;
public override bool IsController => false;
public virtual bool IsController => false;

public override bool Valid => true;

Expand Down
1 change: 0 additions & 1 deletion Configuration/Outputs/Combined/CombinedOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ protected CombinedOutput(ConfigViewModel model, Input input) : base(model, input
public override bool IsCombined => true;
public override bool IsStrum => false;
public override bool IsKeyboard => false;
public override bool IsController => true;


public override bool Valid => true;
Expand Down
18 changes: 12 additions & 6 deletions Configuration/Outputs/Combined/PS2CombinedOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public bool ControllerFound

private static Func<Output, bool> CreateFilter((bool controllerFound, Ps2ControllerType controllerType) tuple)
{
return output => tuple.controllerFound || output is JoystickToDpad ||
return output => !tuple.controllerFound || output is JoystickToDpad ||
(output.Input.InnermostInput() is Ps2Input ps2Input &&
ps2Input.SupportsType(tuple.controllerType));
}
Expand Down Expand Up @@ -192,8 +192,8 @@ public void CreateDefaults()
0, StandardAxisType.RightStickY));
foreach (var pair in Axis)
{

if (pair.Value is StandardAxisType.LeftTrigger or StandardAxisType.RightTrigger || pair.Key is Ps2InputType.GuitarWhammy)
if (pair.Value is StandardAxisType.LeftTrigger or StandardAxisType.RightTrigger ||
pair.Key is Ps2InputType.GuitarWhammy)
{
Outputs.Add(new ControllerAxis(Model,
new Ps2Input(pair.Key, Model, Miso, Mosi, Sck, Att, Ack, true),
Expand All @@ -208,6 +208,7 @@ public void CreateDefaults()
Colors.Black, Array.Empty<byte>(), short.MinValue, short.MaxValue, 0, pair.Value));
}
}

Outputs.Add(new JoystickToDpad(Model, short.MaxValue / 2, false));
UpdateBindings();
}
Expand All @@ -232,16 +233,21 @@ public override void Update(List<Output> modelBindings, Dictionary<int, int> ana
return;
}

ControllerFound = true;
var type = ps2ControllerType[0];
if (!Enum.IsDefined(typeof(Ps2ControllerType), type)) return;
if (!Enum.IsDefined(typeof(Ps2ControllerType), type))
{
ControllerFound = false;
return;
}

ControllerFound = true;
var newType = (Ps2ControllerType) type;
DetectedType = newType;
}

public override void UpdateBindings()
{
if (Model.DeviceType != DeviceControllerType.Guitar)
if (Model.DeviceType == DeviceControllerType.Guitar)
{
if (!Outputs.Items.Any(s => s is GuitarAxis {Type: GuitarAxisType.Whammy}))
{
Expand Down
1 change: 0 additions & 1 deletion Configuration/Outputs/ControllerAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public override string LedOffLabel
}

public override bool IsKeyboard => false;
public override bool IsController => true;
public override bool Valid => _valid.Value;

public override string GetName(DeviceControllerType deviceControllerType, RhythmType? rhythmType)
Expand Down
1 change: 0 additions & 1 deletion Configuration/Outputs/ControllerButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public ControllerButton(ConfigViewModel model, Input input, Color ledOn, Color l
public StandardButtonType Type { get; }

public override bool IsKeyboard => false;
public override bool IsController => true;

public override bool IsStrum => Type is StandardButtonType.DpadUp or StandardButtonType.DpadDown;

Expand Down
1 change: 0 additions & 1 deletion Configuration/Outputs/DJAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public DjAxis(ConfigViewModel model, Input input, Color ledOn, Color ledOff, byt
public DjAxisType Type { get; }

public override bool IsKeyboard => false;
public override bool IsController => true;

public override bool Valid => true;

Expand Down
1 change: 0 additions & 1 deletion Configuration/Outputs/DjButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public DjButton(ConfigViewModel model, Input input, Color ledOn, Color ledOff, b
public override string LedOffLabel => "Released LED Colour";

public override bool IsKeyboard => false;
public override bool IsController => true;


public override bool IsStrum => false;
Expand Down
1 change: 0 additions & 1 deletion Configuration/Outputs/DrumAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public DrumAxis(ConfigViewModel model, Input input, Color ledOn, Color ledOff, b
public override string LedOffLabel => "Drum not Hit LED Colour";

public override bool IsKeyboard => false;
public override bool IsController => true;

public int Threshold
{
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Outputs/EmptyOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class EmptyOutput : Output
.Select(ControllerEnumConverter.GetTypes).Select(s => s.Where(s2 => model.IsPico || s2 is not SimpleType.WtNeckSimple)).ToProperty(this, x => x.CombinedTypes);
}

public override bool IsController => _isController.Value;
public virtual bool IsController => _isController.Value;
public override bool IsKeyboard => _isKeyboard.Value;

public override bool Valid => true;
Expand Down
1 change: 0 additions & 1 deletion Configuration/Outputs/GuitarAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public GuitarAxis(ConfigViewModel model, Input input, Color ledOn, Color ledOff,
public GuitarAxisType Type { get; }

public override bool IsKeyboard => false;
public override bool IsController => true;

public override bool Valid => true;

Expand Down
4 changes: 2 additions & 2 deletions Configuration/Outputs/KeyboardButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public KeyboardButton(ConfigViewModel model, Input input, Color ledOn, Color led
or Key.VolumeMute or Key.VolumeUp;

public override bool IsKeyboard => true;
public override bool IsController => false;
public virtual bool IsController => false;


public override bool Valid => true;
Expand All @@ -170,7 +170,7 @@ public override void UpdateBindings()

public override string GetName(DeviceControllerType deviceControllerType, RhythmType? rhythmType)
{
return EnumToStringConverter.Convert(Key);
return Keys.ContainsKey(Key) ? Keys[Key] : "";
}

public override string GenerateOutput(ConfigField mode)
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Outputs/MouseAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public MouseAxis(ConfigViewModel model, Input input, Color ledOn, Color ledOff,
}

public override bool IsKeyboard => true;
public override bool IsController => false;
public virtual bool IsController => false;


public override bool Valid => true;
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Outputs/MouseButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public MouseButton(ConfigViewModel model, Input input, Color ledOn, Color ledOff
}

public override bool IsKeyboard => true;
public override bool IsController => false;
public virtual bool IsController => false;

public MouseButtonType Type { get; }

Expand Down
Loading

0 comments on commit f4ac989

Please sign in to comment.