Skip to content

Commit

Permalink
port: tgui say (#5605)
Browse files Browse the repository at this point in the history
* tgsay

* some const

* paradisedme

* more constants!

* budle

* talk dmi

* FINAL?

* clean
  • Loading branch information
ROdenFL authored Aug 17, 2024
1 parent 5f5aabb commit aeff8e8
Show file tree
Hide file tree
Showing 69 changed files with 1,784 additions and 288 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/keybindings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define KB_CATEGORY_EMOTE_SILICON 14
#define KB_CATEGORY_EMOTE_ANIMAL 15
#define KB_CATEGORY_EMOTE_CUSTOM 16
#define KB_CATEGORY_COMMUNICATION 17
#define KB_CATEGORY_UNSORTED 1000

///Max length of a keypress command before it's considered to be a forged packet/bogus command
Expand Down
49 changes: 25 additions & 24 deletions code/__DEFINES/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define PREFTOGGLE_CHAT_GHOSTSIGHT (1<<3)
#define PREFTOGGLE_CHAT_PRAYER (1<<4)
#define PREFTOGGLE_CHAT_RADIO (1<<5)
#define PREFTOGGLE_AZERTY (1<<6)
// #define PREFTOGGLE_AZERTY (1<<6) // obsolete
#define PREFTOGGLE_CHAT_DEBUGLOGS (1<<7)
#define PREFTOGGLE_CHAT_LOOC (1<<8)
#define PREFTOGGLE_CHAT_GHOSTRADIO (1<<9)
Expand All @@ -33,37 +33,38 @@
//#define PREFTOGGLE_UI_DARKMODE (1<<17) //not used since tgchat
#define PREFTOGGLE_DISABLE_KARMA (1<<18)
#define PREFTOGGLE_CHAT_NO_MENTORTICKETLOGS (1<<19)
#define PREFTOGGLE_TYPING_ONCE (1<<20)
// #define PREFTOGGLE_TYPING_ONCE (1<<20) // Not used since tgui say
#define PREFTOGGLE_AMBIENT_OCCLUSION (1<<21)
#define PREFTOGGLE_CHAT_GHOSTPDA (1<<22)
#define PREFTOGGLE_NUMPAD_TARGET (1<<23)
// #define PREFTOGGLE_NUMPAD_TARGET 8388608 // Made obsolete with key bindings

#define TOGGLES_TOTAL 16777215 // If you add or remove a preference toggle above, make sure you update this define with the total value of the toggles combined.

#define TOGGLES_DEFAULT (PREFTOGGLE_CHAT_OOC|PREFTOGGLE_CHAT_DEAD|PREFTOGGLE_CHAT_GHOSTEARS|PREFTOGGLE_CHAT_GHOSTSIGHT|PREFTOGGLE_CHAT_PRAYER|PREFTOGGLE_CHAT_RADIO|PREFTOGGLE_CHAT_LOOC|PREFTOGGLE_MEMBER_PUBLIC|PREFTOGGLE_DONATOR_PUBLIC|PREFTOGGLE_AMBIENT_OCCLUSION|PREFTOGGLE_CHAT_GHOSTPDA|PREFTOGGLE_NUMPAD_TARGET)
#define TOGGLES_DEFAULT (PREFTOGGLE_CHAT_OOC|PREFTOGGLE_CHAT_DEAD|PREFTOGGLE_CHAT_GHOSTEARS|PREFTOGGLE_CHAT_GHOSTSIGHT|PREFTOGGLE_CHAT_PRAYER|PREFTOGGLE_CHAT_RADIO|PREFTOGGLE_CHAT_LOOC|PREFTOGGLE_MEMBER_PUBLIC|PREFTOGGLE_DONATOR_PUBLIC|PREFTOGGLE_AMBIENT_OCCLUSION|PREFTOGGLE_CHAT_GHOSTPDA)

// toggles_2 variables. These MUST be prefixed with PREFTOGGLE_2
#define PREFTOGGLE_2_RANDOMSLOT (1<<0) // 1
#define PREFTOGGLE_2_FANCYUI (1<<1) // 2
#define PREFTOGGLE_2_ITEMATTACK (1<<2) // 4
#define PREFTOGGLE_2_WINDOWFLASHING (1<<3) // 8
#define PREFTOGGLE_2_ANON (1<<4) // 16
#define PREFTOGGLE_2_AFKWATCH (1<<5) // 32
#define PREFTOGGLE_2_RUNECHAT (1<<6) // 64
#define PREFTOGGLE_2_DEATHMESSAGE (1<<7) // 128
#define PREFTOGGLE_2_EMOTE_BUBBLE (1<<8) // 256
#define PREFTOGGLE_2_SEE_ITEM_OUTLINES (1<<9) // 512
#define PREFTOGGLE_2_RANDOMSLOT (1<<0) // 1
#define PREFTOGGLE_2_FANCYUI (1<<1) // 2
#define PREFTOGGLE_2_ITEMATTACK (1<<2) // 4
#define PREFTOGGLE_2_WINDOWFLASHING (1<<3) // 8
#define PREFTOGGLE_2_ANON (1<<4) // 16
#define PREFTOGGLE_2_AFKWATCH (1<<5) // 32
#define PREFTOGGLE_2_RUNECHAT (1<<6) // 64
#define PREFTOGGLE_2_DEATHMESSAGE (1<<7) // 128
// #define PREFTOGGLE_2_EMOTE_BUBBLE (1<<8) // 256 tgui say(maybe temporary)
#define PREFTOGGLE_2_SEE_ITEM_OUTLINES (1<<9) // 512
// Yes I know this being an "enable to disable" is misleading, but it avoids having to tweak all existing pref entries
#define PREFTOGGLE_2_REVERB_DISABLE (1<<10) // 1024
#define PREFTOGGLE_2_MC_TAB (1<<11) // 2048
#define PREFTOGGLE_2_DISABLE_TGUI_INPUT (1<<12) // 4096
#define PREFTOGGLE_2_PARALLAX_MULTIZ (1<<13) // 8192
#define PREFTOGGLE_2_DISABLE_VOTE_POPUPS (1<<14) // 16384
#define PREFTOGGLE_2_SWAP_INPUT_BUTTONS (1<<15) // 32768
#define PREFTOGGLE_2_LARGE_INPUT_BUTTONS (1<<16) // 65536
#define PREFTOGGLE_2_BIG_STRIP_MENU (1<<17) // 131072

#define TOGGLES_2_TOTAL 262143 // If you add or remove a preference toggle above, make sure you update this define with the total value of the toggles combined.
#define PREFTOGGLE_2_REVERB_DISABLE (1<<10) // 1024
#define PREFTOGGLE_2_MC_TAB (1<<11) // 2048
#define PREFTOGGLE_2_DISABLE_TGUI_INPUT (1<<12) // 4096
#define PREFTOGGLE_2_PARALLAX_MULTIZ (1<<13) // 8192
#define PREFTOGGLE_2_DISABLE_VOTE_POPUPS (1<<14) // 16384
#define PREFTOGGLE_2_SWAP_INPUT_BUTTONS (1<<15) // 32768
#define PREFTOGGLE_2_LARGE_INPUT_BUTTONS (1<<16) // 65536
#define PREFTOGGLE_2_BIG_STRIP_MENU (1<<17) // 131072
#define PREFTOGGLE_2_ENABLE_TGUI_SAY_LIGHT_MODE (1<<18) // 262144

#define TOGGLES_2_TOTAL 524287// If you add or remove a preference toggle above, make sure you update this define with the total value of the toggles combined.

#define TOGGLES_2_DEFAULT (PREFTOGGLE_2_FANCYUI|PREFTOGGLE_2_ITEMATTACK|PREFTOGGLE_2_WINDOWFLASHING|PREFTOGGLE_2_RUNECHAT|PREFTOGGLE_2_DEATHMESSAGE|PREFTOGGLE_2_SEE_ITEM_OUTLINES|PREFTOGGLE_2_PARALLAX_MULTIZ|PREFTOGGLE_2_SWAP_INPUT_BUTTONS|PREFTOGGLE_2_LARGE_INPUT_BUTTONS)

Expand Down
10 changes: 10 additions & 0 deletions code/__DEFINES/speech_channels.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Used to direct channels to speak into.
#define SAY_CHANNEL "Say"
#define RADIO_CHANNEL "Radio"
#define WHISPER_CHANNEL "Whisper"
#define ME_CHANNEL "Me"
#define OOC_CHANNEL "OOC"
#define LOOC_CHANNEL "LOOC"
#define MENTOR_CHANNEL "Mentor"
#define ADMIN_CHANNEL "Admin"
#define DSAY_CHANNEL "Dsay"
2 changes: 0 additions & 2 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,6 @@

return locate(/mob) in A

// Suppress the mouse macros
/client/var/next_mouse_macro_warning
/mob/proc/LogMouseMacro(verbused, params)
if(!client)
return
Expand Down
6 changes: 4 additions & 2 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@

// Uses client.typing to check if the popup should appear or not
/proc/typing_input(mob/user, message = "", title = "", default = "")
if(user.client.checkTyping()) // Prevent double windows
return null
var/client/C = user.client // Save it in a var in case the client disconnects from the mob
C.typing = TRUE
var/msg = input(user, message, title, default) as text|null
Expand Down Expand Up @@ -313,6 +311,10 @@
/proc/trim(text)
return trim_reduced(text)

/// Returns a string that does not exceed max_length characters in size
/proc/trim_length(text, max_length)
return copytext_char(text, 1, max_length)

//Returns a string with the first element of the string capitalized.
/proc/capitalize(var/t as text)
return uppertext(copytext_char(t, 1, 2)) + copytext_char(t, 2)
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/lists/keybindings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ GLOBAL_LIST_EMPTY(default_hotkeys)

GLOBAL_LIST_INIT(keybindings_groups, list(
"Movement" = KB_CATEGORY_MOVEMENT,
"Communication" = KB_CATEGORY_COMMUNICATION,
"Living" = KB_CATEGORY_LIVING,
"General" = KB_CATEGORY_MOB,
"General Emote" = KB_CATEGORY_EMOTE_GENERIC,
Expand Down
4 changes: 2 additions & 2 deletions code/datums/emote/emote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@

if(intentional && only_unintentional)
return FALSE
if(user.client?.prefs.muted & MUTE_EMOTE)
if(user.client && check_mute(user.client.ckey, MUTE_EMOTE))
to_chat(user, span_warning("You cannot send emotes (muted)."))
return FALSE

Expand Down Expand Up @@ -512,7 +512,7 @@
return FALSE
else
// deadchat handling
if(user.client?.prefs.muted & MUTE_DEADCHAT)
if(user.client && check_mute(user.client.ckey, MUTE_DEADCHAT))
to_chat(user, span_warning("You cannot send deadchat emotes (muted)."))
return FALSE
if(!(user.client?.prefs.toggles & PREFTOGGLE_CHAT_DEAD))
Expand Down
40 changes: 0 additions & 40 deletions code/datums/keybindings/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,6 @@
return TRUE


/datum/keybinding/admin/msay
name = "Msay (for admins)"
keys = list("ShiftF5")


/datum/keybinding/admin/msay/down(client/user)
. = ..()
if(.)
return .
user.get_mentor_say()
return TRUE


/datum/keybinding/admin/asay
name = "Msay/Asay"
keys = list("F5")


/datum/keybinding/admin/asay/down(client/user)
. = ..()
if(.)
return .
user.get_admin_say()
return TRUE


/datum/keybinding/admin/aghost
name = "Aghost"
keys = list("F6")
Expand Down Expand Up @@ -104,17 +78,3 @@
return .
user.invisimin()
return TRUE


/datum/keybinding/admin/dsay
name = "Dsay"
keys = list("F10")


/datum/keybinding/admin/dsay/down(client/user)
. = ..()
if(.)
return .
user.get_dead_say()
return TRUE

52 changes: 0 additions & 52 deletions code/datums/keybindings/client.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,58 +15,6 @@
return TRUE


/datum/keybinding/client/ooc
name = "OOC"
keys = list("F2", "O")


/datum/keybinding/client/ooc/down(client/user)
. = ..()
if(.)
return .
user.ooc()
return TRUE


/datum/keybinding/client/looc
name = "Локальный OOC"
keys = list("L")


/datum/keybinding/client/looc/down(client/user)
. = ..()
if(.)
return .
user.looc()
return TRUE


/datum/keybinding/client/say
name = "Say"
keys = list("F3", "T")


/datum/keybinding/client/say/down(client/user)
. = ..()
if(.)
return .
user.mob.say_wrapper()
return TRUE


/datum/keybinding/client/me
name = "Me"
keys = list("F4", "M")


/datum/keybinding/client/me/down(client/user)
. = ..()
if(.)
return .
user.mob.me_wrapper()
return TRUE


/datum/keybinding/client/t_fullscreen
name = "Переключить Fullscreen"
keys = list("F11")
Expand Down
74 changes: 74 additions & 0 deletions code/datums/keybindings/communication_keybinds.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/datum/keybinding/client/communication
category = KB_CATEGORY_COMMUNICATION
/// Used to store special rights if required by a keybind, such as R_ADMIN
var/required_rights
/// Used to map muted categories to channels
var/mute_category = MUTE_OOC

/datum/keybinding/client/communication/down(client/C)
. = ..()
if(required_rights && !check_rights(required_rights, FALSE, C.mob))
return

if(mute_category && check_mute(C.ckey, mute_category))
to_chat(C, "<span class='danger'>You cannot use [name] (muted).</span>", MESSAGE_TYPE_WARNING)
return

winset(C, null, "command=[C.tgui_say_create_open_command(name)]")

/datum/keybinding/client/communication/ooc
name = OOC_CHANNEL
keys = list("O")

/datum/keybinding/client/communication/ooc/down(client/C)
if(check_rights(R_ADMIN, FALSE, C.mob)) // You may pass
return ..()

if(!CONFIG_GET(flag/ooc_allowed))
to_chat(C, "<span class='danger'>OOC is globally muted.</span>", MESSAGE_TYPE_WARNING)
return

if(!CONFIG_GET(flag/dooc_allowed))
to_chat(C, "<span class='danger'>OOC for dead mobs has been turned off.</span>", MESSAGE_TYPE_WARNING)
return

return ..()

/datum/keybinding/client/communication/looc
name = LOOC_CHANNEL
keys = list("L")

/datum/keybinding/client/communication/say
name = SAY_CHANNEL
keys = list("T")
mute_category = MUTE_IC

/datum/keybinding/client/communication/me
name = ME_CHANNEL
keys = list("M")
mute_category = MUTE_EMOTE

/datum/keybinding/client/communication/whisper
name = WHISPER_CHANNEL
keys = list("U")
mute_category = MUTE_IC

/datum/keybinding/client/communication/radio
name = RADIO_CHANNEL
keys = list("Y")
mute_category = MUTE_IC

/datum/keybinding/client/communication/msay
name = MENTOR_CHANNEL
keys = list("F4")
required_rights = R_MENTOR | R_ADMIN

/datum/keybinding/client/communication/asay
name = ADMIN_CHANNEL
keys = list("F5")
required_rights = R_ADMIN

/datum/keybinding/client/communication/dsay
name = DSAY_CHANNEL
keys = list("F10")
required_rights = R_ADMIN
20 changes: 0 additions & 20 deletions code/datums/keybindings/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,6 @@
return TRUE


/datum/keybinding/living/whisper
name = "Шептать"
keys = list("ShiftT")


/datum/keybinding/living/whisper/down(client/user)
. = ..()
if(.)
return .
var/mob/living/living_mob = user.mob
living_mob.set_typing_indicator(TRUE)
living_mob.hud_typing = TRUE
var/message = typing_input(living_mob, "", "Whisper (text)")
living_mob.hud_typing = FALSE
living_mob.set_typing_indicator(FALSE)
if(message)
living_mob.whisper(message)
return TRUE


/datum/keybinding/living/look_up
name = "Взглянуть вверх"
keys = list("Northwest") // Home
Expand Down
8 changes: 4 additions & 4 deletions code/game/dna/genes/vg_powers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@
for(var/mob/living/target in targets)
var/datum/atom_hud/thoughts/hud = GLOB.huds[THOUGHTS_HUD]
hud.manage_hud(target, THOUGHTS_HUD_PRECISE)
user.hud_typing = TRUE
// user.hud_typing = TRUE do not know what to do
user.thoughts_hud_set(TRUE)
var/say = tgui_input_text(user, "What do you wish to say?", "Project Mind")
user.hud_typing = FALSE
// user.hud_typing = FALSE
user.typing = FALSE
if(!say || usr.stat)
hud.manage_hud(target, THOUGHTS_HUD_DISPERSE)
Expand Down Expand Up @@ -305,10 +305,10 @@
var/mob/living/target = locateUID(href_list["target"])
if(!(target in available_targets))
return
target.hud_typing = TRUE
// target.hud_typing = TRUE
target.thoughts_hud_set(TRUE)
var/say = tgui_input_text(user, "What do you wish to say?", "Scan Mind")
target.hud_typing = FALSE
// target.hud_typing = FALSE
target.typing = FALSE
if(!say || target.stat)
target.thoughts_hud_set(FALSE)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/blob/overmind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
return

if(client)
if(client.prefs.muted & MUTE_IC)
if(check_mute(client.ckey, MUTE_IC))
to_chat(src, "You cannot send IC messages (muted).")
return
if(client.handle_spam_prevention(message, MUTE_IC))
Expand Down
Loading

0 comments on commit aeff8e8

Please sign in to comment.