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_data.h"
32 #include "../ui_sprite.h"
33 #include "../ui_render.h"
34 #include "../ui_input.h"
35 #include "../ui_lua.h"
43 #include "../../cl_language.h"
44 #include "../../input/cl_keys.h"
46 #include "../../../common/scripts_lua.h"
48 #define EXTRADATA_TYPE abstractOptionExtraData_t
49 #define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
83 else if (
EXTRADATA(node).lua_onViewChange != LUA_NOREF) {
129 const float* textColor;
150 currentY = pos[1] + node->
padding;
155 currentDecY = (fontHeight - height) / 2;
168 if (currentY + fontHeight > pos[1] + node->
box.
size[1] - node->
padding) {
182 }
else if (option->
color[3] == 0.0f) {
183 textColor = node->
color;
185 textColor = option->
color;
216 currentY += fontHeight;
280 bool down = deltaY > 0;
284 updated =
EXTRADATA(node).scrollY.move(
EXTRADATA(node).scrollY.viewPos + (down ? 1 : -1));
289 else if (
EXTRADATA(node).lua_onViewChange != LUA_NOREF) {
336 Com_Printf(
"UI_OptionTree_SelectValue: Option value \"%s\" not found\n", value);
354 updated =
EXTRADATA(node).scrollY.move(pos);
359 else if (
EXTRADATA(node).lua_onViewChange != LUA_NOREF) {
368 Com_Printf(
"UI_OptionTreeSetSelectedValue: Invalide number of param\n");
410 updated =
EXTRADATA(node).scrollY.moveDelta(deltaY);
415 else if (
EXTRADATA(node).lua_onViewChange != LUA_NOREF) {
433 int lineHeight =
EXTRADATA(node).lineHeight;
441 behaviour->
name =
"optiontree";
442 behaviour->
extends =
"abstractoption";
struct uiAction_s * onWheelDown
bool onScroll(uiNode_t *node, int deltaX, int deltaY) override
Auto scroll the list.
void onLoading(uiNode_t *node) override
Called before loading. Used to set default attribute values.
uiNode_t * UI_FindOptionByValue(uiOptionIterator_t *iterator, const char *value)
Find an option (and all his parents) by is value.
static uiNode_t * UI_OptionTreeNodeGetOptionAtPosition(uiNode_t *node, int x, int y, int *depth)
const char * UI_AbstractOption_GetCurrentValue(uiNode_t *node)
uiBehaviour_t * behaviour
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...
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 Com_Printf(const char *const fmt,...)
uiNode_t * UI_GetOption(int dataId)
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...
int UI_GetDataVersion(int textId)
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
void onLoaded(uiNode_t *node) override
void R_Color(const vec4_t rgba)
Change the color to given value.
uiNode_t * depthCache[MAX_DEPTH_OPTIONITERATORCACHE]
uiNode_t * UI_OptionIteratorNextOption(uiOptionIterator_t *iterator)
Find the next element from the iterator Iterator skipCollapsed and skipInvisible attribute can contro...
static void UI_OptionTreeSetSelectedValue(uiNode_t *node, const uiCallContext_t *context)
void draw(uiNode_t *node) override
#define OPTIONEXTRADATA(node)
static const int COLLAPSEBUTTON_WIDTH
static uiSprite_t * systemCollapse
static void UI_OptionTreeNodeUpdateCache(uiNode_t *node)
void onLeftClick(uiNode_t *node, int x, int y) override
Handles selectboxes clicks.
#define Vector4Set(v, r, g, b, a)
struct uiAction_s * onWheelUp
SharedPtr< uiNode > UINodePtr
int UI_FindOptionPosition(uiOptionIterator_t *iterator, const uiNode_t *option)
Find an option position from an option iterator.
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
void UI_AbstractOption_SetCurrentValue(uiNode_t *node, const char *value)
int UI_OptionUpdateCache(uiNode_t *option)
update option cache about child, according to collapse and visible status
void UI_OptionTree_SelectValue(uiNode_t *node, const char *value)
void onMouseUp(uiNode_t *node, int x, int y, int button) override
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...
uiNode_t * UI_InitOptionIteratorAtIndex(int index, uiNode_t *option, uiOptionIterator_t *iterator)
Init an option iterator at an index.
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Contain the context of the calling of a function.
static uiSprite_t * systemExpand
int UI_GetParamNumber(const uiCallContext_t *context)
static const int DEPTH_WIDTH
const char * UI_GetParam(const uiCallContext_t *context, int paramID)
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.
void doLayout(uiNode_t *node) override
Call to update the node layout. This common code revalidates the node tree.
void UI_NodeAbsoluteToRelativePos(const uiNode_t *node, int *x, int *y)
Update an absolute position to a relative one.
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)
static uiNode_t * UI_OptionTreeNodeGetFirstOption(uiNode_t *node)
Return the first option of the node.
void UI_DrawFill(int x, int y, int w, int h, const vec4_t color)
Fills a box of pixels with a single color.
uiSprite_t * UI_GetSpriteByName(const char *name)
Return an sprite by is name.
const uiBehaviour_t * ui_optionBehaviour
void UI_RegisterOptionTreeNode(uiBehaviour_t *behaviour)
QGL_EXTERN int GLboolean GLfloat * v
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
const struct value_s * UI_RegisterNodeMethod(uiBehaviour_t *behaviour, const char *name, uiNodeMethod_t function)
Register a node method to a behaviour.
static void UI_OptionTreeNodeUpdateScroll(uiNode_t *node)
Update the scroll according to the number of items and the size of the node.