Initial Work: Manifest, Newsfeed

This commit is contained in:
atermonera
2018-08-26 17:06:14 -07:00
committed by Atermonera
parent 532012c5bf
commit 1c8b408594
6 changed files with 529 additions and 46 deletions
@@ -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 = "<div>Test</div>"
//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)
@@ -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
@@ -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 << "<span class='warning'>Attempting to use [wrapped.name]</span>"
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, "<span class='notice'>Occupation updated.</span>")
// else if(istype(C, /obj/item/weapon/cartridge))
// if(cartridge)
// to_chat(user, "<span class='notice'>\The [src] already has an external device attached!</span>")
// 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, "<span class='notice'>You slot \the [cartridge] into \the [src].</span>")
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, "<span class='notice'>There isn't a commcard to remove!</span>")
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, "<span class='notice'>You remove \the [cartridge] from the [name].</span>")
else
to_chat(usr, "<span class='notice'>You cannot do this while restrained.</span>")
//It's the 26th century. We should have smart watches by now.
/obj/item/device/communicator/watch
name = "communicator watch"
@@ -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
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", "<br>")
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", "<br>")
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
+28
View File
@@ -0,0 +1,28 @@
<!--
Title: Communicator UI
Used In File(s): code\game\objects\items\devices\communicator\communicator.dm
-->
<div class="statusDisplayComm">
<div class="item">
<div class="itemContent" style="width: 100%; text-align: center;">
<span class="average">{{:data.time}} | </span>
{{if data.connectionStatus == 1}}
<img class='uiIcon16 icon-signal-green' style='float: none; vertical-align: top'></img>
{{else}}
<img class='uiIcon16 icon-alert-red' style='float: none; vertical-align: top'></img>
{{/if}}
<span class="average"> | {{:data.owner}} | {{:data.occupation}}</span>
</div>
</div>
</div>
<div>{{:helper.link('Home', 'home', {'switch_template' : 1})}}</div>
<div class='homeContainer'>
<div class='homeScreen'>
{{for data.homeScreen}}
{{:helper.link(value.module, value.icon, {'switch_tab' : value.number}, null, 'link64')}}
{{/for}}
</div>
</div>
+78 -21
View File
@@ -207,10 +207,61 @@ Used In File(s): code\game\objects\items\devices\communicator\communicator.dm
</div>
</div>
<!-- Fifth tab, Notekeeper -->
<!-- Fifth tab, News -->
{{else data.currentTab == 5}}
<h3>News</h3>
<HR>
<div class="itemContent" style="width: 100%;">{{:helper.link('Home', 'home', {'switch_tab' : 1})}}</div><BR>
{{if data.feeds.length}}
<!--Most recent three posts -->
<h4>Recent News</h4>
<div class="statusDisplay" style="height: 250px; overflow: auto;">
{{for data.latest_news}}
<h6>{{:value.channel}}</h6>
-{{:value.body}}<br>
{{if value.has_image}}
<img src='pda_news_tmp_photo_{{:data.feed.channel}}_{{:value.index}}.png' width = '180'><br>
{{if value.caption}}
<span class="caption">{{:value.caption}}</span><br>
{{/if}}
{{/if}}
<span class="footer">
{{:helper.link('Go to', 'arrow', {'newsfeed' : value.channel})}}
[{{:value.message_type}} by <span class="average">{{:value.author}}</span> - {{:value.time_stamp}}]</span>
<br>
{{/for}}
</div>
<HR>
<h4>News Feeds</h4>
<div>
<!--List all newsfeeds -->
{{for data.feeds}}
<div class='itemContent'>
{{:helper.link(value.name, 'arrow', {'newsfeed' : value.name})}}
</div>
{{/for}}
</div>
{{else}}
<!--No news feeds -->
<div class="item">
<div class="itemLabel">
Error
</div>
<div class="itemContent">
No weather reports available. Please try again later.
</div>
</div>
{{/if}}
<!-- Sixth tab, Notekeeper -->
{{else data.currentTab == 6}}
<h3>Note Keeper</h3>
<HR>
@@ -234,9 +285,9 @@ Used In File(s): code\game\objects\items\devices\communicator\communicator.dm
</div>
</div>
<!-- Sixth Tab, Weather -->
<!-- Seventh Tab, Weather -->
{{else data.currentTab == 6}}
{{else data.currentTab == 7}}
<h3>Weather</h3>
<HR>
@@ -244,7 +295,7 @@ Used In File(s): code\game\objects\items\devices\communicator\communicator.dm
<h4>Current Conditions:</h4>
{{#def.atmosphericScan}}
<HR>
<h4>Weather Reports:</h4>
{{for data.weather}}
<div class="item">
@@ -269,9 +320,19 @@ Used In File(s): code\game\objects\items\devices\communicator\communicator.dm
</div>
{{/for}}
<!-- Seventh Tab, Settings -->
<!-- Eighth Tab, Crew Manifest -->
{{else data.currentTab == 7}}
{{else data.currentTab == 8}}
<h3>Crew Manifest</h3>
<HR>
<div class="itemContent" style="width: 100%;">{{:helper.link('Home', 'home', {'switch_tab' : 1})}}</div><BR>
<!-- Ninth Tab, Settings -->
{{else data.currentTab == 9}}
<h3>Settings</h3>
@@ -330,21 +391,17 @@ Used In File(s): code\game\objects\items\devices\communicator\communicator.dm
</div>
</div>
<div class="item">
<div class="itemLabel">
Flashlight:
</div>
<div class = "itemContent">
<div style="float: left; width: 180px;">{{:helper.link(data.flashlight==1 ? 'Disable Flashlight' : 'Enable Flashlight', 'lightbulb', {'Light' : 1}, null,'fixedLeftWide')}}</div>
</div>
<!-- Tenth Tab, External Device -->
{{else data.currentTab == 10}}
<h3>External Plugin</h3>
<HR>
<div class="itemContent" style="width: 100%;">{{:helper.link('Home', 'home', {'switch_tab' : 1})}}</div><BR>
<div class="itemContent">
{{:helper.link('External Device', 'gear', {'switch_template' : 2})}}
</div>
<!-- Eighth Tab, External Device -->
{{else data.currentTab == 8}}
{{/if}}