Skip to content

Commit

Permalink
Every observer now has persistent HUDs defined by the client preferen…
Browse files Browse the repository at this point in the history
…ces (ColonialMarines-Mirror#552)

* Fixes AP ammo box empty icon state. Fixes the examine.

* Every observer now has three huds enabled by default (Med,Squad,Xeno)

* fucks shit up

* Unfucks shit and actually works

* Fix

* I'm stupid

* Changes
  • Loading branch information
Dominik Panic authored and Rohesie committed Oct 26, 2018
1 parent 5269dae commit 2425fe6
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 24 deletions.
6 changes: 6 additions & 0 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ datum/preferences
var/predator_armor_type = 1
var/predator_boot_type = 1

//Ghost preferences
var/ghost_medhud = 1
var/ghost_sechud = 0
var/ghost_squadhud = 1
var/ghost_xenohud = 1

//character preferences
var/real_name //our character's name
var/be_random_name = 0 //whether we are a random name every round
Expand Down
28 changes: 23 additions & 5 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define SAVEFILE_VERSION_MIN 8
#define SAVEFILE_VERSION_MAX 12
#define SAVEFILE_VERSION_MIN 12
#define SAVEFILE_VERSION_MAX 16

//handles converting savefiles to new formats
//MAKE SURE YOU KEEP THIS UP TO DATE!
Expand All @@ -20,11 +20,14 @@
break
return 0

if(savefile_version < 12) //we've split toggles into toggles_sound and toggles_chat
if(savefile_version < 16) //we've split toggles into toggles_sound and toggles_chat
// if(S["toggles"])
// cdel(S["toggles"])
S["toggles_chat"] << TOGGLES_SOUND_DEFAULT
S["toggles_chat"] << TOGGLES_CHAT_DEFAULT

S["ghost_medhud"] << 1
S["ghost_sechud"] << 0
S["ghost_squadhud"] << 1
S["ghost_xenohud"] << 1

savefile_version = SAVEFILE_VERSION_MAX
return 1
Expand Down Expand Up @@ -70,6 +73,11 @@
S["pred_armor_type"] >> predator_armor_type
S["pred_boot_type"] >> predator_boot_type

S["ghost_medhud"] >> ghost_medhud
S["ghost_sechud"] >> ghost_sechud
S["ghost_squadhud"] >> ghost_squadhud
S["ghost_xenohud"] >> ghost_xenohud

//Sanitize
ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor))
lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog))
Expand All @@ -90,6 +98,11 @@
predator_armor_type = sanitize_integer(predator_armor_type,1,1000000,initial(predator_armor_type))
predator_boot_type = sanitize_integer(predator_boot_type,1,1000000,initial(predator_boot_type))

ghost_medhud = sanitize_integer(ghost_medhud,0,1,initial(ghost_medhud))
ghost_sechud = sanitize_integer(ghost_sechud,0,1,initial(ghost_sechud))
ghost_squadhud = sanitize_integer(ghost_squadhud,0,1,initial(ghost_squadhud))
ghost_xenohud = sanitize_integer(ghost_xenohud,0,1,initial(ghost_xenohud))

return 1

/datum/preferences/proc/save_preferences()
Expand Down Expand Up @@ -118,6 +131,11 @@
S["pred_armor_type"] << predator_armor_type
S["pred_boot_type"] << predator_boot_type

S["ghost_medhud"] << ghost_medhud
S["ghost_sechud"] << ghost_sechud
S["ghost_squadhud"] << ghost_squadhud
S["ghost_xenohud"] << ghost_xenohud

return 1

/datum/preferences/proc/load_character(slot)
Expand Down
19 changes: 18 additions & 1 deletion code/modules/mob/dead/observer/login.dm
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
/mob/dead/observer/Login()
..()
ghost_medhud = client.prefs.ghost_medhud
ghost_sechud = client.prefs.ghost_sechud
ghost_squadhud = client.prefs.ghost_squadhud
ghost_xenohud = client.prefs.ghost_xenohud
var/datum/mob_hud/H
if(ghost_medhud)
H = huds[MOB_HUD_MEDICAL_OBSERVER]
H.add_hud_to(src)
if(ghost_sechud)
H = huds[MOB_HUD_SECURITY_ADVANCED]
H.add_hud_to(src)
if(ghost_squadhud)
H = huds[MOB_HUD_SQUAD]
H.add_hud_to(src)
if(ghost_xenohud)
H = huds[MOB_HUD_XENO_STATUS]
H.add_hud_to(src)
return ..()
71 changes: 53 additions & 18 deletions code/modules/mob/dead/observer/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,35 @@
//If you died in the game and are a ghsot - this will remain as null.
//Note that this is not a reliable way to determine if admins started as observers, since they change mobs a lot.
// var/has_enabled_antagHUD = 0
var/list/HUD_toggled = list(0,0,0,0)
// var/antagHUD = 0
var/ghost_medhud = 0
var/ghost_sechud = 0
var/ghost_squadhud = 0
var/ghost_xenohud = 0
// var/antagHUD = 0
universal_speak = 1
var/atom/movable/following = null

/mob/dead/observer/Login()
client.prefs.load_preferences()
ghost_medhud = client.prefs.ghost_medhud
ghost_sechud = client.prefs.ghost_sechud
ghost_squadhud = client.prefs.ghost_squadhud
ghost_xenohud = client.prefs.ghost_xenohud
var/datum/mob_hud/H
if(ghost_medhud)
H = huds[MOB_HUD_MEDICAL_OBSERVER]
H.add_hud_to(src)
if(ghost_sechud)
H = huds[MOB_HUD_SECURITY_ADVANCED]
H.add_hud_to(src)
if(ghost_squadhud)
H = huds[MOB_HUD_SQUAD]
H.add_hud_to(src)
if(ghost_xenohud)
H = huds[MOB_HUD_XENO_STATUS]
H.add_hud_to(src)
return ..()

/mob/dead/observer/New(mob/body)
sight |= SEE_TURFS|SEE_MOBS|SEE_OBJS|SEE_SELF
see_invisible = SEE_INVISIBLE_OBSERVER
Expand Down Expand Up @@ -68,6 +92,7 @@
if(!name) //To prevent nameless ghosts
name = capitalize(pick(first_names_male)) + " " + capitalize(pick(last_names))
real_name = name
Login()
..()
if(ticker && ticker.mode && ticker.mode.flags_round_type & MODE_PREDATOR)
spawn(20)
Expand Down Expand Up @@ -228,32 +253,42 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
var/hud_choice = input("Choose a HUD to toggle", "Toggle HUD", null) as null|anything in listed_huds
if(!client)
return
client.prefs.load_preferences()
ghost_medhud = client.prefs.ghost_medhud
ghost_sechud = client.prefs.ghost_sechud
ghost_squadhud = client.prefs.ghost_squadhud
ghost_xenohud = client.prefs.ghost_xenohud
var/datum/mob_hud/H
var/HUD_nbr = 1

switch(hud_choice)
if("Medical HUD")
ghost_medhud = !ghost_medhud
H = huds[MOB_HUD_MEDICAL_OBSERVER]
ghost_medhud ? H.add_hud_to(src) : H.remove_hud_from(src)
client.prefs.ghost_medhud = ghost_medhud
client.prefs.save_preferences()
to_chat(src, (ghost_medhud ? "\blue <B>[hud_choice] Enabled</B>" : "\blue <B>[hud_choice] Disabled</B>"))
if("Security HUD")
ghost_sechud = !ghost_sechud
H = huds[MOB_HUD_SECURITY_ADVANCED]
HUD_nbr = 2
ghost_sechud ? H.add_hud_to(src) : H.remove_hud_from(src)
client.prefs.ghost_sechud = ghost_sechud
client.prefs.save_preferences()
to_chat(src, (ghost_sechud ? "\blue <B>[hud_choice] Enabled</B>" : "\blue <B>[hud_choice] Disabled</B>"))
if("Squad HUD")
ghost_squadhud = !ghost_squadhud
H = huds[MOB_HUD_SQUAD]
HUD_nbr = 3
ghost_squadhud ? H.add_hud_to(src) : H.remove_hud_from(src)
client.prefs.ghost_squadhud = ghost_squadhud
client.prefs.save_preferences()
to_chat(src, (ghost_squadhud ? "\blue <B>[hud_choice] Enabled</B>" : "\blue <B>[hud_choice] Disabled</B>"))
if("Xeno Status HUD")
ghost_xenohud = !ghost_xenohud
H = huds[MOB_HUD_XENO_STATUS]
HUD_nbr = 4
else
return

if(HUD_toggled[HUD_nbr])
HUD_toggled[HUD_nbr] = 0
H.remove_hud_from(src)
to_chat(src, "\blue <B>[hud_choice] Disabled</B>")
else
HUD_toggled[HUD_nbr] = 1
H.add_hud_to(src)
to_chat(src, "\blue <B>[hud_choice] Enabled</B>")

ghost_xenohud ? H.add_hud_to(src) : H.remove_hud_from(src)
client.prefs.ghost_xenohud = ghost_xenohud
client.prefs.save_preferences()
to_chat(src, (ghost_xenohud ? "\blue <B>[hud_choice] Enabled</B>" : "\blue <B>[hud_choice] Disabled</B>"))


/mob/dead/observer/proc/dead_tele()
Expand Down

0 comments on commit 2425fe6

Please sign in to comment.