yeehaw it's done
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#define MAX_CHANNELS 1000
|
||||
|
||||
/datum/ntnet_conversation
|
||||
var/id = null
|
||||
var/title = "Untitled Conversation"
|
||||
@@ -8,7 +10,11 @@
|
||||
var/static/ntnrc_uid = 0
|
||||
|
||||
/datum/ntnet_conversation/New()
|
||||
id = ntnrc_uid++
|
||||
id = ntnrc_uid + 1
|
||||
if(id > MAX_CHANNELS)
|
||||
qdel(src)
|
||||
return
|
||||
ntnrc_uid = id
|
||||
if(SSnetworks.station_network)
|
||||
SSnetworks.station_network.chat_channels.Add(src)
|
||||
..()
|
||||
@@ -19,12 +25,12 @@
|
||||
return ..()
|
||||
|
||||
/datum/ntnet_conversation/proc/add_message(message, username)
|
||||
message = "[STATION_TIME_TIMESTAMP("hh:mm:ss")] [username]: [message]"
|
||||
message = "[STATION_TIME_TIMESTAMP("hh:mm:ss", world.time)] [username]: [message]"
|
||||
messages.Add(message)
|
||||
trim_message_list()
|
||||
|
||||
/datum/ntnet_conversation/proc/add_status_message(message)
|
||||
messages.Add("[STATION_TIME_TIMESTAMP("hh:mm:ss")] -!- [message]")
|
||||
messages.Add("[STATION_TIME_TIMESTAMP("hh:mm:ss", world.time)] -!- [message]")
|
||||
trim_message_list()
|
||||
|
||||
/datum/ntnet_conversation/proc/trim_message_list()
|
||||
@@ -66,3 +72,5 @@
|
||||
|
||||
add_status_message("[client.username] has changed channel title from [title] to [newtitle]")
|
||||
title = newtitle
|
||||
|
||||
#undef MAX_CHANNELS
|
||||
@@ -316,7 +316,7 @@
|
||||
data["PC_batteryicon"] = "batt_20.gif"
|
||||
else
|
||||
data["PC_batteryicon"] = "batt_5.gif"
|
||||
data["PC_batterypercent"] = "[round(battery_module.battery.percent())] %"
|
||||
data["PC_batterypercent"] = "[round(battery_module.battery.percent())]%"
|
||||
data["PC_showbatteryicon"] = 1
|
||||
else
|
||||
data["PC_batteryicon"] = "batt_5.gif"
|
||||
@@ -348,7 +348,7 @@
|
||||
|
||||
data["PC_programheaders"] = program_headers
|
||||
|
||||
data["PC_stationtime"] = STATION_TIME_TIMESTAMP("hh:mm:ss")
|
||||
data["PC_stationtime"] = STATION_TIME_TIMESTAMP("hh:mm:ss", world.time)
|
||||
data["PC_hasheader"] = 1
|
||||
data["PC_showexitprogram"] = active_program ? 1 : 0 // Hides "Exit Program" button on mainscreen
|
||||
return data
|
||||
|
||||
@@ -38,7 +38,8 @@
|
||||
var/datum/asset/assets = get_asset_datum(/datum/asset/simple/headers)
|
||||
assets.send(user)
|
||||
|
||||
ui = new(user, src, ui_key, "ntos_main", "NTOS Main menu", 400, 500, master_ui, state)
|
||||
ui = new(user, src, ui_key, "ntos_main", "NtOS Main menu", 400, 500, master_ui, state)
|
||||
ui.set_style("ntos")
|
||||
ui.open()
|
||||
ui.set_autoupdate(state = 1)
|
||||
|
||||
@@ -68,10 +69,10 @@
|
||||
switch(action)
|
||||
if("PC_exit")
|
||||
kill_program()
|
||||
return 1
|
||||
return TRUE
|
||||
if("PC_shutdown")
|
||||
shutdown_computer()
|
||||
return 1
|
||||
return TRUE
|
||||
if("PC_minimize")
|
||||
var/mob/user = usr
|
||||
if(!active_program || !all_components[MC_CPU])
|
||||
@@ -156,6 +157,7 @@
|
||||
comp_light_color = new_color
|
||||
light_color = new_color
|
||||
update_light()
|
||||
return TRUE
|
||||
else
|
||||
return
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
var/network_destination = null // Optional string that describes what NTNet server/system this program connects to. Used in default logging.
|
||||
var/available_on_ntnet = 1 // Whether the program can be downloaded from NTNet. Set to 0 to disable.
|
||||
var/available_on_syndinet = 0 // Whether the program can be downloaded from SyndiNet (accessible via emagging the computer). Set to 1 to enable.
|
||||
var/tgui_id // ID of TG UI interface
|
||||
var/ui_style // ID of custom TG UI style (optional)
|
||||
var/ui_x = 575 // Default size of TG UI window, in pixels
|
||||
var/tgui_id // ID of TGUI interface
|
||||
var/ui_style // ID of custom TGUI style (optional)
|
||||
var/ui_x = 575 // Default size of TGUI window, in pixels
|
||||
var/ui_y = 700
|
||||
var/ui_header = null // Example: "something.gif" - a header image that will be rendered in computer's UI when this program is running at background. Images are taken from /icons/program_icons. Be careful not to use too large images!
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
// Check if the user can run program. Only humans can operate computer. Automatically called in run_program()
|
||||
// User has to wear their ID for ID Scan to work.
|
||||
// Can also be called manually, with optional parameter being access_to_check to scan the user's ID
|
||||
/datum/computer_file/program/proc/can_run(mob/user, loud = 0, access_to_check, transfer = 0)
|
||||
/datum/computer_file/program/proc/can_run(mob/user, loud = FALSE, access_to_check, transfer = FALSE)
|
||||
// Defaults to required_access
|
||||
if(!access_to_check)
|
||||
if(transfer && transfer_access)
|
||||
@@ -79,16 +79,16 @@
|
||||
else
|
||||
access_to_check = required_access
|
||||
if(!access_to_check) // No required_access, allow it.
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
if(!transfer && computer && (computer.obj_flags & EMAGGED)) //emags can bypass the execution locks but not the download ones.
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
if(IsAdminGhost(user))
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
if(computer.hasSiliconAccessInArea(user))
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
if(ishuman(user))
|
||||
var/obj/item/card/id/D
|
||||
@@ -101,17 +101,17 @@
|
||||
if(!I && !D)
|
||||
if(loud)
|
||||
to_chat(user, "<span class='danger'>\The [computer] flashes an \"RFID Error - Unable to scan ID\" warning.</span>")
|
||||
return 0
|
||||
return FALSE
|
||||
|
||||
if(I)
|
||||
if(access_to_check in I.GetAccess())
|
||||
return 1
|
||||
return TRUE
|
||||
else if(D)
|
||||
if(access_to_check in D.GetAccess())
|
||||
return 1
|
||||
return TRUE
|
||||
if(loud)
|
||||
to_chat(user, "<span class='danger'>\The [computer] flashes an \"Access Denied\" warning.</span>")
|
||||
return 0
|
||||
return FALSE
|
||||
|
||||
// This attempts to retrieve header data for UIs. If implementing completely new device of different type than existing ones
|
||||
// always include the device here in this proc. This proc basically relays the request to whatever is running the program.
|
||||
@@ -127,15 +127,15 @@
|
||||
if(requires_ntnet && network_destination)
|
||||
generate_network_log("Connection opened to [network_destination].")
|
||||
program_state = PROGRAM_STATE_ACTIVE
|
||||
return 1
|
||||
return 0
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
// Use this proc to kill the program. Designed to be implemented by each program if it requires on-quit logic, such as the NTNRC client.
|
||||
/datum/computer_file/program/proc/kill_program(forced = FALSE)
|
||||
program_state = PROGRAM_STATE_KILLED
|
||||
if(network_destination)
|
||||
generate_network_log("Connection to [network_destination] closed.")
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
|
||||
/datum/computer_file/program/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
||||
@@ -158,17 +158,17 @@
|
||||
// ALWAYS INCLUDE PARENT CALL ..() OR DIE IN FIRE.
|
||||
/datum/computer_file/program/ui_act(action,params,datum/tgui/ui)
|
||||
if(..())
|
||||
return 1
|
||||
return TRUE
|
||||
if(computer)
|
||||
switch(action)
|
||||
if("PC_exit")
|
||||
computer.kill_program()
|
||||
ui.close()
|
||||
return 1
|
||||
return TRUE
|
||||
if("PC_shutdown")
|
||||
computer.shutdown_computer()
|
||||
ui.close()
|
||||
return 1
|
||||
return TRUE
|
||||
if("PC_minimize")
|
||||
var/mob/user = usr
|
||||
if(!computer.active_program || !computer.all_components[MC_CPU])
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
<br>
|
||||
[GLOB.data_core ? GLOB.data_core.get_manifest(0) : ""]
|
||||
"}
|
||||
if(!printer.print_text(contents,text("crew manifest ([])", STATION_TIME_TIMESTAMP("hh:mm:ss"))))
|
||||
if(!printer.print_text(contents,text("crew manifest ([])", STATION_TIME_TIMESTAMP("hh:mm:ss", world.time))))
|
||||
to_chat(usr, "<span class='notice'>Hardware error: Printer was unable to print the file. It may be out of paper.</span>")
|
||||
return
|
||||
else
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
unsendable = 1
|
||||
undeletable = 1
|
||||
size = 4
|
||||
ui_x = 420
|
||||
ui_y = 630
|
||||
available_on_ntnet = 0
|
||||
requires_ntnet = 0
|
||||
tgui_id = "ntos_configuration"
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
t = replacetext(t, "\[/i\]", "</I>")
|
||||
t = replacetext(t, "\[u\]", "<U>")
|
||||
t = replacetext(t, "\[/u\]", "</U>")
|
||||
t = replacetext(t, "\[time\]", "[STATION_TIME_TIMESTAMP("hh:mm:ss")]")
|
||||
t = replacetext(t, "\[time\]", "[STATION_TIME_TIMESTAMP("hh:mm:ss", world.time)]")
|
||||
t = replacetext(t, "\[date\]", "[time2text(world.realtime, "MMM DD")] [GLOB.year_integer]")
|
||||
t = replacetext(t, "\[large\]", "<font size=\"4\">")
|
||||
t = replacetext(t, "\[/large\]", "</font>")
|
||||
|
||||
@@ -10,215 +10,225 @@
|
||||
ui_header = "ntnrc_idle.gif"
|
||||
available_on_ntnet = 1
|
||||
tgui_id = "ntos_net_chat"
|
||||
ui_x = 900
|
||||
ui_y = 675
|
||||
|
||||
var/last_message = null // Used to generate the toolbar icon
|
||||
var/last_message // Used to generate the toolbar icon
|
||||
var/username
|
||||
var/datum/ntnet_conversation/channel = null
|
||||
var/operator_mode = 0 // Channel operator mode
|
||||
var/netadmin_mode = 0 // Administrator mode (invisible to other users + bypasses passwords)
|
||||
var/active_channel
|
||||
var/list/channel_history = list()
|
||||
var/operator_mode = FALSE // Channel operator mode
|
||||
var/netadmin_mode = FALSE // Administrator mode (invisible to other users + bypasses passwords)
|
||||
|
||||
/datum/computer_file/program/chatclient/New()
|
||||
username = "DefaultUser[rand(100, 999)]"
|
||||
|
||||
/datum/computer_file/program/chatclient/ui_act(action, params)
|
||||
if(..())
|
||||
return 1
|
||||
return
|
||||
|
||||
var/datum/ntnet_conversation/channel = SSnetworks.station_network.get_chat_channel_by_id(active_channel)
|
||||
var/authed = FALSE
|
||||
if(channel && ((channel.operator == src) || netadmin_mode))
|
||||
authed = TRUE
|
||||
switch(action)
|
||||
if("PRG_speak")
|
||||
. = 1
|
||||
if(!channel)
|
||||
return 1
|
||||
var/mob/living/user = usr
|
||||
var/message = reject_bad_text(input(user, "Enter message or leave blank to cancel: "))
|
||||
if(!message || !channel)
|
||||
if(!channel || isnull(active_channel))
|
||||
return
|
||||
var/message = reject_bad_text(params["message"])
|
||||
if(!message)
|
||||
return
|
||||
if(channel.password && !(src in channel.clients))
|
||||
if(channel.password == message)
|
||||
channel.add_client(src)
|
||||
return TRUE
|
||||
|
||||
channel.add_message(message, username)
|
||||
var/mob/living/user = usr
|
||||
user.log_talk(message, LOG_CHAT, tag="as [username] to channel [channel.title]")
|
||||
|
||||
return TRUE
|
||||
if("PRG_joinchannel")
|
||||
. = 1
|
||||
var/datum/ntnet_conversation/C
|
||||
for(var/datum/ntnet_conversation/chan in SSnetworks.station_network.chat_channels)
|
||||
if(chan.id == text2num(params["id"]))
|
||||
C = chan
|
||||
break
|
||||
|
||||
if(!C)
|
||||
return 1
|
||||
var/new_target = text2num(params["id"])
|
||||
if(isnull(new_target) || new_target == active_channel)
|
||||
return
|
||||
|
||||
if(netadmin_mode)
|
||||
channel = C // Bypasses normal leave/join and passwords. Technically makes the user invisible to others.
|
||||
return 1
|
||||
active_channel = new_target // Bypasses normal leave/join and passwords. Technically makes the user invisible to others.
|
||||
return TRUE
|
||||
|
||||
if(C.password)
|
||||
var/mob/living/user = usr
|
||||
var/password = reject_bad_text(input(user,"Access Denied. Enter password:"))
|
||||
if(C && (password == C.password))
|
||||
C.add_client(src)
|
||||
channel = C
|
||||
return 1
|
||||
C.add_client(src)
|
||||
channel = C
|
||||
active_channel = new_target
|
||||
channel = SSnetworks.station_network.get_chat_channel_by_id(new_target)
|
||||
if(!(src in channel.clients) && !channel.password)
|
||||
channel.add_client(src)
|
||||
return TRUE
|
||||
if("PRG_leavechannel")
|
||||
. = 1
|
||||
if(channel)
|
||||
channel.remove_client(src)
|
||||
channel = null
|
||||
active_channel = null
|
||||
return TRUE
|
||||
if("PRG_newchannel")
|
||||
. = 1
|
||||
var/mob/living/user = usr
|
||||
var/channel_title = reject_bad_text(input(user,"Enter channel name or leave blank to cancel:"))
|
||||
var/channel_title = reject_bad_text(params["new_channel_name"])
|
||||
if(!channel_title)
|
||||
return
|
||||
var/datum/ntnet_conversation/C = new/datum/ntnet_conversation()
|
||||
var/datum/ntnet_conversation/C = new /datum/ntnet_conversation()
|
||||
C.add_client(src)
|
||||
C.operator = src
|
||||
channel = C
|
||||
C.title = channel_title
|
||||
active_channel = C.id
|
||||
return TRUE
|
||||
if("PRG_toggleadmin")
|
||||
. = 1
|
||||
if(netadmin_mode)
|
||||
netadmin_mode = 0
|
||||
netadmin_mode = FALSE
|
||||
if(channel)
|
||||
channel.remove_client(src) // We shouldn't be in channel's user list, but just in case...
|
||||
channel = null
|
||||
return 1
|
||||
return TRUE
|
||||
var/mob/living/user = usr
|
||||
if(can_run(usr, 1, ACCESS_NETWORK))
|
||||
if(channel)
|
||||
var/response = alert(user, "Really engage admin-mode? You will be disconnected from your current channel!", "NTNRC Admin mode", "Yes", "No")
|
||||
if(response == "Yes")
|
||||
if(channel)
|
||||
channel.remove_client(src)
|
||||
channel = null
|
||||
else
|
||||
return
|
||||
netadmin_mode = 1
|
||||
if(can_run(user, TRUE, ACCESS_NETWORK))
|
||||
for(var/C in SSnetworks.station_network.chat_channels)
|
||||
var/datum/ntnet_conversation/chan = C
|
||||
chan.remove_client(src)
|
||||
netadmin_mode = TRUE
|
||||
return TRUE
|
||||
if("PRG_changename")
|
||||
. = 1
|
||||
var/mob/living/user = usr
|
||||
var/newname = sanitize(input(user,"Enter new nickname or leave blank to cancel:"))
|
||||
var/newname = sanitize(params["new_name"])
|
||||
if(!newname)
|
||||
return 1
|
||||
if(channel)
|
||||
channel.add_status_message("[username] is now known as [newname].")
|
||||
return
|
||||
for(var/C in SSnetworks.station_network.chat_channels)
|
||||
var/datum/ntnet_conversation/chan = C
|
||||
if(src in chan.clients)
|
||||
chan.add_status_message("[username] is now known as [newname].")
|
||||
username = newname
|
||||
|
||||
return TRUE
|
||||
if("PRG_savelog")
|
||||
. = 1
|
||||
if(!channel)
|
||||
return
|
||||
var/mob/living/user = usr
|
||||
var/logname = stripped_input(user,"Enter desired logfile name (.log) or leave blank to cancel:")
|
||||
if(!logname || !channel)
|
||||
return 1
|
||||
var/datum/computer_file/data/logfile = new/datum/computer_file/data/logfile()
|
||||
var/logname = stripped_input(params["log_name"])
|
||||
if(!logname)
|
||||
return
|
||||
var/datum/computer_file/data/logfile = new /datum/computer_file/data/logfile()
|
||||
// Now we will generate HTML-compliant file that can actually be viewed/printed.
|
||||
logfile.filename = logname
|
||||
logfile.stored_data = "\[b\]Logfile dump from NTNRC channel [channel.title]\[/b\]\[BR\]"
|
||||
for(var/logstring in channel.messages)
|
||||
logfile.stored_data += "[logstring]\[BR\]"
|
||||
logfile.stored_data += "\[b\]Logfile dump completed.\[/b\]"
|
||||
logfile.stored_data = "[logfile.stored_data][logstring]\[BR\]"
|
||||
logfile.stored_data = "[logfile.stored_data]\[b\]Logfile dump completed.\[/b\]"
|
||||
logfile.calculate_size()
|
||||
var/obj/item/computer_hardware/hard_drive/hard_drive = computer.all_components[MC_HDD]
|
||||
if(!computer || !hard_drive || !hard_drive.store_file(logfile))
|
||||
if(!computer)
|
||||
// This program shouldn't even be runnable without computer.
|
||||
CRASH("Var computer is null!")
|
||||
return 1
|
||||
if(!hard_drive)
|
||||
computer.visible_message("\The [computer] shows an \"I/O Error - Hard drive connection error\" warning.")
|
||||
computer.visible_message("<span class='warning'>\The [computer] shows an \"I/O Error - Hard drive connection error\" warning.</span>")
|
||||
else // In 99.9% cases this will mean our HDD is full
|
||||
computer.visible_message("\The [computer] shows an \"I/O Error - Hard drive may be full. Please free some space and try again. Required space: [logfile.size]GQ\" warning.")
|
||||
computer.visible_message("<span class='warning'>\The [computer] shows an \"I/O Error - Hard drive may be full. Please free some space and try again. Required space: [logfile.size]GQ\" warning.</span>")
|
||||
return TRUE
|
||||
if("PRG_renamechannel")
|
||||
. = 1
|
||||
if(!operator_mode || !channel)
|
||||
return 1
|
||||
var/mob/living/user = usr
|
||||
var/newname = reject_bad_text(input(user, "Enter new channel name or leave blank to cancel:"))
|
||||
if(!authed)
|
||||
return
|
||||
var/newname = reject_bad_text(params["new_name"])
|
||||
if(!newname || !channel)
|
||||
return
|
||||
channel.add_status_message("Channel renamed from [channel.title] to [newname] by operator.")
|
||||
channel.title = newname
|
||||
return TRUE
|
||||
if("PRG_deletechannel")
|
||||
. = 1
|
||||
if(channel && ((channel.operator == src) || netadmin_mode))
|
||||
if(authed)
|
||||
qdel(channel)
|
||||
channel = null
|
||||
active_channel = null
|
||||
return TRUE
|
||||
if("PRG_setpassword")
|
||||
. = 1
|
||||
if(!channel || ((channel.operator != src) && !netadmin_mode))
|
||||
return 1
|
||||
if(!authed)
|
||||
return
|
||||
|
||||
var/mob/living/user = usr
|
||||
var/newpassword = sanitize(input(user, "Enter new password for this channel. Leave blank to cancel, enter 'nopassword' to remove password completely:"))
|
||||
if(!channel || !newpassword || ((channel.operator != src) && !netadmin_mode))
|
||||
return 1
|
||||
var/new_password = sanitize(params["new_password"])
|
||||
if(!authed)
|
||||
return
|
||||
|
||||
if(newpassword == "nopassword")
|
||||
channel.password = ""
|
||||
else
|
||||
channel.password = newpassword
|
||||
channel.password = new_password
|
||||
return TRUE
|
||||
|
||||
/datum/computer_file/program/chatclient/process_tick()
|
||||
..()
|
||||
. = ..()
|
||||
var/datum/ntnet_conversation/channel = SSnetworks.station_network.get_chat_channel_by_id(active_channel)
|
||||
if(program_state != PROGRAM_STATE_KILLED)
|
||||
ui_header = "ntnrc_idle.gif"
|
||||
if(channel)
|
||||
// Remember the last message. If there is no message in the channel remember null.
|
||||
last_message = channel.messages.len ? channel.messages[channel.messages.len - 1] : null
|
||||
last_message = length(channel.messages) ? channel.messages[length(channel.messages)] : null
|
||||
else
|
||||
last_message = null
|
||||
return 1
|
||||
if(channel && channel.messages && channel.messages.len)
|
||||
ui_header = last_message == channel.messages[channel.messages.len - 1] ? "ntnrc_idle.gif" : "ntnrc_new.gif"
|
||||
return TRUE
|
||||
if(channel?.messages?.len)
|
||||
ui_header = last_message == channel.messages[length(channel.messages)] ? "ntnrc_idle.gif" : "ntnrc_new.gif"
|
||||
else
|
||||
ui_header = "ntnrc_idle.gif"
|
||||
|
||||
/datum/computer_file/program/chatclient/kill_program(forced = FALSE)
|
||||
if(channel)
|
||||
for(var/C in SSnetworks.station_network.chat_channels)
|
||||
var/datum/ntnet_conversation/channel = C
|
||||
channel.remove_client(src)
|
||||
channel = null
|
||||
..()
|
||||
|
||||
/datum/computer_file/program/chatclient/ui_static_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["can_admin"] = can_run(user, FALSE, ACCESS_NETWORK)
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/chatclient/ui_data(mob/user)
|
||||
if(!SSnetworks.station_network || !SSnetworks.station_network.chat_channels)
|
||||
return
|
||||
return list()
|
||||
|
||||
var/list/data = list()
|
||||
|
||||
data = get_header_data()
|
||||
|
||||
var/list/all_channels = list()
|
||||
for(var/C in SSnetworks.station_network.chat_channels)
|
||||
var/datum/ntnet_conversation/conv = C
|
||||
if(conv && conv.title)
|
||||
all_channels.Add(list(list(
|
||||
"chan" = conv.title,
|
||||
"id" = conv.id
|
||||
)))
|
||||
data["all_channels"] = all_channels
|
||||
|
||||
data["active_channel"] = active_channel
|
||||
data["username"] = username
|
||||
data["adminmode"] = netadmin_mode
|
||||
var/datum/ntnet_conversation/channel = SSnetworks.station_network.get_chat_channel_by_id(active_channel)
|
||||
if(channel)
|
||||
data["title"] = channel.title
|
||||
var/list/messages[0]
|
||||
for(var/M in channel.messages)
|
||||
messages.Add(list(list(
|
||||
"msg" = M
|
||||
)))
|
||||
data["messages"] = messages
|
||||
var/list/clients[0]
|
||||
var/authed = FALSE
|
||||
if(!channel.password)
|
||||
authed = TRUE
|
||||
if(netadmin_mode)
|
||||
authed = TRUE
|
||||
var/list/clients = list()
|
||||
for(var/C in channel.clients)
|
||||
if(C == src)
|
||||
authed = TRUE
|
||||
var/datum/computer_file/program/chatclient/cl = C
|
||||
clients.Add(list(list(
|
||||
"name" = cl.username
|
||||
)))
|
||||
data["clients"] = clients
|
||||
operator_mode = (channel.operator == src) ? 1 : 0
|
||||
data["is_operator"] = operator_mode || netadmin_mode
|
||||
|
||||
else // Channel selection screen
|
||||
var/list/all_channels[0]
|
||||
for(var/C in SSnetworks.station_network.chat_channels)
|
||||
var/datum/ntnet_conversation/conv = C
|
||||
if(conv && conv.title)
|
||||
all_channels.Add(list(list(
|
||||
"chan" = conv.title,
|
||||
"id" = conv.id
|
||||
data["authed"] = authed
|
||||
//no fishing for ui data allowed
|
||||
if(authed)
|
||||
data["clients"] = clients
|
||||
var/list/messages = list()
|
||||
for(var/M in channel.messages)
|
||||
messages.Add(list(list(
|
||||
"msg" = M
|
||||
)))
|
||||
data["all_channels"] = all_channels
|
||||
data["messages"] = messages
|
||||
data["is_operator"] = (channel.operator == src) || netadmin_mode
|
||||
else
|
||||
data["clients"] = list()
|
||||
data["messages"] = list()
|
||||
else
|
||||
data["clients"] = list()
|
||||
data["authed"] = FALSE
|
||||
data["messages"] = list()
|
||||
|
||||
return data
|
||||
return data
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
network_destination = "power monitoring system"
|
||||
size = 9
|
||||
tgui_id = "ntos_power_monitor"
|
||||
ui_x = 1200
|
||||
ui_y = 1000
|
||||
ui_style = "ntos"
|
||||
ui_x = 550
|
||||
ui_y = 700
|
||||
|
||||
var/has_alert = 0
|
||||
var/obj/structure/cable/attached_wire
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
network_destination = "supermatter monitoring system"
|
||||
size = 5
|
||||
tgui_id = "ntos_supermatter_monitor"
|
||||
ui_style = "ntos"
|
||||
ui_x = 600
|
||||
ui_y = 400
|
||||
ui_y = 350
|
||||
var/last_status = SUPERMATTER_INACTIVE
|
||||
var/list/supermatters
|
||||
var/obj/machinery/power/supermatter_crystal/active // Currently selected supermatter crystal.
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
var/dev_printer = 0 // 0: None, 1: Standard
|
||||
var/dev_card = 0 // 0: None, 1: Standard
|
||||
|
||||
ui_x = 500
|
||||
ui_y = 400
|
||||
|
||||
// Removes all traces of old order and allows you to begin configuration from scratch.
|
||||
/obj/machinery/lapvend/proc/reset_order()
|
||||
state = 0
|
||||
@@ -46,7 +49,7 @@
|
||||
dev_card = 0
|
||||
|
||||
// Recalculates the price and optionally even fabricates the device.
|
||||
/obj/machinery/lapvend/proc/fabricate_and_recalc_price(fabricate = 0)
|
||||
/obj/machinery/lapvend/proc/fabricate_and_recalc_price(fabricate = FALSE)
|
||||
total_price = 0
|
||||
if(devtype == 1) // Laptop, generally cheaper to make it accessible for most station roles
|
||||
var/obj/item/computer_hardware/battery/battery_module = null
|
||||
@@ -160,7 +163,7 @@
|
||||
if(fabricate)
|
||||
fabricated_tablet.install_component(new/obj/item/computer_hardware/card_slot)
|
||||
return total_price
|
||||
return 0
|
||||
return FALSE
|
||||
|
||||
|
||||
|
||||
@@ -168,90 +171,106 @@
|
||||
|
||||
/obj/machinery/lapvend/ui_act(action, params)
|
||||
if(..())
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
switch(action)
|
||||
if("pick_device")
|
||||
if(state) // We've already picked a device type
|
||||
return 0
|
||||
return FALSE
|
||||
devtype = text2num(params["pick"])
|
||||
state = 1
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
fabricate_and_recalc_price(FALSE)
|
||||
return TRUE
|
||||
if("clean_order")
|
||||
reset_order()
|
||||
return 1
|
||||
return TRUE
|
||||
if("purchase")
|
||||
try_purchase()
|
||||
return 1
|
||||
return TRUE
|
||||
if((state != 1) && devtype) // Following IFs should only be usable when in the Select Loadout mode
|
||||
return 0
|
||||
return FALSE
|
||||
switch(action)
|
||||
if("confirm_order")
|
||||
state = 2 // Wait for ID swipe for payment processing
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
fabricate_and_recalc_price(FALSE)
|
||||
return TRUE
|
||||
if("hw_cpu")
|
||||
dev_cpu = text2num(params["cpu"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
fabricate_and_recalc_price(FALSE)
|
||||
return TRUE
|
||||
if("hw_battery")
|
||||
dev_battery = text2num(params["battery"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
fabricate_and_recalc_price(FALSE)
|
||||
return TRUE
|
||||
if("hw_disk")
|
||||
dev_disk = text2num(params["disk"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
fabricate_and_recalc_price(FALSE)
|
||||
return TRUE
|
||||
if("hw_netcard")
|
||||
dev_netcard = text2num(params["netcard"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
fabricate_and_recalc_price(FALSE)
|
||||
return TRUE
|
||||
if("hw_tesla")
|
||||
dev_apc_recharger = text2num(params["tesla"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
fabricate_and_recalc_price(FALSE)
|
||||
return TRUE
|
||||
if("hw_nanoprint")
|
||||
dev_printer = text2num(params["print"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
fabricate_and_recalc_price(FALSE)
|
||||
return TRUE
|
||||
if("hw_card")
|
||||
dev_card = text2num(params["card"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
return 0
|
||||
fabricate_and_recalc_price(FALSE)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/obj/machinery/lapvend/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
||||
if(stat & (BROKEN | NOPOWER | MAINT))
|
||||
if(ui)
|
||||
ui.close()
|
||||
return 0
|
||||
return FALSE
|
||||
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "computer_fabricator", "Personal Computer Vendor", 500, 400, state = state)
|
||||
ui = new(user, src, ui_key, "computer_fabricator", "Personal Computer Vendor", ui_x, ui_y, state = state)
|
||||
ui.open()
|
||||
ui.set_autoupdate(state = 1)
|
||||
|
||||
/obj/machinery/lapvend/attackby(obj/item/I as obj, mob/user as mob)
|
||||
/obj/machinery/lapvend/attackby(obj/item/I, mob/user)
|
||||
if(istype(I, /obj/item/stack/spacecash))
|
||||
var/obj/item/stack/spacecash/c = I
|
||||
|
||||
if(!user.temporarilyRemoveItemFromInventory(c))
|
||||
return
|
||||
credits += c.value
|
||||
visible_message("<span class='info'><span class='name'>[usr]</span> inserts [c.value] credits into [src].</span>")
|
||||
visible_message("<span class='info'><span class='name'>[user]</span> inserts [c.value] credits into [src].</span>")
|
||||
qdel(c)
|
||||
return
|
||||
/*else if(istype(I, /obj/item/holochip))
|
||||
var/obj/item/holochip/HC = I
|
||||
credits += HC.credits
|
||||
visible_message("<span class='info'>[user] inserts a $[HC.credits] holocredit chip into [src].</span>")
|
||||
qdel(HC)
|
||||
return
|
||||
else if(istype(I, /obj/item/card/id))
|
||||
if(state != 2)
|
||||
return
|
||||
var/obj/item/card/id/ID = I
|
||||
var/datum/bank_account/account = ID.registered_account
|
||||
var/target_credits = total_price - credits
|
||||
if(!account.adjust_money(-target_credits))
|
||||
say("Insufficient money on card to purchase!")
|
||||
return
|
||||
credits += target_credits
|
||||
say("$[target_credits] has been desposited from your account.")
|
||||
return */ //Goonconomy when
|
||||
return ..()
|
||||
|
||||
// Simplified payment processing, returns 1 on success.
|
||||
/obj/machinery/lapvend/proc/process_payment()
|
||||
if(total_price > credits)
|
||||
say("Insufficient credits.")
|
||||
return 0
|
||||
return FALSE
|
||||
else
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/lapvend/ui_data(mob/user)
|
||||
|
||||
@@ -287,5 +306,6 @@
|
||||
credits -= total_price
|
||||
say("Enjoy your new product!")
|
||||
state = 3
|
||||
return 1
|
||||
return 0
|
||||
addtimer(CALLBACK(src, .proc/reset_order), 100)
|
||||
return TRUE
|
||||
return FALSE
|
||||
Reference in New Issue
Block a user