Merge pull request #8581 from Ghommie/Ghommie-cit42

[Ready]Reskinnable PDAs.
This commit is contained in:
kevinz000
2019-06-28 20:30:05 -07:00
committed by GitHub
16 changed files with 182 additions and 99 deletions
+98 -42
View File
@@ -10,6 +10,15 @@ GLOBAL_LIST_EMPTY(PDAs)
#define PDA_SCANNER_HALOGEN 4
#define PDA_SCANNER_GAS 5
#define PDA_SPAM_DELAY 2 MINUTES
#define PDA_STANDARD_OVERLAYS list("pda-r", "blank", "id_overlay", "insert_overlay", "light_overlay", "pai_overlay")
//pda icon overlays list defines
#define PDA_OVERLAY_ALERT 1
#define PDA_OVERLAY_SCREEN 2
#define PDA_OVERLAY_ID 3
#define PDA_OVERLAY_ITEM 4
#define PDA_OVERLAY_LIGHT 5
#define PDA_OVERLAY_PAI 6
/obj/item/pda
name = "\improper PDA"
@@ -31,7 +40,8 @@ GLOBAL_LIST_EMPTY(PDAs)
var/default_cartridge = 0 // Access level defined by cartridge
var/obj/item/cartridge/cartridge = null //current cartridge
var/mode = 0 //Controls what menu the PDA will display. 0 is hub; the rest are either built in or based on cartridge.
var/icon_alert = "pda-r" //Icon to be overlayed for message alerts. Taken from the pda icon file.
var/list/overlays_icons = list('icons/obj/pda_alt.dmi' = list("pda-r", "screen_default", "id_overlay", "insert_overlay", "light_overlay", "pai_overlay"))
var/current_overlays = PDA_STANDARD_OVERLAYS
var/font_index = 0 //This int tells DM which font is currently selected and lets DM know when the last font has been selected so that it can cycle back to the first font when "toggle font" is pressed again.
var/font_mode = "font-family:monospace;" //The currently selected font.
var/background_color = "#808000" //The currently selected background color.
@@ -78,7 +88,9 @@ GLOBAL_LIST_EMPTY(PDAs)
var/list/contained_item = list(/obj/item/pen, /obj/item/toy/crayon, /obj/item/lipstick, /obj/item/flashlight/pen, /obj/item/clothing/mask/cigarette)
var/obj/item/inserted_item //Used for pen, crayon, and lipstick insertion or removal. Same as above.
var/overlays_x_offset = 0 //x offset to use for certain overlays
var/list/overlays_offsets // offsets to use for certain overlays
var/overlays_x_offset = 0
var/overlays_y_offset = 0
var/underline_flag = TRUE //flag for underline
@@ -91,15 +103,13 @@ GLOBAL_LIST_EMPTY(PDAs)
return BRUTELOSS
/obj/item/pda/examine(mob/user)
..()
if(!id && !inserted_item)
return
if(id)
to_chat(user, "<span class='notice'>Alt-click to remove the id.</span>")
. = ..()
var/dat = id ? "<span class='notice'>Alt-click to remove the id.</span>" : ""
if(inserted_item && (!isturf(loc)))
to_chat(user, "<span class='notice'>Ctrl-click to remove [inserted_item].</span>")
dat += "\n<span class='notice'>Ctrl-click to remove [inserted_item].</span>"
if(LAZYLEN(GLOB.pda_reskins))
dat += "\n<span class='notice'>Ctrl-shift-click it to reskin it.</span>"
to_chat(user, dat)
/obj/item/pda/Initialize()
. = ..()
@@ -115,28 +125,71 @@ GLOBAL_LIST_EMPTY(PDAs)
inserted_item = new /obj/item/pen(src)
update_icon()
/obj/item/pda/CtrlShiftClick(mob/living/user)
. = ..()
if(GLOB.pda_reskins && user.canUseTopic(src, BE_CLOSE, NO_DEXTERY))
reskin_obj(user)
/obj/item/pda/reskin_obj(mob/M)
if(!LAZYLEN(GLOB.pda_reskins))
return
var/dat = "<b>Reskin options for [name]:</b>"
for(var/V in GLOB.pda_reskins)
var/output = icon2html(GLOB.pda_reskins[V], M, icon_state)
dat += "\n[V]: <span class='reallybig'>[output]</span>"
to_chat(M, dat)
var/choice = input(M, "Choose the a reskin for [src]","Reskin Object") as null|anything in GLOB.pda_reskins
var/new_icon = GLOB.pda_reskins[choice]
if(QDELETED(src) || isnull(new_icon) || new_icon == icon || M.incapacitated() || !in_range(M,src))
return
icon = new_icon
set_new_overlays()
update_icon()
to_chat(M, "[src] is now skinned as '[choice]'.")
/obj/item/pda/proc/set_new_overlays()
if(!overlays_offsets || !(icon in overlays_offsets))
overlays_x_offset = 0
overlays_y_offset = 0
else
var/list/new_offsets = overlays_offsets[icon]
if(new_offsets)
overlays_x_offset = new_offsets[1]
overlays_y_offset = new_offsets[2]
if(!(icon in overlays_icons))
current_overlays = PDA_STANDARD_OVERLAYS
return
current_overlays = overlays_icons[icon]
/obj/item/pda/equipped(mob/user, slot)
. = ..()
if(!equipped)
if(user.client)
background_color = user.client.prefs.pda_color
switch(user.client.prefs.pda_style)
if(MONO)
font_index = MODE_MONO
font_mode = FONT_MONO
if(SHARE)
font_index = MODE_SHARE
font_mode = FONT_SHARE
if(ORBITRON)
font_index = MODE_ORBITRON
font_mode = FONT_ORBITRON
if(VT)
font_index = MODE_VT
font_mode = FONT_VT
else
font_index = MODE_MONO
font_mode = FONT_MONO
equipped = TRUE
if(equipped)
return
if(user.client)
background_color = user.client.prefs.pda_color
switch(user.client.prefs.pda_style)
if(MONO)
font_index = MODE_MONO
font_mode = FONT_MONO
if(SHARE)
font_index = MODE_SHARE
font_mode = FONT_SHARE
if(ORBITRON)
font_index = MODE_ORBITRON
font_mode = FONT_ORBITRON
if(VT)
font_index = MODE_VT
font_mode = FONT_VT
else
font_index = MODE_MONO
font_mode = FONT_MONO
var/pref_skin = GLOB.pda_reskins[user.client.prefs.pda_skin]
if(icon != pref_skin)
icon = pref_skin
set_new_overlays()
update_icon()
equipped = TRUE
/obj/item/pda/proc/update_label()
name = "PDA-[owner] ([ownjob])" //Name generalisation
@@ -150,26 +203,23 @@ GLOBAL_LIST_EMPTY(PDAs)
/obj/item/pda/GetID()
return id
/obj/item/pda/update_icon()
/obj/item/pda/update_icon(alert = FALSE)
cut_overlays()
add_overlay(alert ? current_overlays[PDA_OVERLAY_ALERT] : current_overlays[PDA_OVERLAY_SCREEN])
var/mutable_appearance/overlay = new()
overlay.pixel_x = overlays_x_offset
if(id)
overlay.icon_state = "id_overlay"
overlay.icon_state = current_overlays[PDA_OVERLAY_ID]
add_overlay(new /mutable_appearance(overlay))
if(inserted_item)
overlay.icon_state = "insert_overlay"
overlay.icon_state = current_overlays[PDA_OVERLAY_ITEM]
add_overlay(new /mutable_appearance(overlay))
if(fon)
overlay.icon_state = "light_overlay"
overlay.icon_state = current_overlays[PDA_OVERLAY_LIGHT]
add_overlay(new /mutable_appearance(overlay))
if(pai)
if(pai.pai)
overlay.icon_state = "pai_overlay"
add_overlay(new /mutable_appearance(overlay))
else
overlay.icon_state = "pai_off_overlay"
add_overlay(new /mutable_appearance(overlay))
overlay.icon_state = "[current_overlays[PDA_OVERLAY_PAI]][pai.pai ? "" : "_off"]"
add_overlay(new /mutable_appearance(overlay))
/obj/item/pda/MouseDrop(mob/over, src_location, over_location)
var/mob/M = usr
@@ -740,8 +790,7 @@ GLOBAL_LIST_EMPTY(PDAs)
to_chat(L, "[icon2html(src)] <b>Message from [hrefstart][signal.data["name"]] ([signal.data["job"]])[hrefend], </b>[signal.format_message()] (<a href='byond://?src=[REF(src)];choice=Message;skiprefresh=1;target=[REF(signal.source)]'>Reply</a>)")
update_icon()
add_overlay(icon_alert)
update_icon(TRUE)
/obj/item/pda/proc/send_to_all(mob/living/U)
if (last_everyone && world.time < last_everyone + PDA_SPAM_DELAY)
@@ -1080,4 +1129,11 @@ GLOBAL_LIST_EMPTY(PDAs)
#undef PDA_SCANNER_HALOGEN
#undef PDA_SCANNER_GAS
#undef PDA_SPAM_DELAY
#undef PDA_STANDARD_OVERLAYS
#undef PDA_OVERLAY_ALERT
#undef PDA_OVERLAY_SCREEN
#undef PDA_OVERLAY_ID
#undef PDA_OVERLAY_ITEM
#undef PDA_OVERLAY_LIGHT
#undef PDA_OVERLAY_PAI
@@ -124,6 +124,16 @@
icon_state = "pda-captain"
detonatable = FALSE
/obj/item/pda/lieutenant
name = "lieutenant PDA"
default_cartridge = /obj/item/cartridge/captain
inserted_item = /obj/item/pen/fountain/captain
icon_state = "pda-lieutenant"
ttone = "bwoink"
detonatable = FALSE
hidden = TRUE
note = "Congratulations, you have chosen the Thinktronic 5230-2 Personal Data Assistant Prestige Edition! To help with navigation, we have provided the following definitions. North: Fore. South: Aft. West: Port. East: Starboard. Quarter is either side of aft."
/obj/item/pda/cargo
name = "cargo technician PDA"
default_cartridge = /obj/item/cartridge/quartermaster
@@ -171,25 +181,29 @@
/obj/item/pda/curator
name = "curator PDA"
icon_state = "pda-library"
icon_alert = "pda-r-library"
overlays_icons = list('icons/obj/pda.dmi' = list("pda-r-library","blank","id_overlay","insert_overlay", "light_overlay", "pai_overlay"),
'icons/obj/pda_alt.dmi' = list("pda-r","screen_default","id_overlay","insert_overlay", "light_overlay", "pai_overlay"))
current_overlays = list("pda-r-library","blank","id_overlay","insert_overlay", "light_overlay", "pai_overlay")
default_cartridge = /obj/item/cartridge/curator
inserted_item = /obj/item/pen/fountain
desc = "A portable microcomputer by Thinktronic Systems, LTD. This model is a WGW-11 series e-reader."
note = "Congratulations, your station has chosen the Thinktronic 5290 WGW-11 Series E-reader and Personal Data Assistant!"
note = "Congratulations, your station has chosen the Thinktronic 5290 WGW-11 Series E-reader and Personal Data Assistant! To help with navigation, we have provided the following definitions. North: Fore. South: Aft. West: Port. East: Starboard. Quarter is either side of aft."
silent = TRUE //Quiet in the library!
overlays_offsets = list('icons/obj/pda.dmi' = list(-3,0))
overlays_x_offset = -3
/obj/item/pda/clear
name = "clear PDA"
icon_state = "pda-clear"
desc = "A portable microcomputer by Thinktronic Systems, LTD. This model is a special edition with a transparent case."
note = "Congratulations, you have chosen the Thinktronic 5230 Personal Data Assistant Deluxe Special Max Turbo Limited Edition!"
note = "Congratulations, you have chosen the Thinktronic 5230 Personal Data Assistant Deluxe Special Max Turbo Limited Edition! To help with navigation, we have provided the following definitions. North: Fore. South: Aft. West: Port. East: Starboard. Quarter is either side of aft."
/obj/item/pda/neko
name = "neko PDA"
icon_state = "pda-neko"
desc = "A portable microcomputer by Thinktronic Systems, LTD. This model is a special edition a feline fine case."
note = "Congratulations, you have chosen the Thinktronic 5230 Personal Data Assistant Deluxe Special Mew Turbo Limited Edition NYA~!"
overlays_icons = list('icons/obj/pda_alt.dmi' = list("pda-r", "screen_neko", "id_overlay", "insert_overlay", "light_overlay", "pai_overlay"))
desc = "A portable microcomputer by Thinktronic Systems, LTD. This model is a special feline edition."
note = "Congratulations, you have chosen the Thinktronic 5230 Personal Data Assistant Deluxe Special Mew Turbo Limited Edition NYA~! To help with navigation, we have provided the following definitions. North: Fore. South: Aft. West: Port. East: Starboard. Quarter is either side of aft."
/obj/item/pda/cook
name = "cook PDA"
+13 -12
View File
@@ -18,8 +18,9 @@
var/acid_level = 0 //how much acid is on that obj
var/persistence_replacement //have something WAY too amazing to live to the next round? Set a new path here. Overuse of this var will make me upset.
var/current_skin //Has the item been reskinned?
var/current_skin //the item reskin
var/list/unique_reskin //List of options to reskin.
var/always_reskinnable = FALSE
// Access levels, used in modules\jobs\access.dm
var/list/req_access
@@ -228,26 +229,26 @@
..()
if(obj_flags & UNIQUE_RENAME)
to_chat(user, "<span class='notice'>Use a pen on it to rename it or change its description.</span>")
if(unique_reskin && !current_skin)
if(unique_reskin && (!current_skin || always_reskinnable))
to_chat(user, "<span class='notice'>Alt-click it to reskin it.</span>")
/obj/AltClick(mob/user)
. = ..()
if(unique_reskin && !current_skin && user.canUseTopic(src, BE_CLOSE, NO_DEXTERY))
if(unique_reskin && (!current_skin || always_reskinnable) && user.canUseTopic(src, BE_CLOSE, NO_DEXTERY))
reskin_obj(user)
/obj/proc/reskin_obj(mob/M)
if(!LAZYLEN(unique_reskin))
return
to_chat(M, "<b>Reskin options for [name]:</b>")
var/dat = "<b>Reskin options for [name]:</b>\n"
for(var/V in unique_reskin)
var/output = icon2html(src, M, unique_reskin[V])
to_chat(M, "[V]: <span class='reallybig'>[output]</span>")
dat += "[V]: <span class='reallybig'>[output]</span>\n"
to_chat(M, dat)
var/choice = input(M,"Warning, you can only reskin [src] once!","Reskin Object") as null|anything in unique_reskin
if(!QDELETED(src) && choice && !current_skin && !M.incapacitated() && in_range(M,src))
if(!unique_reskin[choice])
return
current_skin = choice
icon_state = unique_reskin[choice]
to_chat(M, "[src] is now skinned as '[choice].'")
var/choice = input(M, always_reskinnable ? "Choose the a reskin for [src]" : "Warning, you can only reskin [src] once!","Reskin Object") as null|anything in unique_reskin
if(QDELETED(src) || !choice || (current_skin && !always_reskinnable) || M.incapacitated() || !in_range(M,src) || !unique_reskin[choice] || unique_reskin[choice] == current_skin)
return
current_skin = choice
icon_state = unique_reskin[choice]
to_chat(M, "[src] is now skinned as '[choice]'.")