From bfcd050b7702b95481d80f5af0a4a4318090fdee 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. --- code/_onclick/hud/_defines.dm | 6 +- code/_onclick/hud/robot.dm | 64 ++++++++++++++++++- code/_onclick/hud/screen_objects.dm | 14 ++-- code/game/objects/items.dm | 8 +++ .../mob/living/silicon/robot/inventory.dm | 29 +++++++++ .../modules/mob/living/silicon/robot/robot.dm | 33 +++------- code/modules/mob/mob_defines.dm | 2 +- 7 files changed, 121 insertions(+), 35 deletions(-) diff --git a/code/_onclick/hud/_defines.dm b/code/_onclick/hud/_defines.dm index 35843704d40..365a2171c35 100644 --- a/code/_onclick/hud/_defines.dm +++ b/code/_onclick/hud/_defines.dm @@ -47,7 +47,8 @@ #define ui_inv1 "CENTER-2:16,SOUTH:5" //borgs #define ui_inv2 "CENTER-1 :16,SOUTH:5" //borgs #define ui_inv3 "CENTER :16,SOUTH:5" //borgs -#define ui_borg_store "CENTER+1:16,SOUTH: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 "CENTER-3:14,SOUTH:5" //monkey #define ui_monkey_back "CENTER-2:15,SOUTH:5" //monkey @@ -63,8 +64,7 @@ #define ui_zonesel "EAST-1:28,SOUTH:5" #define ui_acti_alt "EAST-1:28,SOUTH:5" //alternative intent switcher for when the interface is hidden (F12) -#define ui_borg_pull "EAST-3:24,SOUTH+1:7" -#define ui_borg_module "EAST-2:26,SOUTH+1:7" +#define ui_borg_pull "EAST-2:26,SOUTH+1:7" #define ui_borg_panel "EAST-1:28,SOUTH+1:7" //Upper-middle right (damage indicators) diff --git a/code/_onclick/hud/robot.dm b/code/_onclick/hud/robot.dm index 0248fe29392..053a0939b32 100644 --- a/code/_onclick/hud/robot.dm +++ b/code/_onclick/hud/robot.dm @@ -137,7 +137,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.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.rest, mymob.sleep, mymob.mach ) mymob.client.screen += adding + 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 \ No newline at end of file diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index caa18cf47a3..14b8ac47f88 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -263,10 +263,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)) @@ -276,8 +278,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/objects/items.dm b/code/game/objects/items.dm index ed813c12dd6..91b91f4332f 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -117,6 +117,7 @@ /obj/item/attack_hand(mob/user as mob) if (!user) 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,13 @@ 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 diff --git a/code/modules/mob/living/silicon/robot/inventory.dm b/code/modules/mob/living/silicon/robot/inventory.dm index f3ae6c7e5de..b0ddd0f16c1 100644 --- a/code/modules/mob/living/silicon/robot/inventory.dm +++ b/code/modules/mob/living/silicon/robot/inventory.dm @@ -23,6 +23,8 @@ 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 @@ -37,6 +39,33 @@ inv3.icon_state = "inv3" 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_active() uneq_module(module_active) diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 7a234920db6..301c9918b21 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -15,6 +15,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 @@ -67,6 +70,10 @@ 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() @@ -871,31 +878,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"]) diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index f5c8e414940..4902ca14738 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -166,4 +166,4 @@ var/robot_talk_understand = 0 var/alien_talk_understand = 0 - var/turf/listed_turf = null //the current turf being examined in the stat panel + var/turf/listed_turf = null //the current turf being examined in the stat panel \ No newline at end of file