Skip to content

Commit

Permalink
Add UI preference menus for AI hologram and status displays (tgstatio…
Browse files Browse the repository at this point in the history
…n#75740)

This adds two new dropdown menus for AI preferences with holograms and
status displays. It also sets these preferences if admins transform a
player into an AI.
  • Loading branch information
timothymtorres authored Jun 23, 2023
1 parent d93e81c commit 2a19963
Show file tree
Hide file tree
Showing 16 changed files with 256 additions and 106 deletions.
20 changes: 20 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,26 @@
#define AI_EMOTION_BLUE_GLOW "Blue Glow"
#define AI_EMOTION_RED_GLOW "Red Glow"

///Defines for AI hologram preferences
#define AI_HOLOGRAM_BEAR "Bear"
#define AI_HOLOGRAM_CARP "Carp"
#define AI_HOLOGRAM_CAT "Cat"
#define AI_HOLOGRAM_CAT_2 "Cat Alternate"
#define AI_HOLOGRAM_CHICKEN "Chicken"
#define AI_HOLOGRAM_CORGI "Corgi"
#define AI_HOLOGRAM_COW "Cow"
#define AI_HOLOGRAM_CRAB "Crab"
#define AI_HOLOGRAM_DEFAULT "Default"
#define AI_HOLOGRAM_FACE "Floating Face"
#define AI_HOLOGRAM_FOX "Fox"
#define AI_HOLOGRAM_GOAT "Goat"
#define AI_HOLOGRAM_NARSIE "Narsie"
#define AI_HOLOGRAM_PARROT "Parrot"
#define AI_HOLOGRAM_PUG "Pug"
#define AI_HOLOGRAM_RATVAR "Ratvar"
#define AI_HOLOGRAM_SPIDER "Spider"
#define AI_HOLOGRAM_XENO "Xeno Queen"

/// Icon state to use for ai displays that just turns them off
#define AI_DISPLAY_DONT_GLOW "ai_off"
/// Throw modes, defines whether or not to turn off throw mode after
Expand Down
62 changes: 0 additions & 62 deletions code/_globalvars/lists/flavor_misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -122,68 +122,6 @@ GLOBAL_LIST_INIT(ghost_forms_with_accessories_list, list(
))
//stores the ghost forms that support hair and other such things

GLOBAL_LIST_INIT(ai_core_display_screens, sort_list(list(
":thinking:",
"Alien",
"Angel",
"Banned",
"Bliss",
"Blue",
"Clown",
"Database",
"Dorf",
"Firewall",
"Fuzzy",
"Gentoo",
"Glitchman",
"Gondola",
"Goon",
"Hades",
"HAL 9000",
"Heartline",
"Helios",
"House",
"Inverted",
"Matrix",
"Monochrome",
"Murica",
"Nanotrasen",
"Not Malf",
"Portrait",
"President",
"Rainbow",
"Random",
"Red October",
"Red",
"Static",
"Syndicat Meow",
"Text",
"Too Deep",
"Triumvirate-M",
"Triumvirate",
"Weird",
)))

/// A form of resolve_ai_icon that is guaranteed to never sleep.
/// Not always accurate, but always synchronous.
/proc/resolve_ai_icon_sync(input)
SHOULD_NOT_SLEEP(TRUE)

if(!input || !(input in GLOB.ai_core_display_screens))
return "ai"
else
if(input == "Random")
input = pick(GLOB.ai_core_display_screens - "Random")
return "ai-[lowertext(input)]"

/proc/resolve_ai_icon(input)
if (input == "Portrait")
var/datum/portrait_picker/tgui = new(usr)//create the datum
tgui.ui_interact(usr)//datum has a tgui component, here we open the window
return "ai-portrait" //just take this until they decide

return resolve_ai_icon_sync(input)

GLOBAL_LIST_INIT(security_depts_prefs, sort_list(list(
SEC_DEPT_ENGINEERING,
SEC_DEPT_MEDICAL,
Expand Down
30 changes: 4 additions & 26 deletions code/game/machinery/status_display.dm
Original file line number Diff line number Diff line change
Expand Up @@ -463,29 +463,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/status_display/evac, 32)
name = "\improper AI display"
desc = "A small screen which the AI can use to present itself."
current_mode = SD_PICTURE

var/emotion = AI_EMOTION_BLANK

/// A mapping between AI_EMOTION_* string constants, which also double as user readable descriptions, and the name of the iconfile.
var/static/list/emotion_map = list(
AI_EMOTION_BLANK = AI_DISPLAY_DONT_GLOW,
AI_EMOTION_VERY_HAPPY = "ai_veryhappy",
AI_EMOTION_HAPPY = "ai_happy",
AI_EMOTION_NEUTRAL = "ai_neutral",
AI_EMOTION_UNSURE = "ai_unsure",
AI_EMOTION_CONFUSED = "ai_confused",
AI_EMOTION_SAD = "ai_sad",
AI_EMOTION_BSOD = "ai_bsod",
AI_EMOTION_PROBLEMS = "ai_trollface",
AI_EMOTION_AWESOME = "ai_awesome",
AI_EMOTION_DORFY = "ai_urist",
AI_EMOTION_THINKING = "ai_thinking",
AI_EMOTION_FACEPALM = "ai_facepalm",
AI_EMOTION_FRIEND_COMPUTER = "ai_friend",
AI_EMOTION_BLUE_GLOW = "ai_sal",
AI_EMOTION_RED_GLOW = "ai_hal",
)

var/emotion = AI_DISPLAY_DONT_GLOW

MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/status_display/ai, 32)

Expand All @@ -501,8 +479,8 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/status_display/ai, 32)
if(!isAI(user))
return
var/list/choices = list()
for(var/emotion_const in emotion_map)
var/icon_state = emotion_map[emotion_const]
for(var/emotion_const in GLOB.ai_status_display_emotes)
var/icon_state = GLOB.ai_status_display_emotes[emotion_const]
choices[emotion_const] = image(icon = 'icons/obj/status_display.dmi', icon_state = icon_state)

var/emotion_result = show_radial_menu(user, src, choices, tooltips = TRUE)
Expand All @@ -517,7 +495,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/status_display/ai, 32)
update_appearance()
return PROCESS_KILL

set_picture(emotion_map[emotion])
set_picture(GLOB.ai_status_display_emotes[emotion])
return PROCESS_KILL

/obj/item/circuit_component/status_display
Expand Down
2 changes: 1 addition & 1 deletion code/modules/client/preferences/ai_core_display.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/datum/preference/choiced/ai_core_display/init_possible_values()
var/list/values = list()

values["Random"] = icon('icons/mob/silicon/ai.dmi', "ai-empty")
values["Random"] = icon('icons/mob/silicon/ai.dmi', "questionmark")

for (var/screen in GLOB.ai_core_display_screens - "Portrait" - "Random")
values[screen] = icon('icons/mob/silicon/ai.dmi', resolve_ai_icon_sync(screen))
Expand Down
26 changes: 26 additions & 0 deletions code/modules/client/preferences/ai_emote_display.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// What to show on the AI monitor
/datum/preference/choiced/ai_emote_display
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "preferred_ai_emote_display"
should_generate_icons = TRUE

/datum/preference/choiced/ai_emote_display/init_possible_values()
var/list/values = list()

values["Random"] = icon('icons/mob/silicon/ai.dmi', "questionmark")

for(var/emote in GLOB.ai_status_display_emotes)
var/emote_icon = GLOB.ai_status_display_emotes[emote]
values[emote] = icon('icons/obj/status_display.dmi', emote_icon)

return values

/datum/preference/choiced/ai_emote_display/is_accessible(datum/preferences/preferences)
if (!..(preferences))
return FALSE

return istype(preferences.get_highest_priority_job(), /datum/job/ai)

/datum/preference/choiced/ai_emote_display/apply_to_human(mob/living/carbon/human/target, value)
return
25 changes: 25 additions & 0 deletions code/modules/client/preferences/ai_hologram_display.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/// What to show on the AI hologram
/datum/preference/choiced/ai_hologram_display
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "preferred_ai_hologram_display"
should_generate_icons = TRUE

/datum/preference/choiced/ai_hologram_display/init_possible_values()
var/list/values = list()

values["Random"] = icon('icons/mob/silicon/ai.dmi', "questionmark")

for(var/hologram in GLOB.ai_hologram_icons - "Random")
values[hologram] = icon(GLOB.ai_hologram_icons[hologram], GLOB.ai_hologram_icon_state[hologram])

return values

/datum/preference/choiced/ai_hologram_display/is_accessible(datum/preferences/preferences)
if (!..(preferences))
return FALSE

return istype(preferences.get_highest_priority_job(), /datum/job/ai)

/datum/preference/choiced/ai_hologram_display/apply_to_human(mob/living/carbon/human/target, value)
return
3 changes: 2 additions & 1 deletion code/modules/jobs/job_types/_job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,8 @@
return
apply_pref_name(/datum/preference/name/ai, player_client) // This proc already checks if the player is appearance banned.
set_core_display_icon(null, player_client)

apply_pref_emote_display(player_client)
apply_pref_hologram_display(player_client)

/mob/living/silicon/robot/apply_prefs_job(client/player_client, datum/job/job)
if(mmi)
Expand Down
126 changes: 126 additions & 0 deletions code/modules/mob/living/silicon/ai/_preferences.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// A mapping between AI_EMOTION_* string constants, which also double as user readable descriptions, and the name of the iconfile. (used for /obj/machinery/status_display/ai )
GLOBAL_LIST_INIT(ai_status_display_emotes, list(
AI_EMOTION_AWESOME = "ai_awesome",
AI_EMOTION_BLANK = AI_DISPLAY_DONT_GLOW,
AI_EMOTION_BLUE_GLOW = "ai_sal",
AI_EMOTION_BSOD = "ai_bsod",
AI_EMOTION_CONFUSED = "ai_confused",
AI_EMOTION_DORFY = "ai_urist",
AI_EMOTION_FACEPALM = "ai_facepalm",
AI_EMOTION_FRIEND_COMPUTER = "ai_friend",
AI_EMOTION_HAPPY = "ai_happy",
AI_EMOTION_NEUTRAL = "ai_neutral",
AI_EMOTION_PROBLEMS = "ai_trollface",
AI_EMOTION_RED_GLOW = "ai_hal",
AI_EMOTION_SAD = "ai_sad",
AI_EMOTION_THINKING = "ai_thinking",
AI_EMOTION_UNSURE = "ai_unsure",
AI_EMOTION_VERY_HAPPY = "ai_veryhappy",
))

// New items need to also be added to ai_hologram_icon_state list
GLOBAL_LIST_INIT(ai_hologram_icons, list(
AI_HOLOGRAM_BEAR = 'icons/mob/simple/animal.dmi',
AI_HOLOGRAM_CARP = 'icons/mob/simple/carp.dmi',
AI_HOLOGRAM_CAT = 'icons/mob/simple/pets.dmi',
AI_HOLOGRAM_CAT_2 = 'icons/mob/simple/pets.dmi',
AI_HOLOGRAM_CHICKEN = 'icons/mob/simple/animal.dmi',
AI_HOLOGRAM_CORGI = 'icons/mob/simple/pets.dmi',
AI_HOLOGRAM_COW = 'icons/mob/simple/animal.dmi',
AI_HOLOGRAM_CRAB = 'icons/mob/simple/animal.dmi',
AI_HOLOGRAM_DEFAULT = 'icons/mob/silicon/ai.dmi',
AI_HOLOGRAM_FACE = 'icons/mob/silicon/ai.dmi',
AI_HOLOGRAM_FOX = 'icons/mob/simple/pets.dmi',
AI_HOLOGRAM_GOAT = 'icons/mob/simple/animal.dmi',
AI_HOLOGRAM_NARSIE = 'icons/mob/silicon/ai.dmi',
AI_HOLOGRAM_PARROT = 'icons/mob/simple/animal.dmi',
AI_HOLOGRAM_PUG = 'icons/mob/simple/pets.dmi',
AI_HOLOGRAM_RATVAR = 'icons/mob/silicon/ai.dmi',
AI_HOLOGRAM_SPIDER = 'icons/mob/simple/animal.dmi',
AI_HOLOGRAM_XENO = 'icons/mob/nonhuman-player/alien.dmi',
))

// New items need to also be added to ai_hologram_icons list
GLOBAL_LIST_INIT(ai_hologram_icon_state, list(
AI_HOLOGRAM_BEAR = "bear",
AI_HOLOGRAM_CARP = "carp",
AI_HOLOGRAM_CAT = "cat",
AI_HOLOGRAM_CAT_2 = "cat2",
AI_HOLOGRAM_CHICKEN = "chicken_brown",
AI_HOLOGRAM_CORGI = "corgi",
AI_HOLOGRAM_COW = "cow",
AI_HOLOGRAM_CRAB = "crab",
AI_HOLOGRAM_DEFAULT = "default",
AI_HOLOGRAM_FACE = "floating face",
AI_HOLOGRAM_FOX = "fox",
AI_HOLOGRAM_GOAT = "goat",
AI_HOLOGRAM_NARSIE = "horror",
AI_HOLOGRAM_PARROT = "parrot_fly",
AI_HOLOGRAM_PUG = "pug",
AI_HOLOGRAM_RATVAR = "clock",
AI_HOLOGRAM_SPIDER = "guard",
AI_HOLOGRAM_XENO = "alienq",
))


GLOBAL_LIST_INIT(ai_core_display_screens, sort_list(list(
":thinking:",
"Alien",
"Angel",
"Banned",
"Bliss",
"Blue",
"Clown",
"Database",
"Dorf",
"Firewall",
"Fuzzy",
"Gentoo",
"Glitchman",
"Gondola",
"Goon",
"Hades",
"HAL 9000",
"Heartline",
"Helios",
"House",
"Inverted",
"Matrix",
"Monochrome",
"Murica",
"Nanotrasen",
"Not Malf",
"Portrait",
"President",
"Rainbow",
"Random",
"Red October",
"Red",
"Static",
"Syndicat Meow",
"Text",
"Too Deep",
"Triumvirate-M",
"Triumvirate",
"Weird",
)))

/// A form of resolve_ai_icon that is guaranteed to never sleep.
/// Not always accurate, but always synchronous.
/proc/resolve_ai_icon_sync(input)
SHOULD_NOT_SLEEP(TRUE)

if(!input || !(input in GLOB.ai_core_display_screens))
return "ai"
else
if(input == "Random")
input = pick(GLOB.ai_core_display_screens - "Random")
return "ai-[lowertext(input)]"

/proc/resolve_ai_icon(input)
if (input == "Portrait")
var/datum/portrait_picker/tgui = new(usr)//create the datum
tgui.ui_interact(usr)//datum has a tgui component, here we open the window
return "ai-portrait" //just take this until they decide

return resolve_ai_icon_sync(input)
Loading

0 comments on commit 2a19963

Please sign in to comment.