-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ make Bk2LogEntryGenerator and Bk2InputDisplayGenerator static This should simplify stuff and make the logic clearer
- Loading branch information
Showing
45 changed files
with
297 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 0 additions & 65 deletions
65
src/BizHawk.Client.Common/display/IInputDisplayGenerator.cs
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
src/BizHawk.Client.Common/display/InputDisplayGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Text; | ||
using BizHawk.Emulation.Common; | ||
|
||
namespace BizHawk.Client.Common | ||
{ | ||
/// <summary> | ||
/// Generates a display friendly version of the input log entry | ||
/// using .bk2 mnemonics as the basis for display | ||
/// </summary> | ||
public static class Bk2InputDisplayGenerator | ||
{ | ||
public static string Generate(IController source) | ||
{ | ||
if (source.Definition.MnemonicsCache is null) | ||
throw new InvalidOperationException("Can't generate input display string with empty mnemonics cache"); | ||
|
||
var sb = new StringBuilder(); | ||
|
||
foreach ((string buttonName, AxisSpec? axisSpec) in source.Definition.ControlsOrdered.SelectMany(x => x)) | ||
{ | ||
if (axisSpec.HasValue) | ||
{ | ||
int val = source.AxisValue(buttonName); | ||
|
||
if (val == axisSpec.Value.Neutral) | ||
{ | ||
sb.Append(" "); | ||
} | ||
else | ||
{ | ||
sb.Append(val.ToString().PadLeft(5, ' ')).Append(','); | ||
} | ||
} | ||
else | ||
{ | ||
sb.Append(source.IsPressed(buttonName) | ||
? source.Definition.MnemonicsCache[buttonName] | ||
: ' '); | ||
} | ||
} | ||
|
||
return sb.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.