This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
functions:addons:rect [2016/08/09 21:57] – [RectHeight] korshun | functions:addons:rect [2017/07/13 18:42] – monsterovich | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Rectangle API ====== | ====== Rectangle API ====== | ||
- | This is a simple library that implements basic UI elements in ACS. This library is an **addon** for the [[functions: | + | This is a simple library that implements basic UI elements in ACS. This library is an **addon** for the cursor library. |
- | <note tip> | + | <note tip> |
Define '' | Define '' | ||
+ | |||
+ | ===== Usage ===== | ||
+ | |||
+ | < | ||
+ | ... | ||
+ | |||
+ | #define ACSUTILS_RECTLIB_USERVARS 1 // user defined | ||
+ | #include " | ||
+ | #include " | ||
+ | |||
+ | ... | ||
+ | </ | ||
===== Example ===== | ===== Example ===== | ||
Line 22: | Line 34: | ||
UpdateCursor(); | UpdateCursor(); | ||
HudSetPoint(CursorX(), | HudSetPoint(CursorX(), | ||
- | | + | |
for (int i = 0; i <= rects; i++) | for (int i = 0; i <= rects; i++) | ||
Line 30: | Line 42: | ||
if (RectIsPressed(i, | if (RectIsPressed(i, | ||
log(s:" | log(s:" | ||
+ | |||
+ | for (int j = 0; j <= rects; j++) | ||
+ | { | ||
+ | if (RectIntersects(i, | ||
+ | log(s:" | ||
+ | } | ||
HudSetPoint(RectX1(i), | HudSetPoint(RectX1(i), | ||
Line 113: | Line 131: | ||
'' | '' | ||
- | Returns the width of given rectangle. | + | Returns the width of the given rectangle. |
==== RectHeight ==== | ==== RectHeight ==== | ||
Line 128: | Line 146: | ||
'' | '' | ||
- | Returns true if rectangle contains point with //x y// coordiantes, else returns false. | + | Returns true if the rectangle contains |
+ | |||
+ | ==== RectIntersects ==== | ||
+ | '' | ||
+ | |||
+ | Returns true if the rectangle with id //rect// intersects with other rectangle with id // | ||
+ | |||
+ | <note tip> | ||
===== User Data ===== | ===== User Data ===== | ||
Line 138: | Line 163: | ||
'' | '' | ||
- | Sets the value of custom property | + | Sets the value of the given custom property of the rectangle. |
==== RectGetUserData ==== | ==== RectGetUserData ==== | ||
'' | '' | ||
- | Returns the value of custom property | + | Returns the value of the rectangle' |
==== Example ==== | ==== Example ==== | ||
- | A simple implementation of checkbox button. | + | A simple implementation of a checkbox button. |
< | < | ||
Line 175: | Line 199: | ||
'' | '' | ||
- | Returns true if rectangle contains | + | Returns true if the mouse cursor |
==== RectIsClicked ==== | ==== RectIsClicked ==== | ||
'' | '' | ||
- | Returns true if user clicked rectangle once with //key//. | + | Returns true if user clicked |
==== RectIsDown ==== | ==== RectIsDown ==== | ||
'' | '' | ||
- | Returns true if user has the //key// down and rectangle contains | + | Returns true if user is holding |
==== RectIsGrabbed ==== | ==== RectIsGrabbed ==== | ||
'' | '' | ||
- | This function is similar to // | + | This function is similar to // |
==== RectIsPressed ==== | ==== RectIsPressed ==== | ||
'' | '' | ||
- | This function is similar to // | + | This function is similar to // |
- | * Returns true, if user up the //key// after he clicked | + | * Returns true, if user released |
- | * Returns true, if cursor | + | * Returns true, if cursor |
Otherwise, it return false. | Otherwise, it return false. | ||