Add event.availableScopes(), fix LogWithSeparator, cleanup
This commit is contained in:
parent
71aaf349b5
commit
ad8f321ea1
|
@ -363,6 +363,15 @@ namespace BizHawk.Client.Common
|
|||
return false;
|
||||
}
|
||||
|
||||
[LuaMethodExample("local scopes = event.availableScopes();")]
|
||||
[LuaMethod("availableScopes", "Lists the available scopes that can be passed into memory events")]
|
||||
public LuaTable AvailableScopes()
|
||||
{
|
||||
return DebuggableCore?.MemoryCallbacksAvailable() == true
|
||||
? DebuggableCore.MemoryCallbacks.AvailableScopes.ToLuaTable(Lua)
|
||||
: Lua.NewTable();
|
||||
}
|
||||
|
||||
private string ProcessScope(string scope)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(scope))
|
||||
|
|
|
@ -71,23 +71,31 @@ namespace BizHawk.Client.EmuHawk
|
|||
// Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable
|
||||
private static void LogWithSeparator(string separator, string terminator, params object[] outputs)
|
||||
{
|
||||
static string SerialiseTable(LuaTable lti)
|
||||
static string SerializeTable(LuaTable lti)
|
||||
{
|
||||
var keyObjs = lti.Keys;
|
||||
var valueObjs = lti.Values;
|
||||
if (keyObjs.Count != valueObjs.Count) throw new IndexOutOfRangeException("each value must be paired with one key, they differ in number");
|
||||
var values = new List<object>(keyObjs.Count);
|
||||
if (keyObjs.Count != valueObjs.Count)
|
||||
{
|
||||
throw new IndexOutOfRangeException("each value must be paired with one key, they differ in number");
|
||||
}
|
||||
|
||||
var values = new object[keyObjs.Count];
|
||||
var kvpIndex = 0;
|
||||
foreach (var valueObj in valueObjs) values[kvpIndex++] = valueObj;
|
||||
foreach (var valueObj in valueObjs)
|
||||
{
|
||||
values[kvpIndex++] = valueObj;
|
||||
}
|
||||
|
||||
return string.Concat(keyObjs.Cast<object>()
|
||||
.Select((kObj, i) => $"\"{kObj}\": \"{values[i]}\"\n")
|
||||
.OrderBy(s => s)
|
||||
);
|
||||
}
|
||||
|
||||
static void SerialiseAndWrite(object output) => GlobalWin.Tools.LuaConsole.WriteToOutputWindow(
|
||||
static void SerializeAndWrite(object output) => GlobalWin.Tools.LuaConsole.WriteToOutputWindow(
|
||||
output is LuaTable table
|
||||
? SerialiseTable(table)
|
||||
? SerializeTable(table)
|
||||
: output?.ToString() ?? "nil"
|
||||
);
|
||||
|
||||
|
@ -102,11 +110,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
|
||||
SerialiseAndWrite(outputs[0]);
|
||||
SerializeAndWrite(outputs[0]);
|
||||
for (int outIndex = 1, indexAfterLast = outputs.Length; outIndex != indexAfterLast; outIndex++)
|
||||
{
|
||||
GlobalWin.Tools.LuaConsole.WriteToOutputWindow(separator);
|
||||
SerialiseAndWrite(outputs[outIndex]);
|
||||
SerializeAndWrite(outputs[outIndex]);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(terminator))
|
||||
|
|
|
@ -277,6 +277,7 @@
|
|||
<s:Boolean x:Key="/Default/UserDictionary/Words/=nsamp/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Numerics/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=nvidia/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Objs/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=opcode/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=opengl/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Overdump/@EntryIndexedValue">True</s:Boolean>
|
||||
|
|
Loading…
Reference in New Issue