dialogs.inc 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  1. // dialogs.inc - Adding new styles to SAMP GUI - v2.4.2
  2. // By Gammix
  3. #if defined _dialogs_included
  4. #endinput
  5. #endif
  6. #define _dialogs_included
  7. enum
  8. {
  9. DIALOG_STYLE_PREVMODEL = 6,
  10. DIALOG_STYLE_PREVMODEL_LIST
  11. };
  12. #define DIALOG_NORMAL_COLOR (169093220)
  13. #define DIALOG_SELECTION_COLOR (1677721750)
  14. #define DIALOG_MAX_TEXT_DRAWS (100)
  15. static PlayerText:ptxtDialog[MAX_PLAYERS][DIALOG_MAX_TEXT_DRAWS];
  16. static pPool[MAX_PLAYERS];
  17. static pDialogId[MAX_PLAYERS];
  18. static pDialogStyle[MAX_PLAYERS];
  19. static bool:pDialogDualButtons[MAX_PLAYERS];
  20. static pDialogTotalListitems[MAX_PLAYERS];
  21. static pDialogPage[MAX_PLAYERS];
  22. static pDialogListitem[MAX_PLAYERS];
  23. static pDialogLastClick[MAX_PLAYERS];
  24. #define DIALOG_MAX_PAGE_LISTITEMS (6 * 4)
  25. enum E_DIALOG_COMPONENT
  26. {
  27. E_DIALOG_COMPONENT_SCROLL_UP,
  28. E_DIALOG_COMPONENT_SCROLL_DOWN,
  29. E_DIALOG_COMPONENT_BUTTON1,
  30. E_DIALOG_COMPONENT_BUTTON2,
  31. E_DIALOG_COMPONENT_BUTTONC,
  32. E_DIALOG_COMPONENT_MODEL[DIALOG_MAX_PAGE_LISTITEMS],
  33. E_DIALOG_COMPONENT_LABEL[DIALOG_MAX_PAGE_LISTITEMS],
  34. E_DIALOG_COMPONENT_BAR[DIALOG_MAX_PAGE_LISTITEMS],
  35. E_DIALOG_COMPONENT_SCROLL
  36. };
  37. static pDialogComponents[MAX_PLAYERS][E_DIALOG_COMPONENT];
  38. #define Dialog_CountPages(%0,%1) (((%0)-1)/(%1)+1)
  39. static Dialog_Create(playerid, Float:posX, Float:posY, strings[], bgcolor, font, Float:lettersizeX, Float:lettersizeY, textcolor, allign = 0, outline = 1, proportional = 1, shadow = 1, usebox = 0, boxcolor = 0, Float:textsizeX = -1.0, Float:textsizeY = -1.0, model = 0, Float:rotX = 0.0, Float:rotY = 0.0, Float:rotZ = 0.0, Float:zoom = 1.0, selectable = 0, show = 0)
  40. {
  41. ptxtDialog[playerid][pPool[playerid]] = CreatePlayerTextDraw(playerid, posX, posY, strings);
  42. PlayerTextDrawBackgroundColor(playerid, ptxtDialog[playerid][pPool[playerid]], bgcolor);
  43. PlayerTextDrawFont(playerid, ptxtDialog[playerid][pPool[playerid]], font);
  44. PlayerTextDrawLetterSize(playerid, ptxtDialog[playerid][pPool[playerid]], lettersizeX, lettersizeY);
  45. PlayerTextDrawColor(playerid, ptxtDialog[playerid][pPool[playerid]], textcolor);
  46. PlayerTextDrawAlignment(playerid, ptxtDialog[playerid][pPool[playerid]], allign);
  47. PlayerTextDrawSetOutline(playerid, ptxtDialog[playerid][pPool[playerid]], outline);
  48. PlayerTextDrawSetProportional(playerid, ptxtDialog[playerid][pPool[playerid]], proportional);
  49. PlayerTextDrawSetShadow(playerid, ptxtDialog[playerid][pPool[playerid]], shadow);
  50. PlayerTextDrawUseBox(playerid, ptxtDialog[playerid][pPool[playerid]], usebox);
  51. PlayerTextDrawSetSelectable(playerid, ptxtDialog[playerid][pPool[playerid]], selectable);
  52. if (usebox)
  53. {
  54. PlayerTextDrawBoxColor(playerid, ptxtDialog[playerid][pPool[playerid]], boxcolor);
  55. }
  56. if (textsizeX != -1.0 || textsizeY != -1.0)
  57. {
  58. PlayerTextDrawTextSize(playerid, ptxtDialog[playerid][pPool[playerid]], textsizeX, textsizeY);
  59. }
  60. if(font == 5)
  61. {
  62. PlayerTextDrawSetPreviewModel(playerid, ptxtDialog[playerid][pPool[playerid]], model);
  63. PlayerTextDrawSetPreviewRot(playerid, ptxtDialog[playerid][pPool[playerid]], rotX, rotY, rotZ, zoom);
  64. }
  65. if (show)
  66. {
  67. PlayerTextDrawShow(playerid, ptxtDialog[playerid][pPool[playerid]]);
  68. }
  69. pPool[playerid]++;
  70. return (pPool[playerid] - 1);
  71. }
  72. static Dialog_Init(playerid, style, caption[], button1[], button2[])
  73. {
  74. for (new i; i < DIALOG_MAX_TEXT_DRAWS; i++)
  75. {
  76. ptxtDialog[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
  77. }
  78. Dialog_Create(playerid, 173.000000, 122.000000, "_", 50, 1, 0.000000, 0.599999, -1, 0, 0, 1, 1, 1, 200, 462.000000, 19.000000, .show = 1);
  79. Dialog_Create(playerid, 173.000000, 121.000000, caption, 50, 1, 0.129998, 0.799998, -36, 0, 0, 1, 1, 0, .show = 1);
  80. Dialog_Create(playerid, 173.000000, 131.000000, "_", 50, 1, 0.000000, 21.599998, -1, 0, 0, 1, 1, 1, 150, 462.000000, 19.000000, .show = 1);
  81. Dialog_Create(playerid, 177.000000, 135.000000, "_", 50, 1, 0.000000, 18.299997, -1, 0, 0, 1, 1, 1, 100, 458.000000, 19.000000, .show = 1);
  82. Dialog_Create(playerid, 177.000000, 134.000000, "_", 50, 1, 0.000000, 18.499998, -1, 0, 0, 1, 1, 1, -106, 173.000000, 19.000000, .show = 1);
  83. Dialog_Create(playerid, 454.000000, 135.000000, "_", 50, 1, 0.000000, 18.299997, -1, 0, 0, 1, 1, 1, -106, 452.000000, 19.000000, .show = 1);
  84. Dialog_Create(playerid, 461.000000, 135.000000, "_", 50, 1, 0.000000, 18.299997, -1, 0, 0, 1, 1, 1, -106, 459.000000, 19.000000, .show = 1);
  85. Dialog_Create(playerid, 462.000000, 134.000000, "_", 50, 1, 0.000000, -0.300001, -1, 0, 0, 1, 1, 1, -106, 174.000000, 19.000000, .show = 1);
  86. Dialog_Create(playerid, 462.000000, 304.000000, "_", 50, 1, 0.000000, -0.400001, -1, 0, 0, 1, 1, 1, -106, 173.000000, 19.000000, .show = 1);
  87. pDialogComponents[playerid][E_DIALOG_COMPONENT_SCROLL_UP] = Dialog_Create(playerid, 453.000000, 133.000000, "LD_POOL:ball", 50, 4, 0.500000, 1.000000, -106, 0, 0, 1, 1, 1, 255, 7.000000, 9.00000, .selectable = 1, .show = 1);
  88. Dialog_Create(playerid, 454.000000, 134.000000, "LD_BEAT:up", 255, 4, 0.500000, 1.000000, 255, 0, 0, 1, 1, 1, 255, 5.000000, 6.000000, .show = 1);
  89. pDialogComponents[playerid][E_DIALOG_COMPONENT_SCROLL_DOWN] = Dialog_Create(playerid, 453.000000, 293.000000, "LD_POOL:ball", 50, 4, 0.500000, 1.000000, -106, 0, 0, 1, 1, 1, 255, 7.000000, 9.00000, .selectable = 1, .show = 1);
  90. Dialog_Create(playerid, 454.000000, 295.000000, "LD_BEAT:down", 255, 4, 0.500000, 1.000000, 255, 0, 0, 1, 1, 1, 255, 5.000000, 6.000000, .show = 1);
  91. if (button2[0])
  92. {
  93. Dialog_Create(playerid, 302.000000, 310.000000, "_", 50, 1, 0.000000, -0.400001, -1, 0, 0, 1, 1, 1, -106, 253.000000, 19.000000, .show = 1);
  94. Dialog_Create(playerid, 302.000000, 324.000000, "_", 50, 1, 0.000000, -0.400001, -1, 0, 0, 1, 1, 1, -106, 253.000000, 19.000000, .show = 1);
  95. Dialog_Create(playerid, 253.000000, 304.000000, "(", 0, 1, 0.200000, 2.000000, -106, 0, 0, 1, 1, .show = 1);
  96. Dialog_Create(playerid, 299.000000, 304.000000, ")", 0, 1, 0.200000, 2.000000, -106, 0, 0, 1, 1, .show = 1);
  97. pDialogComponents[playerid][E_DIALOG_COMPONENT_BUTTON1] = Dialog_Create(playerid, 254.000000, 309.000000, "ld_plan:tvbase", 50, 4, 0.000000, 0.899998, 255, 0, 0, 1, 1, 1, 255, 46.000000, 13.000000, .selectable = 1, .show = 1);
  98. Dialog_Create(playerid, 278.000000, 311.000000, button1, 50, 1, 0.129998, 0.799998, -36, 2, 0, 1, 1, 0, .show = 1);
  99. Dialog_Create(playerid, 372.000000, 310.000000, "_", 50, 1, 0.000000, -0.400001, -1, 0, 0, 1, 1, 1, -106, 323.000000, 19.000000, .show = 1);
  100. Dialog_Create(playerid, 372.000000, 324.000000, "_", 50, 1, 0.000000, -0.400001, -1, 0, 0, 1, 1, 1, -106, 323.000000, 19.000000, .show = 1);
  101. Dialog_Create(playerid, 323.000000, 304.000000, "(", 0, 1, 0.210000, 2.000000, -106, 0, 0, 1, 1, .show = 1);
  102. Dialog_Create(playerid, 369.000000, 304.000000, ")", 0, 1, 0.230000, 1.999999, -106, 0, 0, 1, 1, .show = 1);
  103. pDialogComponents[playerid][E_DIALOG_COMPONENT_BUTTON2] = Dialog_Create(playerid, 324.000000, 309.000000, "ld_plan:tvbase", 50, 4, 0.000000, 0.899998, 255, 0, 0, 1, 1, 1, 255, 46.000000, 13.000000, .selectable = 1, .show = 1);
  104. Dialog_Create(playerid, 348.000000, 311.000000, button2, 50, 1, 0.140000, 0.899999, -36, 2, 0, 1, 1, 0, .show = 1);
  105. }
  106. else
  107. {
  108. Dialog_Create(playerid, 342.000000, 310.000000, "_", 50, 1, 0.000000, -0.400001, -1, 0, 0, 1, 1, 1, -106, 293.000000, 19.000000, .show = 1);
  109. Dialog_Create(playerid, 342.000000, 324.000000, "_", 50, 1, 0.000000, -0.400001, -1, 0, 0, 1, 1, 1, -106, 293.000000, 19.000000, .show = 1);
  110. Dialog_Create(playerid, 293.000000, 304.000000, "(", 0, 1, 0.200000, 2.000000, -106, 0, 0, 1, 1, .show = 1);
  111. Dialog_Create(playerid, 339.000000, 304.000000, ")", 0, 1, 0.219999, 2.000000, -106, 0, 0, 1, 1, .show = 1);
  112. pDialogComponents[playerid][E_DIALOG_COMPONENT_BUTTONC] = Dialog_Create(playerid, 294.000000, 309.000000, "ld_plan:tvbase", 50, 4, 0.000000, 0.899998, 255, 0, 0, 1, 1, 1, 255, 46.000000, 13.000000, .selectable = 1, .show = 1);
  113. Dialog_Create(playerid, 317.000000, 311.000000, button1, 50, 1, 0.140000, 0.899999, -36, 2, 0, 1, 1, 0, .show = 1);
  114. }
  115. if (style == DIALOG_STYLE_PREVMODEL)
  116. {
  117. new count;
  118. new Float:base[2] = {179.000000, 134.000000};
  119. for (new i; i < (6 * 4); i++)
  120. {
  121. pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][i] = Dialog_Create(playerid, base[0], base[1], "_", 169090660, 5, 0.129998, 0.799998, -1, 0, 0, 1, 1, 1, 0, 44.000000, 41.000000, .selectable = 1);
  122. pDialogComponents[playerid][E_DIALOG_COMPONENT_LABEL][i] = Dialog_Create(playerid, base[0] + 2.000000, base[1] + 1.000000, "", 50, 1, 0.140000, 0.899999, -36, 0, 1, 1, 2, 0);
  123. base[0] += 45.000000;
  124. count++;
  125. if (count == 6)
  126. {
  127. base[0] = 179.000000;
  128. base[1] += 42.000000;
  129. count = 0;
  130. }
  131. }
  132. }
  133. else
  134. {
  135. for (new i; i < (5); i++)
  136. {
  137. pDialogComponents[playerid][E_DIALOG_COMPONENT_BAR][i] = Dialog_Create(playerid, 177.000000, (134.000000 + (33.0 * i)), "ld_plan:tvbase", 50, 4, 0.129997, 0.799997, DIALOG_NORMAL_COLOR, 0, 0, 1, 1, 1, 0, 274.000000, 32.000000, .selectable = 1);
  138. pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][i] = Dialog_Create(playerid, 178.000000, (134.000000 + (33.0 * i)), "_", 169090660, 5, 0.129997, 0.799997, -1, 0, 0, 1, 1, 1, 0, 34.000000, 30.000000);
  139. pDialogComponents[playerid][E_DIALOG_COMPONENT_LABEL][i] = Dialog_Create(playerid, 215.000000, (135.000000 + (33.0 * i)), "", 50, 1, 0.099999, 0.599997, -36, 0, 1, 1, 2, 0);
  140. }
  141. }
  142. pDialogComponents[playerid][E_DIALOG_COMPONENT_SCROLL] = Dialog_Create(playerid, 0.000000, 0.000000, "_", 0, 1, 0.0, 0.0, 0);
  143. }
  144. static Dialog_Exit(playerid)
  145. {
  146. for (new i; i < pPool[playerid]; i++)
  147. {
  148. PlayerTextDrawHide(playerid, ptxtDialog[playerid][i]);
  149. PlayerTextDrawDestroy(playerid, ptxtDialog[playerid][i]);
  150. ptxtDialog[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
  151. }
  152. pPool[playerid] = 0;
  153. new varname[45];
  154. for (new i; i < pDialogTotalListitems[playerid]; i++)
  155. {
  156. format(varname, sizeof (varname), "DialogModel_%i", i);
  157. DeletePVar(playerid, varname);
  158. format(varname, sizeof (varname), "DialogLabel_%i", i);
  159. DeletePVar(playerid, varname);
  160. }
  161. }
  162. static Dialog_SetModel(playerid, id, set)
  163. {
  164. new varname[45];
  165. format(varname, sizeof (varname), "DialogModel_%i", id);
  166. return SetPVarInt(playerid, varname, set);
  167. }
  168. static Dialog_GetModel(playerid, id)
  169. {
  170. new varname[45];
  171. format(varname, sizeof (varname), "DialogModel_%i", id);
  172. return GetPVarInt(playerid, varname);
  173. }
  174. static Dialog_SetLabel(playerid, id, set[])
  175. {
  176. new varname[45];
  177. format(varname, sizeof (varname), "DialogLabel_%i", id);
  178. return SetPVarString(playerid, varname, set);
  179. }
  180. static Dialog_GetLabel(playerid, id)
  181. {
  182. new varname[45];
  183. format(varname, sizeof (varname), "DialogLabel_%i", id);
  184. new get[35];
  185. GetPVarString(playerid, varname, get, sizeof (get));
  186. return get;
  187. }
  188. static Dialog_SetPage(playerid, page, selected)
  189. {
  190. new index;
  191. if (pDialogStyle[playerid] == DIALOG_STYLE_PREVMODEL)
  192. {
  193. PlayerTextDrawDestroy(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_SCROLL]]);
  194. pPool[playerid]--;
  195. if (Dialog_CountPages(pDialogTotalListitems[playerid], (6 * 4)) > 1)
  196. {
  197. new Float:whiles = (145.500000 / Dialog_CountPages(pDialogTotalListitems[playerid], (6 * 4)));
  198. pDialogComponents[playerid][E_DIALOG_COMPONENT_SCROLL] = Dialog_Create(playerid, 455.000000, (144.000000 + (whiles * page)), "_", 0, 1, 0.000000, (whiles / 8.83), 0, .usebox = 1, .boxcolor = DIALOG_SELECTION_COLOR, .textsizeX = 458.000000, .textsizeY = 0.000000, .show = 1);
  199. }
  200. for (new i = ((page) * (6 * 4)); i < pDialogTotalListitems[playerid]; i++)
  201. {
  202. if (index < (6 * 4))
  203. {
  204. if (Dialog_GetModel(playerid, i) >= 0)
  205. {
  206. if (selected == index)
  207. {
  208. PlayerTextDrawBackgroundColor(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]], DIALOG_SELECTION_COLOR);
  209. pDialogListitem[playerid] = i;
  210. }
  211. else
  212. {
  213. PlayerTextDrawBackgroundColor(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]], 169090660);
  214. }
  215. PlayerTextDrawSetPreviewModel(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]], Dialog_GetModel(playerid, i));
  216. PlayerTextDrawSetPreviewRot(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]], 0.0, 0.0, 0.0, 1.0);
  217. if (strlen(Dialog_GetLabel(playerid, i)))
  218. {
  219. PlayerTextDrawSetString(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_LABEL][index]], Dialog_GetLabel(playerid, i));
  220. }
  221. PlayerTextDrawShow(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]]);
  222. PlayerTextDrawShow(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_LABEL][index]]);
  223. index++;
  224. }
  225. }
  226. }
  227. index = (6 * 4);
  228. for (new i = ((page + 1) * (6 * 4)); i > pDialogTotalListitems[playerid]; i--)
  229. {
  230. index--;
  231. PlayerTextDrawHide(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]]);
  232. PlayerTextDrawHide(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_LABEL][index]]);
  233. }
  234. }
  235. else
  236. {
  237. PlayerTextDrawDestroy(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_SCROLL]]);
  238. pPool[playerid]--;
  239. if (Dialog_CountPages(pDialogTotalListitems[playerid], (5)) > 1)
  240. {
  241. new Float:whiles = (145.500000 / Dialog_CountPages(pDialogTotalListitems[playerid], (5)));
  242. pDialogComponents[playerid][E_DIALOG_COMPONENT_SCROLL] = Dialog_Create(playerid, 455.000000, (144.000000 + (whiles * page)), "_", 0, 1, 0.000000, (whiles / 8.83), 0, .usebox = 1, .boxcolor = DIALOG_SELECTION_COLOR, .textsizeX = 458.000000, .textsizeY = 0.000000, .show = 1);
  243. }
  244. for (new i = (page * 5); i < pDialogTotalListitems[playerid]; i++)
  245. {
  246. if (index < 5)
  247. {
  248. if (Dialog_GetModel(playerid, i) >= 0)
  249. {
  250. if (selected == index)
  251. {
  252. PlayerTextDrawColor(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_BAR][index]], ((DIALOG_SELECTION_COLOR & ~0xFF) | 0xFF));
  253. pDialogListitem[playerid] = i;
  254. }
  255. else
  256. {
  257. PlayerTextDrawColor(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_BAR][index]], ((DIALOG_NORMAL_COLOR & ~0xFF) | 0xFF));
  258. }
  259. PlayerTextDrawSetPreviewModel(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]], Dialog_GetModel(playerid, i));
  260. PlayerTextDrawSetPreviewRot(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]], 0.0, 0.0, 0.0, 1.0);
  261. if (strlen(Dialog_GetLabel(playerid, i)))
  262. {
  263. PlayerTextDrawSetString(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_LABEL][index]], Dialog_GetLabel(playerid, i));
  264. }
  265. PlayerTextDrawShow(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_BAR][index]]);
  266. PlayerTextDrawShow(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]]);
  267. PlayerTextDrawShow(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_LABEL][index]]);
  268. index++;
  269. }
  270. }
  271. }
  272. index = 5;
  273. for (new i = ((page + 1) * (5)); i > pDialogTotalListitems[playerid]; i--)
  274. {
  275. index--;
  276. PlayerTextDrawHide(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_BAR][index]]);
  277. PlayerTextDrawHide(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]]);
  278. PlayerTextDrawHide(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_LABEL][index]]);
  279. }
  280. }
  281. }
  282. forward Dialog_HideForPlayer(playerid);
  283. public Dialog_HideForPlayer(playerid)
  284. {
  285. switch (pDialogStyle[playerid])
  286. {
  287. case DIALOG_STYLE_PREVMODEL,
  288. DIALOG_STYLE_PREVMODEL_LIST:
  289. {
  290. Dialog_Exit(playerid);
  291. pDialogStyle[playerid] = -1;
  292. CancelSelectTextDraw(playerid);
  293. }
  294. default:
  295. {
  296. ShowPlayerDialog(playerid, -1, 0, "", "", "", "");
  297. pDialogStyle[playerid] = -1;
  298. }
  299. }
  300. pDialogId[playerid] = -1;
  301. pDialogDualButtons[playerid] = false;
  302. pDialogTotalListitems[playerid] = 0;
  303. pDialogPage[playerid] = 0;
  304. pDialogListitem[playerid] = 0;
  305. pDialogLastClick[playerid] = 0;
  306. }
  307. stock Dialog_ShowToPlayer(playerid, dialogid, style, caption[], info[], button1[], button2[])
  308. {
  309. if (playerid < 0 || playerid >= MAX_PLAYERS)
  310. {
  311. return false;
  312. }
  313. switch (pDialogStyle[playerid])
  314. {
  315. case DIALOG_STYLE_PREVMODEL,
  316. DIALOG_STYLE_PREVMODEL_LIST:
  317. {
  318. Dialog_Exit(playerid);
  319. pDialogStyle[playerid] = -1;
  320. }
  321. }
  322. CallRemoteFunction("Dialog_HideForPlayer", "i", playerid);
  323. if (dialogid >= 0)
  324. {
  325. pDialogId[playerid] = dialogid;
  326. pDialogStyle[playerid] = style;
  327. switch (style)
  328. {
  329. case DIALOG_STYLE_PREVMODEL,
  330. DIALOG_STYLE_PREVMODEL_LIST:
  331. {
  332. Dialog_Init(playerid, style, caption, button1, button2);
  333. new bool:insert_label;
  334. new dest[35];
  335. new pos;
  336. for (new i, j = strlen(info); i <= j; i++)
  337. {
  338. if (info[i] == '\n' || i == j)
  339. {
  340. strmid((dest[0] = EOS, dest), info, pos, i);
  341. pos = i + 1;
  342. if (insert_label)
  343. {
  344. Dialog_SetLabel(playerid, pDialogTotalListitems[playerid], dest);
  345. pDialogTotalListitems[playerid]++;
  346. }
  347. else
  348. {
  349. if (i == j)
  350. {
  351. if (dest[0])
  352. {
  353. Dialog_SetModel(playerid, pDialogTotalListitems[playerid], strval(dest));
  354. pDialogTotalListitems[playerid]++;
  355. }
  356. }
  357. else
  358. {
  359. Dialog_SetModel(playerid, pDialogTotalListitems[playerid], strval(dest));
  360. }
  361. }
  362. insert_label = (! insert_label);
  363. }
  364. }
  365. Dialog_SetPage(playerid, 0, 0);
  366. SelectTextDraw(playerid, DIALOG_SELECTION_COLOR);
  367. }
  368. default:
  369. {
  370. ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2);
  371. }
  372. }
  373. }
  374. return true;
  375. }
  376. #if defined _ALS_ShowPlayerDialog
  377. #undef ShowPlayerDialog
  378. #else
  379. #define _ALS_ShowPlayerDialog
  380. #endif
  381. #define ShowPlayerDialog Dialog_ShowToPlayer
  382. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  383. {
  384. switch (pDialogStyle[playerid])
  385. {
  386. case DIALOG_STYLE_PREVMODEL,
  387. DIALOG_STYLE_PREVMODEL_LIST:
  388. {
  389. if (clickedid == Text:INVALID_TEXT_DRAW)
  390. {
  391. Dialog_Exit(playerid);
  392. pDialogStyle[playerid] = -1;
  393. CancelSelectTextDraw(playerid);
  394. if (funcidx("OnDialogResponse") != -1)
  395. CallRemoteFunction("OnDialogResponse", "iiiis", playerid, pDialogId[playerid], 0, pDialogListitem[playerid], "\1");
  396. pDialogId[playerid] = -1;
  397. pDialogDualButtons[playerid] = false;
  398. pDialogTotalListitems[playerid] = 0;
  399. pDialogPage[playerid] = 0;
  400. pDialogListitem[playerid] = 0;
  401. pDialogLastClick[playerid] = 0;
  402. }
  403. return 1;
  404. }
  405. }
  406. #if defined Dialog_OnPlayerClickTextDraw
  407. return Dialog_OnPlayerClickTextDraw(playerid, clickedid);
  408. #else
  409. return 0;
  410. #endif
  411. }
  412. #if defined _ALS_OnPlayerClickTextDraw
  413. #undef OnPlayerClickTextDraw
  414. #else
  415. #define _ALS_OnPlayerClickTextDraw
  416. #endif
  417. #define OnPlayerClickTextDraw Dialog_OnPlayerClickTextDraw
  418. #if defined Dialog_OnPlayerClickTextDraw
  419. forward Dialog_OnPlayerClickTextDraw(playerid, Text:clickedid);
  420. #endif
  421. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  422. {
  423. switch (pDialogStyle[playerid])
  424. {
  425. case DIALOG_STYLE_PREVMODEL,
  426. DIALOG_STYLE_PREVMODEL_LIST:
  427. {
  428. if (playertextid == ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_BUTTON2]])
  429. {
  430. Dialog_Exit(playerid);
  431. pDialogStyle[playerid] = -1;
  432. CancelSelectTextDraw(playerid);
  433. if (funcidx("OnDialogResponse") != -1)
  434. CallRemoteFunction("OnDialogResponse", "iiiis", playerid, pDialogId[playerid], 0, pDialogListitem[playerid], "\1");
  435. pDialogId[playerid] = -1;
  436. pDialogDualButtons[playerid] = false;
  437. pDialogTotalListitems[playerid] = 0;
  438. pDialogPage[playerid] = 0;
  439. pDialogListitem[playerid] = 0;
  440. pDialogLastClick[playerid] = 0;
  441. }
  442. else if (playertextid == ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_BUTTON1]] || playertextid == ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_BUTTONC]])
  443. {
  444. Dialog_Exit(playerid);
  445. pDialogStyle[playerid] = -1;
  446. CancelSelectTextDraw(playerid);
  447. if (funcidx("OnDialogResponse") != -1)
  448. CallRemoteFunction("OnDialogResponse", "iiiis", playerid, pDialogId[playerid], 1, pDialogListitem[playerid], "\1");
  449. pDialogId[playerid] = -1;
  450. pDialogDualButtons[playerid] = false;
  451. pDialogTotalListitems[playerid] = 0;
  452. pDialogPage[playerid] = 0;
  453. pDialogListitem[playerid] = 0;
  454. pDialogLastClick[playerid] = 0;
  455. }
  456. else if (playertextid == ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_SCROLL_UP]])
  457. {
  458. if ((pDialogPage[playerid] - 1) < 0)
  459. {
  460. PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
  461. }
  462. else
  463. {
  464. pDialogPage[playerid]--;
  465. Dialog_SetPage(playerid, pDialogPage[playerid], 0);
  466. }
  467. }
  468. else if (playertextid == ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_SCROLL_DOWN]])
  469. {
  470. if ((pDialogPage[playerid] + 1) >= Dialog_CountPages(pDialogTotalListitems[playerid], ((pDialogStyle[playerid] == DIALOG_STYLE_PREVMODEL) ? (6 * 4) : (5))))
  471. {
  472. PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
  473. }
  474. else
  475. {
  476. pDialogPage[playerid]++;
  477. Dialog_SetPage(playerid, pDialogPage[playerid], 0);
  478. }
  479. }
  480. else
  481. {
  482. if (pDialogStyle[playerid] == DIALOG_STYLE_PREVMODEL)
  483. {
  484. new id = -1;
  485. for (new i; i < (6 * 4); i++)
  486. {
  487. if (((pDialogPage[playerid] * (6 * 4)) + i) < pDialogTotalListitems[playerid])
  488. {
  489. if (playertextid == ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][i]])
  490. {
  491. pDialogListitem[playerid] = (pDialogPage[playerid] * (6 * 4)) + i;
  492. id = i;
  493. break;
  494. }
  495. }
  496. else
  497. {
  498. break;
  499. }
  500. }
  501. if (id != -1)
  502. {
  503. if (GetTickCount() - pDialogLastClick[playerid] <= 200)
  504. {
  505. Dialog_Exit(playerid);
  506. pDialogStyle[playerid] = -1;
  507. CancelSelectTextDraw(playerid);
  508. if (funcidx("OnDialogResponse") != -1)
  509. CallRemoteFunction("OnDialogResponse", "iiiis", playerid, pDialogId[playerid], 1, pDialogListitem[playerid], "\1");
  510. pDialogId[playerid] = -1;
  511. pDialogDualButtons[playerid] = false;
  512. pDialogTotalListitems[playerid] = 0;
  513. pDialogPage[playerid] = 0;
  514. pDialogListitem[playerid] = 0;
  515. pDialogLastClick[playerid] = 0;
  516. }
  517. else
  518. {
  519. for (new i; i < (6 * 4); i++)
  520. {
  521. if (((pDialogPage[playerid] * (6 * 4)) + i) < pDialogTotalListitems[playerid])
  522. {
  523. if (id == i)
  524. {
  525. PlayerTextDrawBackgroundColor(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][i]], DIALOG_SELECTION_COLOR);
  526. }
  527. else
  528. {
  529. PlayerTextDrawBackgroundColor(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][i]], DIALOG_NORMAL_COLOR);
  530. }
  531. PlayerTextDrawShow(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][i]]);
  532. }
  533. else
  534. {
  535. break;
  536. }
  537. }
  538. }
  539. pDialogLastClick[playerid] = GetTickCount();
  540. }
  541. }
  542. else
  543. {
  544. new id = -1;
  545. for (new i; i < 5; i++)
  546. {
  547. if (((pDialogPage[playerid] * (5)) + i) < pDialogTotalListitems[playerid])
  548. {
  549. if (playertextid == ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_BAR][i]])
  550. {
  551. pDialogListitem[playerid] = (pDialogPage[playerid] * (5)) + i;
  552. id = i;
  553. break;
  554. }
  555. }
  556. else
  557. {
  558. break;
  559. }
  560. }
  561. if (id != -1)
  562. {
  563. if (GetTickCount() - pDialogLastClick[playerid] <= 200)
  564. {
  565. Dialog_Exit(playerid);
  566. pDialogStyle[playerid] = -1;
  567. CancelSelectTextDraw(playerid);
  568. if (funcidx("OnDialogResponse") != -1)
  569. CallRemoteFunction("OnDialogResponse", "iiiis", playerid, pDialogId[playerid], 1, pDialogListitem[playerid], "\1");
  570. pDialogId[playerid] = -1;
  571. pDialogDualButtons[playerid] = false;
  572. pDialogTotalListitems[playerid] = 0;
  573. pDialogPage[playerid] = 0;
  574. pDialogListitem[playerid] = 0;
  575. pDialogLastClick[playerid] = 0;
  576. }
  577. else
  578. {
  579. for (new i; i < 5; i++)
  580. {
  581. if (((pDialogPage[playerid] * (5)) + i) < pDialogTotalListitems[playerid])
  582. {
  583. if (id == i)
  584. {
  585. PlayerTextDrawColor(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_BAR][i]], ((DIALOG_SELECTION_COLOR & ~0xFF) | 0xFF));
  586. }
  587. else
  588. {
  589. PlayerTextDrawColor(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_BAR][i]], ((DIALOG_NORMAL_COLOR & ~0xFF) | 0xFF));
  590. }
  591. PlayerTextDrawShow(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_BAR][i]]);
  592. }
  593. else
  594. {
  595. break;
  596. }
  597. }
  598. }
  599. pDialogLastClick[playerid] = GetTickCount();
  600. }
  601. }
  602. }
  603. return 1;
  604. }
  605. }
  606. #if defined Dialog_OnPlayerClickPlayerTD
  607. return Dialog_OnPlayerClickPlayerTD(playerid, playertextid);
  608. #else
  609. return 0;
  610. #endif
  611. }
  612. #if defined _ALS_OnPlayerClickPlayerTD
  613. #undef OnPlayerClickPlayerTextDraw
  614. #else
  615. #define _ALS_OnPlayerClickPlayerTD
  616. #endif
  617. #define OnPlayerClickPlayerTextDraw Dialog_OnPlayerClickPlayerTD
  618. #if defined Dialog_OnPlayerClickPlayerTD
  619. forward Dialog_OnPlayerClickPlayerTD(playerid, PlayerText:playertextid);
  620. #endif
  621. stock Dialog_SetListitem(playerid, listitem, str[], model = -1, Float:model_x = 0.0, Float:model_y = 0.0, Float:model_z = 0.0, Float:model_zoom = 1.0, model_color1 = -1, model_color2 = -1)
  622. {
  623. if (playerid < 0 || playerid >= MAX_PLAYERS)
  624. {
  625. return false;
  626. }
  627. if (pDialogStyle[playerid] == -1)
  628. {
  629. return false;
  630. }
  631. new index;
  632. switch (pDialogStyle[playerid])
  633. {
  634. case DIALOG_STYLE_PREVMODEL,
  635. DIALOG_STYLE_PREVMODEL_LIST:
  636. {
  637. if (listitem >= pDialogTotalListitems[playerid])
  638. {
  639. return false;
  640. }
  641. index = listitem - (floatround(Float:(listitem - (6 * 4)), floatround_floor) * (6 * 4));
  642. if (index >= (6 * 4))
  643. {
  644. return false;
  645. }
  646. if (model >= 0)
  647. {
  648. Dialog_SetModel(playerid, listitem, model);
  649. PlayerTextDrawSetPreviewModel(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]], model);
  650. PlayerTextDrawSetPreviewRot(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]], model_x, model_y, model_z, model_zoom);
  651. PlayerTextDrawSetPreviewVehCol(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]], model_color1, model_color2);
  652. PlayerTextDrawShow(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_MODEL][index]]);
  653. }
  654. if (str[0])
  655. {
  656. Dialog_SetLabel(playerid, listitem, str);
  657. PlayerTextDrawSetString(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_LABEL][index]], str);
  658. PlayerTextDrawShow(playerid, ptxtDialog[playerid][pDialogComponents[playerid][E_DIALOG_COMPONENT_LABEL][index]]);
  659. }
  660. }
  661. }
  662. return true;
  663. }