From 9c21e0bcdc0779f3df2823b6cc8e6eab86057ed0 Mon Sep 17 00:00:00 2001 From: Datraen Date: Fri, 8 Apr 2016 23:07:10 -0400 Subject: [PATCH] Manually ports /tg/'s darkclick code. https://github.com/tgstation/-tg-station/pull/10272 by Razharas. --- code/_helpers/unsorted.dm | 12 ++++++++++++ code/_onclick/click.dm | 17 +++++++++++++++++ code/_onclick/hud/ai.dm | 2 ++ code/_onclick/hud/alien_larva.dm | 5 +++-- code/_onclick/hud/human.dm | 3 ++- code/_onclick/hud/other_mobs.dm | 9 ++++++--- code/_onclick/hud/robot.dm | 3 ++- code/modules/client/client defines.dm | 2 ++ code/modules/client/client procs.dm | 4 ++++ .../mob/living/simple_animal/simple_animal.dm | 3 ++- code/modules/mob/login.dm | 2 +- code/modules/mob/mob.dm | 1 + html/changelogs/Datraen-DarkClickPort.yml | 6 ++++++ 13 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 html/changelogs/Datraen-DarkClickPort.yml diff --git a/code/_helpers/unsorted.dm b/code/_helpers/unsorted.dm index f9a6583897..dc17e47a59 100644 --- a/code/_helpers/unsorted.dm +++ b/code/_helpers/unsorted.dm @@ -1310,3 +1310,15 @@ var/mob/dview/dview_mob = new // call to generate a stack trace and print to runtime logs /proc/crash_with(msg) CRASH(msg) + +/proc/screen_loc2turf(scr_loc, turf/origin) + var/tX = splittext(scr_loc, ",") + var/tY = splittext(tX[2], ":") + var/tZ = origin.z + tY = tY[1] + tX = splittext(tX[1], ":") + tX = tX[1] + tX = max(1, min(world.maxx, origin.x + (text2num(tX) - (world.view + 1)))) + tY = max(1, min(world.maxy, origin.y + (text2num(tY) - (world.view + 1)))) + return locate(tX, tY, tZ) + diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index 7d7468b91a..8980eefcf9 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -325,3 +325,20 @@ else direction = WEST if(direction != dir) facedir(direction) + +/obj/screen/click_catcher + icon = 'icons/mob/screen1_full.dmi' + icon_state = "passage0" + layer = 0 + mouse_opacity = 2 + screen_loc = "1,1" + +/obj/screen/click_catcher/Click(location, control, params) + var/list/modifiers = params2list(params) + if(modifiers["middle"] && istype(usr, /mob/living/carbon)) + var/mob/living/carbon/C = usr + C.swap_hand() + else + var/turf/T = screen_loc2turf(modifiers["screen-loc"], get_turf(usr)) + T.Click(location, control, params) + return 1 diff --git a/code/_onclick/hud/ai.dm b/code/_onclick/hud/ai.dm index ab959eae53..44c2a762bb 100644 --- a/code/_onclick/hud/ai.dm +++ b/code/_onclick/hud/ai.dm @@ -130,6 +130,8 @@ using.layer = SCREEN_LAYER adding += using + mymob.client.screen = list() mymob.client.screen += adding + other + mymob.client.screen += mymob.client.void return \ No newline at end of file diff --git a/code/_onclick/hud/alien_larva.dm b/code/_onclick/hud/alien_larva.dm index 59004934d7..4fa0e4110a 100644 --- a/code/_onclick/hud/alien_larva.dm +++ b/code/_onclick/hud/alien_larva.dm @@ -41,6 +41,7 @@ mymob.fire.name = "fire" mymob.fire.screen_loc = ui_fire - mymob.client.screen = null + mymob.client.screen = list() mymob.client.screen += list( mymob.healths, mymob.blind, mymob.flash, mymob.fire) //, mymob.rest, mymob.sleep, mymob.mach ) - mymob.client.screen += src.adding + src.other \ No newline at end of file + mymob.client.screen += src.adding + src.other + mymob.client.screen += mymob.client.void \ No newline at end of file diff --git a/code/_onclick/hud/human.dm b/code/_onclick/hud/human.dm index 63ef549122..c631a3435d 100644 --- a/code/_onclick/hud/human.dm +++ b/code/_onclick/hud/human.dm @@ -361,10 +361,11 @@ mymob.radio_use_icon.color = ui_color mymob.radio_use_icon.alpha = ui_alpha - mymob.client.screen = null + mymob.client.screen = list() mymob.client.screen += hud_elements mymob.client.screen += src.adding + src.hotkeybuttons + mymob.client.screen += mymob.client.void inventory_shown = 0; return diff --git a/code/_onclick/hud/other_mobs.dm b/code/_onclick/hud/other_mobs.dm index 69896b163a..76922e398c 100644 --- a/code/_onclick/hud/other_mobs.dm +++ b/code/_onclick/hud/other_mobs.dm @@ -27,9 +27,10 @@ blobhealthdisplay.screen_loc = ui_internal blobhealthdisplay.layer = 20 - mymob.client.screen = null + mymob.client.screen = list() mymob.client.screen += list(blobpwrdisplay, blobhealthdisplay) + mymob.client.screen += mymob.client.void /datum/hud/proc/slime_hud(ui_style = 'icons/mob/screen1_Midnight.dmi') @@ -94,8 +95,9 @@ src.adding += using hurt_intent = using - mymob.client.screen = null + mymob.client.screen = list() mymob.client.screen += src.adding + mymob.client.screen += mymob.client.void return @@ -151,6 +153,7 @@ mymob.purged.name = "purged" mymob.purged.screen_loc = ui_construct_purge - mymob.client.screen = null + mymob.client.screen = list() mymob.client.screen += list(mymob.fire, mymob.healths, mymob.pullin, mymob.zone_sel, mymob.purged, mymob.flash) + mymob.client.screen += mymob.client.void diff --git a/code/_onclick/hud/robot.dm b/code/_onclick/hud/robot.dm index 95f8f3c9d3..a272ba83aa 100644 --- a/code/_onclick/hud/robot.dm +++ b/code/_onclick/hud/robot.dm @@ -157,10 +157,11 @@ var/obj/screen/robot_inventory mymob.gun_move_icon = new /obj/screen/gun/move(null) mymob.radio_use_icon = new /obj/screen/gun/radio(null) - mymob.client.screen = null + mymob.client.screen = list() 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, robot_inventory, mymob.gun_setting_icon) mymob.client.screen += src.adding + src.other + mymob.client.screen += mymob.client.void return diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index 0961115d6a..b559652132 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -46,3 +46,5 @@ var/related_accounts_cid = "Requires database" //So admins know why it isn't working - Used to determine what other accounts previously logged in from this computer id preload_rsc = 0 // This is 0 so we can set it to an URL once the player logs in and have them download the resources from a different server. + var/global/obj/screen/click_catcher/void + diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index c7a6dd7ccb..4c05ebece5 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -159,6 +159,10 @@ send_resources() nanomanager.send_resources(src) + + if(!void) + void = new() + screen += void if(prefs.lastchangelog != changelog_hash) //bolds the changelog button on the interface so we know there are updates. src << "You have unread updates in the changelog." diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index 2de63692a9..2fbad9deee 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -72,7 +72,8 @@ /mob/living/simple_animal/Login() if(src && src.client) - src.client.screen = null + src.client.screen = list() + src.client.screen += src.client.void ..() /mob/living/simple_animal/updatehealth() diff --git a/code/modules/mob/login.dm b/code/modules/mob/login.dm index 7658f28ce1..7f6fdd8aab 100644 --- a/code/modules/mob/login.dm +++ b/code/modules/mob/login.dm @@ -30,7 +30,7 @@ world.update_status() client.images = null //remove the images such as AIs being unable to see runes - client.screen = null //remove hud items just in case + client.screen = list() //remove hud items just in case if(hud_used) qdel(hud_used) //remove the hud objects hud_used = new /datum/hud(src) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 059208e323..4503ae144b 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -362,6 +362,7 @@ log_game("[usr.key] AM failed due to disconnect.") return client.screen.Cut() + client.screen += client.void if(!client) log_game("[usr.key] AM failed due to disconnect.") return diff --git a/html/changelogs/Datraen-DarkClickPort.yml b/html/changelogs/Datraen-DarkClickPort.yml new file mode 100644 index 0000000000..c34938f923 --- /dev/null +++ b/html/changelogs/Datraen-DarkClickPort.yml @@ -0,0 +1,6 @@ +author: Datraen + +delete-after: True + +changes: + - rscadd: "Manually ports /tg/station's dark click code https://github.com/tgstation/-tg-station/pull/10272 by Razharas."