26 #include "../ui_main.h"
27 #include "../ui_parse.h"
28 #include "../ui_behaviour.h"
29 #include "../ui_actions.h"
30 #include "../ui_font.h"
31 #include "../ui_sprite.h"
32 #include "../ui_render.h"
33 #include "../ui_input.h"
34 #include "../ui_lua.h"
42 #include "../../cl_language.h"
43 #include "../../input/cl_keys.h"
45 #include "../../../common/scripts_lua.h"
47 #define EXTRADATA_TYPE abstractOptionExtraData_t
48 #define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
50 #define CORNER_SIZE 25
69 if (lineHeight == 0) {
80 else if (
EXTRADATA(node).lua_onViewChange != LUA_NOREF) {
94 const float* textColor;
112 currentY = pos[1] + node->
padding;
116 while (option && count <
EXTRADATA(node).scrollY.viewPos) {
117 option = option->
next;
122 for (; option; option = option->
next) {
123 int decX = pos[0] + node->
padding;
125 if (currentY + lineHeight > pos[1] + node->
box.
size[1] - node->
padding) {
139 }
else if (option->
color[3] == 0.0f) {
140 textColor = node->
color;
142 textColor = option->
color;
163 currentY += lineHeight;
169 for (; option; option = option->
next) {
189 currentY = pos[1] + node->
padding;
192 if (lineHeight == 0) {
198 while (option && count <
EXTRADATA(node).scrollY.viewPos) {
199 option = option->
next;
204 for (; option; option = option->
next) {
205 if (y < currentY + lineHeight)
207 if (currentY + lineHeight > pos[1] + node->
box.
size[1] - node->
padding)
209 currentY += lineHeight;
237 bool down = deltaY > 0;
241 updated =
EXTRADATA(node).scrollY.moveDelta(down ? 1 : -1);
246 else if (
EXTRADATA(node).lua_onViewChange != LUA_NOREF) {
308 updated =
EXTRADATA(node).scrollY.moveDelta(deltaY);
313 else if (
EXTRADATA(node).lua_onViewChange != LUA_NOREF) {
331 int lineHeight =
EXTRADATA(node).lineHeight;
339 behaviour->
name =
"optionlist";
340 behaviour->
extends =
"abstractoption";
struct uiAction_s * onWheelDown
void UI_RegisterOptionListNode(uiBehaviour_t *behaviour)
const char * UI_AbstractOption_GetCurrentValue(uiNode_t *node)
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
void UI_DrawSpriteInBox(bool flip, const uiSprite_t *sprite, uiSpriteStatus_t status, int posX, int posY, int sizeX, int sizeY)
virtual void onMouseMove(uiNode_t *node, int x, int y)
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
void R_Color(const vec4_t rgba)
Change the color to given value.
static void UI_OptionListNodeUpdateScroll(uiNode_t *node)
Update the scroll according to the number of items and the size of the node.
void onMouseUp(uiNode_t *node, int x, int y, int button) override
#define OPTIONEXTRADATA(node)
void onMouseDown(uiNode_t *node, int x, int y, int button) override
Track mouse down/up events to implement drag&drop-like scrolling, for touchscreen devices...
#define Vector4Set(v, r, g, b, a)
struct uiAction_s * onWheelUp
void onLoaded(uiNode_t *node) override
SharedPtr< uiNode > UINodePtr
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
void UI_AbstractOption_SetCurrentValue(uiNode_t *node, const char *value)
bool onScroll(uiNode_t *node, int deltaX, int deltaY) override
Auto scroll the list.
Atomic structure used to define most of the UI.
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
const char * CL_Translate(const char *t)
const char * UI_GetFontFromNode(const uiNode_t *const node)
Return the font for a specific node or default font.
node behaviour, how a node work
struct uiAction_s * onWheel
int UI_FontGetHeight(const char *fontID)
int UI_DrawString(const char *fontID, align_t align, int x, int y, int absX, int maxWidth, int lineHeight, const char *c, int boxHeight, int scrollPos, int *curLine, bool increaseLine, longlines_t method)
int getCellHeight(uiNode_t *node) override
Return size of the cell, which is the size (in virtual "pixel") which represent 1 in the scroll value...
void UI_DrawFill(int x, int y, int w, int h, const vec4_t color)
Fills a box of pixels with a single color.
void onLeftClick(uiNode_t *node, int x, int y) override
Handles selectboxes clicks.
static uiNode_t * UI_OptionListNodeGetOptionAtPosition(uiNode_t *node, int x, int y)
uiNode_t * UI_AbstractOption_GetFirstOption(uiNode_t *node)
Return the first option of the node.
void draw(uiNode_t *node) override
void onLoading(uiNode_t *node) override
Called before loading. Used to set default attribute values.