forked from p2sr/srconfigs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cm_ghost.cfg
35 lines (28 loc) · 3.61 KB
/
cm_ghost.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// We'll prompt the user as to whether they want to connect using toasts
// Util functions for temporarily fucking with cvars
sar_function __tmp_cvar_save "svar_from_cvar __tmp_cvar_$1 $1"
sar_function __tmp_cvar_restore "sar_expand $1 $$__tmp_cvar_$1"
// Capture svars quietly by temporarily filtering all console output
sar_function svar_capture_quiet "__tmp_cvar_save sar_con_filter; __tmp_cvar_save sar_con_filter_default; sar_con_filter 1; sar_con_filter_default 0; svar_capture $'$1$' $'$2$'; __tmp_cvar_restore sar_con_filter; __tmp_cvar_restore sar_con_filter_default"
// Temporarily save binds to svars so we can let the user just press a key
sar_function __tmp_bind_save "svar_capture_quiet __tmp $'bind $1$'; sar_expand __tmp_bind_save_h $$__tmp"
sar_function __tmp_bind_save_h "svar_set __tmp $2; cond $'!var:__tmp=is$' svar_set __tmp_bind_$1 $'$3$'"
sar_function __tmp_bind_restore "sar_expand svar_set __tmp $'$$__tmp_bind_$1$$-x$'; __choose $'var:__tmp=x$' $'unbind $1$' $'sar_expand bind $1 $$'$$__tmp_bind_$1$$'$'"
// Temporarily save the user's toast settings so we can make the toast
// big and imposing, like someone who is not zach
sar_alias __tmp_toast_save "__tmp_cvar_save sar_toast_x; __tmp_cvar_save sar_toast_y; __tmp_cvar_save sar_toast_align; __tmp_cvar_save sar_toast_anchor; __tmp_cvar_save sar_toast_disable; __tmp_cvar_save sar_toast_width; __tmp_cvar_save sar_toast_background; __tmp_cvar_save sar_toast_compact; __tmp_cvar_save sar_toast_font"
sar_alias __tmp_toast_restore "__tmp_cvar_restore sar_toast_x; __tmp_cvar_restore sar_toast_y; __tmp_cvar_restore sar_toast_align; __tmp_cvar_restore sar_toast_anchor; __tmp_cvar_restore sar_toast_disable; __tmp_cvar_restore sar_toast_width; __tmp_cvar_restore sar_toast_background; __tmp_cvar_restore sar_toast_compact; __tmp_cvar_restore sar_toast_font"
// Aliases for actually doing the prompt
sar_toast_tag_set_duration cm_ghost_warning forever
sar_alias __cm_ghost_warning cond "!var:__cm_ghost_warning=1" "svar_set __cm_ghost_warning 1; sar_toast_tag_dismiss_all speedrun; __tmp_toast_save; sar_toast_font 68; sar_toast_width 500; sar_toast_setpos top center; __tmp_bind_save y; __tmp_bind_save n; bind y __cm_ghost_accept; bind n __cm_ghost_reject; __cm_ghost_warning_text"
sar_alias __cm_ghost_warning_done cond "var:__cm_ghost_warning=1" "svar_set __cm_ghost_warning 0; sar_toast_tag_dismiss_all cm_ghost_warning; __tmp_toast_restore; __tmp_bind_restore y; __tmp_bind_restore n"
sar_function __cm_ghost_warning_text "sar_toast_create cm_ghost_warning $'This can be changed later via the 'cm_ghost_server' svar.$'; sar_toast_create cm_ghost_warning $'Press N to stay disconnected$'; sar_toast_create cm_ghost_warning $'Press Y to connect to the server$'; sar_toast_create cm_ghost_warning $'There is a world-wide 'ghost server' that players can connect to and chat on while playing Challenge Mode.$'; echo $'----> Press Y or N ingame, not here! <----$'"
sar_alias __cm_ghost_accept "svar_set cm_ghost_server 1; __cm_ghost_warning_done; __cm_ghost_tryconnect"
sar_alias __cm_ghost_reject "svar_set cm_ghost_server 0; __cm_ghost_warning_done"
sar_on_exit __cm_ghost_warning_done
// Show the prompt on first load if we've not decided whether to connect
sar_on_load cond "var:category=sp_cm & var:cm_ghost_server=-1" "__cm_ghost_warning"
// Aliases to actually connect
sar_alias __cm_ghost_tryconnect cond "var:category=sp_cm & var:cm_ghost_server=1 & !var:__cm_ghosts=1" "svar_set __cm_ghosts 1; ghost_connect cm.portal2.sr"
sar_on_load __cm_ghost_tryconnect
sar_on_load cond "!(var:category=sp_cm & var:cm_ghost_server=1) & var:__cm_ghosts=1" "svar_set __cm_ghosts 0; ghost_disconnect"