checkbox gui element

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1542 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2008-01-02 19:21:12 +00:00
parent e9a9896669
commit 472c0ef3a2
7 changed files with 250 additions and 150 deletions
+62 -63
View File
@@ -7,13 +7,13 @@ newmenu main
menuitem "Multiplayer" "showmenu multiplayer"
menuitem "Singleplayer" "showmenu singleplayer"
menuitem "Player Setup" "showmenu setup"
menuitem "Options" "showmenu options"
menuitem "Settings" "showmenu settings"
menuitem "Demo" "showmenu demo"
menuitem "Editing" "showmenu editing"
menuitem "Help" "showmenu help"
menuitem "About" "showmenu about"
menuitem "Quit" "quit"
// menumdl path anim rotation-speed{0..100} scale{0..100}
// chmenumdl menuname newpath
@@ -32,10 +32,15 @@ alias genmapitems [
newmenu maps
genmapitems "ac_complex ac_mines ac_depot ac_desert ac_desert2 ac_snow ac_power ac_elevation"
menuitem "show all.." [showmenu "all maps"]
newmenu "all maps"
menudirlist "packages/maps" "cgz" "map $arg1"
newmenu maps_ctf
genmapitems "ac_mines ac_depot ac_power ac_elevation"
menuitem "show all.." [showmenu "all maps"]
newmenu setup
@@ -93,10 +98,16 @@ gencrosshairs "default.png cube.png dot.png dot_wide.png o.png o_dot.png o_x.png
newmenu demo
menuitem "record demo" "recorddemo"
menuitem "stop recording" "stopdemo"
menuitem "list demos" "listdemos"
menuitem "getdemo" "getdemo"
menuitem "record demo" "recorddemo"
menuitem "play demo" [showmenu "play demo"]
menuitem "stop recording/playback" "stopdemo"
menuitem "list demos" "listdemos"
menuitem "getdemo" "getdemo"
newmenu "play demo"
menudirlist "demos/" "dmo" "demo $arg1"
newmenu multiplayer
@@ -148,10 +159,10 @@ alias startbotmap [
newmenu singleplayer
// teamplay note mature yet
//menuitem "Bot Team Deathmatch" "alias tmp_mode 7; showmenu botskill"
menuitem "Bot Team Deathmatch" "alias tmp_mode 7; showmenu botskill"
menuitem "Bot Deathmatch" "alias tmp_mode 8; showmenu botskill"
menuitem "Bot One Shot, One Kill" "alias tmp_mode 12; showmenu botskill"
menuitem "Empty Map" "showmenu maps"
menuitem "Empty Map" "mode 0; showmenu maps"
newmenu botskill
@@ -421,10 +432,13 @@ menuitem "V-19 Combat Shotgun" "nextprimary 2;echo V-19 Combat Shotgun chosen"
//menuitem "DR-17 HE-Grenade" "echo DR-17 HE-Grenade chosen" "chmenumdl equipment vwep/grenade_static mapmodel 40 80"
//menuitem "SN-Tech Kelvar Vest" "echo SN-Tech Kelvar Vest chosen" "chmenumdl equipment pickups/kevlar mapmodel 40 20"
newmenu options
newmenu settings
menuitem "quick setup.." [showmenu "quick setup"]
menuitem "keyboard/mouse controls" "showmenu controls"
menuitem "video settings" "showmenu video"
menuitem "sound settings" "showmenu sound"
menuitem "world settings" "showmenu world"
menuitem "tweak minlod.. (higher = less popup, possibly lower fps)" "showmenu minlod"
menuitem "tweak fpsrange.. (higher = possibly more popup)" "showmenu fpsrange"
menuitem "tweak water subdivision" "showmenu watersubdiv"
@@ -437,24 +451,12 @@ menuitem "tweak gamma" "showmenu ga
newmenu "quick setup"
menuitemtextinput "nickname: " "unnamed" [
if (= $arg1 0) [ alias new_name $arg2 ] []
]
menuitemtextinput "screen width: " "$scr_w" [
if (= $arg1 0) [ alias new_scr_w $arg2 ] []
]
menuitemtextinput "screen height: " "$scr_h" [
if (= $arg1 0) [ alias new_scr_h $arg2 ] []
]
menuitemslider "mouse sensitivity: "2 100 "($sensitivity)" 2 "" [
if (= $arg1 0) [] [ alias new_sensitivity $arg3 ]
]
menuitemslider "graphics quality: " 1 4 "(getgfxq; $gfxq)" 1 "low medium good awesome" [
if (= $arg1 0) [] [ alias new_gfx_quality $arg3 ]
]
menuitemslider "sound quality: " 1 3 "(getsoundq; $soundq)" 1 "low medium good" [
if (= $arg1 0) [] [ alias new_sound_quality $arg3 ]
]
menuitemtextinput "nickname: " "" "name $arg1"
menuitemtextinput "screen width: " "$scr_w" "scr_w $arg1"
menuitemtextinput "screen height: " "$scr_h" "scr_h $arg1"
menuitemslider "mouse sensitivity: "2 100 "($sensitivity)" 2 "" "sensitivity $arg1"
menuitemslider "graphics detail: " 1 4 "(getgfxq; $gfxq)" 1 "low medium good best" "new_gfx_quality $arg1"
menuitemslider "sound detail: " 1 3 "(getsoundq; $soundq)" 1 "low medium high" "new_sound_quality $arg1"
alias getgfxq [
if (= $minlod 200) [ alias gfxq 4 ] [
@@ -477,7 +479,7 @@ menuitem "OK" [
scr_w $new_scr_w
scr_h $new_scr_h
if (= $new_gfx_quality 4) [ // awesome gfx quality
if (= $new_gfx_quality 4) [ // highest gfx quality
minlod 200
fpsrange 100 1000
watersubdiv 2
@@ -506,7 +508,7 @@ menuitem "OK" [
dynshadow 40
lighterror 4
fsaa 0
] [ // poor
] [ // low
minlod 25
fpsrange 20 25
watersubdiv 16
@@ -521,17 +523,26 @@ menuitem "OK" [
if (= $new_sound_quality 3) [ // high sound
soundchans 64
maxsoundsatonce 15
maxsoundsatonce 40
soundbufferlen 1024
footsteps 1
bulletairsound 1
bulletbouncesound 1
] [
if (= $new_sound_quality 2) [ // medium
soundchans 32
maxsoundsatonce 5
maxsoundsatonce 10
soundbufferlen 1024
footsteps 1
bulletairsound 0
bulletbouncesound 0
] [ // low
soundchans 32
maxsoundsatonce 5
soundbufferlen 2048 // causes sound lag while reducing cpu load
footsteps 0
bulletairsound 0
bulletbouncesound 0
]
]
@@ -568,26 +579,27 @@ menuitemkeyinput "map overview: " toggleshowmap
menuitemkeyinput "drop CTF flag: " dropflag
newmenu gamma
newmenu video
menuitem "gamma 50"
menuitem "gamma 60"
menuitem "gamma 70"
menuitem "gamma 80"
menuitem "gamma 90"
menuitem "gamma 100"
menuitem "gamma 110"
menuitem "gamma 120"
menuitem "gamma 130"
menuitem "gamma 140"
menuitem "gamma 150"
newmenu minlod
menuitem "minimum (25)" "minlod 25"
menuitem "decent (60)" "minlod 60"
menuitem "good (100)" "minlod 100"
menuitem "fps be damned (250)" "minlod 250"
menuitemtextinput "screen width: " "$scr_w" "scr_w $arg1"
menuitemtextinput "screen height: " "$scr_h" "scr_h $arg1"
menuitemslider "antialiasing (FSAA) :" 0 5 "$fsaa" 1 "off 2 4 8 16" [
alias valuemap "0 2 4 8 16"
fsaa (at $valuemap $arg1)
]
menuitemslider "gamma :" 30 300 "$gamma" 5 "" "gamma $arg1"
menuitemslider "minimal level of detail" 25 250 "$minlod" 5 ["low" "decent" "good" "best"] [
alias valuemap "25 60 100 250"
minlod (at $valuemap $arg1)
]
menuitemcheckbox "water reflection: " "$waterreflect" "waterreflect $arg1"
menuitemslider "water subdivision: " 0 4 "$watersubdiv" 1 ["lowest quality" "low quality" "medium quality" "high quality" "highest quality"] [
alias valuemap "16 8 4 2 1"
watersubdiv (at $valuemap $arg1)
]
menuitemcheckbox "dynamic light: " "$dynlight" [ if (= $arg1 1) [ dynlight 16 ] [ dynlight 0 ] ]
menuitemcheckbox "dynamic shadows: " "$dynshadow" [ if (= $arg1 1) [ dynshadow 40 ] [ dynshadow 0 ] ]
menuitemslider "light error: " 1 100 "$lighterror" 5 "" "lighterror $arg1"
newmenu fpsrange
@@ -597,24 +609,11 @@ menuitem "sensible default (30-40)" "fpsrange 30 40"
menuitem "fps whore (60-60)" "fpsrange 60 60"
menuitem "I don't understand LOD (100+)" "fpsrange 100 1000"
newmenu watersubdiv
menuitem "subdivision 1 (insane polygon wastage)" "watersubdiv 1"
menuitem "subdivision 2 (high quality)" "watersubdiv 2"
menuitem "subdivision 4 (medium quality)" "watersubdiv 4"
menuitem "subdivision 8 (low quality)" "watersubdiv 8"
menuitem "subdivision 16 (my 486 can do water too)" "watersubdiv 16"
newmenu dynlight
menuitem "enable dynamic light/shadows" "dynlight 16"
menuitem "disable dynamic light/shadows" "dynlight 0"
newmenu "water reflection"
menuitem "enable water reflection" "waterreflect 1"
menuitem "disable water reflection" "waterreflect 0"
newmenu "player shadows"
menuitem "enable dynamic player shadows" "dynshadow 40"
+10 -6
View File
@@ -277,17 +277,21 @@ void keypress(int code, bool isdown, int cooked)
{
if(code==SDLK_RETURN)
{
if(cmdline.buf[0])
string buf; // use a copy to safely close the commandline
s_strcpy(buf, cmdline.buf);
saycommand(NULL);
if(buf[0])
{
if(vhistory.empty() || strcmp(vhistory.last(), cmdline.buf))
if(vhistory.empty() || strcmp(vhistory.last(), buf))
{
vhistory.add(newstring(cmdline.buf)); // cap this?
vhistory.add(newstring(buf)); // cap this?
}
histpos = vhistory.length();
if(cmdline.buf[0]=='/') execute(cmdline.buf+1);
else toserver(cmdline.buf);
if(buf[0]=='/') execute(buf+1);
else toserver(buf);
}
saycommand(NULL);
}
else if(code==SDLK_ESCAPE)
{
+5 -2
View File
@@ -38,7 +38,7 @@ struct textinputbuffer
buf[0] = '\0';
}
void key(int code, bool isdown, int unicode)
bool key(int code, bool isdown, int unicode)
{
switch(code)
{
@@ -84,7 +84,8 @@ struct textinputbuffer
case SDLK_v:
extern void pasteconsole(char *dst);
if(SDL_GetModState()&(KMOD_LCTRL|KMOD_RCTRL)) { pasteconsole(buf); return; }
if(SDL_GetModState()&(KMOD_LCTRL|KMOD_RCTRL)) pasteconsole(buf);
break;
default:
{
@@ -100,11 +101,13 @@ struct textinputbuffer
buf[pos++] = unicode;
}
buf[len+1] = '\0';
return true;
}
}
break;
}
}
return false;
}
};
+150 -75
View File
@@ -8,7 +8,6 @@ gmenu *curmenu = NULL, *lastmenu = NULL;
vector<gmenu *> menustack;
void menuset(void *m)
{
if(curmenu==m) return;
@@ -87,23 +86,23 @@ void rendermenu()
m.render();
}
void gmenu::renderbg(int x1, int y1, int x2, int y2, bool border)
{
static Texture *tex = NULL;
if(!tex) tex = textureload("packages/textures/makke/menu.jpg");
blendbox(x1, y1, x2, y2, border, tex->id);
}
void mitem::render(int x, int y, int w)
{
if(bgcolor) renderbg(x, y, w);
else if(isselection()) blendbox(x-FONTH, y-FONTH/6, x+w+FONTH, y+FONTH+FONTH/6, false);
if(isselection()) renderbg(x, y, w, NULL);
else if(bgcolor) renderbg(x, y, w, bgcolor);
}
void mitem::renderbg(int x, int y, int w) { blendbox(x-FONTH, y-FONTH/6, x+w+FONTH, y+FONTH+FONTH/6, false, -1, bgcolor); };
void mitem::renderbg(int x, int y, int w, color *c)
{
if(isselection()) blendbox(x-FONTH, y-FONTH/6, x+w+FONTH, y+FONTH+FONTH/6, false, -1, c);
else blendbox(x, y, x+w, y+FONTH, false, -1, c);
};
bool mitem::isselection() { return parent->allowinput && parent->items.inrange(parent->menusel) && parent->items[parent->menusel]==this; }
color mitem::gray(0.2f, 0.2f, 0.2f);
color mitem::white(1.0f, 1.0f, 1.0f);
color mitem::whitepulse(1.0f, 1.0f, 1.0f);
// text item
struct mitemtext : mitem
@@ -150,15 +149,16 @@ struct mitemtextinput : mitemtext
{
textinputbuffer input;
char *defaultvalueexp;
bool modified;
mitemtextinput(gmenu *parent, char *text, char *value, char *action, char *hoveraction, color *bgcolor) : mitemtext(parent, text, action, hoveraction, bgcolor), defaultvalueexp(value)
mitemtextinput(gmenu *parent, char *text, char *value, char *action, char *hoveraction, color *bgcolor) : mitemtext(parent, text, action, hoveraction, bgcolor), defaultvalueexp(value), modified(false)
{
s_strcpy(input.buf, value);
};
virtual ~mitemtextinput() { }
virtual void select() { focus(false); focus(true); } // fixme
virtual void select() { } // fixme
virtual int width() { return text_width(input.buf) + text_width(text); }
@@ -177,30 +177,31 @@ struct mitemtextinput : mitemtext
{
SDL_EnableUNICODE(on);
if(!strlen(input.buf)) setdefaultvalue();
if(action)
if(!on && modified)
{
push("arg1", on ? "1" : "0");
push("arg2", input.buf);
modified = false;
push("arg1", input.buf);
execute(action);
pop("arg2");
pop("arg1");
}
}
virtual void key(int code, bool isdown, int unicode)
{
input.key(code, isdown, unicode);
if(input.key(code, isdown, unicode)) modified = true;
}
virtual void init()
{
setdefaultvalue();
modified = false;
}
void setdefaultvalue()
{
const char *p = defaultvalueexp;
s_strcpy(input.buf, parseword(p));
char *r = executeret(p);
s_strcpy(input.buf, r ? r : "");
}
};
@@ -208,11 +209,14 @@ struct mitemtextinput : mitemtext
struct mitemslider : mitem
{
int min_, max_, step, value;
int min_, max_, step, value, maxvaluewidth;
char *text, *valueexp, *display, *action;
string curval;
static int sliderwidth;
mitemslider(gmenu *parent, char *text, int min_, int max_, int step, char *value, char *display, char *action, color *bgcolor) : mitem(parent, bgcolor), min_(min_), max_(max_), step(step), value(min_), text(text), valueexp(value), display(display), action(action)
mitemslider(gmenu *parent, char *text, int min_, int max_, int step, char *value, char *display, char *action, color *bgcolor) : mitem(parent, bgcolor), min_(min_), max_(max_), step(step), value(min_), maxvaluewidth(0), text(text), valueexp(value), display(display), action(action)
{
if(sliderwidth==0) sliderwidth = VIRTW/4;
}
virtual ~mitemslider()
@@ -223,50 +227,23 @@ struct mitemslider : mitem
DELETEA(action);
}
virtual int width() { return text_width(text) + 600; } // fixme
virtual void focus(bool on)
{
if(action)
{
push("arg1", on ? "1" : "0");
push("arg2", "0");
setvaluealias();
execute(action);
pop("arg3");
pop("arg2");
pop("arg1");
}
}
virtual int width() { return text_width(text) + sliderwidth + maxvaluewidth; }
virtual void render(int x, int y, int w)
{
bool sel = isselection();
static color white1(0.2f, 0.2f, 0.2f);
color white2(1.0f, 1.0f, 1.0f, sel ? (sinf(lastmillis/200.0f)+1.0f)/2.0f : 1.0f);
int range = max_-min_;
int cval = value-min_;
int tw = text_width(text);
if(sel) blendbox(x+tw, y-FONTH/6, x+w+FONTH, y+FONTH+FONTH/6, false);
if(sel) renderbg(x+w-sliderwidth, y, sliderwidth, NULL);
draw_text(text, x, y);
draw_text(curval, x+tw, y);
string v;
if(display) // extract display name from list
{
char *val = indexlist(display, cval);
s_strcpy(v, val);
delete[] val;
}
else itoa(v, value);
int vw = text_width(v);
draw_text(v, x+w-vw, y);
blendbox(x+w-sliderwidth, y+FONTH/3, x+w, y+FONTH*2/3, false, -1, &gray);
blendbox(x+tw+FONTH, y+FONTH/3, x+w, y+FONTH*2/3, false, -1, &white1);
int sliderwidth = (x+w)-(x+tw+FONTH);
int offset = cval/(float)range*sliderwidth;
blendbox(x+tw+offset+FONTH, y, x+tw+offset+FONTH*1.2f, y+FONTH, false, -1, &white2);
blendbox(x+w-sliderwidth+offset-FONTH/6, y, x+w-sliderwidth+offset+FONTH/6, y+FONTH, false, -1, sel ? &whitepulse : &white);
}
virtual void key(int code, bool isdown, int unicode)
@@ -278,42 +255,65 @@ struct mitemslider : mitem
virtual void init()
{
const char *p = valueexp;
char *v = parseword(p);
char *v = executeret(p);
if(v) value = min(max_, max(min_, atoi(v)));
displaycurvalue();
getmaxvaluewidth();
}
void slide(bool right)
{
displaycurvalue();
value += right ? step : -step;
value = min(max_, max(min_, value));
if(action)
{
value += right ? step : -step;
value = min(max_, max(min_, value));
push("arg1", "-1");
push("arg2", right ? "1" : "-1");
setvaluealias();
string v;
itoa(v, value);
push("arg1", v);
execute(action);
pop("arg3");
pop("arg2");
pop("arg1");
}
}
void displaycurvalue()
{
if(display) // extract display name from list
{
char *val = indexlist(display, value-min_);
s_strcpy(curval, val);
delete[] val;
}
else itoa(curval, value);
}
void setvaluealias()
{
string v;
itoa(v, value);
push("arg3", v);
void getmaxvaluewidth()
{
int oldvalue = value;
maxvaluewidth = 0;
for(int v = min_; v <= max_; v++)
{
value = v;
displaycurvalue();
maxvaluewidth = max(text_width(curval), maxvaluewidth);
}
value = oldvalue;
}
};
int mitemslider::sliderwidth = 0;
// key input item
struct mitemkeyinput : mitem
{
char *text, *bindcmd, *keyname;
static char *unknown, *empty;
bool capture;
mitemkeyinput(gmenu *parent, char *text, char *bindcmd, color *bgcolor) : mitem(parent, bgcolor), text(text), bindcmd(bindcmd), keyname(NULL), capture(false) {};
mitemkeyinput(gmenu *parent, char *text, char *bindcmd, color *bgcolor) : mitem(parent, bgcolor), text(text), bindcmd(bindcmd), keyname(NULL), capture(false)
{
}
virtual int width() { return text_width(text)+(keyname ? text_width(keyname) : char_width('_')); }
@@ -323,7 +323,7 @@ struct mitemkeyinput : mitem
static color capturec(0.4f, 0, 0);
if(isselection()) blendbox(x+w-tk-FONTH, y-FONTH/6, x+w+FONTH, y+FONTH+FONTH/6, false, -1, capture ? &capturec : NULL);
draw_text(text, x, y);
draw_text(keyname ? keyname : "?", x+w-tk, y);
draw_text(keyname, x+w-tk, y);
}
virtual void init()
@@ -332,24 +332,84 @@ struct mitemkeyinput : mitem
capture = false;
}
virtual void select() { capture = true; }
virtual void select()
{
capture = true;
keyname = empty;
}
virtual void key(int c, bool isdown, int unicode)
virtual void key(int code, bool isdown, int unicode)
{
if(!capture) return;
if(!capture || code < -5 || code > SDLK_MENU) return;
keym *km;
while((km = findbinda(bindcmd))) { bindkey(km, ""); } // clear existing binds to this cmd
if(bindc(c, bindcmd)) parent->init(); // re-init all bindings
if(bindc(code, bindcmd)) parent->init(); // re-init all bindings
else conoutf("\f3could not bind key");
}
void displaycurrentbind()
{
keym *km = findbinda(bindcmd);
keyname = km ? km->name : NULL;
keyname = km ? km->name : unknown;
}
};
char *mitemkeyinput::unknown = "?";
char *mitemkeyinput::empty = " ";
// checkbox menu item
struct mitemcheckbox : mitem
{
char *text, *valueexp, *action;
bool checked;
mitemcheckbox(gmenu *parent, char *text, char *value, char *action, color *bgcolor) : mitem(parent, bgcolor), text(text), valueexp(value), action(action), checked(false)
{
}
~mitemcheckbox()
{
DELETEA(text);
DELETEA(valueexp);
DELETEA(action);
}
virtual int width() { return text_width(text); }
virtual void select()
{
checked = !checked;
push("arg1", checked ? "1" : "0");
execute(action);
pop("arg1");
}
virtual void init()
{
const char *p = valueexp;
char *r = executeret(p);
checked = (r && atoi(r) > 0);
}
virtual void render(int x, int y, int w)
{
bool sel = isselection();
const static int boxsize = FONTH;
static color gray(0.2f, 0.2f, 0.2f);
draw_text(text, x, y);
if(isselection()) renderbg(x+w-boxsize, y, boxsize, NULL);
blendbox(x+w-boxsize, y, x+w, y+boxsize, false, -1, &gray);
if(checked)
{
int x1 = x+w-boxsize-FONTH/6, x2 = x+w+FONTH/6, y1 = y-FONTH/6, y2 = y+boxsize+FONTH/6;
line(x1, y1, x2, y2, sel ? &whitepulse : &white);
line(x2, y1, x1, y2, sel ? &whitepulse : &white);
}
}
};
// console iface
void *addmenu(const char *name, const char *title, bool allowinput, void (__cdecl *refreshfunc)(void *, bool))
@@ -413,6 +473,12 @@ void menuitemkeyinput(char *text, char *bindcmd)
lastmenu->items.add(new mitemkeyinput(lastmenu, newstring(text), newstring(bindcmd), NULL));
}
void menuitemcheckbox(char *text, char *value, char *action)
{
if(!lastmenu) return;
lastmenu->items.add(new mitemcheckbox(lastmenu, newstring(text), newstring(value), newstring(action), NULL));
}
void menumdl(char *mdl, char *anim, char *rotspeed, char *scale)
{
if(!lastmenu || !mdl || !anim) return;
@@ -449,6 +515,7 @@ COMMAND(menuitem, ARG_3STR);
COMMAND(menuitemtextinput, ARG_4STR);
COMMAND(menuitemslider, ARG_7STR);
COMMAND(menuitemkeyinput, ARG_4STR);
COMMAND(menuitemcheckbox, ARG_3STR);
COMMAND(showmenu, ARG_1STR);
COMMAND(newmenu, ARG_1STR);
COMMAND(menumdl, ARG_5STR);
@@ -499,7 +566,7 @@ bool menukey(int code, bool isdown, int unicode)
{
if(!curmenu->allowinput || !curmenu->items.inrange(menusel)) return false;
mitem &m = *curmenu->items[menusel];
if(code==SDLK_RETURN || code==-1 || code==-2)
if(code==SDLK_RETURN || code==SDLK_SPACE || code==-1 || code==-2)
{
if(!curmenu->items.inrange(menusel)) { menuset(NULL); return true; }
m.select();
@@ -590,6 +657,7 @@ void gmenu::render()
offset = menusel - (menusel%pagesize),
mdisp = min(items.length(), pagesize),
cdisp = min(items.length()-offset, pagesize);
mitem::whitepulse.alpha = (sinf(lastmillis/200.0f)+1.0f)/2.0f;
if(title) text_startcolumns();
int w = 0;
loopv(items)
@@ -631,3 +699,10 @@ void gmenu::render()
draw_text(footer, x, y);
}
}
void gmenu::renderbg(int x1, int y1, int x2, int y2, bool border)
{
static Texture *tex = NULL;
if(!tex) tex = textureload("packages/textures/makke/menu.jpg");
blendbox(x1, y1, x2, y2, border, tex->id);
}
+3 -1
View File
@@ -94,7 +94,8 @@ struct mitem
virtual void key(int code, bool isdown, int unicode) {}
virtual void init() {}
bool isselection();
void renderbg(int x, int y, int w);
void renderbg(int x, int y, int w, color *c);
static color gray, white, whitepulse;
};
struct mdirlist
@@ -156,6 +157,7 @@ extern void pingservers();
extern void gl_init(int w, int h, int bpp, int depth, int fsaa);
extern void cleangl();
extern void line(int x1, int y1, float z1, int x2, int y2, float z2);
extern void line(int x1, int y1, int x2, int y2, color *c = NULL);
extern void box(block &b, float z1, float z2, float z3, float z4);
extern void dot(int x, int y, float z);
extern void linestyle(float width, int r, int g, int b);
+12
View File
@@ -93,6 +93,18 @@ void line(int x1, int y1, float z1, int x2, int y2, float z2)
xtraverts += 4;
}
void line(int x1, int y1, int x2, int y2, color *c)
{
glDisable(GL_BLEND);
if(c) glColor4f(c->r, c->g, c->b, c->alpha);
glBegin(GL_LINES);
glVertex2f((float)x1, (float)y1);
glVertex2f((float)x2, (float)y2);
glEnd();
glEnable(GL_BLEND);
}
void linestyle(float width, int r, int g, int b)
{
glLineWidth(width);
+8 -3
View File
@@ -501,6 +501,7 @@ void particle_fireball(int type, vec &o)
}
VARP(holettl, 0, 10000, 30000);
VARP(bulletbouncesound, 0, 1, 1);
bool addbullethole(vec &from, vec &to, float radius)
{
@@ -514,7 +515,7 @@ bool addbullethole(vec &from, vec &to, float radius)
o.add(ray.mul(dist));
o.add(vec(surface).mul(0.005f));
newparticle(o, surface, holettl, 7);
playsound(S_BULLETBOUNCE, NULL, NULL, &o);
if(bulletbouncesound) playsound(S_BULLETBOUNCE, NULL, NULL, &o);
return true;
}
@@ -530,11 +531,12 @@ bool addscorchmark(vec &o, float radius)
}
VARP(shotlinettl, 0, 0, 10000);
VARP(bulletairsound, 0, 1, 1);
void addshotline(dynent *pl, vec &from, vec &to)
{
if(pl == player1) return;
bool fx = player1->isspectating() && shotlinettl > 0; // allow fx only in spect mode
bool fx = shotlinettl > 0 && (player1->isspectating() || !multiplayer(false)); // allow fx only in spect mode and locally
if(rnd(3) && !fx) return; // show all shotlines when fx enabled
int start = (camera1->o.dist(to) <= 10.0f) ? 8 : 5;
@@ -550,9 +552,12 @@ void addshotline(dynent *pl, vec &from, vec &to)
newparticle(o, d, fx ? shotlinettl : 75, 6);
// shotline sound fx
vec fromuv, touv, soundpos(unitv);
if(!bulletairsound) return;
vec fromuv, touv;
float fd = camera1->o.dist(from, fromuv);
float td = camera1->o.dist(to, touv);
if(fd < 8.0f || td < 8.0f) return; // ignore near shots
vec soundpos(unitv);
soundpos.mul(fd/(fd+td)*dist);
soundpos.add(from);
playsound(S_BULLETAIR, NULL, NULL, &soundpos);