From 56989c8fbdb6a68cda4e10c27b19e577056cd73a Mon Sep 17 00:00:00 2001 From: Markolie Date: Tue, 28 Jul 2015 04:39:00 +0200 Subject: [PATCH] Convert multi shuttle UI's to NanoUI --- code/controllers/verbs.dm | 3 + code/game/area/Space Station 13 areas.dm | 4 +- code/game/gamemodes/nuclear/nuclearbomb.dm | 2 + code/modules/nano/nanoui.dm | 2 + code/modules/shuttles/antagonist.dm | 7 +- code/modules/shuttles/shuttles_multi.dm | 218 +++++++++++++------- nano/templates/nuclear_bomb.tmpl | 3 + nano/templates/shuttle_control_console.tmpl | 4 +- 8 files changed, 159 insertions(+), 84 deletions(-) diff --git a/code/controllers/verbs.dm b/code/controllers/verbs.dm index 3d70b903fdc..e83de442f1f 100644 --- a/code/controllers/verbs.dm +++ b/code/controllers/verbs.dm @@ -103,6 +103,9 @@ if("Scheduler") debug_variables(processScheduler) feedback_add_details("admin_verb","DprocessScheduler") + if("Nano") + debug_variables(nanomanager) + feedback_add_details("admin_verb","DNano") message_admins("Admin [key_name_admin(usr)] is debugging the [controller] controller.") return diff --git a/code/game/area/Space Station 13 areas.dm b/code/game/area/Space Station 13 areas.dm index b74473576ea..e5e5ca78c0c 100644 --- a/code/game/area/Space Station 13 areas.dm +++ b/code/game/area/Space Station 13 areas.dm @@ -1910,11 +1910,11 @@ area/security/podbay icon_state = "yellow" /area/shuttle/derelict/ship/engipost - name = "\improper Abandoned Ship" + name = "\improper Engineering Outpost" icon_state = "yellow" /area/shuttle/derelict/ship/station - name = "\improper Abandoned Ship" + name = "\improper NSS Cyberiad" icon_state = "yellow" /area/solar/derelict_starboard diff --git a/code/game/gamemodes/nuclear/nuclearbomb.dm b/code/game/gamemodes/nuclear/nuclearbomb.dm index c9f28e0c47c..4abd916a992 100644 --- a/code/game/gamemodes/nuclear/nuclearbomb.dm +++ b/code/game/gamemodes/nuclear/nuclearbomb.dm @@ -23,6 +23,7 @@ var/bomb_set var/timing_wire var/removal_stage = 0 // 0 is no removal, 1 is covers removed, 2 is covers open, 3 is sealant open, 4 is unwrenched, 5 is removed from bolts. var/lastentered + var/is_syndicate = 0 use_power = 0 unacidable = 1 @@ -186,6 +187,7 @@ obj/machinery/nuclearbomb/proc/nukehack_win(mob/user as mob) var/uiwidth var/uiheight var/uititle + data["is_syndicate"] = is_syndicate if(!src.opened) data["hacking"] = 0 data["auth"] = src.auth diff --git a/code/modules/nano/nanoui.dm b/code/modules/nano/nanoui.dm index 0a588e9b51a..ad797db7d74 100644 --- a/code/modules/nano/nanoui.dm +++ b/code/modules/nano/nanoui.dm @@ -392,6 +392,8 @@ nanoui is used to open and update nano browser uis * @return nothing */ /datum/nanoui/proc/open() + if(!user.client) + return var/window_size = "" if (width && height) window_size = "size=[width]x[height];" diff --git a/code/modules/shuttles/antagonist.dm b/code/modules/shuttles/antagonist.dm index c5152734570..1f5dccefdc2 100644 --- a/code/modules/shuttles/antagonist.dm +++ b/code/modules/shuttles/antagonist.dm @@ -2,8 +2,8 @@ name = "skipjack control console" req_access = list(access_vox) shuttle_tag = "Vox Skipjack" - icon_screen = "syndishuttle" - icon_keyboard = "syndie_key" + is_syndicate = 1 + warn_on_return = 1 /obj/machinery/computer/shuttle_control/multi/vox/attack_ai(user as mob) user << "\red Access Denied." @@ -13,8 +13,7 @@ name = "Syndicate control console" req_access = list(access_syndicate) shuttle_tag = "Syndicate" - icon_screen = "syndishuttle" - icon_keyboard = "syndie_key" + is_syndicate = 1 /obj/machinery/computer/shuttle_control/multi/syndicate/attack_ai(user as mob) user << "\red Access Denied." diff --git a/code/modules/shuttles/shuttles_multi.dm b/code/modules/shuttles/shuttles_multi.dm index d66f2e4ae80..09f1bce62a1 100644 --- a/code/modules/shuttles/shuttles_multi.dm +++ b/code/modules/shuttles/shuttles_multi.dm @@ -1,7 +1,7 @@ //This is a holder for things like the Vox and Nuke shuttle. /datum/shuttle/multi_shuttle - var/cloaked = 1 + var/can_cloak = 1 var/at_origin = 1 var/returned_home = 0 var/move_time = 240 @@ -16,11 +16,11 @@ var/area/last_departed var/list/destinations var/area/origin - var/return_warning = 0 /datum/shuttle/multi_shuttle/New() ..() - if(origin) last_departed = origin + if(origin) + last_departed = origin /datum/shuttle/multi_shuttle/move(var/area/origin, var/area/destination) ..() @@ -29,115 +29,181 @@ returned_home = 1 /datum/shuttle/multi_shuttle/proc/announce_departure() - if(cloaked || isnull(departure_message)) return command_announcement.Announce(departure_message,(announcer ? announcer : "Central Command")) /datum/shuttle/multi_shuttle/proc/announce_arrival() - if(cloaked || isnull(arrival_message)) return command_announcement.Announce(arrival_message,(announcer ? announcer : "Central Command")) /obj/machinery/computer/shuttle_control/multi - icon_screen = "syndishuttle" - icon_keyboard = "syndie_key" + icon_screen = "shuttle" + icon_keyboard = "med_key" + var/is_syndicate = 0 + var/warn_on_return = 0 + +/obj/machinery/computer/shuttle_control/multi/New() + ..() + if(is_syndicate) + icon_screen = "syndishuttle" + icon_keyboard = "syndie_key" /obj/machinery/computer/shuttle_control/multi/attack_hand(user as mob) - if(..(user)) - return - src.add_fingerprint(user) - + return 1 + + if(!allowed(user)) + user << "\red Access Denied." + return 1 + + ui_interact(user) + +/obj/machinery/computer/shuttle_control/multi/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) + var/data[0] var/datum/shuttle/multi_shuttle/MS = shuttle_controller.shuttles[shuttle_tag] - if(!istype(MS)) return + if (!istype(MS)) + return - var/dat - dat = "
[shuttle_tag] Ship Control
" + var/shuttle_state + switch(MS.moving_status) + if(SHUTTLE_IDLE) shuttle_state = "idle" + if(SHUTTLE_WARMUP) shuttle_state = "warmup" + if(SHUTTLE_INTRANSIT) shuttle_state = "in_transit" + if(MS.moving_status == SHUTTLE_IDLE && (MS.last_move + MS.cooldown*10) > world.time) + shuttle_state = "charging" - - if(MS.moving_status != SHUTTLE_IDLE) - dat += "Location: Moving
" + var/shuttle_status + if (MS.moving_status != SHUTTLE_IDLE) + shuttle_status = "Proceeding to destination." + else if (MS.at_origin) + shuttle_status = "Standing-by at base." else var/area/areacheck = get_area(src) - dat += "Location: [areacheck.name]
" + shuttle_status = "Standing-by at [sanitize(areacheck.name)]." - if((MS.last_move + MS.cooldown*10) > world.time) - dat += "Engines charging.
" - else - dat += "Engines ready.
" + data = list( + "shuttle_status" = shuttle_status, + "shuttle_state" = shuttle_state, + "can_launch" = can_launch(), + "can_return_to_base" = can_return_to_base(), + "can_cloak" = MS.can_cloak, + "cloaked" = MS.cloaked, + "is_syndicate" = is_syndicate + ) - dat += "
Toggle cloaking field
" - dat += "Move ship
" - dat += "Return to base
" + ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) - user << browse("[dat]", "window=[shuttle_tag]shuttlecontrol;size=300x600") + if (!ui) + ui = new(user, src, ui_key, "shuttle_control_multi_console.tmpl", "[shuttle_tag] Ship Control", 470, 310) + ui.set_initial_data(data) + ui.open() + ui.set_auto_update(1) +/obj/machinery/computer/shuttle_control/multi/proc/can_launch() + var/datum/shuttle/multi_shuttle/MS = shuttle_controller.shuttles[shuttle_tag] + if (!istype(MS)) + return + + if (MS.moving_status != SHUTTLE_IDLE) + return 0 + + if((MS.last_move + MS.cooldown * 10) > world.time) + return 0 + + return 1 + +/obj/machinery/computer/shuttle_control/multi/proc/can_return_to_base() + var/datum/shuttle/multi_shuttle/MS = shuttle_controller.shuttles[shuttle_tag] + if (!istype(MS)) + return + + if(MS.moving_status != SHUTTLE_IDLE) + return 0 + + if((MS.last_move + MS.cooldown * 10) > world.time) + return 0 + + if(MS.at_origin) + return 0 + + return 1 + +/obj/machinery/computer/shuttle_control/multi/proc/return_to_base() + var/datum/shuttle/multi_shuttle/MS = shuttle_controller.shuttles[shuttle_tag] + if (!istype(MS)) + return + + if(!can_return_to_base()) + return + + if(warn_on_return) + var/confirm = alert("Returning to your home base will end your mission. Are you sure you want to return to base?", "Confirm Return to Base", "Yes", "No") + if(confirm == "No") + return + + MS.long_jump(MS.last_departed,MS.origin,MS.interim,MS.move_time) + MS.last_departed = MS.origin + MS.at_origin = 1 + +/obj/machinery/computer/shuttle_control/multi/proc/toggle_cloak() + var/datum/shuttle/multi_shuttle/MS = shuttle_controller.shuttles[shuttle_tag] + if (!istype(MS)) + return + + MS.cloaked = !MS.cloaked + +/obj/machinery/computer/shuttle_control/multi/proc/launch_multi() + var/datum/shuttle/multi_shuttle/MS = shuttle_controller.shuttles[shuttle_tag] + if (!istype(MS)) + return + + if(MS.moving_status != SHUTTLE_IDLE) + return 0 + + if((MS.last_move + MS.cooldown * 10) > world.time) + return 0 + + var/choice = input("Select a destination.") as null|anything in MS.destinations + if(!choice) + return + + if(MS.at_origin) + MS.announce_arrival() + MS.last_departed = MS.origin + MS.at_origin = 0 + MS.long_jump(MS.last_departed, MS.destinations[choice], MS.interim, MS.move_time) + MS.last_departed = MS.destinations[choice] + return + + else if(choice == MS.origin) + MS.announce_departure() + + MS.short_jump(MS.last_departed, MS.destinations[choice]) + MS.last_departed = MS.destinations[choice] + /obj/machinery/computer/shuttle_control/multi/Topic(href, href_list) if(..()) return 1 + + if(!allowed(usr)) + return 1 usr.set_machine(src) src.add_fingerprint(usr) var/datum/shuttle/multi_shuttle/MS = shuttle_controller.shuttles[shuttle_tag] - if(!istype(MS)) return - - //world << "multi_shuttle: last_departed=[MS.last_departed], origin=[MS.origin], interim=[MS.interim], travel_time=[MS.move_time]" - - if (MS.moving_status != SHUTTLE_IDLE) - usr << "\blue [shuttle_tag] vessel is moving." + if(!istype(MS)) return if(href_list["start"]) - - if(MS.at_origin) - usr << "\red You are already at your home base." - return - - if(!MS.return_warning) - usr << "\red Returning to your home base will end your mission. If you are sure, press the button again." - //TODO: Actually end the mission. - MS.return_warning = 1 - return - - MS.long_jump(MS.last_departed,MS.origin,MS.interim,MS.move_time) - MS.last_departed = MS.origin - MS.at_origin = 1 + return_to_base() if(href_list["toggle_cloak"]) - - MS.cloaked = !MS.cloaked - usr << "\red Ship stealth systems have been [(MS.cloaked ? "activated. The station will not" : "deactivated. The station will")] be warned of our arrival." + toggle_cloak() if(href_list["move_multi"]) - if((MS.last_move + MS.cooldown*10) > world.time) - usr << "\red The ship's drive is inoperable while the engines are charging." - return - - var/choice = input("Select a destination.") as null|anything in MS.destinations - if(!choice) return - - usr << "\blue [shuttle_tag] main computer recieved message." - - if(MS.at_origin) - MS.announce_arrival() - MS.last_departed = MS.origin - MS.at_origin = 0 - - - MS.long_jump(MS.last_departed, MS.destinations[choice], MS.interim, MS.move_time) - MS.last_departed = MS.destinations[choice] - return - - else if(choice == MS.origin) - - MS.announce_departure() - - MS.short_jump(MS.last_departed, MS.destinations[choice]) - MS.last_departed = MS.destinations[choice] - - updateUsrDialog() \ No newline at end of file + launch_multi() diff --git a/nano/templates/nuclear_bomb.tmpl b/nano/templates/nuclear_bomb.tmpl index 1cb59404b72..087e3efb640 100644 --- a/nano/templates/nuclear_bomb.tmpl +++ b/nano/templates/nuclear_bomb.tmpl @@ -2,6 +2,9 @@ Title: Nuke Control Panel/Nuclear Bomb Defusion Used In File(s): \code\game\gamemodes\nuclear\nuclearbomb.dm --> +{{if data.is_syndicate}} + {{:helper.syndicateMode()}} +{{/if}} {{if !data.hacking}}
Authorization Disk: {{if data.auth}}{{:helper.link('++++++++++', 'eject', {'auth' : 1})}} {{else}} {{:helper.link('----------', 'disk', {'auth' : 1})}}{{/if}} diff --git a/nano/templates/shuttle_control_console.tmpl b/nano/templates/shuttle_control_console.tmpl index ccc4df70aaf..36540683159 100644 --- a/nano/templates/shuttle_control_console.tmpl +++ b/nano/templates/shuttle_control_console.tmpl @@ -13,9 +13,9 @@ {{if data.shuttle_state == "idle"}} IDLE {{else data.shuttle_state == "warmup"}} - SPINNING UP + SPINNING UP {{else data.shuttle_state == "in_transit"}} - ENGAGED + ENGAGED {{else}} ERROR {{/if}}