Skip to content

Commit

Permalink
Removed Legacy function to fix #5
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickk888SAMP committed Aug 21, 2022
1 parent b5d2d25 commit d54372f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 50 deletions.
31 changes: 5 additions & 26 deletions ndialog-pages.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
Script: NDialog-Pages
Type: Include
Version: 3.0.0
Version: 3.1.0
Author: Nickk888
Date: 09.06.2022
Date: 21.08.2022
Repository: https://github.com/Nickk888SAMP/Dialog-Pages
Natives:
AddDialogListitem(playerid, const itemstring[]);
AddDialogListitem(playerid, const itemstring[], va_args<>); // Only works when y_va is included
ClearDialogListitems(playerid);
ShowPlayerDialog(playerid, dialogid, style, const caption[], #, const button1[], const button2[], items_per_page = 0, const nextbutton[] = "{FF0000}>>>", const backbutton[] = "{FF0000}<<<");
ShowPlayerDialogPages(playerid, const function[], style, const caption[], const button1[], const button2[], items_per_page, const nextbutton[] = "{FF0000}>>>", const backbutton[] = "{FF0000}<<<");
**********************************************************************************************************************************/
Expand All @@ -20,8 +19,8 @@ ShowPlayerDialogPages(playerid, const function[], style, const caption[], const
INCLUDES
*************************************************************/
#tryinclude <YSI_Coding\y_hooks> //By Y_Less | Thank you, great include <3
#tryinclude <YSI_Coding\y_va> //By Y_Less | Thank you, great include <3
#tryinclude <YSI_Coding\y_hooks> //By Y_Less | Thank you, great include <3
#tryinclude <YSI_Coding\y_va> //By Y_Less | Thank you, great include <3
#if defined NDP_USE_LOGGER
#include <logger> //Uncomment to include logger, useful for debugging.
#endif
Expand All @@ -30,7 +29,6 @@ ShowPlayerDialogPages(playerid, const function[], style, const caption[], const
FORWARDS
*************************************************************/
forward _NDP_ShowPlayerDialog_(playerid, dialogid, style, const caption[], const info[], const button1[], const button2[], items_per_page = 0, const nextbutton[] = "{FF0000}>>>", const backbutton[] = "{FF0000}<<<");
forward ShowPlayerDialogPages(playerid, const function[], style, const caption[], const button1[], const button2[], items_per_page, const nextbutton[] = "{FF0000}>>>", const backbutton[] = "{FF0000}<<<");
forward OnDialogPagesPerformed(playerid, const dialog[], response, bool:success, bool:pagechange);
Expand Down Expand Up @@ -228,17 +226,6 @@ NDP_DialogInvoke(playerid, type, const function[], dialogid, style, const captio
return 0;
}
/* Internal Function. Wrapper for ShowPlayerDialog adding custom parameters. ! DON'T USE IT ! */
_NDP_ShowPlayerDialog_(playerid, dialogid, style, const caption[], const info[], const button1[], const button2[], items_per_page = 0, const nextbutton[] = "{FF0000}>>>", const backbutton[] = "{FF0000}<<<")
{
#pragma unused info
if(!NDP_DialogInvoke(playerid, NDP_DIALOG_TYPE_LEGACY, "ndp_null", dialogid, style, caption, button1, button2, items_per_page, nextbutton, backbutton))
{
return ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2);
}
return 0;
}
/* Internal Function. Calculates the amount of items per page in the Dialog. ! DON'T USE IT ! */
NDP_CalculateListitemsPerPage(playerid)
{
Expand Down Expand Up @@ -538,12 +525,4 @@ NDP_ProcessDialogResponse(playerid, dialogid, response, listitem, inputtext[], d
#endif
#define OnDialogResponse NDP_OnDialogResponse
#endif
// ALS Hooking
#if defined _ALS_ShowPlayerDialog
#undef ShowPlayerDialog
#else
#define _ALS_ShowPlayerDialog
#endif
#define ShowPlayerDialog _NDP_ShowPlayerDialog_
#endif
39 changes: 16 additions & 23 deletions ndp_examples.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
#define MAX_DIALOG_ITEMS 150
#define NDP_AUTO_REMOVE_NEW_LINE false
#define NDP_USE_LOGGER
//#define NDP_USE_LOGGER
#include <ndialog-pages>
new ndp_e_str[128];
CMD:ndptest1(playerid, params[])
/* Commands */
CMD:ndptest1(playerid, params[]) // DIALOG_STYLE_LIST
{
for(new i; i < MAX_DIALOG_ITEMS; i++)
{
Expand All @@ -23,11 +24,11 @@ CMD:ndptest1(playerid, params[])
AddDialogListitem(playerid, ndp_e_str);
#endif
}
ShowPlayerDialog(playerid, 586, DIALOG_STYLE_LIST, "{FFFFFF}Test Dialog ID {FF00FF}586", #, "Button 1", "Button 2", 15);
ShowPlayerDialogPages(playerid, "NDP_Test", DIALOG_STYLE_LIST, "{FFFFFF}Test Dialog Name {FF00FF}NDP_Test", "Button 1", "Button 2", 15);
return 1;
}
CMD:ndptest2(playerid, params[])
CMD:ndptest2(playerid, params[]) // DIALOG_STYLE_TABLIST
{
for(new i; i < MAX_DIALOG_ITEMS; i++)
{
Expand All @@ -38,11 +39,11 @@ CMD:ndptest2(playerid, params[])
AddDialogListitem(playerid, ndp_e_str);
#endif
}
ShowPlayerDialog(playerid, 586, DIALOG_STYLE_TABLIST, "{FFFFFF}Test Dialog ID {FF00FF}586", #, "Button 1", "Button 2", 27);
ShowPlayerDialogPages(playerid, "NDP_Test", DIALOG_STYLE_TABLIST, "{FFFFFF}Test Dialog Name {FF00FF}NDP_Test", "Button 1", "Button 2", 27);
return 1;
}
CMD:ndptest3(playerid, params[])
CMD:ndptest3(playerid, params[]) // DIALOG_STYLE_TABLIST_HEADERS
{
AddDialogListitem(playerid, "{FFFFFF}Column 1\t{FF00FF}Column 2\t{FFFF00}Column 3\t{00FFFF}Column 4");
for(new i; i < MAX_DIALOG_ITEMS; i++)
Expand All @@ -54,11 +55,11 @@ CMD:ndptest3(playerid, params[])
AddDialogListitem(playerid, ndp_e_str);
#endif
}
ShowPlayerDialog(playerid, 586, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}Test Dialog ID {FF00FF}586", #, "Button 1", "Button 2", 32);
ShowPlayerDialogPages(playerid, "NDP_Test", DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}Test Dialog Name {FF00FF}NDP_Test", "Button 1", "Button 2", 32);
return 1;
}
CMD:ndptest4(playerid, params[])
CMD:ndptest4(playerid, params[]) // DIALOG_STYLE_LIST
{
ClearDialogListitems(playerid);
for(new i; i < MAX_DIALOG_ITEMS; i++)
Expand All @@ -70,27 +71,19 @@ CMD:ndptest4(playerid, params[])
AddDialogListitem(playerid, ndp_e_str);
#endif
}
ShowPlayerDialogPages(playerid, "NDP_Test", DIALOG_STYLE_LIST, "{FFFFFF}Test Dialog ID {FF00FF}586 {FFFFFF}DialogPages Callback", "Button 1", "Button 2", 15);
ShowPlayerDialogPages(playerid, "NDP_Test", DIALOG_STYLE_LIST, "{FFFFFF}Test Dialog Name {FF00FF}NDP_Test", "Button 1", "Button 2", 15);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 586 && response)
{
if(listitem != INVALID_LISTITEM)
{
format(ndp_e_str, sizeof ndp_e_str, "{FFFF00}[NDialog-Pages] {FFFFFF}You have selected listitem ID: {FFFF00}%i", listitem);
SendClientMessage(playerid, -1, ndp_e_str);
}
}
return 0;
}
/* Callback */
DialogPages:NDP_Test(playerid, response, listitem)
{
new dstr[128];
format(dstr, sizeof dstr, "{FFFF00}[NDialog-Pages] {FFFFFF}You have selected listitem ID: {FFFF00}%i", listitem);
if(!response)
return 1;
format(ndp_e_str, sizeof ndp_e_str, "[NDialog-Pages] You have selected listitem ID: %i", listitem);
SendClientMessage(playerid, -1, ndp_e_str);
print(ndp_e_str);
return 1;
}
4 changes: 3 additions & 1 deletion pawn.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"user": "Nickk888SAMP",
"repo": "Dialog-Pages",
"tag": "3.0.0",
"entry": "ndp_examples.pwn",
"output": "ndp_examples.amx",
"dependencies": [
"pawn-lang/samp-stdlib",
"https://github.com/pawn-lang/YSI-Includes:v5.06.1932"
"https://github.com/pawn-lang/YSI-Includes:v5.06.1932",
"Southclaws/zcmd"
],
"runtime": {
"version": "0.3.7",
Expand Down

0 comments on commit d54372f

Please sign in to comment.