Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved tooltip #625

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions gamemodes/sss/core/ui/tool-tip.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,21 @@

static
bool: ToolTips[MAX_PLAYERS],
PlayerText: ToolTipText[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
PlayerText: ToolTipText[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...},
Timer: ToolTipTimer[MAX_PLAYERS] = {Timer:0, ...};

ShowHelpTip(playerid, const text[], time = 0)
{
if(!ToolTips[playerid])
return 0;

stop ToolTipTimer[playerid];

PlayerTextDrawSetString(playerid, ToolTipText[playerid], text);
PlayerTextDrawShow(playerid, ToolTipText[playerid]);

if(time > 0)
defer HideHelpTip_Delay(playerid, time);
ToolTipTimer[playerid] = defer HideHelpTip_Delay(playerid, time);

return 1;
}
Expand All @@ -50,40 +53,43 @@ hook OnPlayerConnect(playerid)
ToolTipText[playerid] =CreatePlayerTextDraw(playerid, 150.000000, 350.000000, "Tip: You can access the trunks of cars by pressing F at the back");
PlayerTextDrawBackgroundColor (playerid, ToolTipText[playerid], 255);
PlayerTextDrawFont (playerid, ToolTipText[playerid], 1);
PlayerTextDrawLetterSize (playerid, ToolTipText[playerid], 0.300000, 1.499999);
PlayerTextDrawColor (playerid, ToolTipText[playerid], 16711935);
PlayerTextDrawLetterSize (playerid, ToolTipText[playerid], 0.3, 1.2);
PlayerTextDrawColor (playerid, ToolTipText[playerid], 0x2f5a26ff);
PlayerTextDrawSetOutline (playerid, ToolTipText[playerid], 1);
PlayerTextDrawSetProportional (playerid, ToolTipText[playerid], 1);
PlayerTextDrawSetShadow (playerid, ToolTipText[playerid], 0);
PlayerTextDrawUseBox (playerid, ToolTipText[playerid], 1);
PlayerTextDrawBoxColor (playerid, ToolTipText[playerid], 0);
PlayerTextDrawTextSize (playerid, ToolTipText[playerid], 520.000000, 0.000000);
PlayerTextDrawTextSize (playerid, ToolTipText[playerid], 490.000000, 0.000000);
}

hook OnPlayerPickUpItem(playerid, Item:itemid)
hook OnPlayerGetItem(playerid, Item:itemid)
{
if(ToolTips[playerid])
{
new
itemname[MAX_ITEM_NAME],
itemtipkey[12],
str[288];
str[390],
ItemType:itemtype = GetItemType(GetPlayerItem(playerid));

GetItemTypeUniqueName(GetItemType(itemid), itemname);
GetItemTypeUniqueName(itemtype, itemname);

if(strlen(itemname) > 9)
itemname[9] = EOS;

format(itemtipkey, sizeof(itemtipkey), "%s_T", itemname);
itemtipkey[11] = EOS;

format(str, sizeof(str), "%s~n~~n~~b~Type /tooltips to toggle these messages", ls(playerid, itemtipkey, true));
GetItemTypeName(itemtype, itemname);

format(str, sizeof(str), "~y~%s: ~g~%s~n~~n~~b~%s", itemname, ls(playerid, itemtipkey, true), ls(playerid, "TOOLTIPTG", true));

ShowHelpTip(playerid, str, 20000);
}
}

hook OnPlayerDropItem(playerid, Item:itemid)
hook OnItemRemovedFromPlayer(playerid, Item:itemid)
{
if(ToolTips[playerid])
HideHelpTip(playerid);
Expand Down