Skip to content

Instantly share code, notes, and snippets.

@ohmypxl
Last active August 24, 2022 14:01
Show Gist options
  • Save ohmypxl/960468877bc881ba7c19d1a490d7355a to your computer and use it in GitHub Desktop.
Save ohmypxl/960468877bc881ba7c19d1a490d7355a to your computer and use it in GitHub Desktop.
YSI Dialog Wrapper
/*
This is ported from easyDialog.inc for easier usage
But this only works for public functions and dumbest idea ever
I could just use indirection internally but meh
- Aiura
*/
#if defined _inc_y_dialog_wrapper
#undef _inc_y_dialog_wrapper
#endif
#if defined _INC_dialog_wrapper
#endinput
#endif
#define _INC_dialog_wrapper
#include <YSI_Visual\y_dialog>
#include <code-parse>
// The parser only finds string and num, and do a bit of cleanups
#define DialogResponse%0(%1) FUNC_PARSER(DIALOG,STR:NUM:)(%0(%1)) %0(playerid,response,listitem,string:inputtext[])@dR_%0();@dR_%0()
#define DIALOG_STR(%9,%9,%2,%9)%8$%0(%1)%3(%4);%5(%6) %8$%0(%1)%3(%4,%2);%5(%6,%2[])
#define DIALOG_NUM(%9,%9,%2)%8$%0(%1)%3(%4);%5(%6) %8$%0(%1)%3(%4,%2);%5(%6,%2)
#define DIALOG_END(%9)%8$%0(%1)%3(,%4);%5(,%6) %8$%0(%1);%0(%1)%3(%4);%5(%6)
#define DIALOG_NUL(%9)%8$ %8$
// Cleanup
#define @dR_%0\32; @dR_
#endinput
// Examples
DialogResponse DialogName(playerid, response)
{
if (!respose)
{
Kick(playerid);
}
return 1;
}
Func()
{
Dialog_ShowCallback(playerid, using public DialogName<iiiis>, DIALOG_STYLE_MSGBOX, "Login Hello", "Login World", "Link Start", "Quit");
}
@ohmypxl
Copy link
Author

ohmypxl commented Aug 4, 2022

Note

This wrapper are meant to be used in modules structure, and this is why i don't upload it on normal repos and make it sampctl compatible.

But, you're welcome do it i guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment