[Include] IndexDrawer - List TD Solution
#1


>> IndexDrawer v0.9.2 <<
A Listed TextDraw Selection Solution
Available On GitHub
Hi all SAMP developers! I'm Anna SB, an amateur PAWN dev. I was looking for a text-to-go selection pane, like the one which Blacklite created. So I decided on creating one myself and publish it as an include to let other devs use too.
This solution is very very very customisable so it can be used for any theme. Some options are missing that will be added in future updates. Anyhow you can follow the development process on my GitHub.
For now, release v0.9.2 contains a variety of tools for creating global IndexDraws.

What is IndexDrawer?
IndexDrawer is a selection menu created using SAMP TextDraws. These menus don't need a mouse to be selected; only a key character, number or a small phrase that is unique for each menu option is used to select them, typing that phrase will cause the include to trigger a callback and let you react to the client's selection.
For example a menu like this:
Код:
My Menu

1. Give Me a Car
2. Give Me a Bus
3. Give Me Money
K. Kill Me
There are 4 characters selected as keys for these options. For example if a player that is seeing this menu, types "K", an event will be raised that lets you know:
* Which menu it was: ID of the IndexDraw that can be used for various commands...
* Which player it was: ID of the player who selected that.
* Selected option's index: Here 'K' has the fourth index.
* Selection phrase used: Player typed 'K'.
* Selected option's title: Option selected was named "Kill Me".

So we can let players choose an option from a menu just by typing a letter or two, and don't bother with mouse-based selection. Now let's use it!

Getting Started: Including
pawn Код:
#define MAX_SLOTS XXXX
#include <IndexDrawer>
// You sould define MAX_SLOTS before including the IndexDrawer,
// XXXX is the max players that can join your server, for example mine is 100.
Getting Started: Creating iDraws
pawn Код:
new idraw = IndexDrawCreate(Float:x, Float:y, title[], Float:xsize, Float:ysize, backcolor, align, font, outline, titlecolor[], enumcolor[], textcolor[])
// titlecolor, enumcolor and textcolor values are gametext colors like "~r~" with max length of 12.
// enumcolor is the color used for list bullet numbers.

IndexDrawLetterSize(idraw, Float:x, Float:y)
// Same as TextDrawLetterSize

IndexDrawCancelKey(idraw, keystate)
// Set a key which causes the selection to cancel, for example KEY_SPRINT.
// Default value is KEY_FIRE and if you want it you don't need to call this.

new index = IndexDrawAddOption(idraw, keytitle[], keystate[])
// Adds an option that can be selected by typing the keystate's value into the chatbox while selecting.
// Max. length of keytitle is 20 and for keystate is 2.

IndexDrawRemoveOption(idraw, index)
Making Use of: Interaction
pawn Код:
IndexDrawShowForPlayer(playerid, idraw)

IndexDrawHideForPlayer(playerid, idraw)

IndexDrawDispose(idraw)
// Destroys the iDraw and releases all its related resources.

new ActiveDraw = GetPlayerActiveIndexDraw(playerid)

new bool:IsActive = IsPlayerIndexDrawActive(playerid, idraw)
Necessary Part: Callbacks
pawn Код:
public OnIndexDrawCanceled(playerid, idraw)
// Triggers when an iDraw selection is cancelled for a user using the cancellation key.

public OnIndexDrawSelected(playerid, idraw, index, keystate[], keytitle[])
// Triggers when a player has selected an option by text-ing its index key.
Download Link on GitHub
Thanks and rep/star please! Don't forget to report any bug you seen on GitHub issues tab.
Kind kind regards - Anna SB
Reply
#2

You don't have to use format function for just setting or copying a string into an array, use strcpy instead.
pawn Код:
#define strcpy(%0,%1,%2) \
    strcat((%0[0] = '\0', %0), %1, %2)
I don't have any idea about your work, it would be nice if you post some pictures.
Reply
#3

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
You don't have to use format function for just setting or copying a string into an array, use strcpy instead.
pawn Код:
#define strcpy(%0,%1,%2) \
    strcat((%0[0] = '\0', %0), %1, %2)
I don't have any idea about your work, it would be nice if you post some pictures.
Ow thanks for your advice, actually I'm a C# dev mainly and I don't usually mess up with these old C stuff, so thanks for letting me know that.
About pictures: Yes I will add some pictures soon for clarification.
Reply
#4

+ Added description for clarification.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)