From eeeb68638fc581951bba0b960af06f57f4bffa67 Mon Sep 17 00:00:00 2001 From: errorage Date: Mon, 6 Jan 2014 04:25:28 +0100 Subject: [PATCH] Partial commit for the cyborg UI upgrade, which gets rid of the pop-up window for module selection, instead displaying the available modules in storage-item like fashion. Conflicts: code/_onclick/hud/_defines.dm code/_onclick/hud/robot.dm code/game/objects/items.dm code/modules/mob/living/silicon/robot/inventory.dm code/modules/mob/living/silicon/robot/robot.dm code/modules/mob/mob_defines.dm --- code/_onclick/hud/_defines.dm | 9 +-- code/_onclick/hud/robot.dm | 64 ++++++++++++++++++- code/_onclick/hud/screen_objects.dm | 14 ++-- code/game/machinery/camera/tracking.dm | 2 +- code/game/objects/items.dm | 22 ++++++- .../mob/living/silicon/robot/inventory.dm | 49 ++++++++++++++ .../modules/mob/living/silicon/robot/robot.dm | 38 ++++------- code/modules/mob/mob_helpers.dm | 5 ++ 8 files changed, 165 insertions(+), 38 deletions(-) diff --git a/code/_onclick/hud/_defines.dm b/code/_onclick/hud/_defines.dm index cfe0bf6012e..2e0db684bd7 100644 --- a/code/_onclick/hud/_defines.dm +++ b/code/_onclick/hud/_defines.dm @@ -47,7 +47,9 @@ #define ui_inv1 "6:16,1:5" //borgs #define ui_inv2 "7:16,1:5" //borgs #define ui_inv3 "8:16,1:5" //borgs -#define ui_borg_store "9:16,1:5" //borgs +#define ui_borg_module "CENTER+1:16,SOUTH:5" +#define ui_borg_store "CENTER+2:16,SOUTH:5" //borgs + #define ui_monkey_mask "5:14,1:5" //monkey #define ui_monkey_back "6:14,1:5" //monkey @@ -61,9 +63,8 @@ #define ui_zonesel "14:28,1:5" #define ui_acti_alt "14:28,1:5" //alternative intent switcher for when the interface is hidden (F12) -#define ui_borg_pull "12:24,2:7" -#define ui_borg_module "13:26,2:7" -#define ui_borg_panel "14:28,2:7" +#define ui_borg_pull "EAST-2:26,SOUTH+1:7" +#define ui_borg_panel "EAST-1:28,SOUTH+1:7" //Gun buttons #define ui_gun1 "13:26,3:7" diff --git a/code/_onclick/hud/robot.dm b/code/_onclick/hud/robot.dm index 62cf2247c3a..837d41ab7f8 100644 --- a/code/_onclick/hud/robot.dm +++ b/code/_onclick/hud/robot.dm @@ -164,7 +164,69 @@ mymob.client.screen = null - mymob.client.screen += list( mymob.throw_icon, mymob.zone_sel, mymob.oxygen, mymob.fire, mymob.hands, mymob.healths, mymob:cells, mymob.pullin, mymob.blind, mymob.flash, mymob.gun_setting_icon) //, mymob.rest, mymob.sleep, mymob.mach ) + mymob.client.screen += list(mymob.zone_sel, mymob.oxygen, mymob.fire, mymob.hands, mymob.healths, mymob:cells, mymob.pullin, mymob.blind, mymob.flash, mymob.gun_setting_icon) //, mymob.rest, mymob.sleep, mymob.mach ) mymob.client.screen += src.adding + src.other return + + +/datum/hud/proc/toggle_show_robot_modules() + if(!isrobot(mymob)) return + + var/mob/living/silicon/robot/r = mymob + + r.shown_robot_modules = !r.shown_robot_modules + update_robot_modules_display() + +/datum/hud/proc/update_robot_modules_display() + if(!isrobot(mymob)) return + + var/mob/living/silicon/robot/r = mymob + + if(r.shown_robot_modules) + //Modules display is shown + r.client.screen += r.throw_icon //"store" icon + + if(!r.module) + usr << "\red No module selected" + return + + if(!r.module.modules) + usr << "\red Selected module has no modules to select" + return + + if(!r.robot_modules_background) + return + + var/display_rows = round((r.module.modules.len) / 8) +1 //+1 because round() returns floor of number + r.robot_modules_background.screen_loc = "CENTER-4:16,SOUTH+1:7 to CENTER+3:16,SOUTH+[display_rows]:7" + r.client.screen += r.robot_modules_background + + var/x = -4 //Start at CENTER-4,SOUTH+1 + var/y = 1 + + for(var/atom/movable/A in r.module.modules) + if( (A != r.module_state_1) && (A != r.module_state_2) && (A != r.module_state_3) ) + //Module is not currently active + r.client.screen += A + if(x < 0) + A.screen_loc = "CENTER[x]:16,SOUTH+[y]:7" + else + A.screen_loc = "CENTER+[x]:16,SOUTH+[y]:7" + A.layer = 20 + + x++ + if(x == 4) + x = -4 + y++ + + else + //Modules display is hidden + r.client.screen -= r.throw_icon //"store" icon + + for(var/atom/A in r.module.modules) + if( (A != r.module_state_1) && (A != r.module_state_2) && (A != r.module_state_3) ) + //Module is not currently active + r.client.screen -= A + r.shown_robot_modules = 0 + r.client.screen -= r.robot_modules_background diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 4ca8f9f5d75..e486fb65c10 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -331,10 +331,12 @@ usr.drop_item_v() if("module") - if(issilicon(usr)) - if(usr:module) + if(isrobot(usr)) + var/mob/living/silicon/robot/R = usr + if(R.module) + R.hud_used.toggle_show_robot_modules() return 1 - usr:pick_module() + R.pick_module() if("radio") if(issilicon(usr)) @@ -344,8 +346,10 @@ usr:installed_modules() if("store") - if(issilicon(usr)) - usr:uneq_active() + if(isrobot(usr)) + var/mob/living/silicon/robot/R = usr + R.uneq_active() + R.hud_used.update_robot_modules_display() if("module1") if(istype(usr, /mob/living/silicon/robot)) diff --git a/code/game/machinery/camera/tracking.dm b/code/game/machinery/camera/tracking.dm index 8124adc6d07..9b9394fb88d 100644 --- a/code/game/machinery/camera/tracking.dm +++ b/code/game/machinery/camera/tracking.dm @@ -155,7 +155,7 @@ else //world << "[D.name] not close enough | [get_dist(D, target)] | [dist]" if(tobeopened) - switch(alert(G, "Do you want to open \the [tobeopened] for [target]?","Doorknob_v2a.exe","Yes","No")) + switch(alert(src, "Do you want to open \the [tobeopened] for [target]?","Doorknob_v2a.exe","Yes","No")) if("Yes") var/nhref = "src=\ref[tobeopened];aiEnable=7" tobeopened.Topic(nhref, params2list(nhref), tobeopened, 1) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 109f36be7a1..e6a8b6cfb79 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -119,6 +119,7 @@ return if (istype(src.loc, /obj/item/weapon/storage)) + //If the item is in a storage item, take it out var/obj/item/weapon/storage/S = src.loc S.remove_from_storage(src) @@ -171,6 +172,25 @@ user.put_in_active_hand(src) return + +/obj/item/attack_alien(mob/user as mob) + var/mob/living/carbon/alien/A = user + + if(!A.has_fine_manipulation || w_class >= 4) + if(src in A.contents) // To stop Aliens having items stuck in their pockets + A.drop_from_inventory(src) + user << "Your claws aren't capable of such fine manipulation." + return + attack_paw(A) + +/obj/item/attack_ai(mob/user as mob) + if (istype(src.loc, /obj/item/weapon/robot_module)) + //If the item is part of a cyborg module, equip it + if(!isrobot(user)) return + var/mob/living/silicon/robot/R = user + R.activate_module(src) + R.hud_used.update_robot_modules_display() + // Due to storage type consolidation this should get used more now. // I have cleaned it up a little, but it could probably use more. -Sayu /obj/item/attackby(obj/item/weapon/W as obj, mob/user as mob) @@ -619,4 +639,4 @@ //not sure if this is worth it. It attaches the blood_overlay to every item of the same type if they don't have one already made. for(var/obj/item/A in world) if(A.type == type && !A.blood_overlay) - A.blood_overlay = I \ No newline at end of file + A.blood_overlay = I diff --git a/code/modules/mob/living/silicon/robot/inventory.dm b/code/modules/mob/living/silicon/robot/inventory.dm index 3b16b7a5a72..47036010b48 100644 --- a/code/modules/mob/living/silicon/robot/inventory.dm +++ b/code/modules/mob/living/silicon/robot/inventory.dm @@ -15,6 +15,26 @@ if (client) client.screen -= module_state_1 contents -= module_state_1 + +/mob/living/silicon/robot/proc/uneq_module(obj/item/O) + if(!O) + return 0 + + if(istype(O,/obj/item/borg/sight)) + var/obj/item/borg/sight/S = O + sight_mode &= ~S.sight_mode + else if(istype(O, /obj/item/device/flashlight)) + var/obj/item/device/flashlight/F = O + if(F.on) + F.on = 0 + F.update_brightness(src) + if(client) + client.screen -= O + contents -= O + if(module) + O.loc = module //Return item to module so it appears in its contents, so it can be taken out again. + + if(module_active == O) module_active = null module_state_1 = null inv1.icon_state = "inv1" @@ -37,6 +57,35 @@ module_state_3 = null inv3.icon_state = "inv3" updateicon() + return 1 + +/mob/living/silicon/robot/proc/activate_module(var/obj/item/O) + if(!(locate(O) in src.module.modules) && O != src.module.emag) + return + if(activated(O)) + src << "Already activated" + return + if(!module_state_1) + module_state_1 = O + O.layer = 20 + contents += O + if(istype(module_state_1,/obj/item/borg/sight)) + sight_mode |= module_state_1:sight_mode + else if(!module_state_2) + module_state_2 = O + O.layer = 20 + contents += O + if(istype(module_state_2,/obj/item/borg/sight)) + sight_mode |= module_state_2:sight_mode + else if(!module_state_3) + module_state_3 = O + O.layer = 20 + contents += O + if(istype(module_state_3,/obj/item/borg/sight)) + sight_mode |= module_state_3:sight_mode + else + src << "You need to disable a module first!" + /mob/living/silicon/robot/proc/uneq_all() module_active = null diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 3568b581ec5..638011ecd12 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -18,6 +18,9 @@ var/obj/screen/inv2 = null var/obj/screen/inv3 = null + var/shown_robot_modules = 0 //Used to determine whether they have the module menu shown or not + var/obj/screen/robot_modules_background + //3 Modules can be activated at any one time. var/obj/item/weapon/robot_module/module = null var/module_active = null @@ -71,6 +74,13 @@ spark_system.set_up(5, 0, src) spark_system.attach(src) + +// wires = new(src) + + robot_modules_background = new() + robot_modules_background.icon_state = "block" + robot_modules_background.layer = 19 //Objects that appear on screen are on layer 20, UI should be just below it. + ident = rand(1, 999) updatename("Default") updateicon() @@ -1111,31 +1121,7 @@ if (href_list["act"]) var/obj/item/O = locate(href_list["act"]) - if(!(locate(O) in src.module.modules) && O != src.module.emag) - return - if(activated(O)) - src << "Already activated" - return - if(!module_state_1) - module_state_1 = O - O.layer = 20 - contents += O - if(istype(module_state_1,/obj/item/borg/sight)) - sight_mode |= module_state_1:sight_mode - else if(!module_state_2) - module_state_2 = O - O.layer = 20 - contents += O - if(istype(module_state_2,/obj/item/borg/sight)) - sight_mode |= module_state_2:sight_mode - else if(!module_state_3) - module_state_3 = O - O.layer = 20 - contents += O - if(istype(module_state_3,/obj/item/borg/sight)) - sight_mode |= module_state_3:sight_mode - else - src << "You need to disable a module first!" + activate_module(O) installed_modules() if (href_list["deact"]) @@ -1286,4 +1272,4 @@ triesleft = 0 return else - src << "Your icon has been set. You now require a module reset to change it." \ No newline at end of file + src << "Your icon has been set. You now require a module reset to change it." diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index eda2722ae36..58bf31d55d7 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -90,6 +90,11 @@ return 1 return 0 +/proc/isAIEye(A) + if(istype(A, /mob/camera/aiEye)) + return 1 + return 0 + /proc/ispAI(A) if(istype(A, /mob/living/silicon/pai)) return 1