46 #include "../ui_main.h"
47 #include "../ui_internal.h"
48 #include "../ui_parse.h"
49 #include "../ui_font.h"
50 #include "../ui_input.h"
51 #include "../ui_draw.h"
52 #include "../ui_render.h"
58 #include "../../cl_language.h"
60 #include "../../../common/scripts_lua.h"
62 #define EXTRADATA(node) UI_EXTRADATA(node, abstractOptionExtraData_t)
64 #define SELECTBOX_DEFAULT_HEIGHT 20.0f
66 #define SELECTBOX_SIDE_WIDTH 7.0f
67 #define SELECTBOX_RIGHT_WIDTH 20.0f
69 #define SELECTBOX_SPACER 2.0f
70 #define SELECTBOX_BOTTOM_HEIGHT 4.0f
97 static vec4_t invisColor = {1.0, 1.0, 1.0, 0.7};
106 imageName =
"ui/selectbox";
135 selBoxX, node->
box.
size[0] - 4,
159 imageName =
"ui/selectbox";
172 7.0
f, 28.0
f, 0.0
f, 21.0
f, image);
176 16.0
f, 28.0
f, 7.0
f, 21.0
f, image);
180 23.0
f, 28.0
f, 16.0
f, 21.0
f, image);
194 selBoxX, node->
box.
size[0] - 4,
204 Com_Printf(
"uiSelectBoxNode::drawOverWindow: Node '%s' contains unsynchronized option list. Fixed.\n",
UI_GetPath(node));
210 7.0
f, 32.0
f, 0.0
f, 28.0
f, image);
215 16.0f, 32.0f, 7.0f, 28.0f, image);
220 23.0f, 32.0f, 16.0f, 28.0f, image);
236 int clickedAtOption = (y - pos[1]);
245 if (clickedAtOption < node->box.size[1]) {
250 clickedAtOption = (clickedAtOption - node->
box.
size[1]) / node->
box.
size[1];
251 if (clickedAtOption < 0 || clickedAtOption >=
EXTRADATA(node).count)
259 for (; option; option = option->
next) {
262 if (clickedAtOption == 0)
291 behaviour->
name =
"selectbox";
292 behaviour->
extends =
"abstractoption";
void draw(uiNode_t *node) override
void UI_CaptureDrawOver(uiNode_t *node)
Capture a node we will draw over all nodes (per window)
void onLeftClick(uiNode_t *node, int x, int y) override
Handles selectboxes clicks.
const char * UI_AbstractOption_GetCurrentValue(uiNode_t *node)
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
call when the mouse move is the node is captured
void drawOverWindow(uiNode_t *node) override
void UI_RegisterSelectBoxNode(uiBehaviour_t *behaviour)
void Com_Printf(const char *const fmt,...)
void R_Color(const vec4_t rgba)
Change the color to given value.
#define SELECTBOX_SIDE_WIDTH
#define OPTIONEXTRADATA(node)
#define SELECTBOX_BOTTOM_HEIGHT
#define Vector4Set(v, r, g, b, a)
SharedPtr< uiNode > UINodePtr
const struct image_s * UI_LoadImage(const char *name)
Searches for an image in the image array.
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
void UI_DrawNormImage(bool flip, float x, float y, float w, float h, float sh, float th, float sl, float tl, const image_t *image)
Draw a normalized (to the screen) image.
void UI_AbstractOption_SetCurrentValue(uiNode_t *node, const char *value)
const char * UI_GetReferenceString(const uiNode_t *const node, const char *ref)
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.
#define SELECTBOX_DEFAULT_HEIGHT
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 UI_NodeAbsoluteToRelativePos(const uiNode_t *node, int *x, int *y)
Update an absolute position to a relative one.
node behaviour, how a node work
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)
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 onLoading(uiNode_t *node) override
Called before loading. Used to set default attribute values.
void onLoaded(uiNode_t *node) override
#define SELECTBOX_RIGHT_WIDTH
uiNode_t * UI_AbstractOption_GetFirstOption(uiNode_t *node)
Return the first option of the node.