static void UI_MaterialEditorRemoveStage_f (void) { image_t* image; int id, stageID; if (Cmd_Argc() < 3) { Com_Printf("Usage: %s <image index> <stage index>\n", Cmd_Argv(0)); return; } id = atoi(Cmd_Argv(1)); if (id < 0 || id >= r_numImages) { Com_Printf("Given image index (%i) is out of bounds\n", id); return; } image = R_GetImageAtIndex(id); stageID = atoi(Cmd_Argv(2)); if (stageID < 0 || stageID >= image->material.num_stages) { Com_Printf("Given stage index (%i) is out of bounds\n", stageID); return; } materialStage_t** const anchor = stageID == 0 ? &image->material.stages : &UI_MaterialEditorGetStage(&image->material, stageID - 1)->next; materialStage_t* const s = *anchor; *anchor = s->next; Mem_Free(s); image->material.num_stages--; UI_MaterialEditorUpdate(image, nullptr); }
static void UI_MaterialEditorSelectStage_f (void) { image_t* image; int id, stageID; materialStage_t* materialStage; if (Cmd_Argc() < 3) { Com_Printf("Usage: %s <image index> <stage index>\n", Cmd_Argv(0)); return; } id = atoi(Cmd_Argv(1)); if (id < 0 || id >= r_numImages) { Com_Printf("Given image index (%i) is out of bounds\n", id); return; } image = R_GetImageAtIndex(id); stageID = atoi(Cmd_Argv(2)); if (stageID < 0 || stageID >= image->material.num_stages) { Com_Printf("Given stage index (%i) is out of bounds\n", stageID); return; } materialStage = UI_MaterialEditorGetStage(&image->material, stageID); UI_MaterialEditorUpdate(image, materialStage); }
/** * Updates the material editor node for a given image and a given material stage * @param image The image to load into the material editor * @param materialStage The material stage to display */ static void UI_MaterialEditorUpdate (image_t *image, materialStage_t *materialStage) { linkedList_t *materialStagesList = NULL; if (image->normalmap == NULL) UI_ExecuteConfunc("hideshaders true 0 0 0 0"); else UI_ExecuteConfunc("hideshaders false %f %f %f %f", image->material.bump, image->material.hardness, image->material.parallax, image->material.specular); if (image->normalmap == NULL) Cvar_Set("me_imagename", image->name); else Cvar_Set("me_imagename", va("%s (nm)", image->name)); if (!image->material.num_stages) { UI_ExecuteConfunc("hidestages true"); } else { int i; if (materialStage) { const char *stageType = Cvar_GetString("me_stagetype"); if (stageType[0] == '\0') stageType = "stretch"; UI_ExecuteConfunc("hidestages false %s", stageType); } else Cvar_Set("me_stage_id", "-1"); for (i = 0; i < image->material.num_stages; i++) { const materialStage_t *stage = UI_MaterialEditorGetStage(&image->material, i); char stageName[MAX_VAR] = "stage "; if (stage == materialStage) { UI_ExecuteConfunc("updatestagevalues %f %f %f %f %f %f %f %f %f %f %f %f %f %f", stage->rotate.hz, stage->rotate.deg, stage->stretch.hz, stage->stretch.dhz, stage->stretch.amp, stage->stretch.damp, stage->pulse.hz, stage->pulse.dhz, stage->scroll.ds, stage->scroll.dt, stage->scroll.s, stage->scroll.t, stage->scale.s, stage->scale.t); } UI_MaterialEditorStagesToName(stage, stageName, sizeof(stageName) - 1); LIST_AddString(&materialStagesList, stageName); } } UI_RegisterLinkedListText(TEXT_MATERIAL_STAGES, materialStagesList); }
static void UI_MaterialEditorRemoveStage_f (void) { image_t *image; int id, stageID; if (Cmd_Argc() < 3) { Com_Printf("Usage: %s <image index> <stage index>\n", Cmd_Argv(0)); return; } id = atoi(Cmd_Argv(1)); if (id < 0 || id >= r_numImages) { Com_Printf("Given image index (%i) is out of bounds\n", id); return; } image = R_GetImageAtIndex(id); stageID = atoi(Cmd_Argv(2)); if (stageID < 0 || stageID >= image->material.num_stages) { Com_Printf("Given stage index (%i) is out of bounds\n", stageID); return; } if (stageID == 0) { materialStage_t *s = image->material.stages; image->material.stages = s->next; Mem_Free(s); } else { materialStage_t *sParent = UI_MaterialEditorGetStage(&image->material, stageID - 1); materialStage_t *s = sParent->next; sParent->next = s->next; Mem_Free(s); } image->material.num_stages--; UI_MaterialEditorUpdate(image, NULL); }
static void UI_MaterialEditorChangeValue_f (void) { image_t* image; int id, stageType; const char* var, *value; size_t bytes; if (Cmd_Argc() < 5) { Com_Printf("Usage: %s <image index> <stage index> <variable> <value>\n", Cmd_Argv(0)); return; } id = atoi(Cmd_Argv(1)); if (id < 0 || id >= r_numImages) { Com_Printf("Given image index (%i) is out of bounds\n", id); return; } var = Cmd_Argv(3); value = Cmd_Argv(4); image = R_GetImageAtIndex(id); stageType = UI_MaterialEditorNameToStage(var); if (stageType == -1) { const value_t* val = UI_FindPropertyByName(materialValues, var); if (!val) { Com_Printf("Could not find material variable for '%s'\n", var); return; } Com_ParseValue(&image->material, value, val->type, val->ofs, val->size, &bytes); } else { materialStage_t* stage; int stageID; const value_t* val = UI_FindPropertyByName(materialStageValues, var); if (!val) { Com_Printf("Could not find material stage variable for '%s'\n", var); return; } stageID = atoi(Cmd_Argv(2)); if (stageID < 0 || stageID >= image->material.num_stages) { Com_Printf("Given stage index (%i) is out of bounds\n", stageID); return; } stage = UI_MaterialEditorGetStage(&image->material, stageID); assert(stage); stage->flags |= stageType; Com_ParseValue(stage, value, val->type, val->ofs, val->size, &bytes); /* a texture or envmap means render it */ if (stage->flags & (STAGE_TEXTURE | STAGE_ENVMAP)) stage->flags |= STAGE_RENDER; if (stage->flags & (STAGE_TAPE | STAGE_TERRAIN | STAGE_DIRTMAP)) stage->flags |= STAGE_LIGHTING; } R_ModReloadSurfacesArrays(); }