diff --git a/code/modules/shuttle/shuttle_manipulator.dm b/code/modules/shuttle/shuttle_manipulator.dm index b69d219161b..5e601c1611f 100644 --- a/code/modules/shuttle/shuttle_manipulator.dm +++ b/code/modules/shuttle/shuttle_manipulator.dm @@ -1,8 +1,3 @@ -#define SHUTTLE_MANIPULATOR_STATUS 1 -#define SHUTTLE_MANIPULATOR_TEMPLATE 2 -#define SHUTTLE_MANIPULATOR_MOD 3 -#define NUM_SHUTTLE_MANIPULATOR_TABS 3 - /obj/machinery/shuttle_manipulator name = "shuttle manipulator" @@ -15,7 +10,7 @@ icon = 'icons/obj/machines/shuttle_manipulator.dmi' icon_state = "holograph_on" - var/current_tab = SHUTTLE_MANIPULATOR_STATUS + var/selected_menu_key = "stat" var/busy // UI state variables var/datum/map_template/shuttle/selected @@ -49,15 +44,25 @@ attack_hand(user) /obj/machinery/shuttle_manipulator/attack_hand(mob/user as mob) - user.set_machine(src) - interact(user) + ui_interact(user) + +/obj/machinery/shuttle_manipulator/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) + + // this is the data which will be sent to the ui + var/data[0] + data["selectedMenuKey"] = selected_menu_key + + data["templates"] = list() + var/list/templates = data["templates"] + data["templates_tabs"] = list() + data["selected"] = list() -/obj/machinery/shuttle_manipulator/interact(mob/user) for(var/shuttle_id in shuttle_templates) var/datum/map_template/shuttle/S = shuttle_templates[shuttle_id] if(!templates[S.port_id]) + data["templates_tabs"] += S.port_id templates[S.port_id] = list( "port_id" = S.port_id, "templates" = list()) @@ -70,12 +75,16 @@ L["admin_notes"] = S.admin_notes if(selected == S) - shuttle_data["selected"] = L + data["selected"] = L templates[S.port_id]["templates"] += list(L) + data["templates_tabs"] = sortList(data["templates_tabs"]) - // Status panel + data["existing_shuttle"] = null + + // Status panel + data["shuttles"] = list() for(var/i in shuttle_master.mobile) var/obj/docking_port/mobile/M = i var/list/L = list() @@ -83,62 +92,30 @@ L["id"] = M.id L["timer"] = M.timer L["timeleft"] = M.getTimerStr() - L["mode"] = capitalize(M.mode) + var/can_fast_travel = FALSE + if(M.timer && M.timeLeft() >= 50) + can_fast_travel = TRUE + L["can_fast_travel"] = can_fast_travel + L["mode"] = M.mode L["status"] = M.getStatusText() if(M == existing_shuttle) - shuttle_data["existing_shuttle"] = L + data["existing_shuttle"] = L - shuttle_data["shuttles"] += list(L) + data["shuttles"] += list(L) - var/dat = "" - dat += "
" - dat += "Status" - dat += "Templates" - dat += "Modification" - dat += "
" - dat += "
" + // update the ui if it exists, returns null if no ui is passed/found + ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) + if(!ui) + // the ui does not exist, so we'll create a new() one + // for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm + ui = new(user, src, ui_key, "shuttle_manipulator.tmpl", "Shuttle Manipulator", 660, 700) + // when the ui is first opened this is the data it will use + ui.set_initial_data(data) + // open the new ui window + ui.open() + // auto update every Master Controller tick + ui.set_auto_update(1) - if(busy) - dat += "
Shuttle Manipulation in progress...
" - else - dat += "
" - - switch(current_tab) - if(SHUTTLE_MANIPULATOR_STATUS) - dat += "
" - for(var/list/shuttle in shuttle_data["shuttles"]) - dat += "
" - dat += "[shuttle["name"]] [shuttle["id"]]: [shuttle["mode"]] [shuttle["status"]] [shuttle["timer"]] " - dat += "Jump To" - dat += "Fast Travel" - dat += "
" - dat += "
" - if(SHUTTLE_MANIPULATOR_TEMPLATE) - dat += "
" - for(var/list/shuttle in shuttle_data["shuttles"]) - dat += "
" - dat += " [shuttle["name"]]
[shuttle["description"]]
[shuttle["admin_notes"]]
" - dat += "Load Template" - dat += "Select Template" - dat += "Preview Template" - dat += "
" - dat += "
" - if(SHUTTLE_MANIPULATOR_MOD) - dat += "
" - for(var/list/shuttle in shuttle_data["shuttles"]) - dat += "
" - dat += "[shuttle["name"]] [shuttle["id"]]
[shuttle["description"]]
[shuttle["admin_notes"]]
" - dat += "Send to port" - dat += "Jump To" - dat += "
" - dat += "
" - dat += "
" - - var/datum/browser/popup = new(user, "shuttle manipulator", "Shuttle Manipulator", 500, 500) - popup.set_content(dat) - popup.open() - - return /obj/machinery/shuttle_manipulator/Topic(href, href_list) if(..()) @@ -187,14 +164,6 @@ var/mdp = action_load(S) if(mdp) user.forceMove(get_turf(mdp)) - if(href_list["tabchange"]) - var/newtab = text2num(href_list["tab"]) - // I am NOT making this take like 10 lines - if(!(newtab in list(1,2,3))) - log_debug("[newtab] is not a valid tab ID!") - return - . = TRUE - current_tab = round(newtab) /obj/machinery/shuttle_manipulator/proc/action_load( datum/map_template/shuttle/loading_template) diff --git a/nano/templates/shuttle_mainpulator.tmpl.txt b/nano/templates/shuttle_mainpulator.tmpl.txt deleted file mode 100644 index 6a27d82b8e4..00000000000 --- a/nano/templates/shuttle_mainpulator.tmpl.txt +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - - - {{#if data.selected}} - - {{/if}} - {{#if !data.selected}} - No shuttle selected. - {{/if}} - - - - - {{#if data.selected.description}} - {{data.selected.description}} - {{/if}} - {{#if data.selected.admin_notes}} - {{data.selected.admin_notes}} - {{/if}} - - -{{#if data.existing_shuttle}} - - Status: {{data.existing_shuttle.status}} - {{#if data.existing_shuttle.timer}} - ({{data.existing_shuttle.timeleft}}) - {{/if}} - - Jump To - - -{{/if}} - -{{#if !data.existing_shuttle}} - -{{/if}} - - - Preview - - - Load - - - - - - - {{#if data.selected.description}} - {{data.selected.description}} - {{/if}} - {{#if data.selected.admin_notes}} - {{data.selected.admin_notes}} - {{/if}} - - -{{#if data.existing_shuttle}} - - Status: {{data.existing_shuttle.status}} - {{#if data.existing_shuttle.timer}} - ({{data.existing_shuttle.timeleft}}) - {{/if}} - - Jump To - - -{{/if}} - -{{#if !data.existing_shuttle}} - -{{/if}} - - - Preview - - - Load - - - - - -{{#each data.shuttles}} - - {{status}} - {{#if timer}} - ({{timeleft}}) - {{/if}} - - Jump To - - -{{/each}} - - - - - {{#each data.templates}} - - {{#each templates}} - - {{#if description}} - {{description}} - {{/if}} - {{#if admin_notes}} - {{admin_notes}} - {{/if}} - - - {{data.selected.shuttle_id == shuttle_id ? "Selected" : "Select"}} - - - - {{/each}} - - {{/each}} - \ No newline at end of file diff --git a/nano/templates/shuttle_manipulator.tmpl b/nano/templates/shuttle_manipulator.tmpl new file mode 100644 index 00000000000..288550fe647 --- /dev/null +++ b/nano/templates/shuttle_manipulator.tmpl @@ -0,0 +1,77 @@ + + +

Operations

+
+ {{:helper.link('Status', 'link', {'selectMenuKey' : 'stat'}, data.selectedMenuKey == 'stat' ? 'selected' : null)}} + {{:helper.link('Templates', 'link', {'selectMenuKey' : 'stemp'}, data.selectedMenuKey == 'stemp' ? 'selected' : null)}} + {{:helper.link('Modification', 'link', {'selectMenuKey' : 'mod'}, data.selectedMenuKey == 'mod' ? 'selected' : null)}} +
+ +
 
+ + +{{if !data.selectedMenuKey || data.selectedMenuKey == 'stat'}} + +
+ + {{for data.shuttles}} + Name: {{value.name}} + ID: {{value.shuttle_id}} + Shuttle Timer: {{value.timeleft}} + Shuttle Mode: {{value.mode}} + Shuttle Status: {{value.status}} + {{:helper.link('Jump to', 'exclamation-circle', {'jump_to' : 1, 'id' : value.shuttle_id} : null)}} + {{:helper.link('Fast Travel', 'exclamation-circle', {'fast_travel' : 1},: null)}} + {{/for}} +
+ +{{else data.selectedMenuKey == 'stemp'}} +
+ + {{for data.templates}} + {{if description}} + Description: {{data.description}} + {{/if}} + {{if admin_notes}} + Admin Notes: {{data.admin_notes}} + {{/if}} + + {{:helper.link('select template', 'exclamation-circle', {'use_template' : 1}: null)}} + {{/for}} +
+ +{{else data.selectedMenuKey == 'mod'}} +
+ + {{if data.selected.description}} + Description: {{data.selected.description}} + {{/if}} + {{if data.selected.admin_notes}} + Admin Notes: {{data.selected.admin_notes}} + {{/if}} + + + + {{:helper.link('Jump to', 'exclamation-circle', {'jump_to' : 1, 'id' : data.selected.shuttle_id} : null)}} + + + {{if data.existing_shuttle}} + Existing Shuttle: {{data.existing_shuttle.name}} + Status: {{data.existing_shuttle.status}} + {{if data.existing_shuttle.timer}} + ({{data.existing_shuttle.timeleft}}) + {{/if}} + {{/if}} + + {{:helper.link('Preview', 'exclamation-circle', {'preview' : 1, 'id' : data.selected.shuttle_id} : null)}} + {{:helper.link('Load', 'exclamation-circle', {'load' : 1, 'id' : data.selected.shuttle_id} : null)}} + + + + + + +
+