Material editor related code. More...
#include "../../client.h"
#include "../ui_main.h"
#include "../ui_data.h"
#include "../ui_windows.h"
#include "../ui_nodes.h"
#include "../ui_actions.h"
#include "../ui_render.h"
#include "../ui_parse.h"
#include "ui_node_abstractnode.h"
#include "ui_node_abstractscrollable.h"
#include "../../cl_video.h"
#include "../../renderer/r_image.h"
#include "../../renderer/r_draw.h"
#include "../../renderer/r_model.h"
#include "ui_node_material_editor.h"
Go to the source code of this file.
Data Structures | |
struct | materialDescription_s |
Defines | |
#define | EXTRADATA(node) UI_EXTRADATA(node, abstractScrollableExtraData_t) |
#define | IMAGE_WIDTH 64 |
#define | MARGIN 3 |
Typedefs | |
typedef struct materialDescription_s | materialDescription_t |
Functions | |
static materialStage_t * | UI_MaterialEditorGetStage (material_t *material, int stageIndex) |
static int | UI_MaterialEditorNodeGetImageCount (uiNode_t *node) |
return the number of images we can display | |
static void | UI_MaterialEditorNodeUpdateView (uiNode_t *node, qboolean reset) |
Update the scrollable view. | |
static void | UI_MaterialEditorNodeDraw (uiNode_t *node) |
static int | UI_MaterialEditorNodeGetImageAtPosition (uiNode_t *node, int x, int y) |
Return index of the image (r_images[i]) else NULL. | |
static void | UI_MaterialEditorStagesToName (const materialStage_t *stage, char *buf, size_t size) |
static void | UI_MaterialEditorUpdate (image_t *image, materialStage_t *materialStage) |
static int | UI_MaterialEditorNameToStage (const char *stageName) |
static void | UI_MaterialEditorMouseDown (uiNode_t *node, int x, int y, int button) |
static void | UI_MaterialEditorNodeInit (uiNode_t *node) |
Called when we push a window with this node. | |
static void | UI_MaterialEditorNodeWheel (uiNode_t *node, qboolean down, int x, int y) |
Called when the user wheel the mouse over the node. | |
static void | UI_MaterialEditorStart_f (void) |
static void | UI_MaterialEditorChangeValue_f (void) |
static void | UI_MaterialEditorSelectStage_f (void) |
static void | UI_MaterialEditorRemoveStage_f (void) |
static void | UI_MaterialEditorNewStage_f (void) |
void | UI_RegisterMaterialEditorNode (uiBehaviour_t *behaviour) |
Variables | |
static const materialDescription_t | materialDescriptions [] |
static const value_t | materialValues [] |
static const value_t | materialStageValues [] |
Material editor related code.
Definition in file ui_node_material_editor.c.
#define EXTRADATA | ( | node | ) | UI_EXTRADATA(node, abstractScrollableExtraData_t) |
Definition at line 42 of file ui_node_material_editor.c.
#define IMAGE_WIDTH 64 |
Definition at line 46 of file ui_node_material_editor.c.
Referenced by UI_MaterialEditorNodeDraw(), UI_MaterialEditorNodeGetImageAtPosition(), and UI_MaterialEditorNodeUpdateView().
#define MARGIN 3 |
Referenced by UI_MaterialEditorNodeDraw().
typedef struct materialDescription_s materialDescription_t |
static void UI_MaterialEditorChangeValue_f | ( | void | ) | [static] |
Definition at line 421 of file ui_node_material_editor.c.
References Cmd_Argc(), Cmd_Argv(), Com_ParseValue(), Com_Printf(), materialStage_s::flags, id, image_s::material, material_s::num_stages, value_s::ofs, r_images, R_ModReloadSurfacesArrays(), r_numImages, value_s::size, STAGE_DIRTMAP, STAGE_ENVMAP, STAGE_LIGHTING, STAGE_RENDER, STAGE_TAPE, STAGE_TERRAIN, STAGE_TEXTURE, value_s::type, UI_FindPropertyByName(), UI_MaterialEditorGetStage(), and UI_MaterialEditorNameToStage().
Referenced by UI_RegisterMaterialEditorNode().
static materialStage_t* UI_MaterialEditorGetStage | ( | material_t * | material, | |
int | stageIndex | |||
) | [static] |
Definition at line 74 of file ui_node_material_editor.c.
References materialStage_s::next, and material_s::stages.
Referenced by UI_MaterialEditorChangeValue_f(), UI_MaterialEditorRemoveStage_f(), UI_MaterialEditorSelectStage_f(), and UI_MaterialEditorUpdate().
static void UI_MaterialEditorMouseDown | ( | uiNode_t * | node, | |
int | x, | |||
int | y, | |||
int | button | |||
) | [static] |
Definition at line 327 of file ui_node_material_editor.c.
References id, K_MOUSE1, uiNode_s::num, uiNode_s::onChange, r_images, UI_ExecuteEventActions(), UI_MaterialEditorNodeGetImageAtPosition(), and UI_MaterialEditorUpdate().
Referenced by UI_RegisterMaterialEditorNode().
static int UI_MaterialEditorNameToStage | ( | const char * | stageName | ) | [static] |
Converts a stage name into the stage flag
stageName | The name to search the flag for |
Definition at line 315 of file ui_node_material_editor.c.
References materialDescription_s::name, and materialDescription_s::stageFlag.
Referenced by UI_MaterialEditorChangeValue_f().
static void UI_MaterialEditorNewStage_f | ( | void | ) | [static] |
Definition at line 555 of file ui_node_material_editor.c.
References Cmd_Argc(), Cmd_Argv(), Com_Printf(), id, m, image_s::material, Mem_PoolAlloc, materialStage_s::next, material_s::num_stages, r_images, r_numImages, material_s::stages, UI_MaterialEditorUpdate(), and vid_imagePool.
Referenced by UI_RegisterMaterialEditorNode().
static void UI_MaterialEditorNodeDraw | ( | uiNode_t * | node | ) | [static] |
node | The node to draw |
Definition at line 129 of file ui_node_material_editor.c.
References EXTRADATA, i, IMAGE_WIDTH, it_world, MARGIN, image_s::name, uiNode_s::num, uiNode_s::padding, pos, qfalse, R_DrawRect(), r_images, r_numImages, uiNode_s::selectedColor, uiNode_s::size, image_s::type, UI_AbstractScrollableNodeIsSizeChange(), UI_DrawNormImage(), UI_GetNodeAbsPos(), and UI_MaterialEditorNodeUpdateView().
Referenced by UI_RegisterMaterialEditorNode().
static int UI_MaterialEditorNodeGetImageAtPosition | ( | uiNode_t * | node, | |
int | x, | |||
int | y | |||
) | [static] |
Return index of the image (r_images[i]) else NULL.
Definition at line 190 of file ui_node_material_editor.c.
References EXTRADATA, i, IMAGE_WIDTH, it_world, image_s::name, uiNode_s::padding, pos, r_images, r_numImages, uiNode_s::size, image_s::type, UI_GetNodeAbsPos(), and UI_NodeAbsoluteToRelativePos().
Referenced by UI_MaterialEditorMouseDown().
static int UI_MaterialEditorNodeGetImageCount | ( | uiNode_t * | node | ) | [static] |
return the number of images we can display
Definition at line 89 of file ui_node_material_editor.c.
References i, it_world, image_s::name, r_images, r_numImages, and image_s::type.
Referenced by UI_MaterialEditorNodeUpdateView().
static void UI_MaterialEditorNodeInit | ( | uiNode_t * | node | ) | [static] |
Called when we push a window with this node.
Definition at line 353 of file ui_node_material_editor.c.
References uiNode_s::num, qtrue, and UI_MaterialEditorNodeUpdateView().
Referenced by UI_RegisterMaterialEditorNode().
Update the scrollable view.
Definition at line 112 of file ui_node_material_editor.c.
References IMAGE_WIDTH, uiNode_s::padding, pos, uiNode_s::size, UI_AbstractScrollableNodeSetY(), and UI_MaterialEditorNodeGetImageCount().
Referenced by UI_MaterialEditorNodeDraw(), and UI_MaterialEditorNodeInit().
Called when the user wheel the mouse over the node.
Definition at line 362 of file ui_node_material_editor.c.
References UI_AbstractScrollableNodeScrollY().
Referenced by UI_RegisterMaterialEditorNode().
static void UI_MaterialEditorRemoveStage_f | ( | void | ) | [static] |
Definition at line 515 of file ui_node_material_editor.c.
References Cmd_Argc(), Cmd_Argv(), Com_Printf(), id, image_s::material, Mem_Free, materialStage_s::next, material_s::num_stages, r_images, r_numImages, material_s::stages, UI_MaterialEditorGetStage(), and UI_MaterialEditorUpdate().
Referenced by UI_RegisterMaterialEditorNode().
static void UI_MaterialEditorSelectStage_f | ( | void | ) | [static] |
Definition at line 486 of file ui_node_material_editor.c.
References Cmd_Argc(), Cmd_Argv(), Com_Printf(), id, image_s::material, material_s::num_stages, r_images, r_numImages, UI_MaterialEditorGetStage(), and UI_MaterialEditorUpdate().
Referenced by UI_RegisterMaterialEditorNode().
static void UI_MaterialEditorStagesToName | ( | const materialStage_t * | stage, | |
char * | buf, | |||
size_t | size | |||
) | [static] |
Definition at line 250 of file ui_node_material_editor.c.
References materialStage_s::flags, materialDescription_s::name, Q_strcat(), materialDescription_s::stageFlag, and va().
Referenced by UI_MaterialEditorUpdate().
static void UI_MaterialEditorStart_f | ( | void | ) | [static] |
Definition at line 368 of file ui_node_material_editor.c.
References ca_active, cls, Com_Printf(), qfalse, client_static_s::state, and UI_PopWindow().
Referenced by UI_RegisterMaterialEditorNode().
static void UI_MaterialEditorUpdate | ( | image_t * | image, | |
materialStage_t * | materialStage | |||
) | [static] |
Updates the material editor node for a given image and a given material stage
image | The image to load into the material editor | |
materialStage | The material stage to display |
Definition at line 266 of file ui_node_material_editor.c.
References stretch_s::amp, material_s::bump, Cvar_GetString(), Cvar_Set(), stretch_s::damp, rotate_s::deg, pulse_s::dhz, stretch_s::dhz, scroll_s::ds, scroll_s::dt, material_s::hardness, pulse_s::hz, stretch_s::hz, rotate_s::hz, i, LIST_AddString(), image_s::material, MAX_VAR, image_s::name, image_s::normalmap, material_s::num_stages, material_s::parallax, materialStage_s::pulse, materialStage_s::rotate, scale_s::s, scroll_s::s, materialStage_s::scale, materialStage_s::scroll, material_s::specular, materialStage_s::stretch, scale_s::t, scroll_s::t, TEXT_MATERIAL_STAGES, UI_ExecuteConfunc(), UI_MaterialEditorGetStage(), UI_MaterialEditorStagesToName(), UI_RegisterLinkedListText(), and va().
Referenced by UI_MaterialEditorMouseDown(), UI_MaterialEditorNewStage_f(), UI_MaterialEditorRemoveStage_f(), and UI_MaterialEditorSelectStage_f().
void UI_RegisterMaterialEditorNode | ( | uiBehaviour_t * | behaviour | ) |
Definition at line 589 of file ui_node_material_editor.c.
References Cmd_AddCommand(), uiBehaviour_s::draw, uiBehaviour_s::extends, uiBehaviour_s::init, uiBehaviour_s::mouseDown, uiBehaviour_s::mouseWheel, uiBehaviour_s::name, UI_MaterialEditorChangeValue_f(), UI_MaterialEditorMouseDown(), UI_MaterialEditorNewStage_f(), UI_MaterialEditorNodeDraw(), UI_MaterialEditorNodeInit(), UI_MaterialEditorNodeWheel(), UI_MaterialEditorRemoveStage_f(), UI_MaterialEditorSelectStage_f(), and UI_MaterialEditorStart_f().
const materialDescription_t materialDescriptions[] [static] |
{ {"texture", STAGE_TEXTURE}, {"envmap", STAGE_ENVMAP}, {"blend", STAGE_BLEND}, {"color", STAGE_COLOR}, {"pulse", STAGE_PULSE}, {"stretch", STAGE_STRETCH}, {"rotate", STAGE_ROTATE}, {"scroll.s", STAGE_SCROLL_S}, {"scroll.t", STAGE_SCROLL_T}, {"scale.s", STAGE_SCALE_S}, {"scale.t", STAGE_SCALE_T}, {"terrain", STAGE_TERRAIN}, {"tape", STAGE_TAPE}, {"lightmap", STAGE_LIGHTMAP}, {"anim", STAGE_ANIM}, {"dirtmap", STAGE_DIRTMAP}, {NULL, 0} }
Definition at line 53 of file ui_node_material_editor.c.
const value_t materialStageValues[] [static] |
{ {"rotate.hz", V_FLOAT, offsetof(materialStage_t, rotate.deg), 0}, {"rotate.deg", V_FLOAT, offsetof(materialStage_t, rotate.hz), 0}, {"stretch.hz", V_FLOAT, offsetof(materialStage_t, stretch.hz), 0}, {"stretch.dhz", V_FLOAT, offsetof(materialStage_t, stretch.dhz), 0}, {"stretch.amp", V_FLOAT, offsetof(materialStage_t, stretch.amp), 0}, {"stretch.damp", V_FLOAT, offsetof(materialStage_t, stretch.damp), 0}, {"pulse.hz", V_FLOAT, offsetof(materialStage_t, pulse.hz), 0}, {"pulse.dhz", V_FLOAT, offsetof(materialStage_t, pulse.dhz), 0}, {"scroll.s", V_FLOAT, offsetof(materialStage_t, scroll.s), 0}, {"scroll.t", V_FLOAT, offsetof(materialStage_t, scroll.t), 0}, {"scroll.ds", V_FLOAT, offsetof(materialStage_t, scroll.ds), 0}, {"scroll.dt", V_FLOAT, offsetof(materialStage_t, scroll.dt), 0}, {"scale.s", V_FLOAT, offsetof(materialStage_t, scale.s), 0}, {"scale.t", V_FLOAT, offsetof(materialStage_t, scale.t), 0}, {"terrain.floor", V_FLOAT, offsetof(materialStage_t, terrain.floor), 0}, {"terrain.ceil", V_FLOAT, offsetof(materialStage_t, terrain.ceil), 0}, {"tape.floor", V_FLOAT, offsetof(materialStage_t, tape.floor), 0}, {"tape.ceil", V_FLOAT, offsetof(materialStage_t, tape.ceil), 0}, {"tape.center", V_FLOAT, offsetof(materialStage_t, tape.center), 0}, {"anim.frames", V_INT, offsetof(materialStage_t, anim.num_frames), 0}, {"anim.dframe", V_INT, offsetof(materialStage_t, anim.dframe), 0}, {"anim.dtime", V_FLOAT, offsetof(materialStage_t, anim.dtime), 0}, {"anim.fps", V_FLOAT, offsetof(materialStage_t, anim.fps), 0}, {"dirt.intensity", V_FLOAT, offsetof(materialStage_t, dirt.intensity), 0}, {"blend.src", V_INT, offsetof(materialStage_t, blend.src), 0}, {"blend.dest", V_INT, offsetof(materialStage_t, blend.dest), 0}, {NULL, V_NULL, 0, 0}, }
Definition at line 390 of file ui_node_material_editor.c.
const value_t materialValues[] [static] |
{ {"bump", V_FLOAT, offsetof(material_t, bump), 0}, {"parallax", V_FLOAT, offsetof(material_t, parallax), 0}, {"specular", V_FLOAT, offsetof(material_t, specular), 0}, {"hardness", V_FLOAT, offsetof(material_t, hardness), 0}, {NULL, V_NULL, 0, 0}, }
Definition at line 380 of file ui_node_material_editor.c.