30 #include "../ui_main.h"
31 #include "../ui_internal.h"
32 #include "../ui_nodes.h"
33 #include "../ui_parse.h"
34 #include "../ui_input.h"
35 #include "../ui_render.h"
36 #include "../ui_internal.h"
40 #include "../../client.h"
41 #include "../../renderer/r_draw.h"
42 #include "../../renderer/r_mesh.h"
43 #include "../../renderer/r_mesh_anim.h"
44 #include "../../renderer/r_model.h"
46 #include "../../../common/scripts_lua.h"
48 #define EXTRADATA_TYPE modelExtraData_t
49 #define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
51 #define ROTATE_SPEED 0.5
52 #define MAX_OLDREFVALUE MAX_VAR
77 const char* need = m->
next !=
nullptr ? m->
next->
id :
"none";
106 Com_Printf(
"UI_ModelNodeLoaded: '%s' use a tag but is not a submodel. Tag removed.\n",
UI_GetPath(node));
110 if (
EXTRADATA(node).oldRefValue ==
nullptr)
115 Com_Printf(
"UI_ModelNodeLoaded: Please set a pos and size to the node '%s'. Note: 'origin' is a relative value to the center of the node\n",
UI_GetPath(node));
142 nodeorigin[2] =
EXTRADATA(node).origin[2];
156 bool autoScaleComputed =
false;
166 assert(model->
model);
197 Com_Printf(
"UI Model: Could not get the model '%s'\n", parentModel->
model);
218 if (!autoScaleComputed)
219 Sys_Error(
"Wrong order of model nodes - the tag and parent model node must be after the base model node");
220 pmi.
scale = autoScale;
241 if (!autoScaleComputed) {
246 autoScaleComputed =
true;
248 mi->
scale = autoScale;
265 if (anim ==
nullptr || !
Q_streq(anim, ref))
294 if (!source || source[0] ==
'\0')
304 Com_Printf(
"Could not find model '%s'\n", source);
318 nodeorigin[2] =
EXTRADATA(node).origin[2];
372 EXTRADATA(node).animationState =
nullptr;
378 Com_Error(
ERR_DROP,
"Model %s should have animState_t for animation %s - but doesn't\n", mi.
name, ref);
385 if (anim && !
Q_streq(anim, ref))
404 const char* childRef;
427 childSource[0] =
'\0';
429 Q_strncpyz(childSource, childRef,
sizeof(childSource));
431 mi.
name = childSource;
452 float* rotateAngles =
EXTRADATA(node).angles;
459 rotateAngles[
YAW] -= floor(rotateAngles[
YAW] / 360.0) * 360.0;
461 if (rotateAngles[
ROLL] < 0.0)
462 rotateAngles[
ROLL] = 0.0;
463 else if (rotateAngles[
ROLL] > 180.0)
464 rotateAngles[
ROLL] = 180.0;
530 localBehaviour = behaviour;
531 behaviour->
name =
"model";
bool Q_strnull(const char *string)
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
#define VectorCopy(src, dest)
static void UI_DrawModelNodeWithUIModel(uiNode_t *node, const char *source, modelInfo_t *mi, uiModel_t *model)
Draw a model using UI model definition.
void Sys_Error(const char *error,...)
void UI_PopClipRect(void)
#define VectorSet(v, x, y, z)
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
bool UI_NodeInstanceOf(const uiNode_t *node, const char *behaviourName)
Check the node inheritance.
void VectorMA(const vec3_t veca, const float scale, const vec3_t vecb, vec3_t outVector)
Sets vector_out (vc) to vevtor1 (va) + scale * vector2 (vb)
void onMouseDown(uiNode_t *node, int x, int y, int button) override
bool UI_CheckVisibility(uiNode_t *node)
Check the if conditions for a given node.
static const vec3_t scale
void draw(uiNode_t *node) override
void UI_DrawModelNode(uiNode_t *node, const char *source)
uiBehaviour_t * behaviour
void clone(uiNode_t const *source, uiNode_t *clone) override
Call to update a cloned node.
void Com_Printf(const char *const fmt,...)
void onMouseUp(uiNode_t *node, int x, int y, int button) override
uiModel_t models[UI_MAX_MODELS]
void UI_Model_SetAnimationSource(uiNode_t *node, const char *animName)
virtual void clone(uiNode_t const *source, uiNode_t *clone)
void UI_FreeStringProperty(void *pointer)
Free a string property if it is allocated into ui_dynStringPool.
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
memPool_t * cl_genericPool
void R_AnimChange(animState_t *as, const model_t *mod, const char *name)
Changes the animation for md2 models.
void R_DrawModelDirect(modelInfo_t *mi, modelInfo_t *pmi, const char *tagname)
Draws a model in 2d mode (for rendering model data from the ui)
void Com_Error(int code, const char *fmt,...)
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
#define Vector4Set(v, r, g, b, a)
memPool_t * ui_dynStringPool
void UI_RegisterModelNode(uiBehaviour_t *behaviour)
SharedPtr< uiNode > UINodePtr
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
#define UI_EXTRADATA(NODE, TYPE)
static void UI_InitModelInfoView(uiNode_t *node, modelInfo_t *mi, uiModel_t *model)
Set the Model info view (angle, origin, scale) according to the node definition.
const char * UI_GetReferenceString(const uiNode_t *const node, const char *ref)
model_t * R_FindModel(const char *name)
Tries to load a model.
void R_AnimRun(animState_t *as, const model_t *mod, int msec)
Run the animation of the given model.
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 R_ModelAutoScale(const vec2_t boxSize, modelInfo_t *mi, vec3_t scale, vec3_t center)
Compute scale and center for a model info data structure.
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
uiModel_t * UI_GetUIModel(const char *modelName)
Returns pointer to UI model.
#define Mem_PoolAllocTypeN(type, n, pool)
void doLayout(uiNode_t *node) override
Call to update the node layout. This common code revalidates the node tree.
void UI_Model_SetSkinSource(uiNode_t *node, const char *skinName)
void initNodeDynamic(uiNode_t *node) override
node behaviour, how a node work
const char * R_AnimGetName(const animState_t *as, const model_t *mod)
Get the current running animation for a model.
void UI_Model_SetModelSource(uiNode_t *node, const char *modelName)
void deleteNode(uiNode_t *node) override
void onLoading(uiNode_t *node) override
Called before loading. Used to set default attribute values.
void UI_PushClipRect(int x, int y, int width, int height)
virtual void deleteNode(uiNode_t *node)
static const uiBehaviour_t * localBehaviour
static void UI_ListUIModels_f(void)
#define Mem_PoolStrDup(in, pool, tagNum)
Model that have more than one part (top and down part of an aircraft)
void UI_Model_SetTagSource(uiNode_t *node, const char *tagName)
#define Mem_PoolAllocType(type, pool)
virtual void doLayout(uiNode_t *node)
Call to update the node layout. This common code revalidates the node tree.
void onLoaded(uiNode_t *node) override
char * UI_AllocStaticString(const char *string, int size)
Allocate a string into the UI static memory.
#define Vector4Copy(src, dest)
void R_CleanupDepthBuffer(int x, int y, int width, int height)
"Clean up" the depth buffer into a rect
void UI_GetNodeScreenPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node in the screen. Screen position is not used for the node rende...