8
« on: May 08, 2024, 06:10:37 AM »
Just wanted to post on this- i think an additional key for modded menus is a good idea.
I implemented my own version in my old mod extender project, using the ~ key would bring up an external menu with mods and their designated key. then, when one of the keys gets activated, it would get the menu def information and write it into the games menu def files, save, and then macro the keys into that menu, so you dont need to manually open up the crafting menu and all that, allows for infinite menus, as you're able to exchange mod menus with a single key (i used Z)
Could probably be done with a simple keyboard/autohotkey interface if you want to avoid UI, which is the way i had mine setup.
Idk if this is useful to anyone, but to give you an idea of how it works in code:
private void ModManager_KeyDown(object sender, KeyEventArgs e) // Hide/Show extended menus
{
if (e.KeyCode == Keys.Escape)
{
this.Hide();
//MainForm.Show();
//WindowHandling.SetForegroundWindow(DefaultData.URW.MainWindowHandle);
}
else
{
foreach (Keys k in AssignedKeys.Keys)
{
if ((e.KeyCode | e.Modifiers) == k && !PlayerM.IsViewingRecipes && PlayerM.IsViewingWorld)
{
MainForm.GameEventHandler.HotkeyFunctions.RecipeCheck();
string GameKey = AssignedKeys[k][0].Split('-')[1];
string Menu = AssignedKeys[k][0].Split('*')[1];
File.WriteAllText(DefaultData.GameDirectory + Files.DefaultMenudef, AssignedKeys[k][0]); // <---writes selected menu key to menu def then performs macro to access menu
switch (Menu)
{
case "MAKE": // Shift M, +
WindowHandling.PostMessage(RWMain.TargetProcess.MainWindowHandle, WindowHandling.WM_CHAR, '+', IntPtr.Zero);
Thread.Sleep(25);
WindowHandling.PostMessage(RWMain.TargetProcess.MainWindowHandle, WindowHandling.WM_CHAR, GameKey.ToCharArray()[0], IntPtr.Zero);
break;
case "COOKERY": // alt C, s + c
WindowHandling.PostMessage(RWMain.TargetProcess.MainWindowHandle, WindowHandling.WM_CHAR, 's', IntPtr.Zero);
Thread.Sleep(50);
WindowHandling.PostMessage(RWMain.TargetProcess.MainWindowHandle, WindowHandling.WM_CHAR, 'c', IntPtr.Zero);
Thread.Sleep(25);
WindowHandling.PostMessage(RWMain.TargetProcess.MainWindowHandle, WindowHandling.WM_CHAR, GameKey.ToCharArray()[0], IntPtr.Zero);
break;
}
this.Hide();
//MainForm.Show();
//WindowHandling.SetForegroundWindow(DefaultData.URW.MainWindowHandle);
}
}
}// else if ()
}