Created
December 14, 2020 22:45
-
-
Save Y-Less/3a7bbe3b16bf28a35ac1349a6abb7e50 to your computer and use it in GitHub Desktop.
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
YSI_Core/y_core/y_samp_natives.inc | 7 ++++++ | |
YSI_Core/y_testing/y_testing_entry.inc | 16 ++++---------- | |
YSI_Visual/y_dialog/y_dialog_impl.inc | 40 ++++++++++++++++++++++------------ | |
3 files changed, 37 insertions(+), 26 deletions(-) | |
diff --git a/YSI_Core/y_core/y_samp_natives.inc b/YSI_Core/y_core/y_samp_natives.inc | |
index f871a819..eb0da12a 100644 | |
--- a/YSI_Core/y_core/y_samp_natives.inc | |
+++ b/YSI_Core/y_core/y_samp_natives.inc | |
@@ -80,3 +80,10 @@ native YSI_PrintF(const format[], GLOBAL_TAG_TYPES:...) = printf; | |
native YSI_SetTimer(const funcname[], interval, repeating) = SetTimer; | |
native YSI_SetTimerEx(const funcname[], interval, repeating, const format[], GLOBAL_TAG_TYPES:...) = SetTimerEx; | |
+// This doesn't always exist, but must for y_testing and y_dialog. | |
+#if !defined _ALS_ShowPlayerDialog | |
+ native YSI_ShowPlayerDialog(playerid, dialogid, style, const caption[], const info[], const button1[], const button2[]) = ShowPlayerDialog; | |
+ #define _ALS_ShowPlayerDialog | |
+ #define ShowPlayerDialog YSI_ShowPlayerDialog | |
+#endif | |
+ | |
diff --git a/YSI_Core/y_testing/y_testing_entry.inc b/YSI_Core/y_testing/y_testing_entry.inc | |
index 758749f3..cfe22533 100644 | |
--- a/YSI_Core/y_testing/y_testing_entry.inc | |
+++ b/YSI_Core/y_testing/y_testing_entry.inc | |
@@ -311,8 +311,6 @@ stock _Testing_Start(const name[]) | |
* </remarks> | |
*//*------------------------------------------------------------------------**/ | |
-native YSI_ShowPlayerDialog(playerid, dialogid, style, const caption[], const info[], const button1[], const button2[]) = ShowPlayerDialog; | |
- | |
stock Testing_Ask(playerid, const str[] = "", GLOBAL_TAG_TYPES:...) | |
{ | |
#pragma unused str | |
@@ -346,7 +344,7 @@ stock Testing_Ask(playerid, const str[] = "", GLOBAL_TAG_TYPES:...) | |
#emit ADD | |
#emit SCTRL 4 | |
//format(YSI_g_sFailMessage, sizeof (YSI_g_sFailMessage), str, ___(2)); | |
- YSI_ShowPlayerDialog(playerid, Y_TESTING_DIALOG_ID, DIALOG_STYLE_MSGBOX, "Did the test pass?", YSI_g_sFailMessage, "Yes", "No"); | |
+ ShowPlayerDialog(playerid, Y_TESTING_DIALOG_ID, DIALOG_STYLE_MSGBOX, "Did the test pass?", YSI_g_sFailMessage, "Yes", "No"); | |
YSI_g_sAsked = true; | |
} | |
@@ -650,11 +648,7 @@ Testing_Next_retry: | |
Testing_Next(playerid); | |
return 1; | |
} | |
- #if defined Testing_OnDialogResponse | |
- return Testing_OnDialogResponse(playerid, dialogid, response, listitem, inputtext); | |
- #else | |
- return 1; | |
- #endif | |
+ return Testing_OnDialogResponse(playerid, dialogid, response, listitem, inputtext); | |
} | |
#if defined _ALS_OnDialogResponse | |
@@ -662,10 +656,8 @@ Testing_Next_retry: | |
#else | |
#define _ALS_OnDialogResponse | |
#endif | |
- #define OnDialogResponse Testing_OnDialogResponse | |
- #if defined Testing_OnDialogResponse | |
- forward Testing_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]); | |
- #endif | |
+ #define OnDialogResponse(%0) CHAIN_PUBLIC:Testing_OnDialogResponse(%0) | |
+ CHAIN_FORWARD:Testing_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) = 0; | |
#endif | |
forward OnTestsComplete(tests, checks, fails); | |
diff --git a/YSI_Visual/y_dialog/y_dialog_impl.inc b/YSI_Visual/y_dialog/y_dialog_impl.inc | |
index 99b32659..82c6460c 100644 | |
--- a/YSI_Visual/y_dialog/y_dialog_impl.inc | |
+++ b/YSI_Visual/y_dialog/y_dialog_impl.inc | |
@@ -72,6 +72,10 @@ Optional plugins: | |
#define YSI_DIALOG_ID _A<_yD@> | |
+CHAIN_HOOK(Dialog) | |
+#undef CHAIN_ORDER | |
+#define CHAIN_ORDER CHAIN_NEXT(Dialog) | |
+ | |
static stock | |
YSI_g_sPlayerDialog[MAX_PLAYERS] = {-1, ...}, | |
bool:YSI_g_sPlayerMaster[MAX_PLAYERS] = {false, ...}, | |
@@ -113,24 +117,18 @@ stock Dialog_ShowCallbackData(playerid, callback[E_CALLBACK_DATA], style, const | |
return Dialog_ShowCallback(playerid, F@_@iiiis:callback[E_CALLBACK_DATA:0], style, title, caption, button1, button2); | |
} | |
-#if defined _ALS_ShowPlayerDialog | |
- #define Dialog_ShowPlayerNative ShowPlayerDialog | |
-#else | |
- native Dialog_ShowPlayerNative(playerid, dialogid, style, const caption[], const info[], const button1[], const button2[]) = ShowPlayerDialog; | |
-#endif | |
- | |
stock Dialog_Show(playerid, style, const string:title[], const string:caption[], const string:button1[], const string:button2[] = "") | |
{ | |
broadcastfunc Dialog_Set(playerid, YSI_DIALOG_ID); | |
YSI_g_sPlayerMaster[playerid] = true; | |
- return Dialog_ShowPlayerNative(playerid, YSI_DIALOG_ID, style, title, caption, button1, button2); | |
+ return ShowPlayerDialog(playerid, YSI_DIALOG_ID, style, title, caption, button1, button2); | |
} | |
stock Dialog_Hide(playerid) | |
{ | |
// This almost looks like a Windows API function call! | |
broadcastfunc Dialog_Set(playerid, -1); | |
- return Dialog_ShowPlayerNative(playerid, -1, 0, NULL, NULL, NULL, NULL); | |
+ return ShowPlayerDialog(playerid, -1, 0, NULL, NULL, NULL, NULL); | |
} | |
HOOK__ OnPlayerDisconnect(playerid, reason) | |
@@ -147,7 +145,7 @@ HOOK__ OnPlayerDisconnect(playerid, reason) | |
return 1; | |
} | |
-HOOK__ OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) | |
+public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) | |
{ | |
// Apparently there's a hack to alter this. | |
dialogid = YSI_g_sPlayerDialog[playerid]; | |
@@ -174,14 +172,28 @@ HOOK__ OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) | |
} | |
// Free the data. | |
Indirect_Release(callback); | |
- return Y_HOOKS_BREAK_RETURN_1; | |
+ return 1; | |
} | |
- return Y_HOOKS_BREAK_RETURN_0; | |
+ return 0; | |
+ } | |
+ else if (dialogid == -1) | |
+ { | |
+ return 0; | |
} | |
else | |
- return Y_HOOKS_CONTINUE_RETURN_0; | |
+ { | |
+ return Dialog_OnDialogResponse(playerid, dialogid, response, listitem, inputtext); | |
+ } | |
} | |
+#if defined _ALS_OnDialogResponse | |
+ #undef OnDialogResponse | |
+#else | |
+ #define _ALS_OnDialogResponse | |
+#endif | |
+#define OnDialogResponse(%0) CHAIN_PUBLIC:Dialog_OnDialogResponse(%0) | |
+CHAIN_FORWARD:Dialog_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) = 0; | |
+ | |
stock Dialog_ShowPlayerDialog(playerid, dialog, style, const string:title[], const string:caption[], const string:button1[], const string:button2[]) | |
{ | |
// Fail. | |
@@ -189,7 +201,7 @@ stock Dialog_ShowPlayerDialog(playerid, dialog, style, const string:title[], con | |
return 0; | |
broadcastfunc Dialog_Set(playerid, dialog); | |
YSI_g_sPlayerMaster[playerid] = true; | |
- return Dialog_ShowPlayerNative(playerid, dialog, style, title, caption, button1, button2); | |
+ return ShowPlayerDialog(playerid, dialog, style, title, caption, button1, button2); | |
} | |
#if defined _ALS_ShowPlayerDialog | |
@@ -197,7 +209,7 @@ stock Dialog_ShowPlayerDialog(playerid, dialog, style, const string:title[], con | |
#else | |
#define _ALS_ShowPlayerDialog | |
#endif | |
-#define ShowPlayerDialog Dialog_ShowPlayerDialog | |
+#define ShowPlayerDialog( Dialog_ShowPlayerDialog( | |
#define _ALS_HidePlayerDialog | |
#define HidePlayerDialog Dialog_Hide |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment