-
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.
Refactor InputDisplayGenerator + LogEntryGenerator + ControllerDefini…
…tion (#3782) * refactor InputDisplayGenerator and LogEntryGenerator handling * Fix NRE in Tastudio. I can already see this avalanching into 100 different bugs * cba, revert 48f4e13 and bring back bullshit dummy default MovieController * Refactor MnemonicCache + make Bk2LogEntryGenerator and Bk2InputDisplayGenerator static. This should simplify stuff and make the logic clearer
- Loading branch information
Showing
50 changed files
with
239 additions
and
401 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
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
62 changes: 0 additions & 62 deletions
62
src/BizHawk.Client.Common/display/IInputDisplayGenerator.cs
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
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,46 @@ | ||
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
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
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.