diff --git a/code/game/objects/items/devices/communicator/UI.dm b/code/game/objects/items/devices/communicator/UI.dm index 445b0b59c5d..26c04b24f5a 100644 --- a/code/game/objects/items/devices/communicator/UI.dm +++ b/code/game/objects/items/devices/communicator/UI.dm @@ -14,7 +14,6 @@ var/im_list_ui[0] //List of messages. var/weather[0] - var/injection = null var/modules_ui[0] //Home screen info. //First we add other 'local' communicators. @@ -82,8 +81,6 @@ ) weather[++weather.len] = W - injection = "
Test
" - //Modules for homescreen. for(var/list/R in modules) modules_ui[++modules_ui.len] = R @@ -111,7 +108,6 @@ data["weather"] = weather data["aircontents"] = src.analyze_air() data["flashlight"] = fon - data["injection"] = injection // update the ui if it exists, returns null if no ui is passed/found ui = GLOB.nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) @@ -245,7 +241,14 @@ else note = "" notehtml = note - + if(href_list["switch_template"]) + var/datum/nanoui/ui = nanomanager.get_open_ui(usr, src, "main") + if(ui) + switch(href_list["switch_template"]) + if("1") + ui.reinitialise("communicator.tmpl") + if("2") + ui.reinitialise("comm2.tmpl") if(href_list["Light"]) fon = !fon set_light(fon * flum) diff --git a/code/game/objects/items/devices/communicator/cartridge.dm b/code/game/objects/items/devices/communicator/cartridge.dm index e69de29bb2d..021a2604dee 100644 --- a/code/game/objects/items/devices/communicator/cartridge.dm +++ b/code/game/objects/items/devices/communicator/cartridge.dm @@ -0,0 +1,282 @@ +// Communicator peripherals + +/obj/item/weapon/commcard + name = "generic commcard" + desc = "A peripheral plug-in for personal communicators." + icon = 'icons/obj/pda.dmi' + icon_state = "cart" + item_state = "electronic" + w_class = ITEMSIZE_TINY + + var/list/internal_devices = list() + var/list/ui_templates = list() + +/obj/item/weapon/commcard/engineering + name = "\improper Power-ON cartridge" + icon_state = "cart-e" + //Power monitor + //Halogen counter + +/obj/item/weapon/commcard/engineering/New() + ..() + //Add power monitor to ui template + +/obj/item/weapon/commcard/atmos + name = "\improper BreatheDeep cartridge" + icon_state = "cart-a" + //Gas scanner + +/obj/item/weapon/commcard/atmos/New() + ..() + //var/obj/item/[Gas scanner]/S = new(src) + //internal_devices.Add(S) + +/obj/item/weapon/commcard/medical + name = "\improper Med-U cartridge" + icon_state = "cart-m" + //Med records + //Med scanner + //Halogen counter + +/obj/item/weapon/commcard/medical/New() + ..() + var/obj/item/device/healthanalyzer/H = new(src) + internal_devices.Add(H) + //Add med records to ui template + +/obj/item/weapon/commcard/medical/chemistry + name = "\improper ChemWhiz cartridge" + icon_state = "cart-chem" + //Reagent scanner + +/obj/item/weapon/commcard/medical/chemistry/New() + ..() + var/obj/item/device/reagent_scanner/R = new(src) + internal_devices.Add(R) + +/obj/item/weapon/commcard/medical/detective + name = "\improper D.E.T.E.C.T. cartridge" + icon_state = "cart-s" + //Security records + +/obj/item/weapon/commcard/medical/detective/New() + ..() + // Add sec records to ui template + +/obj/item/weapon/commcard/int_aff + name = "\improper P.R.O.V.E. cartridge" + icon_state = "cart-s" + //Sec records + +/obj/item/weapon/commcard/int_aff/New() + ..() + //Add sec records to ui template + +/obj/item/weapon/commcard/int_aff/security + name = "\improper R.O.B.U.S.T. cartridge" + icon_state = "cart-s" + //Sec bot access + +/obj/item/weapon/commcard/int_aff/security/New() + ..() + //Add sec bot access to ui template + +/obj/item/weapon/commcard/janitor + name = "\improper CustodiPRO cartridge" + desc = "The ultimate in clean-room design." + //Janitorial Supplies Locator + +/obj/item/weapon/commcard/janitor/New() + ..() + // Add janitoral locator to ui template + +/obj/item/weapon/commcard/service + name = "\improper Serv-U Pro" + desc = "A data cartridge designed to serve YOU!" + //I'm gonna regret this but recipes menu + +/obj/item/weapon/commcard/service/New() + ..() + // Add list of recipes to ui template + // SEE: /code/modules/food/recipe_dump.dm + +/obj/item/weapon/commcard/signal + name = "generic signaler cartridge" + desc = "A data cartridge with an integrated radio signaler module." + //Signaller + +/obj/item/weapon/commcard/signal/New() + ..() + // Make a signaller, add it to internal devices + // Access the signaller through the ui template + // I'm probably gonna regret this too + +/obj/item/weapon/commcard/signal/science + name = "\improper Signal Ace 2 cartridge" + desc = "Complete with integrated radio signaler!" + icon_state = "cart-tox" + //Reagent scanner + //Gas scanner + +/obj/item/weapon/commcard/signal/science/New() + ..() + var/obj/item/device/reagent_scanner/R = new(src) + //var/obj/item/[Gas scanner]/S = new(src) + //internal_devices.Add(S) + internal_devices.Add(R) + +/obj/item/weapon/commcard/quartermaster + name = "\improper Space Parts & Space Vendors cartridge" + desc = "Perfect for the Quartermaster on the go!" + icon_state = "cart-q" + //Supply records + //Supply bot access + +/obj/item/weapon/commcard/quartermaster/New() + ..() + // Add supply records to ui template + // Add supply bot access to ui template + +/obj/item/weapon/commcard/miner + name = "\improper Drill-Jockey 4.5" + desc = "It's covered in some sort of sand." + //Ore processing instructions?! + +/obj/item/weapon/commcard/miner/New() + ..() + // Add ore recipes to ui template + +/obj/item/weapon/commcard/head + name = "\improper Easy-Record DELUXE" + icon_state = "cart-h" + //Status display + //Employment records + +/obj/item/weapon/commcard/head/New() + ..() + // Add status display to ui template + // Add employment records to ui template + +/obj/item/weapon/commcard/head/hop + name = "\improper HumanResources9001 cartridge" + icon_state = "cart-h" + //Sec records + //Supply records + //Supply bot access + //Janitorial Supplies Locator + //Service menu + +/obj/item/weapon/commcard/head/hop/New() + ..() + // Add sec records to ui template + // Add supply records to ui template + // Add supply bot access to ui template + // Add janitorial supplies locator to template + // Add service menu to template + +/obj/item/weapon/commcard/head/hos + name = "\improper R.O.B.U.S.T. DELUXE" + icon_state = "cart-hos" + // Sec records + // Sec bot access + +/obj/item/weapon/commcard/head/hos/New() + ..() + // Add sec records to ui template + // Add sec bot access to ui template + +/obj/item/weapon/commcard/head/rd + name = "\improper Signal Ace DELUXE" + icon_state = "cart-rd" + //Signaller + //Gas scanner + //Reagent scanner + +/obj/item/weapon/commcard/head/rd/New() + ..() + // Add signaller to internal devices + // Add signaller access to ui template + var/obj/item/device/reagent_scanner/R = new(src) + //var/obj/item/[Gas scanner]/S = new(src) + //internal_devices.Add(S) + internal_devices.Add(R) + + +/obj/item/weapon/commcard/head/cmo + name = "\improper Med-U DELUXE" + icon_state = "cart-cmo" + //Med records + //Med scanner + //Reagent scanner + //Halogen counter + +/obj/item/weapon/commcard/head/cmo/New() + ..() + var/obj/item/device/healthanalyzer/H = new(src) + var/obj/item/device/reagent_scanner/R = new(src) + internal_devices.Add(R) + internal_devices.Add(H) + +/obj/item/weapon/commcard/head/ce + name = "\improper Power-On DELUXE" + icon_state = "cart-ce" + //Power monitor + //Gas scanner + //Halogen counter + +/obj/item/weapon/commcard/head/ce/New() + ..() + // Add power monitor to ui template + // Add gas scanner to internal devices + +/obj/item/weapon/commcard/head/captain + name = "\improper Value-PAK cartridge" + desc = "Now with 200% more value!" + icon_state = "cart-c" + //Literally everything: + //Power monitor + //Med records + //Sec records + //Supply records + //Med scanner + //Reagent scanner + //Gas scanner + //Supply bot access + //Sec bot access + //Janitorial supply locator + +/obj/item/weapon/commcard/head/captain/New() + ..() + // Add med records to ui template + // Add sec records to ui template + // Add supply records to ui template + // Add supply bot access to ui template + // Add sec bot access to ui template + // Add power monitor to ui template + // Add janitorial locator to ui template + // Add service menu to ui template + // Add gas scanner to internal devices + var/obj/item/device/healthanalyzer/H = new(src) + var/obj/item/device/reagent_scanner/R = new(src) + internal_devices.Add(R) + internal_devices.Add(H) + +/obj/item/weapon/commcard/mercenary + name = "\improper Detomatix cartridge" + icon_state = "cart" + //Syndi shuttle door controller + +/obj/item/weapon/commcard/mercenary/New() + ..() + // Fuck if I know how that thing works + +/obj/item/weapon/commcard/explorer + name = "\improper Explorator cartridge" + icon_state = "cart-tox" + //GPS + +/obj/item/weapon/commcard/explorer/New() + ..() + var/obj/item/device/gps/G = new(src) + internal_devices.Add(G) + // Add GPS access to ui template \ No newline at end of file diff --git a/code/game/objects/items/devices/communicator/communicator.dm b/code/game/objects/items/devices/communicator/communicator.dm index d7e62a53c74..485e531d897 100644 --- a/code/game/objects/items/devices/communicator/communicator.dm +++ b/code/game/objects/items/devices/communicator/communicator.dm @@ -31,7 +31,7 @@ var/global/list/obj/item/device/communicator/all_communicators = list() var/note = "Thank you for choosing the T-14.2 Communicator, this is your notepad!" //Current note in the notepad function var/notehtml = "" - var/obj/item/weapon/cartridge/cartridge = null //current cartridge + var/obj/item/weapon/commcard/cartridge = null //current cartridge var/fon = 0 // Internal light var/flum = 2 // Brightness @@ -39,9 +39,12 @@ var/global/list/obj/item/device/communicator/all_communicators = list() list("module" = "Phone", "icon" = "phone64", "number" = 2), list("module" = "Contacts", "icon" = "person64", "number" = 3), list("module" = "Messaging", "icon" = "comment64", "number" = 4), - list("module" = "Note", "icon" = "note64", "number" = 5), - list("module" = "Weather", "icon" = "sun64", "number" = 6), - list("module" = "Settings", "icon" = "gear64", "number" = 7) + list("module" = "News", "icon" = "note64", "number" = 5), // Need a different icon, + list("module" = "Note", "icon" = "note64", "number" = 6), + list("module" = "Weather", "icon" = "sun64", "number" = 7), + list("module" = "Crew Manifest", "icon" = "note64", "number" = 8), // Need a different icon, + list("module" = "Settings", "icon" = "gear64", "number" = 9), + list("module" = "External Device", "icon" = "external64", "number" = 10) ) //list("module" = "Name of Module", "icon" = "icon name64", "number" = "what tab is the module") var/selected_tab = 1 @@ -188,10 +191,24 @@ var/global/list/obj/item/device/communicator/all_communicators = list() if(!get_connection_to_tcomms()) close_connection(reason = "Connection timed out") +// Proc: attack() +// Parameters: 2 (M - what is being attacked. user - the mob that has the communicator) +// Description: When the communicator has an attached commcard with internal devices, relay the attack() through to those devices. +// Contents of the for loop are copied from gripper code, because that does approximately what we want to do. +/obj/item/device/communicator/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob) + if(cartridge && cartridge.internal_devices) + for(var/obj/item/wrapped in cartridge.internal_devices) + if(wrapped) //The force of the wrapped obj gets set to zero during the attack() and afterattack(). + user << "Attempting to use [wrapped.name]" + wrapped.attack(M,user) + M.attackby(wrapped, user) //attackby reportedly gets procced by being clicked on, at least according to Anewbe. + return 0 + // Proc: attackby() // Parameters: 2 (C - what is used on the communicator. user - the mob that has the communicator) // Description: When an ID is swiped on the communicator, the communicator reads the job and checks it against the Owner name, if success, the occupation is added. /obj/item/device/communicator/attackby(obj/item/C as obj, mob/user as mob) + ..() if(istype(C, /obj/item/weapon/card/id)) var/obj/item/weapon/card/id/idcard = C if(!idcard.registered_name || !idcard.assignment) @@ -201,12 +218,14 @@ var/global/list/obj/item/device/communicator/all_communicators = list() else if(owner == idcard.registered_name) occupation = idcard.assignment to_chat(user, "Occupation updated.") -// else if(istype(C, /obj/item/weapon/cartridge)) -// if(cartridge) -// to_chat(user, "\The [src] already has an external device attached!") -// else -// modules.Add(list("module" = "External Device", "icon = external64", "number" = 8)) -// cartridge = C + + if(istype(C, /obj/item/weapon/commcard) && !cartridge) + cartridge = C + user.drop_item() + cartridge.loc = src + to_chat(usr, "You slot \the [cartridge] into \the [src].") + modules.Add(list("module" = "External Device", "icon" = "external64", "number" = 8)) + nanomanager.update_uis(src) // update all UIs attached to src return // Proc: attack_self() @@ -330,6 +349,30 @@ var/global/list/obj/item/device/communicator/all_communicators = list() client_huds |= global_hud.whitense client_huds |= global_hud.darkMask +/obj/item/device/communicator/verb/verb_remove_cartridge() + set category = "Object" + set name = "Remove commcard" + set src in usr + + if(issilicon(usr)) + return + if(!cartridge) + to_chat(usr, "There isn't a commcard to remove!") + return + + if(!(usr.stat || usr.restrained() || usr.paralysis || usr.stunned || usr.weakened)) + var/turf/T = get_turf(src) + cartridge.loc = T + if (ismob(loc)) + var/mob/M = loc + M.put_in_hands(cartridge) + else + cartridge.loc = get_turf(src) + cartridge = null + to_chat(usr, "You remove \the [cartridge] from the [name].") + else + to_chat(usr, "You cannot do this while restrained.") + //It's the 26th century. We should have smart watches by now. /obj/item/device/communicator/watch name = "communicator watch" diff --git a/code/game/objects/items/devices/communicator/helper.dm b/code/game/objects/items/devices/communicator/helper.dm index 9c121112ac2..0dcf5c137df 100644 --- a/code/game/objects/items/devices/communicator/helper.dm +++ b/code/game/objects/items/devices/communicator/helper.dm @@ -11,17 +11,87 @@ var/co2_level = environment.gas["carbon_dioxide"]/total_moles var/phoron_level = environment.gas["phoron"]/total_moles var/unknown_level = 1-(o2_level+n2_level+co2_level+phoron_level) + + // Label is what the entry is describing + // Type identifies which unit or other special characters to use + // Val is the information reported + // Bad_high/_low are the values outside of which the entry reports as dangerous + // Poor_high/_low are the values outside of which the entry reports as unideal + // Values were extracted from the template itself results = list( - "pressure" = "[round(pressure,0.1)]", - "nitrogen" = "[round(n2_level*100,0.1)]", - "oxygen" = "[round(o2_level*100,0.1)]", - "carbon_dioxide" = "[round(co2_level*100,0.1)]", - "phoron" = "[round(phoron_level*100,0.01)]", - "other" = "[round(unknown_level, 0.01)]", - "temp" = "[round(environment.temperature-T0C,0.1)]", - "reading" = 1 + list("entry" = "Pressure", "type" = "pressure", "val" = "[round(pressure,0.1)]", "bad_high" = 120, "poor_high" = 110, "poor_low" = 95, "bad_low" = 80), + list("entry" = "Temperature", "type" = "temp", "val" = "[round(environment.temperature-T0C,0.1)]", "bad_high" = 35, "poor_high" = 25, "poor_low" = 15, "bad_low" = 5), + list("entry" = "Oxygen", "type" = "pressure", "val" = "[round(o2_level*100,0.1)]", "bad_high" = 140, "poor_high" = 135, "poor_low" = 19, "bad_low" = 17), + list("entry" = "Nitrogen", "type" = "pressure", "val" = "[round(n2_level*100,0.1)]", "bad_high" = 105, "poor_high" = 85, "poor_low" = 50, "bad_low" = 40), + list("entry" = "Carbon Dioxide", "type" = "pressure", "val" = "[round(co2_level*100,0.1)]", "bad_high" = 10, "poor_high" = 5, "poor_low" = 0, "bad_low" = 0), + list("entry" = "Phoron", "type" = "pressure", "val" = "[round(phoron_level*100,0.01)]", "bad_high" = 0.5, "poor_high" = 0, "poor_low" = 0, "bad_low" = 0), + list("entry" = "Other", "type" = "pressure", "val" = "[round(unknown_level, 0.01)]", "bad_high" = 1, "poor_high" = 0.5, "poor_low" = 0, "bad_low" = 0) ) if(isnull(results)) - results = list("reading" = 0) - return results \ No newline at end of file + results = list(list("entry" = "pressure", "val" = "0")) + return results + + +// Proc - compile_news() +// Parameters - none +// Description - Returns the list of newsfeeds, compiled for template processing +/obj/item/device/communicator/proc/compile_news() + var/list/feeds = list() + for(var/datum/feed_channel/channel in news_network.network_channels) + var/list/messages = list() + if(!channel.censored) + var/index = 0 + for(var/datum/feed_message/FM in channel.messages) + index++ + if(FM.img) + usr << browse_rsc(FM.img, "pda_news_tmp_photo_[feeds["channel"]]_[index].png") + // News stories are HTML-stripped but require newline replacement to be properly displayed in NanoUI + var/body = replacetext(FM.body, "\n", "
") + messages[++messages.len] = list( + "author" = FM.author, + "body" = body, + "message_type" = FM.message_type, + "time_stamp" = FM.time_stamp, + "has_image" = (FM.img != null), + "caption" = FM.caption, + "index" = index + ) + + feeds[++feeds.len] = list( + "name" = channel.channel_name, + "censored" = channel.censored, + "author" = channel.author, + "messages" = messages + ) + return feeds + +// Proc - get_recent_news() +// Parameters - none +// Description - Returns the latest three newscasts, compiled for template processing +/obj/item/device/communicator/proc/get_recent_news() + var/list/news = list() + + // Compile all the newscasts + for(var/datum/feed_channel/channel in news_network.network_channels) + if(!channel.censored) + for(var/datum/feed_message/FM in channel.messages) + var/body = replacetext(FM.body, "\n", "
") + news[++news.len] = list( + "channel" = channel.channel_name, + "author" = FM.author, + "body" = body, + "message_type" = FM.message_type, + "time_stamp" = FM.time_stamp, + "has_image" = (FM.img != null), + "caption" = FM.caption, + ) + + // Cut out all but the youngest three + while(news.len > 3) + var/oldest = min(news[0]["time_stamp"], news[1]["time_stamp"], news[2]["time_stamp"], news[3]["time_stamp"]) + for(var/i = 0, i < 4, i++) + if(news[i]["time_stamp"] == oldest) + news.Remove(news[i]) + + return news \ No newline at end of file diff --git a/nano/templates/comm2.tmpl b/nano/templates/comm2.tmpl new file mode 100644 index 00000000000..ca80ef6ca3d --- /dev/null +++ b/nano/templates/comm2.tmpl @@ -0,0 +1,28 @@ + + +
+
+
+ {{:data.time}} | + {{if data.connectionStatus == 1}} + + {{else}} + + {{/if}} + | {{:data.owner}} | {{:data.occupation}} +
+
+
+ + +
{{:helper.link('Home', 'home', {'switch_template' : 1})}}
+
+
+ {{for data.homeScreen}} + {{:helper.link(value.module, value.icon, {'switch_tab' : value.number}, null, 'link64')}} + {{/for}} +
+
\ No newline at end of file diff --git a/nano/templates/communicator.tmpl b/nano/templates/communicator.tmpl index 8625a93ed0a..81d3b7dd81e 100644 --- a/nano/templates/communicator.tmpl +++ b/nano/templates/communicator.tmpl @@ -207,10 +207,61 @@ Used In File(s): code\game\objects\items\devices\communicator\communicator.dm - + {{else data.currentTab == 5}} +

News

+ +
+
{{:helper.link('Home', 'home', {'switch_tab' : 1})}}

+ {{if data.feeds.length}} + + +

Recent News

+
+ {{for data.latest_news}} +
{{:value.channel}}
+ -{{:value.body}}
+ {{if value.has_image}} +
+ {{if value.caption}} + {{:value.caption}}
+ {{/if}} + {{/if}} + + {{:helper.link('Go to', 'arrow', {'newsfeed' : value.channel})}} + [{{:value.message_type}} by {{:value.author}} - {{:value.time_stamp}}] +
+ {{/for}} +
+
+ +

News Feeds

+
+ + {{for data.feeds}} +
+ {{:helper.link(value.name, 'arrow', {'newsfeed' : value.name})}} +
+ {{/for}} +
+ {{else}} + +
+
+ Error +
+
+ No weather reports available. Please try again later. +
+
+ {{/if}} + + + +{{else data.currentTab == 6}} +

Note Keeper


@@ -234,9 +285,9 @@ Used In File(s): code\game\objects\items\devices\communicator\communicator.dm - + -{{else data.currentTab == 6}} +{{else data.currentTab == 7}}

Weather


@@ -244,7 +295,7 @@ Used In File(s): code\game\objects\items\devices\communicator\communicator.dm

Current Conditions:

{{#def.atmosphericScan}} - +

Weather Reports:

{{for data.weather}}
@@ -269,9 +320,19 @@ Used In File(s): code\game\objects\items\devices\communicator\communicator.dm
{{/for}} - + -{{else data.currentTab == 7}} +{{else data.currentTab == 8}} + +

Crew Manifest

+ +
+
{{:helper.link('Home', 'home', {'switch_tab' : 1})}}

+ + + + +{{else data.currentTab == 9}}

Settings

@@ -330,21 +391,17 @@ Used In File(s): code\game\objects\items\devices\communicator\communicator.dm -
-
- Flashlight: -
-
-
{{:helper.link(data.flashlight==1 ? 'Disable Flashlight' : 'Enable Flashlight', 'lightbulb', {'Light' : 1}, null,'fixedLeftWide')}}
-
+ + +{{else data.currentTab == 10}} + +

External Plugin

+ +
+
{{:helper.link('Home', 'home', {'switch_tab' : 1})}}

+ +
+ {{:helper.link('External Device', 'gear', {'switch_template' : 2})}}
- - - -{{else data.currentTab == 8}} - - - - {{/if}}