Small update. Just because.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4405 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2013-06-26 03:34:39 +00:00
parent 138eecf7d7
commit 56131015c6
8 changed files with 387 additions and 121 deletions

View File

@ -668,7 +668,7 @@ int (vector *curmousepos, vector mousediff) editor_spline_overlay =
local spline_t *s;
local int ri;
local string str;
float min, sec;
local float minv, sec;
if (splinefile < 0)
spline_init();
@ -691,7 +691,7 @@ int (vector *curmousepos, vector mousediff) editor_spline_overlay =
drawrawstring(v, str, '8 8 0', '1 0 0', 1);
else
drawrawstring(v, str, '8 8 0', '1 1 1', 1);
ri += strlen(str) + 1i;
ri += (int)(strlen(str) + 1);
v_x += 4 + strlen(str) * 8;
menu->flags = MF_DS_VALUE;
@ -704,8 +704,8 @@ int (vector *curmousepos, vector mousediff) editor_spline_overlay =
v_y += 8;
sec = time;
min = floor(sec/60);
sec -= min*60;
minv = floor(sec/60);
sec -= minv*60;
drawrawstring(v, sprintf("time: %g:%02.0f", min, sec), '8 8 0', '1 1 1', 1);
submenu_position = pos + '0 8';

View File

@ -6,8 +6,13 @@ enum
MODE_SPLINEEDIT=2,
MODE_TERRAINEDIT=3,
MODE_PARTICLEEDIT=4,
MODE_ENTSEDIT=5,
MODE_COUNT=5
};
string editornames[] = {"LIGHTS", "SPLINES", "TERRAIN", "PARTICLES", "ENTITIES"};
float autocvar_ca_show;
var float autocvar_ca_editormode = MODE_LIGHTEDIT;
string autocvar_ca_colourtint;
@ -29,6 +34,7 @@ void() wrap_renderscene =
{
local int retval;
vector col;
local float i;
vidsize = getproperty(VF_SCREENVSIZE);
@ -100,6 +106,8 @@ void() wrap_renderscene =
if (autocvar_ca_editormode == MODE_LIGHTEDIT)
editor_lights_add();
else if (autocvar_ca_editormode == MODE_ENTSEDIT)
editor_ents_add();
else if (autocvar_ca_editormode == MODE_SPLINEEDIT)
editor_spline_add();
else if (autocvar_ca_editormode == MODE_TERRAINEDIT)
@ -107,39 +115,17 @@ void() wrap_renderscene =
renderscene();
if (autocvar_ca_editormode == MODE_LIGHTEDIT)
col = '1 0 0';
else if (curmousepos_y < 8 && curmousepos_x >= 64*(MODE_LIGHTEDIT-1) && curmousepos_x < 64*MODE_LIGHTEDIT)
col = '0 0 1';
else
col = '1 1 1';
drawrawstring('64 0 0'*(MODE_LIGHTEDIT-1), "LIGHTS", '8 8 0', col, 1);
if (autocvar_ca_editormode == MODE_SPLINEEDIT)
col = '1 0 0';
else if (curmousepos_y < 8 && curmousepos_x >= 64*(MODE_SPLINEEDIT-1) && curmousepos_x < 64*MODE_SPLINEEDIT)
col = '0 0 1';
else
col = '1 1 1';
drawrawstring('64 0 0'*(MODE_SPLINEEDIT-1), "SPLINES", '8 8 0', col, 1);
if (autocvar_ca_editormode == MODE_PARTICLEEDIT)
col = '1 0 0';
else if (curmousepos_y < 8 && curmousepos_x >= 64*(MODE_PARTICLEEDIT-1) && curmousepos_x < 64*MODE_PARTICLEEDIT)
col = '0 0 1';
else
col = '1 1 1';
drawrawstring('64 0 0'*(MODE_PARTICLEEDIT-1), "PARTICLES", '8 8 0', col, 1);
if (autocvar_ca_editormode == MODE_TERRAINEDIT)
col = '1 0 0';
else if (curmousepos_y < 8 && curmousepos_x >= 64*(MODE_TERRAINEDIT-1) && curmousepos_x < 64*MODE_TERRAINEDIT)
col = '0 0 1';
else
col = '1 1 1';
drawrawstring('64 0 0'*(MODE_TERRAINEDIT-1), "TERRAIN", '8 8 0', col, 1);
for (i = 0; i < MODE_COUNT; i++)
{
if (autocvar_ca_editormode == i+1)
col = '1 0 0';
else if (curmousepos_y < 8 && curmousepos_x >= 64*(i) && curmousepos_x < 64*(i+1))
col = '0 0 1';
else
col = '1 1 1';
drawrawstring('64 0 0'*i, editornames[i], '8 8 0', col, 1);
}
if (autocvar_ca_editormode == MODE_LIGHTEDIT)
editor_lights_overlay(curmousepos);
@ -153,6 +139,8 @@ void() wrap_renderscene =
editor_particles_overlay(curmousepos);
else if (autocvar_ca_editormode == MODE_TERRAINEDIT)
editor_terrain_overlay(curmousepos);
else if (autocvar_ca_editormode == MODE_ENTSEDIT)
editor_ents_overlay(curmousepos);
drawcharacter(curmousepos - '4 4', '+', '8 8', '1 1 1', 1);
};
@ -257,7 +245,19 @@ float (float event, float parama, float paramb) wrap_InputEvent =
if (orig_input_event)
return orig_input_event(event, parama, paramb);
return FALSE;
}
};
void(float mask) wrap_addentities =
{
if (autocvar_ca_show)
{
mask = mask - (mask & MASK_VIEWMODEL);
if (autocvar_ca_editormode == MODE_ENTSEDIT)
mask = 0;
}
addentities(mask);
};
@ -267,7 +267,7 @@ void(float width, float height, float do2d) CSQC_UpdateView =
clearscene();
setproperty(VF_DRAWENGINESBAR, 1);
setproperty(VF_DRAWCROSSHAIR, 1);
addentities(intermission?MASK_ENGINE:(MASK_VIEWMODEL|MASK_ENGINE));
wrap_addentities(intermission?MASK_ENGINE:(MASK_VIEWMODEL|MASK_ENGINE));
wrap_renderscene();
};
@ -386,7 +386,7 @@ float(string txt, string info) CSQC_ConsoleLink =
*/
/*this is a fallback function, in case the main progs does not have one*/
float (float event, float parama, float paramb) CSQC_InputEvent =
float (float event, float parama, float paramb, float devid) CSQC_InputEvent =
{
return wrap_InputEvent(event, parama, paramb);
};
@ -399,12 +399,18 @@ void(float prevprogs) init =
{
/*its easy to wrap a builtin*/
externset(0, wrap_renderscene, "renderscene");
externset(0, wrap_addentities, "addentities");
/*wrap the parent's input event function*/
orig_input_event = externvalue(0, "CSQC_InputEvent");
externset(0, wrap_InputEvent, "CSQC_InputEvent");
}
csfixups();
localcmd(sprintf("alias rtlight_editor \"set ca_show 1; set ca_editormode %s\"\n", MODE_LIGHTEDIT));
localcmd(sprintf("alias camquake_editor \"set ca_show 1; set ca_editormode %s\"\n", MODE_SPLINEEDIT));
localcmd(sprintf("alias terrain_editor \"set ca_show 1; set ca_editormode %s\"\n", MODE_TERRAINEDIT));
localcmd(sprintf("alias r_part_editor \"set ca_show 1; set ca_editormode %s\"\n", MODE_PARTICLEEDIT));
localcmd(sprintf("alias entities_editor \"set ca_show 1; set ca_editormode %s\"\n", MODE_ENTSEDIT));
};
void() CSQC_Shutdown =

View File

@ -6,6 +6,7 @@ csfixups.qc
editor_lights.qc
editor_terrain.qc
editor_ents.qc
textfield.qc
editor_particles.qc
menu.qc

View File

@ -0,0 +1,168 @@
#define ENTS_NYI
#ifdef ENTS_NYI
void() editor_ents_add =
{
};
void(vector mousepos) editor_ents_overlay =
{
drawrawstring('0 32 0', "Not Yet Implemented", '8 8 0', '1 1 1', 1);
};
#else
static float selectedent;
static entity tempent;
typedef struct
{
string name;
string value;
} entfield_t;
typedef struct
{
//quick access for rendering.
float modelindex;
float alpha;
vector org;
float scale;
entfield_t *fields;
float numfields;
} entedit_t;
static entedit_t *editents;
static float numents;
float(entedit_t *ent, string field) editor_ents_findfield =
{
float i;
for (i = 0; i < ent->numfields; i++)
{
if (ent->fields[i].name == field)
return i;
}
return -1;
};
void(entedit_t *ent, string field, string value) editor_ents_setfieldvalue =
{
float f = editor_ents_findfield(ent, field);
if (f < 0)
{
local entfield_t *nf;
f = ent->numfields;
ent->numfields = ent->numfields + 1;
//extend the list
nf = memalloc(sizeof(entfield_t)*ent->numfields);
memcpy((__variant*)nf, (__variant*)ent->fields, sizeof(entfield_t)*f);
memfree((__variant*)ent->fields);
ent->fields = nf;
ent->fields[f].name = strzone(field);
}
print(sprintf("set %s to %s\n", field, value));
ent->fields[f].value = strzone(value);
};
entedit_t*() editor_ents_new =
{
local float nent;
local entedit_t *newents;
nent = numents;
numents += 1;
//extend the list
newents = memalloc(sizeof(entedit_t)*numents);
memcpy((__variant*)newents, (__variant*)editents, sizeof(entedit_t)*nent);
memfree((__variant*)editents);
editents = newents;
print("new entity\n");
return &editents[nent];
};
void(float num) editor_ents_delete =
{
};
void() editor_ents_reload =
{
local string field, value;
print("RELOADING ENTS\n");
//reset ent state
getentitytoken(__NULL__);
while (1)
{
field = getentitytoken();
if not (field)
{
break;
}
if (field == "{")
{
local entedit_t *nent;
nent = editor_ents_new();
while(1)
{
field = getentitytoken();
if not (field)
{
print("Truncated ent lump\n");
return;
}
if (field == "}")
break;
value = getentitytoken();
editor_ents_setfieldvalue(nent, field, value);
}
}
else
{
print("Corrupt ent lump\n");
return;
}
}
};
void() editor_ents_add =
{
float e;
if (!tempent)
{
tempent = spawn();
editor_ents_reload();
}
for (e = 0; e < numents; e++)
{
//skip worldspawn...
if (editents[e].modelindex == 1)
continue;
tempent.modelindex = editents[e].modelindex;
tempent.alpha = editents[e].alpha;
tempent.scale = editents[e].scale;
if (e == selectedent)
{
if (gettime(0)*5f & 1)
continue;
tempent.effects |= 8192f;
}
else
tempent.effects &~= 8192f;
setorigin(tempent, editents[e].org);
addentity(tempent);
}
};
void(vector mousepos) editor_ents_overlay =
{
};
#endif

View File

@ -41,7 +41,7 @@ void() editor_lights_add =
#define NUMLFIELDS 14
#define NUMCMDS 7
static string fldname[NUMLFIELDS+1+NUMCMDS] = { "bad",
static var string fldname[NUMLFIELDS+1+NUMCMDS] = { "bad",
" num",
" org",
" rgb",
@ -74,7 +74,7 @@ static string(int fld, float foredit) readfield =
return ftos(selectedlight);
return strcat(ftos(selectedlight), " / ", ftos(dynamiclight_get(-1f, -1f)));
case 2:
return vtos(dynamiclight_get(selectedlight, LFIELD_ORIGIN));
return sprintf("%v", dynamiclight_get(selectedlight, LFIELD_ORIGIN));
case 3:
return sprintf("%v", dynamiclight_get(selectedlight, LFIELD_COLOUR));
case 4:
@ -249,6 +249,7 @@ static void(vector fwd, vector vorg) selectbestlight =
float l, b=selectedlight, d, bd;
vector ldir;
l = dynamiclight_get(-1f, -1f);
bd = 0;
while(l > 0)
{
l--;

View File

@ -406,5 +406,5 @@ void(vector mousepos) editor_particles_overlay =
y_y += 8;
}
textfield_draw('128 32 0', &tf_particle, &fields);
textfield_draw('128 32 0', &tf_particle, fields);
};

View File

@ -1,25 +1,24 @@
enum
{
ter_reload = 0, //reload the entire thing
ter_save = 1, //save the entire heightmap
ter_sethole = 2,
ter_height_set = 3, //set heights to a specific value
ter_height_smooth = 4, //smooth the heights slightly (non-destructive)
ter_height_spread = 5, //smooth the heights slightly (leaves center as-is)
ter_height_raise = 6, //raise the terrain in a bell (negative value to lower)
ter_height_lower = 7, //lower the terrain in a bell (negative value to raise)
ter_tex_kill = 8, //set section texture
ter_tex_get = 9, //get section texture
ter_mixpaint = 10, //paint a specific texture
ter_mixconcentrate = 11, //figure out which is the strongest mixed texture and make it stronger
ter_mixnoise = 12, //add random noise to the affected samples
ter_mixblur = 13, //blur the texture mixture
ter_water_set = 14, //lower the terrain in a bell (negative value to raise)
ter_mesh_add = 15, //add a mesh
ter_mesh_kill = 16, //remove meshes within the radius
ter_tint = 17, //pants new colour modifiers/tints
ter_height_flatten, //smooth the heights slightly (non-destructive), such that the middle becomes flatter faster than the edges
ter_reload, //reload the entire thing
ter_save, //save the entire heightmap
ter_sethole, //punch a hole in the terrain
ter_height_set, //set heights to a specific value
ter_height_smooth, //smooth the heights slightly (non-destructive)
ter_height_spread, //smooth the heights slightly (leaves center as-is)
ter_height_flatten, //smooth the heights slightly (non-destructive), such that the middle becomes flatter faster than the edges
ter_height_raise, //raise the terrain in a bell (negative value to lower)
ter_height_lower, //lower the terrain in a bell (negative value to raise)
ter_tex_kill, //set section texture
ter_tex_get, //get section texture
ter_mixpaint, //paint a specific texture
ter_mixconcentrate, //figure out which is the strongest mixed texture and make it stronger
ter_mixnoise, //add random noise to the affected samples
ter_mixblur, //blur the texture mixture
ter_water_set, //lower the terrain in a bell (negative value to raise)
ter_mesh_add, //add a mesh
ter_mesh_kill, //remove meshes within the radius
ter_tint, //pants new colour modifiers/tints
ter_blank,
ter_radius,
ter_quant,
@ -35,10 +34,13 @@ static var float epercent = 40;
static string tex[8];
static var string tint[8] = {"1 1 1", "1.2 0.9 0.9", "0 1 0"};
static string meshname;
static float curtool;
static var float curtool = ter_blank;
static int painttex;
static float mautorepeattime;
static entity tempent;
static var float texturesearch = -1;
static float texturesearchfirst;
static string texturesearchhighlighted;
float autocvar_mod_terrain_networked;
@ -53,6 +55,7 @@ static string toolname[ter_count] =
"height set",
"height smooth",
"height spread",
"height flatten",
"height raise",
"height lower",
"tex kill",
@ -90,92 +93,122 @@ void(vector m) editor_do =
switch(curtool)
{
case ter_reload:
mautorepeattime = 0; //don't autorepeat that...
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "f", TEREDIT_RELOAD);
else if (!(float)terrain_edit(TEREDIT_RELOAD))
print("Unable to reload terrain.\n");
else
print("Terrain changes discarded.\n");
break;
case ter_save:
mautorepeattime = 0; //don't autorepeat that...
if (autocvar_mod_terrain_networked)
sendevent("teredit", "f", curtool);
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "f", TEREDIT_SAVE);
else
{
if (curtool == ter_save)
print("Saving...\n");
else if (curtool == ter_reload)
print("Reloading...\n");
terrain_edit(curtool);
}
print(sprintf("Saved %g chunks\n", (float)terrain_edit(TEREDIT_SAVE)));
break;
case ter_sethole: //use view center instead of targetted - you cannot target that which is not there
if (autocvar_mod_terrain_networked)
sendevent("teredit", "fvff", curtool, trace_endpos, eradius, equant);
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvff", TEREDIT_SETHOLE, trace_endpos, eradius, equant);
else
terrain_edit(curtool, trace_endpos, eradius, equant);
terrain_edit(TEREDIT_SETHOLE, trace_endpos, eradius, equant);
break;
case ter_height_smooth:
case ter_height_spread:
if (autocvar_mod_terrain_networked)
sendevent("teredit", "fvff", curtool, trace_endpos, eradius, epercent/100.0);
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvff", TEREDIT_HEIGHT_SMOOTH, trace_endpos, eradius, epercent/100.0);
else
terrain_edit(curtool, trace_endpos, eradius, epercent/100.0);
terrain_edit(TEREDIT_HEIGHT_SMOOTH, trace_endpos, eradius, epercent/100.0);
break;
case ter_height_spread:
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvff", TEREDIT_HEIGHT_SPREAD, trace_endpos, eradius, epercent/100.0);
else
terrain_edit(TEREDIT_HEIGHT_SPREAD, trace_endpos, eradius, epercent/100.0);
break;
case ter_water_set:
case ter_height_set:
case ter_height_smooth:
case ter_height_raise:
case ter_height_lower:
if (autocvar_mod_terrain_networked)
sendevent("teredit", "fvff", curtool, trace_endpos, eradius, equant);
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvff", TEREDIT_WATER_SET, trace_endpos, eradius, equant);
else
terrain_edit(curtool, trace_endpos, eradius, equant);
terrain_edit(TEREDIT_WATER_SET, trace_endpos, eradius, equant);
break;
case ter_height_set:
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvff", TEREDIT_HEIGHT_SET, trace_endpos, eradius, equant);
else
terrain_edit(TEREDIT_HEIGHT_SET, trace_endpos, eradius, equant);
break;
case ter_height_raise:
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvff", TEREDIT_HEIGHT_RAISE, trace_endpos, eradius, equant);
else
terrain_edit(TEREDIT_HEIGHT_RAISE, trace_endpos, eradius, equant);
break;
case ter_height_lower:
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvff", TEREDIT_HEIGHT_LOWER, trace_endpos, eradius, equant);
else
terrain_edit(TEREDIT_HEIGHT_LOWER, trace_endpos, eradius, equant);
break;
case ter_tex_get:
strunzone(tex[0]);
strunzone(tex[1]);
strunzone(tex[2]);
strunzone(tex[3]);
tex[0] = strzone(terrain_edit(curtool, trace_endpos, 0, 0));
tex[1] = strzone(terrain_edit(curtool, trace_endpos, 0, 1));
tex[2] = strzone(terrain_edit(curtool, trace_endpos, 0, 2));
tex[3] = strzone(terrain_edit(curtool, trace_endpos, 0, 3));
tex[0] = strzone(terrain_edit(TEREDIT_TEX_GET, trace_endpos, 0, 0));
tex[1] = strzone(terrain_edit(TEREDIT_TEX_GET, trace_endpos, 0, 1));
tex[2] = strzone(terrain_edit(TEREDIT_TEX_GET, trace_endpos, 0, 2));
tex[3] = strzone(terrain_edit(TEREDIT_TEX_GET, trace_endpos, 0, 3));
break;
// case ter_mixset:
// terrain_edit(curtool, trace_endpos, eradius, equant, emix);
// break;
case ter_mixpaint:
if (autocvar_mod_terrain_networked)
sendevent("teredit", "fvffs", curtool, trace_endpos, eradius, epercent/100.0, tex[painttex]);
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvffs", TEREDIT_MIX_PAINT, trace_endpos, eradius, epercent/100.0, tex[painttex]);
else
terrain_edit(curtool, trace_endpos, eradius, epercent/100.0, tex[painttex]);
terrain_edit(TEREDIT_MIX_PAINT, trace_endpos, eradius, epercent/100.0, tex[painttex]);
break;
case ter_tex_kill:
if (autocvar_mod_terrain_networked)
sendevent("teredit", "fvffs", curtool, trace_endpos, eradius, equant, tex[painttex]);
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvffs", TEREDIT_TEX_KILL, trace_endpos, eradius, equant, tex[painttex]);
else
terrain_edit(curtool, trace_endpos, eradius, equant, tex[painttex]);
terrain_edit(TEREDIT_TEX_KILL, trace_endpos, eradius, equant, tex[painttex]);
break;
case ter_mixconcentrate:
case ter_mixnoise:
case ter_mixblur:
if (autocvar_mod_terrain_networked)
sendevent("teredit", "fvff", curtool, trace_endpos, eradius, equant);
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvff", TEREDIT_MIX_UNIFY, trace_endpos, eradius, equant);
else
terrain_edit(curtool, trace_endpos, eradius, equant);
terrain_edit(TEREDIT_MIX_UNIFY, trace_endpos, eradius, equant);
break;
case ter_mixnoise:
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvff", TEREDIT_MIX_NOISE, trace_endpos, eradius, equant);
else
terrain_edit(TEREDIT_MIX_NOISE, trace_endpos, eradius, equant);
break;
case ter_mixblur:
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvff", TEREDIT_MIX_BLUR, trace_endpos, eradius, equant);
else
terrain_edit(TEREDIT_MIX_BLUR, trace_endpos, eradius, equant);
break;
case ter_tint:
if (autocvar_mod_terrain_networked)
sendevent("teredit", "fvffvf", curtool, trace_endpos, eradius, epercent/100.0, stov(tint[painttex]), 1);
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvffvf", TEREDIT_TINT, trace_endpos, eradius, epercent/100.0, stov(tint[painttex]), 1);
else
terrain_edit(curtool, trace_endpos, eradius, epercent/100.0, stov(tint[painttex]), 1);
terrain_edit(TEREDIT_TINT, trace_endpos, eradius, epercent/100.0, stov(tint[painttex]), 1);
break;
case ter_mesh_add:
terrain_edit(curtool, tempent);
terrain_edit(TEREDIT_MESH_ADD, tempent);
break;
case ter_mesh_kill:
if (autocvar_mod_terrain_networked)
sendevent("teredit", "fvf", curtool, trace_endpos, eradius);
if (autocvar_mod_terrain_networked && !isserver())
sendevent("teredit", "fvf", TEREDIT_MESH_KILL, trace_endpos, eradius);
else
terrain_edit(curtool, trace_endpos, eradius);
terrain_edit(TEREDIT_MESH_KILL, trace_endpos, eradius);
break;
}
};
@ -184,8 +217,21 @@ float(float keyc, float unic, vector m) editor_terrain_key =
{
if (curtool >= ter_radius && curtool <= ter_tex)
{
string txt;
string txt = "";
float nt = curtool;
if (curtool == ter_tex)
{
if (keyc == 512 && m_x > 128)
{
txt = texturesearchhighlighted;
nt = ter_mixpaint;
}
if (keyc == 515)
texturesearchfirst += floor((vidsize_x)/128) - 1;
if (keyc == 516)
texturesearchfirst -= floor((vidsize_x)/128) - 1;
}
if (curtool == ter_radius)
txt = itos((int)eradius);
if (curtool == ter_quant)
@ -323,7 +369,7 @@ void(vector mousepos) editor_terrain_add =
{
float s,c;
float r;
vector tx, p, col,t;
vector tx, p, col;
float a;
if (mousepos_x < 128)
return;
@ -448,4 +494,47 @@ void(vector mousepos) editor_terrain_overlay =
drawstring(pos, toolname[i], '8 8 0', colour, 1, 0);
pos_y += 8;
}
if (texturesearchhighlighted)
{
strunzone(texturesearchhighlighted);
texturesearchhighlighted = 0;
}
if (curtool == ter_tex)
{
if (texturesearch < 0)
texturesearch = search_begin("textures/*", FALSE, TRUE);
if (texturesearchfirst > search_getsize(texturesearch)-4)
texturesearchfirst = search_getsize(texturesearch)-4;
if (texturesearchfirst < 0)
texturesearchfirst = 0;
i = texturesearchfirst;
pos = '128 16';
local float x;
for (pos_y = 8; pos_y < vidsize_y; pos_y+=128+8)
for (x = 0; x < floor(vidsize_x / 128)-1; )
{
string fname = search_getfilename(texturesearch, i);
i+=1;
if (fname == "")
break;
if (substring(fname, -1, 1) == "/")
continue;
drawpic(pos + [x*128, 8], fname, '128 128', '1 1 1', 1, 0);
if (substring(fname, 0, 9) == "textures/")
fname = substring(fname, 9, -1);
string ext = substring(fname, -4, 4);
if (ext == ".png" || ext == ".tga" || ext == ".jpg")
fname = substring(fname, 0, -5);
drawstring(pos + [x*128, 0], fname, '8 8 0', '1 1 1', 1, 0);
x+=1;
if (mousepos_x > pos_x+x*128 && mousepos_y > pos_y && mousepos_x < pos_x+(x+1)*128 && mousepos_y < pos_y+(128+8))
{
if (texturesearchhighlighted)
strunzone(texturesearchhighlighted);
texturesearchhighlighted = strzone(fname);
}
}
}
};

View File

@ -2,7 +2,8 @@
typedef struct
{
float *current;
float *currentf;
int *currenti;
float key;
vector *mousepos;
vector mousediff;
@ -33,7 +34,7 @@ void(menu_t *menu, string fieldname, vector pos, float *value, float minv, float
spos = rpos;
spos_x = pos_x + strlen(fieldname) * 8 + 4;
/*if they're dragging us, update*/
if ((int)menu->current == (int)value)
if (menu->currentf == value)
{
if (mousedown == 1)
{
@ -46,7 +47,7 @@ void(menu_t *menu, string fieldname, vector pos, float *value, float minv, float
}
else
{
menu->current = (int*)__NULL__;
menu->currentf = (float*)__NULL__;
}
}
else
@ -81,7 +82,7 @@ void(menu_t *menu, string fieldname, vector pos, float *value, float minv, float
if (key == 512)
{
f = *value;
menu->current = value;
menu->currentf = value;
mp_x = spos_x + 9 * 8 * (f - minv) / (maxv - minv) + 4;
*menu->mousepos = mp;
}
@ -110,7 +111,7 @@ void(menu_t *menu, string fieldname, vector pos, float *value) sliderf_fixed_wid
if (!(menu->flags & MF_DS_VALUE))
epos_x += strlen(sprintf("%f", *value)) * 8;
/*if they're dragging us, update*/
if ((int)menu->current == (int)value)
if (menu->currentf == value)
{
if (mousedown == 1)
{
@ -122,7 +123,7 @@ void(menu_t *menu, string fieldname, vector pos, float *value) sliderf_fixed_wid
}
else
{
menu->current = (int*)__NULL__;
menu->currentf = (float*)__NULL__;
}
}
else
@ -153,7 +154,7 @@ void(menu_t *menu, string fieldname, vector pos, float *value) sliderf_fixed_wid
if (key == 512)
{
f = *value;
menu->current = value;
menu->currentf = value;
mp_x = spos_x + 4;
*mpp = mp;
}
@ -185,7 +186,7 @@ void(menu_t *menu, string fieldname, vector pos, int *value, int minv, int maxv)
if (!(menu->flags & MF_DS_VALUE))
epos_x = strlen(sprintf("%i", *value)) * 8;
/*if they're dragging us, update*/
if ((int)menu->current == (int)value)
if (menu->currenti == value)
{
if (mousedown == 1)
{
@ -198,7 +199,7 @@ void(menu_t *menu, string fieldname, vector pos, int *value, int minv, int maxv)
}
else
{
menu->current = (int*)__NULL__;
menu->currenti = (int*)__NULL__;
}
}
else
@ -233,7 +234,7 @@ void(menu_t *menu, string fieldname, vector pos, int *value, int minv, int maxv)
if (key == 512)
{
f = *value;
menu->current = value;
menu->currenti = value;
mp_x = spos_x + 9 * 8 * (f - minv) / (maxv - minv) + 4;
*menu->mousepos = mp;
}