| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992 |
- /*----------------------------------------------------------------------------*\
- | y_GUI
- \*----------------------------------------------------------------------------*/
- #include <a_samp>
- #include "y_bit"
- /*----------------------------------------------------------------------------*/
- #if !defined MAX_GUIS
- #define MAX_GUIS (32)
- #endif
- #if MAX_GUIS < 1
- #undef MAX_GUIS
- #define MAX_GUIS (1)
- #endif
- #if !defined MAX_GUI_ELEMENTS
- #define MAX_GUI_ELEMENTS (16)
- #endif
- #if MAX_GUI_ELEMENTS < 1
- #undef MAX_GUI_ELEMENTS
- #define MAX_GUI_ELEMENTS (1)
- #endif
- #if !defined MAX_GUI_ELEMENTS_LENGTH
- #define MAX_GUI_ELEMENTS_LENGTH (32)
- #endif
- #if MAX_GUI_ELEMENTS < 1
- #undef MAX_GUI_ELEMENTS_LENGTH
- #define MAX_GUI_ELEMENTS_LENGTH (16)
- #endif
- #define NO_GUI (GUI:-1)
- /*----------------------------------------------------------------------------*/
- #define GUI_IsValid(%0) ((GUI:0 <= (%0) < GUI:MAX_GUIS) && Bit_Get(YSI_g_sGUIBeingUsed, (%0)))
- /*----------------------------------------------------------------------------*/
- static stock
- BitArray: YSI_g_sGUIBeingUsed<MAX_GUIS>, // Being used
-
- // Title variables
- BitArray: YSI_g_sGUITitleUsing<MAX_GUIS>, // Using title
- YSI_g_sGUITitleText[MAX_GUIS][64 char], // Title text (Packed)
- Float: YSI_g_sGUITitlePos[MAX_GUIS][2], // Position
- Float: YSI_g_sGUITitleSize[MAX_GUIS][2], // Size
- YSI_g_sGUITitleColor[MAX_GUIS], // Text color
- BitArray: YSI_g_sGUITitleBox<MAX_GUIS>, // Using box
- Float: YSI_g_sGUITitleBPos[MAX_GUIS][2], // Box Position
- Float: YSI_g_sGUITitleBSize[MAX_GUIS][2], // Box Size
- YSI_g_sGUITitleBColor[MAX_GUIS], // Box color
-
- // Items (buttons)
- BitArray: YSI_g_sGUIItemUsing[MAX_GUIS]<MAX_GUI_ELEMENTS>, // Using button
- YSI_g_sGUIItemText[MAX_GUIS][MAX_GUI_ELEMENTS][MAX_GUI_ELEMENTS_LENGTH char], // Button text (Packed string)
- Float: YSI_g_sGUIItemPos[MAX_GUIS][MAX_GUI_ELEMENTS][2], // Button position
- Float: YSI_g_sGUIItemSize[MAX_GUIS][MAX_GUI_ELEMENTS][2], // Button size
- Float: YSI_g_sGUIItemBSize[MAX_GUIS][MAX_GUI_ELEMENTS], // Buttom box size
- YSI_g_sGUIItemColor[MAX_GUIS][MAX_GUI_ELEMENTS], // Button color
- YSI_g_sGUIItemBColor[MAX_GUIS][MAX_GUI_ELEMENTS], // Button box color
- // Textdraws
- Text: YSI_g_sGUITextTitle[MAX_GUIS][2],
- Text: YSI_g_sGUITextButton[MAX_GUIS][MAX_GUI_ELEMENTS],
- // Per player variables
- BitArray: YSI_g_spGUIUsing<MAX_PLAYERS>,
- YSI_g_spGUI[MAX_PLAYERS],
- YSI_g_spGUITick[MAX_PLAYERS],
- YSI_g_spGUIItem[MAX_PLAYERS];
- /*----------------------------------------------------------------------------*/
- stock
- GUI_ShowForPlayer(playerid, GUI: gui)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:gui))
- return 0;
- // ---------------------------------------------------------------------
- if (!Bit_Get(YSI_g_spGUIUsing, playerid))
- Bit_Let(YSI_g_spGUIUsing, playerid);
- // ---------------------------------------------------------------------
- YSI_g_spGUI[playerid] = _:gui;
- YSI_g_spGUIItem[playerid] = 0;
- // ---------------------------------------------------------------------
- if (Bit_Get(YSI_g_sGUITitleUsing, _:gui))
- TextDrawShowForPlayer(playerid, YSI_g_sGUITextTitle[_:gui][0]);
- if (Bit_Get(YSI_g_sGUITitleBox, _:gui))
- TextDrawShowForPlayer(playerid, YSI_g_sGUITextTitle[_:gui][1]);
- // ---------------------------------------------------------------------
- // Maybe you can use y_iterate here
- for (new pos; pos < MAX_GUI_ELEMENTS; pos ++)
- if (Bit_Get(YSI_g_sGUIItemUsing[_:gui], pos))
- TextDrawShowForPlayer(playerid, YSI_g_sGUITextButton[_:gui][pos]);
- // ---------------------------------------------------------------------
- return 1;
- }
- stock
- GUI_HideForPlayer(playerid)
- {
- if (!Bit_Get(YSI_g_spGUIUsing, playerid))
- return 0;
- // ---------------------------------------------------------------------
- Bit_Vet(YSI_g_spGUIUsing, playerid);
- // ---------------------------------------------------------------------
- YSI_g_spGUI[playerid] = 0;
- YSI_g_spGUIItem[playerid] = 0;
- // ---------------------------------------------------------------------
- if (Bit_Get(YSI_g_sGUITitleUsing, _:gui))
- TextDrawHideForPlayer(playerid, YSI_g_sGUITextTitle[_:gui][0]);
- if (Bit_Get(YSI_g_sGUITitleBox, _:gui))
- TextDrawHideForPlayer(playerid, YSI_g_sGUITextTitle[_:gui][1]);
- // ---------------------------------------------------------------------
- // Maybe you can use y_iterate here
- for (new pos; pos < MAX_GUI_ELEMENTS; pos ++)
- if (Bit_Get(YSI_g_sGUIItemUsing[_:gui], pos))
- TextDrawHideForPlayer(playerid, YSI_g_sGUITextButton[_:gui][pos]);
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock GUI:GUI_Create()
- {
- for (new pos = 0; pos != MAX_GUIS; ++pos)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, pos))
- {
- Bit_Let(YSI_g_sGUIBeingUsed, pos);
- return GUI:pos;
- }
- }
- return NO_GUI;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Delete(GUI: Handle)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- // ---------------------------------------------------------------------
- Bit_Vet(YSI_g_sGUIBeingUsed, _:Handle);
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Title_Use(GUI: Handle)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- // ---------------------------------------------------------------------
- Bit_Let(YSI_g_sGUITitleUsing, _:Handle);
- Bit_Vet(YSI_g_sGUITitleBox, _:Handle);
- YSI_g_sGUITitleText[_:Handle][0] = 0;
- YSI_g_sGUITitlePos[_:Handle][0] = 0.0;
- YSI_g_sGUITitlePos[_:Handle][1] = 0.0;
- YSI_g_sGUITitleSize[_:Handle][0] = 0.0;
- YSI_g_sGUITitleSize[_:Handle][1] = 0.0;
- YSI_g_sGUITitleColor[_:Handle] = 0xFFFFFFFF;
- YSI_g_sGUITitleBPos[_:Handle][0] = 0.0;
- YSI_g_sGUITitleBPos[_:Handle][1] = 0.0;
- YSI_g_sGUITitleBSize[_:Handle][0] = 0.0;
- YSI_g_sGUITitleBSize[_:Handle][1] = 0.0;
- YSI_g_sGUITitleBColor[_:Handle] = 0x00000077;
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Title_Remove(GUI: Handle)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- // ---------------------------------------------------------------------
- Bit_Vet(YSI_g_sGUITitleUsing, _:Handle);
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Title_SetText(GUI: Handle, Text[])
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- // ---------------------------------------------------------------------
- strpack(YSI_g_sGUITitleText[_:Handle], Text, 64);
- // ---------------------------------------------------------------------
- return 1;
- }
- stock
- GUI_Title_GetText(GUI: Handle, Text[])
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- // ---------------------------------------------------------------------
- strunpack(Text, YSI_g_sGUITitleText[_:Handle], 64);
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Title_SetPos(GUI: Handle, Float: posX, Float: posY)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- // ---------------------------------------------------------------------
- YSI_g_sGUITitlePos[_:Handle][0] = posX;
- YSI_g_sGUITitlePos[_:Handle][1] = posY;
- // ---------------------------------------------------------------------
- return 1;
- }
- stock
- GUI_Title_GetPos(GUI: Handle, &Float: posX, &Float: posY)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- // ---------------------------------------------------------------------
- posX = YSI_g_sGUITitlePos[_:Handle][0];
- posY = YSI_g_sGUITitlePos[_:Handle][1];
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Title_SetSize(GUI: Handle, Float: sizeX, Float: sizeY)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- // ---------------------------------------------------------------------
- YSI_g_sGUITitleSize[_:Handle][0] = sizeX;
- YSI_g_sGUITitleSize[_:Handle][1] = sizeY;
- // ---------------------------------------------------------------------
- return 1;
- }
- stock
- GUI_Title_GetSize(GUI: Handle, &Float: sizeX, &Float: sizeY)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- // ---------------------------------------------------------------------
- sizeX = YSI_g_sGUITitleSize[_:Handle][0];
- sizeY = YSI_g_sGUITitleSize[_:Handle][1];
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- #define GUI_Title_SetColour GUI_Title_SetColor
- stock
- GUI_Title_SetColor(GUI: Handle, Color)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- // ---------------------------------------------------------------------
- YSI_g_sGUITitleColor[_:Handle] = Color;
- // ---------------------------------------------------------------------
- return 1;
- }
- #define GUI_Title_GetColour GUI_Title_GetColor
- stock
- GUI_Title_GetColor(GUI: Handle, &Color)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- // ---------------------------------------------------------------------
- Color = YSI_g_sGUITitleColor[_:Handle];
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Title_Box(GUI: Handle, bool: Use)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- // ---------------------------------------------------------------------
- if (Use)
- {
- Bit_Let(YSI_g_sGUITitleBox, _:Handle);
- }
- else
- {
- Bit_Vet(YSI_g_sGUITitleBox, _:Handle);
- }
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Title_SetBPos(GUI: Handle, Float: posX, Float: posY)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- if (!Bit_Get(YSI_g_sGUITitleBox, _:Handle))
- return -2;
- // ---------------------------------------------------------------------
- YSI_g_sGUITitleBPos[_:Handle][0] = posX;
- YSI_g_sGUITitleBPos[_:Handle][1] = posY;
- // ---------------------------------------------------------------------
- return 1;
- }
- stock
- GUI_Title_GetBPos(GUI: Handle, &Float: posX, &Float: posY)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- if (!Bit_Get(YSI_g_sGUITitleBox, _:Handle))
- return -2;
- // ---------------------------------------------------------------------
- posX = YSI_g_sGUITitleBPos[_:Handle][0];
- posY = YSI_g_sGUITitleBPos[_:Handle][1];
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Title_SetBSize(GUI: Handle, Float: sizeX, Float: sizeY)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- if (!Bit_Get(YSI_g_sGUITitleBox, _:Handle))
- return -2;
- // ---------------------------------------------------------------------
- YSI_g_sGUITitleBSize[_:Handle][0] = sizeX;
- YSI_g_sGUITitleBSize[_:Handle][1] = sizeY;
- // ---------------------------------------------------------------------
- return 1;
- }
- stock
- GUI_Title_GetBSize(GUI: Handle, &Float: sizeX, &Float: sizeY)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- if (!Bit_Get(YSI_g_sGUITitleBox, _:Handle))
- return -2;
- // ---------------------------------------------------------------------
- sizeX = YSI_g_sGUITitleBSize[_:Handle][0];
- sizeY = YSI_g_sGUITitleBSize[_:Handle][1];
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- #define GUI_Title_SetBackgroundColor GUI_Title_SetBColor
- #define GUI_Title_SetBackgroundColour GUI_Title_SetBColor
- #define GUI_Title_SetBColour GUI_Title_SetBColor
- stock
- GUI_Title_SetBColor(GUI: Handle, Color)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- if (!Bit_Get(YSI_g_sGUITitleBox, _:Handle))
- return -2;
- // ---------------------------------------------------------------------
- YSI_g_sGUITitleBColor[_:Handle] = Color;
- // ---------------------------------------------------------------------
- return 1;
- }
- #define GUI_Title_GetBackgroundColor GUI_Title_GetBColor
- #define GUI_Title_GetBackgroundColour GUI_Title_GetBColor
- #define GUI_Title_GetBColour GUI_Title_GetBColor
- stock
- GUI_Title_GetBColor(GUI: Handle, &Color)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- return -1;
- if (!Bit_Get(YSI_g_sGUITitleBox, _:Handle))
- return -2;
- // ---------------------------------------------------------------------
- Color = YSI_g_sGUITitleBColor[_:Handle];
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Item_Use(GUI: Handle, ItemID, bool: Use)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- // ---------------------------------------------------------------------
- if (Use)
- {
- Bit_Let(YSI_g_sGUIItemUsing[_:Handle], ItemID);
- }
- else
- {
- Bit_Vet(YSI_g_sGUIItemUsing[_:Handle], ItemID);
- }
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Item_SetText(GUI: Handle, ItemID, Text[])
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUIItemUsing[_:Handle], ItemID))
- return -1;
- // ---------------------------------------------------------------------
- strpack(YSI_g_sGUIItemText[_:Handle][ItemID], Text, MAX_GUI_ELEMENTS_LENGTH);
- // ---------------------------------------------------------------------
- return 1;
- }
- stock
- GUI_Item_GetText(GUI: Handle, ItemID, Dest[])
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUIItemUsing[_:Handle], ItemID))
- return -1;
- // ---------------------------------------------------------------------
- strunpack(Dest, YSI_g_sGUIItemText, MAX_GUI_ELEMENTS_LENGTH);
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Item_SetPos(GUI: Handle, ItemID, Float: posX, Float: posY)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUIItemUsing[_:Handle], ItemID))
- return -1;
- // ---------------------------------------------------------------------
- YSI_g_sGUIItemPos[_:Handle][ItemID][0] = posX;
- YSI_g_sGUIItemPos[_:Handle][ItemID][1] = posY;
- // ---------------------------------------------------------------------
- return 1;
- }
- stock
- GUI_Item_GetPos(GUI: Handle, ItemID, &Float: posX, &Float: posY)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUIItemUsing[_:Handle], ItemID))
- return -1;
- // ---------------------------------------------------------------------
- posX = YSI_g_sGUIItemPos[_:Handle][ItemID][0];
- posY = YSI_g_sGUIItemPos[_:Handle][ItemID][1];
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Item_SetSize(GUI: Handle, ItemID, Float: sizeX, Float: sizeY)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUIItemUsing[_:Handle], ItemID))
- return -1;
- // ---------------------------------------------------------------------
- YSI_g_sGUIItemSize[_:Handle][ItemID][0] = sizeX;
- YSI_g_sGUIItemSize[_:Handle][ItemID][1] = sizeY;
- // ---------------------------------------------------------------------
- return 1;
- }
- stock
- GUI_Item_GetSize(GUI: Handle, ItemID, &Float: sizeX, &Float: sizeY)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUIItemUsing[_:Handle], ItemID))
- return -1;
- // ---------------------------------------------------------------------
- sizeX = YSI_g_sGUIItemSize[_:Handle][ItemID][0];
- sizeY = YSI_g_sGUIItemSize[_:Handle][ItemID][1];
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Item_SetBSize(GUI: Handle, ItemID, Float: size)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUIItemUsing[_:Handle], ItemID))
- return -1;
- // ---------------------------------------------------------------------
- YSI_g_sGUIItemBSize[_:Handle][ItemID] = size;
- // ---------------------------------------------------------------------
- return 1;
- }
- stock
- GUI_Item_GetBSize(GUI: Handle, ItemID, &Float: size)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUIItemUsing[_:Handle], ItemID))
- return -1;
- // ---------------------------------------------------------------------
- size = YSI_g_sGUIItemBSize[_:Handle][ItemID];
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- #define GUI_Item_SetColour GUI_Item_SetColor
- stock
- GUI_Item_SetColor(GUI: Handle, ItemID, Color)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUIItemUsing[_:Handle], ItemID))
- return -1;
- // ---------------------------------------------------------------------
- YSI_g_sGUIItemColor[_:Handle][ItemID] = Color;
- // ---------------------------------------------------------------------
- return 1;
- }
- #define GUI_Item_GetColour GUI_Item_GetColor
- stock
- GUI_Item_GetColor(GUI: Handle, ItemID, &Color)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUIItemUsing[_:Handle], ItemID))
- return -1;
- // ---------------------------------------------------------------------
- Color = YSI_g_sGUIItemColor[_:Handle][ItemID];
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- #define GUI_Item_SetBColor GUI_Item_SetBackgroundColor
- #define GUI_Item_SetBColour GUI_Item_SetBackgroundColor
- #define GUI_Item_SetBackgroundColour GUI_Item_SetBackgroundColor
- stock
- GUI_Item_SetBackgroundColor(GUI: Handle, ItemID, Color)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUIItemUsing[_:Handle], ItemID))
- return -1;
- // ---------------------------------------------------------------------
- YSI_g_sGUIItemBColor[_:Handle][ItemID] = Color;
- // ---------------------------------------------------------------------
- return 1;
- }
- #define GUI_Item_GetBColor GUI_Item_GetBackgroundColor
- #define GUI_Item_GetBColour GUI_Item_GetBackgroundColor
- #define GUI_Item_GetBackgroundColour GUI_Item_GetBackgroundColor
- stock
- GUI_Item_GetBackgroundColor(GUI: Handle, ItemID, &Color)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- if (!Bit_Get(YSI_g_sGUIItemUsing[_:Handle], ItemID))
- return -1;
- // ---------------------------------------------------------------------
- Color = YSI_g_sGUIItemBColor[_:Handle][ItemID];
- // ---------------------------------------------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- stock
- GUI_Update(GUI: Handle)
- {
- if (!Bit_Get(YSI_g_sGUIBeingUsed, _:Handle))
- return 0;
- // ---------------------------------------------------------------------
- if (Bit_Get(YSI_g_sGUITitleUsing, _:Handle))
- {
- new
- szString[64];
- strunpack(szString, YSI_g_sGUITitleText[_:Handle]);
- // Creating the textdraw -------------------------------------------
- YSI_g_sGUITextTitle[_:Handle][0] = TextDrawCreate(
- YSI_g_sGUITitlePos[_:Handle][0],
- YSI_g_sGUITitlePos[_:Handle][1],
- szString
- );
- // Text size -------------------------------------------------------
- TextDrawLetterSize(
- YSI_g_sGUITextTitle[_:Handle][0],
- YSI_g_sGUITitleSize[_:Handle][0],
- YSI_g_sGUITitleSize[_:Handle][1]
- );
- // Text color ------------------------------------------------------
- TextDrawColor(
- YSI_g_sGUITextTitle[_:Handle][0],
- YSI_g_sGUITitleColor[_:Handle]
- );
- }
- // ---------------------------------------------------------------------
- if (Bit_Get(YSI_g_sGUITitleBox, _:Handle))
- {
- // Creating the box ------------------------------------------------
- YSI_g_sGUITextTitle[_:Handle][1] = TextDrawCreate(
- YSI_g_sGUITitleBPos[_:Handle][0],
- YSI_g_sGUITitleBPos[_:Handle][1],
- "_"
- );
- // Use box ---------------------------------------------------------
- TextDrawUseBox(
- YSI_g_sGUITextTitle[_:Handle][1],
- 1
- );
- // Box size --------------------------------------------------------
- TextDrawTextSize(
- YSI_g_sGUITextTitle[_:Handle][1],
- YSI_g_sGUITitleBPos[_:Handle][0] + YSI_g_sGUITitleBSize[_:Handle][0],
- 0.0
- );
- TextDrawLetterSize(
- YSI_g_sGUITextTitle[_:Handle][1],
- 1.0,
- YSI_g_sGUITitleBSize[_:Handle][0] * 0.112957 // MAYBE this value isn't perfect
- );
- // Box color -------------------------------------------------------
- TextDrawBoxColor(
- YSI_g_sGUITextTitle[_:Handle][1],
- YSI_g_sGUITitleBColor[_:Handle]
- );
- }
- // ---------------------------------------------------------------------
- new
- szString[64];
- for (new Pos; Pos < MAX_GUIS; Pos ++)
- {
- if (Bit_Get(YSI_g_sGUIItemUsing[_:Handle], Pos))
- {
- strunpack(szString, YSI_g_sGUIItemText[_:Handle][Pos]);
- // Create the textdraw -----------------------------------------
- YSI_g_sGUITextButton[_:Handle][Pos] = TextDrawCreate(
- YSI_g_sGUIItemPos[_:Handle][Pos][0],
- YSI_g_sGUIItemPos[_:Handle][Pos][1],
- szString);
- // Alignment ---------------------------------------------------
- TextDrawAlignment(
- YSI_g_sGUITextButton[_:Handle][Pos],
- 2
- );
- // Size --------------------------------------------------------
- TextDrawLetterSize(
- YSI_g_sGUITextButton[_:Handle][Pos],
- YSI_g_sGUIItemSize[_:Handle][Pos][0],
- YSI_g_sGUIItemSize[_:Handle][Pos][1]
- );
- // Color -------------------------------------------------------
- TextDrawColor(
- YSI_g_sGUITextButton[_:Handle][Pos],
- YSI_g_sGUIItemColor[_:Handle][Pos]
- );
- // Use box -----------------------------------------------------
- TextDrawUseBox(
- YSI_g_sGUITextButton[_:Handle][Pos],
- 1
- );
- // Box size ----------------------------------------------------
- TextDrawTextSize(
- YSI_g_sGUITextButton[_:Handle][Pos],
- 0.0,
- YSI_g_sGUIItemBSize[_:Handle][Pos]
- );
- // Box color ---------------------------------------------------
- TextDrawBoxColor(
- YSI_g_sGUITextButton[_:Handle][Pos],
- YSI_g_sGUIItemBColor[_:Handle][Pos]
- );
- }
- }
- // ---------------------------------------------------------------------
- return 1;
- }
- /*-----------------------------------------*/
|