26 #include "../../client.h"
27 #include "../ui_main.h"
28 #include "../ui_data.h"
29 #include "../ui_windows.h"
30 #include "../ui_nodes.h"
31 #include "../ui_behaviour.h"
32 #include "../ui_actions.h"
33 #include "../ui_render.h"
34 #include "../ui_parse.h"
35 #include "../ui_lua.h"
41 #include "../../cl_video.h"
42 #include "../../renderer/r_image.h"
43 #include "../../renderer/r_model.h"
45 #include "../../../common/scripts_lua.h"
47 #define EXTRADATA(node) UI_EXTRADATA(node, abstractScrollableExtraData_t)
51 #define IMAGE_WIDTH 64
82 while (stageIndex-- > 0) {
84 materialStage = materialStage->
next;
105 if (strstr(image->
name,
"tex_common"))
123 if (imagesPerLine > 0 && imagesPerColumn > 0) {
124 const int pos = reset ? 0 : -1;
125 setScrollY(node, pos, imagesPerColumn, imageCount / imagesPerLine);
141 if (imagesPerLine <= 0)
159 if (strstr(image->
name,
"tex_common"))
177 if (
i == node->
num) {
210 if (columnRequested >= imagesPerLine || lineRequested >= imagesPerColumn)
226 if (strstr(image->
name,
"tex_common"))
231 if (cnt / imagesPerLine <
EXTRADATA(node).scrollY.viewPos) {
236 if (cntView % imagesPerLine == columnRequested && cntView / imagesPerLine == lineRequested)
240 if (cntView / imagesPerLine > lineRequested)
286 if (stageType[0] ==
'\0')
287 stageType =
"stretch";
293 char stageName[
MAX_VAR] =
"stage ";
294 if (stage == materialStage) {
319 if (!strncmp(md->
name, stageName, strlen(md->
name)))
338 if (node->
num !=
id) {
367 bool down = deltaY > 0;
368 const int diff = (
down) ? 1 : -1;
379 Com_Printf(
"Material editor is only usable in battlescape mode\n");
431 const char* var, *value;
435 Com_Printf(
"Usage: %s <image index> <stage index> <variable> <value>\n",
Cmd_Argv(0));
441 Com_Printf(
"Given image index (%i) is out of bounds\n",
id);
451 if (stageType == -1) {
454 Com_Printf(
"Could not find material variable for '%s'\n", var);
464 Com_Printf(
"Could not find material stage variable for '%s'\n", var);
470 Com_Printf(
"Given stage index (%i) is out of bounds\n", stageID);
477 stage->
flags |= stageType;
505 Com_Printf(
"Given image index (%i) is out of bounds\n",
id);
513 Com_Printf(
"Given stage index (%i) is out of bounds\n", stageID);
533 Com_Printf(
"Given image index (%i) is out of bounds\n",
id);
541 Com_Printf(
"Given stage index (%i) is out of bounds\n", stageID);
567 Com_Printf(
"Given image index (%i) is out of bounds\n",
id);
590 behaviour->
name =
"material_editor";
591 behaviour->
extends =
"abstractscrollable";
static void UI_MaterialEditorSelectStage_f(void)
const char * Cmd_Argv(int arg)
Returns a given argument.
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
Material editor related header.
void onWindowOpened(uiNode_t *node, linkedList_t *params) override
Called when we push a window with this node.
void UI_RegisterLinkedListText(int dataId, linkedList_t *text)
share a linked list of text with a data id
struct materialDescription_s materialDescription_t
struct uiAction_s * onChange
static const vec3_t scale
static const value_t materialStageValues[]
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
void UI_RegisterMaterialEditorNode(uiBehaviour_t *behaviour)
void Com_Printf(const char *const fmt,...)
void R_ModReloadSurfacesArrays(void)
static void UI_MaterialEditorStart_f(void)
static void UI_MaterialEditorNewStage_f(void)
image_t * R_GetImageAtIndex(int i)
Returns an image pointer from the r_images linked list, as if r_images would be a plain contiguous ar...
void LIST_AddString(linkedList_t **listDest, const char *data)
Adds an string to a new or to an already existing linked list. The string is copied here...
void updateView(uiNode_t *node, bool reset)
Update the scrollable view.
static void UI_MaterialEditorStagesToName(const materialStage_t *stage, char *buf, size_t size)
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
SharedPtr< uiNode > UINodePtr
static const value_t materialValues[]
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_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
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...
resultStatus_t Com_ParseValue(void *base, const char *token, valueTypes_t type, int ofs, size_t size, size_t *writtenBytes)
Parse a value from a string.
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
static void UI_MaterialEditorRemoveStage_f(void)
void draw(uiNode_t *node) override
const value_t * UI_FindPropertyByName(const value_t *propertyList, const char *name)
Find a value_t by name into a array of value_t.
static materialStage_t * UI_MaterialEditorGetStage(material_t *material, int stageIndex)
static const materialDescription_t materialDescriptions[]
static int UI_MaterialEditorNameToStage(const char *stageName)
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
static int UI_MaterialEditorNodeGetImageAtPosition(uiNode_t *node, int x, int y)
Return index of the image (r_images[i]) else nullptr.
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
void UI_PopWindow(bool all)
Pops a window from the window stack.
static void UI_MaterialEditorUpdate(image_t *image, materialStage_t *materialStage)
memPool_t * vid_imagePool
void UI_DrawRect(int x, int y, int w, int h, const vec4_t color, float lineWidth, int pattern)
struct image_s * normalmap
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
const char * Cvar_GetString(const char *varName)
Returns the value of cvar as string.
void onMouseDown(uiNode_t *node, int x, int y, int button) override
#define Mem_PoolAllocType(type, pool)
static void UI_MaterialEditorChangeValue_f(void)
static int UI_MaterialEditorNodeGetImageCount(uiNode_t *node)
return the number of images we can display
struct materialStage_s * next
void UI_ExecuteConfunc(const char *fmt,...)
Executes confunc - just to identify those confuncs in the code - in this frame.
bool onScroll(uiNode_t *node, int deltaX, int deltaY) override
Called when the user wheel the mouse over the node.