32#include "../ui_main.h"
33#include "../ui_nodes.h"
34#include "../ui_font.h"
35#include "../ui_parse.h"
36#include "../ui_behaviour.h"
37#include "../ui_input.h"
38#include "../ui_render.h"
39#include "../ui_sprite.h"
46#include "../../client.h"
47#include "../../../shared/utf8.h"
49#include "../../../common/scripts_lua.h"
51#if SDL_VERSION_ATLEAST(2,0,0)
55#include <SDL/SDL_screenkeyboard.h>
59#define EXTRADATA_TYPE textEntryExtraData_t
60#define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
67#define MAX_CVAR_EDITING_LENGTH 256
79 UI_EXTRADATA(node, textEntryExtraData_s).background = sprite;
176 const char* cvarRef =
"*cvar:";
183#if SDL_VERSION_ATLEAST(2,0,0)
184 SDL_StartTextInput();
187 SDL_Rect r = {
static_cast<int>(pos[0]),
static_cast<int>(pos[1]),
static_cast<int>(node->
box.
size[0]),
static_cast<int>(node->
box.
size[1])};
188 SDL_SetTextInputRect(&r);
193 SDL_ANDROID_GetScreenKeyboardTextInput(
buf,
sizeof(
buf));
216#if SDL_VERSION_ATLEAST(2,0,0)
242 int length = strlen(buffer);
246 if (
length + charLength >=
sizeof(buffer))
250 if (insertedLength > 0)
315 const float* textColor;
323 }
else if (node->
state) {
324 textColor = node->
color;
327 textColor = node->
color;
388 behaviour->
name =
"textentry";
int CL_Milliseconds(void)
void R_Color(const vec4_t rgba)
Change the color to given value.
void draw(uiNode_t *node) override
void onLeftClick(uiNode_t *node, int x, int y) override
Called when the user click with the right mouse button.
bool onKeyPressed(uiNode_t *node, unsigned int key, unsigned short unicode) override
Called when we press a key when the node got the focus.
void onFocusLost(uiNode_t *node) override
Called when the node lost the focus.
void onFocusGained(uiNode_t *node) override
Called when the node got the focus.
void onLoading(uiNode_t *node) override
Call before the script initialization of the node.
cvar_t * Cvar_ForceSet(const char *varName, const char *value)
Will set the variable even if NOSET or LATCH.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
QGL_EXTERN GLuint GLsizei GLsizei * length
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
align_t
We need this here for checking the boundaries from script values.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
node behaviour, how a node work
Contain the context of the calling of a function.
Atomic structure used to define most of the UI.
struct uiAction_s * onChange
struct uiAction_s * onClick
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
const struct value_s * UI_RegisterNodeMethod(uiBehaviour_t *behaviour, const char *name, uiNodeMethod_t function)
Register a node method to a behaviour.
#define UI_RegisterOveridedNodeProperty(BEHAVIOUR, NAME)
Initialize a property which override an inherited property. It is yet only used for the documentation...
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
const char * UI_GetFontFromNode(const uiNode_t *const node)
Return the font for a specific node or default font.
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
bool UI_ExecuteLuaEventScript_XY(uiNode_t *node, LUA_EVENT event, int x, int y)
Executes a lua event handler with (x,y) argument.
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.
SharedPtr< uiNode > UINodePtr
static const char HIDECHAR
void UI_TextEntryNodeUnFocus(uiNode_t *node, const uiCallContext_t *context)
force exit the edit mode of a textentry node
static void UI_TextEntryNodeEdit(uiNode_t *node, unsigned int unicode)
edit the current cvar with a char
#define MAX_CVAR_EDITING_LENGTH
void UI_TextEntryNodeFocus(uiNode_t *node, const uiCallContext_t *context)
force edition of a textentry node
static void UI_TextEntryNodeValidateEdition(uiNode_t *node)
callback from the keyboard
static const char CURSOR_OFF
static cvar_t * editedCvar
static const char CURSOR_ON
static void UI_TextEntryNodeAbortEdition(uiNode_t *node)
callback from the keyboard
static char cvarValueBackup[MAX_CVAR_EDITING_LENGTH]
void UI_RegisterTextEntryNode(uiBehaviour_t *behaviour)
void UI_TextEntry_SetBackgroundByName(uiNode_t *node, const char *name)
set background sprite
#define UI_EXTRADATA(NODE, TYPE)
const char * UI_GetReferenceString(const uiNode_t *const node, const char *ref)
int UI_DrawStringInBox(const char *fontID, align_t align, int x, int y, int width, int height, const char *text, longlines_t method)
draw a line into a bounding box
void UI_DrawSpriteInBox(bool flip, const uiSprite_t *sprite, uiSpriteStatus_t status, int posX, int posY, int sizeX, int sizeY)
uiSprite_t * UI_GetSpriteByName(const char *name)
Return an sprite by is name.
int UTF8_delete_char_at(char *s, int pos)
Delete a whole (possibly multibyte) character from a string.
int UTF8_insert_char_at(char *s, int n, int pos, int c)
Insert a (possibly multibyte) UTF-8 character into a string.
size_t UTF8_strlen(const char *str)
Count the number of character (not the number of bytes) of a zero termination string.
char * UTF8_strncpyz(char *dest, const char *src, size_t limit)
UTF8 capable string copy function.
int UTF8_encoded_len(int c)
#define Vector4Set(v, r, g, b, a)