ui_node_item.c
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "../ui_nodes.h"
00028 #include "../ui_parse.h"
00029 #include "ui_node_model.h"
00030 #include "ui_node_item.h"
00031 #include "ui_node_container.h"
00032 #include "ui_node_abstractnode.h"
00033
00034 #include "../../client.h"
00035 #include "../../cl_game.h"
00036 #include "../../renderer/r_draw.h"
00037
00038 #define EXTRADATA(node) UI_EXTRADATA(node, modelExtraData_t)
00039
00043 static void UI_ItemNodeDraw (uiNode_t *node)
00044 {
00045 const objDef_t *od;
00046 const char* ref = UI_GetReferenceString(node, EXTRADATA(node).model);
00047 vec2_t pos;
00048
00049 if (!ref || ref[0] == '\0')
00050 return;
00051
00052 UI_GetNodeAbsPos(node, pos);
00053 R_CleanupDepthBuffer(pos[0], pos[1], node->size[0], node->size[1]);
00054
00055 od = INVSH_GetItemByIDSilent(ref);
00056 if (od) {
00057 item_t item = {1, NULL, NULL, 0, 0};
00058 const vec4_t color = {1, 1, 1, 1};
00059 vec3_t pos;
00060 item.t = INVSH_GetItemByIDX(od->idx);
00061
00062 if (EXTRADATA(node).containerLike || INV_IsArmour(item.t)) {
00063
00064
00065 UI_GetNodeAbsPos(node, pos);
00066 pos[0] += node->size[0] / 2.0;
00067 pos[1] += node->size[1] / 2.0;
00068 pos[2] = 0;
00070 UI_DrawItem(node, pos, &item, -1, -1, EXTRADATA(node).scale, color);
00071 } else {
00072 UI_DrawModelNode(node, GAME_GetModelForItem(item.t, NULL));
00073 }
00074 } else {
00075 GAME_DisplayItemInfo(node, ref);
00076 }
00077 }
00078
00080 static const value_t properties[] = {
00081
00082 {"containerlike", V_BOOL, UI_EXTRADATA_OFFSETOF(modelExtraData_t, containerLike), MEMBER_SIZEOF(modelExtraData_t, containerLike)},
00083
00084 {NULL, V_NULL, 0, 0}
00085 };
00086
00087 void UI_RegisterItemNode (uiBehaviour_t *behaviour)
00088 {
00089 behaviour->name = "item";
00090 behaviour->properties = properties;
00091 behaviour->extends = "model";
00092 behaviour->draw = UI_ItemNodeDraw;
00093 }