private IntPtr AddonSelectYesNoOnSetupDetour(IntPtr addon, uint a2, IntPtr dataPtr) { PluginLog.Debug($"AddonSelectYesNo.OnSetup"); var result = AddonSelectYesNoOnSetupHook.Original(addon, a2, dataPtr); try { var data = Marshal.PtrToStructure <AddonSelectYesNoOnSetupData>(dataPtr); var text = LastSeenDialogText = Marshal.PtrToStringAnsi(data.textPtr).Replace('\n', ' '); if (Configuration.Enabled) { foreach (var item in Configuration.TextEntries) { if (item.Enabled && !string.IsNullOrEmpty(item.Text)) { if ((item.IsRegex && (item.Regex?.IsMatch(text) ?? false)) || (!item.IsRegex && text.Contains(item.Text))) { unsafe { var addonObj = (AddonSelectYesno *)addon; var yesButton = addonObj->YesButton; if (yesButton != null && !yesButton->IsEnabled) { PluginLog.Debug($"AddonSelectYesNo: Enabling yes button"); yesButton->AtkComponentBase.OwnerNode->AtkResNode.Flags ^= 1 << 5; } } PluginLog.Debug($"AddonSelectYesNo: Selecting yes"); Click.SendClick("select_yes"); break; } } } } } catch (Exception ex) { PluginLog.Error(ex, "Don't crash the game"); } return(result); }
private IntPtr AddonNoTextMatchDetour(IntPtr addon, uint a2, IntPtr dataPtr, Hook <OnSetupDelegate> hook, bool enabled, params string[] clicks) { var result = hook.Original(addon, a2, dataPtr); try { if (Configuration.Enabled && enabled) { foreach (var click in clicks) { Click.SendClick(click); } } } catch (Exception ex) { PluginLog.Error(ex, "Don't crash the game"); } return(result); }