mirror of
https://github.com/kwsch/NHSE.git
synced 2026-09-27 20:36:55 -05:00
Added support for USB-botbase (#299)
Only for player item injection at this time; no sync / toggle between modes
This commit is contained in:
@@ -9,13 +9,17 @@ public partial class SysBotUI : Form
|
||||
{
|
||||
private readonly AutoInjector Injector;
|
||||
private readonly SysBotController Bot;
|
||||
private readonly AutoInjector InjectorUSB;
|
||||
private readonly USBBotController BotUSB;
|
||||
|
||||
public SysBotUI(AutoInjector injector, SysBotController c)
|
||||
public SysBotUI(AutoInjector injector, SysBotController c, AutoInjector injectorUSB, USBBotController b)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.TranslateInterface(GameInfo.CurrentLanguage);
|
||||
Bot = c;
|
||||
Injector = injector;
|
||||
BotUSB = b;
|
||||
InjectorUSB = injectorUSB;
|
||||
|
||||
var offset = Bot.GetDefaultOffset();
|
||||
Injector.SetWriteOffset(offset);
|
||||
@@ -122,5 +126,79 @@ private void RamOffset_TextChanged(object sender, EventArgs e)
|
||||
|
||||
Injector.SetWriteOffset(offset);
|
||||
}
|
||||
|
||||
private void ReadUSB_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!BotUSB.Connect())
|
||||
return;
|
||||
|
||||
var offset = StringUtil.GetHexValue(RamOffsetUSB.Text);
|
||||
if (offset == 0)
|
||||
{
|
||||
WinFormsUtil.Error(MessageStrings.MsgInvalidHexValue);
|
||||
return;
|
||||
}
|
||||
|
||||
InjectorUSB.SetWriteOffset(offset);
|
||||
|
||||
try
|
||||
{
|
||||
var result = InjectorUSB.Read(true);
|
||||
if (result == InjectionResult.Success)
|
||||
return;
|
||||
WinFormsUtil.Alert(result.ToString());
|
||||
}
|
||||
#pragma warning disable CA1031 // Do not catch general exception types
|
||||
catch (Exception ex)
|
||||
#pragma warning restore CA1031 // Do not catch general exception types
|
||||
{
|
||||
WinFormsUtil.Error(ex.Message);
|
||||
}
|
||||
|
||||
BotUSB.Disconnect();
|
||||
}
|
||||
|
||||
private void WriteUSB_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!BotUSB.Connect())
|
||||
return;
|
||||
|
||||
var offset = StringUtil.GetHexValue(RamOffsetUSB.Text);
|
||||
if (offset == 0)
|
||||
{
|
||||
WinFormsUtil.Error(MessageStrings.MsgInvalidHexValue);
|
||||
return;
|
||||
}
|
||||
|
||||
InjectorUSB.SetWriteOffset(offset);
|
||||
|
||||
try
|
||||
{
|
||||
var result = InjectorUSB.Write(true);
|
||||
if (result == InjectionResult.Success)
|
||||
return;
|
||||
WinFormsUtil.Alert(result.ToString());
|
||||
}
|
||||
#pragma warning disable CA1031 // Do not catch general exception types
|
||||
catch (Exception ex)
|
||||
#pragma warning restore CA1031 // Do not catch general exception types
|
||||
{
|
||||
WinFormsUtil.Error(ex.Message);
|
||||
}
|
||||
|
||||
BotUSB.Disconnect();
|
||||
}
|
||||
|
||||
private void RamOffsetUSB_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
var offset = StringUtil.GetHexValue(RamOffsetUSB.Text);
|
||||
if (offset == 0)
|
||||
{
|
||||
WinFormsUtil.Error(MessageStrings.MsgInvalidHexValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Injector.SetWriteOffset(offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user