Add command to return CN of spectated player

Also cleanup and added key shortcut to "whois" spectated player
(bound to "I" by default).

DOCREF spectatecn
This commit is contained in:
aurhat
2016-12-25 22:47:50 +01:00
parent 1663179a63
commit ab43f7acd5
3 changed files with 36 additions and 16 deletions
+7 -4
View File
@@ -287,10 +287,13 @@ newmenu [Spectating keys]
menuitem "Select an action and press ENTER to bind a new key:" -1
menuitem "" -1
menuitem "\f2Demo watching:" -1
menuitemspectkeyinput [Toggle game speed: ] key_demo_togglespeed
menuitemspectkeyinput [Increase game speed: ] key_demo_gamespeedup
menuitemspectkeyinput [Decrease game speed: ] key_demo_gamespeeddown
menuitemspectkeyinput [Reset game speed: ] key_demo_gamespeedreset
menuitemspectkeyinput [Toggle game speed: ] speckey_demo_togglespeed
menuitemspectkeyinput [Increase game speed: ] speckey_demo_gamespeedup
menuitemspectkeyinput [Decrease game speed: ] speckey_demo_gamespeeddown
menuitemspectkeyinput [Reset game speed: ] speckey_demo_gamespeedreset
menuitem "" -1
menuitem "\f2Misc spectating keys:" -1
menuitemspectkeyinput [Whois spectated player: ] speckey_whois_spectatecn
newmenu Mouse
menuitemcheckbox [Invert mouse: ] "$invmouse" [ invmouse $arg1 ]
+11 -8
View File
@@ -9,10 +9,6 @@ alias key_console_end [ conskip -1000 ]
alias key_console_forward [ conskip -5 ]
alias key_console_rewind [ conskip 5 ]
alias key_console_scroll [ if (strcmp $modifier 0) [ tempalias __confade $confade ] ; onrelease "confade $__confade ; if (! $__scrolled) [ conskip -1000 ]" ; confade 0 ; tempalias __scrolled 0 ; domodifier conscroll ]
alias key_demo_gamespeeddown [ if (watchingdemo) [ if (<= $gamespeed 100) [ gamespeed (- $gamespeed 10) ] [ gamespeed (- $gamespeed 100) ]; gamespeed ] ]
alias key_demo_gamespeedup [ if (watchingdemo) [ if (< $gamespeed 100) [ gamespeed (+ $gamespeed 10) ] [ gamespeed (+ $gamespeed 100) ]; gamespeed ] ]
alias key_demo_gamespeedreset [ if (watchingdemo) [ gamespeed 100; gamespeed ] ]
alias key_demo_togglespeed [ if (watchingdemo) [ onrelease (concat gamespeed $gamespeed) ; gamespeed 1000 ] ]
alias key_domodifier_1 [ domodifier 1 ]
alias key_domodifier_2 [ domodifier 2 ]
alias key_escape [ if $connected [ ingamemenu ] [ if (watchingdemo) [ showmenu [Watching demo] ] [ showmenu main ] ] ]
@@ -67,6 +63,12 @@ alias editkey_tagclip_clip [ edittagclip clip ]
alias editkey_scroll_spawns [ domodifier spawns ]
alias editkey_scroll_todoents [ domodifier todoents ]
alias speckey_demo_gamespeeddown [ if (watchingdemo) [ if (<= $gamespeed 100) [ gamespeed (- $gamespeed 10) ] [ gamespeed (- $gamespeed 100) ]; gamespeed ] ]
alias speckey_demo_gamespeedup [ if (watchingdemo) [ if (< $gamespeed 100) [ gamespeed (+ $gamespeed 10) ] [ gamespeed (+ $gamespeed 100) ]; gamespeed ] ]
alias speckey_demo_gamespeedreset [ if (watchingdemo) [ gamespeed 100; gamespeed ] ]
alias speckey_demo_togglespeed [ if (watchingdemo) [ onrelease (concat gamespeed $gamespeed) ; gamespeed 1000 ] ]
alias speckey_whois_spectatecn [ if (>= (spectatecn) 0) [ whois (spectatecn) ] ]
_defaultbinds 1 // do not save the following binds to saved.cfg
_resetallbinds
@@ -149,13 +151,14 @@ bind E edittoggle
editbind E edittoggle
bind F []
editbind F editkey_cubes_solid
specbind F key_demo_togglespeed
specbind F speckey_demo_togglespeed
bind G quicknadethrow
editbind G editkey_cubes_space
bind H []
editbind H editkey_cubes_hf_floor
bind I []
editbind I editkey_cubes_hf_ceiling
specbind I speckey_whois_spectatecn
bind J []
bind K []
editbind K corner
@@ -216,15 +219,15 @@ bind INSERT []
editbind INSERT editkey_floortex_up
bind HOME []
editbind HOME editkey_walltex_up
specbind HOME key_demo_gamespeedreset
specbind HOME speckey_demo_gamespeedreset
bind END []
editbind END editkey_walltex_dn
bind PAGEUP []
editbind PAGEUP editkey_ceiltex_up
specbind PAGEUP key_demo_gamespeedup
specbind PAGEUP speckey_demo_gamespeedup
bind PAGEDOWN []
editbind PAGEDOWN editkey_ceiltex_dn
specbind PAGEDOWN key_demo_gamespeeddown
specbind PAGEDOWN speckey_demo_gamespeeddown
bind F1 key_voteyes
bind F2 key_voteno
bind F3 []
+18 -4
View File
@@ -1662,6 +1662,8 @@ void spectate()
else tryrespawn();
}
COMMAND(spectate, "");
void setfollowplayer(int cn)
{
// silently ignores invalid player-cn value passed
@@ -1675,6 +1677,8 @@ void setfollowplayer(int cn)
}
}
COMMANDF(setfollowplayer, "i", (int *cn) { setfollowplayer(*cn); });
// set new spect mode
void spectatemode(int mode)
{
@@ -1713,6 +1717,8 @@ void spectatemode(int mode)
player1->spectatemode = mode;
}
COMMANDF(spectatemode, "i", (int *mode) { spectatemode(*mode); });
void togglespect() // cycle through all spectating modes
{
if(m_botmode)
@@ -1726,16 +1732,24 @@ void togglespect() // cycle through all spectating modes
}
}
COMMAND(togglespect, "");
void changefollowplayer(int shift)
{
if(!m_botmode) updatefollowplayer(shift);
}
COMMAND(spectate, "");
COMMANDF(spectatemode, "i", (int *mode) { spectatemode(*mode); });
COMMAND(togglespect, "");
COMMANDF(changefollowplayer, "i", (int *dir) { changefollowplayer(*dir); });
COMMANDF(setfollowplayer, "i", (int *cn) { setfollowplayer(*cn); });
void spectatecn()
{
int spectcn = -1;
if(player1->isspectating() && player1->spectatemode >= SM_FOLLOW1ST && player1->spectatemode <= SM_FOLLOW3RD_TRANSPARENT)
spectcn = player1->followplayercn;
intret(spectcn);
}
COMMAND(spectatecn, "");
void serverextension(char *ext, char *args)
{