From fea00718a0c889669e07d576cadcccd7fded90c2 Mon Sep 17 00:00:00 2001 From: Razharas Date: Thu, 4 Jun 2015 07:47:20 +0300 Subject: [PATCH] Made swap hands use screen object Made swap hands use screen object Also now blindness is restricting your ability to click You can shoot at darkness now, it calculates the turf you want to shoot Added toggleable verb into the prefs tab for autoclick Made proc that calculates turf from screen loc and origin turf --- code/__HELPERS/unsorted.dm | 11 +++++++++++ code/_onclick/hud/alien.dm | 1 + code/_onclick/hud/alien_larva.dm | 1 + code/_onclick/hud/human.dm | 2 +- code/_onclick/hud/monkey.dm | 1 + code/_onclick/hud/other_mobs.dm | 1 + code/_onclick/hud/robot.dm | 1 + code/_onclick/hud/screen_objects.dm | 12 ++++++------ code/modules/client/client procs.dm | 16 +++++----------- code/modules/client/preferences.dm | 5 +---- code/modules/client/preferences_toggles.dm | 9 +++++++++ 11 files changed, 38 insertions(+), 22 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index adb3b60c80b..468389350b0 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1304,3 +1304,14 @@ var/list/WALLITEMS = list( "lime","darkgreen","cyan","navy","teal","purple","indigo") else return "white" + +/proc/screen_loc2turf(scr_loc, turf/origin) + var/tX = text2list(scr_loc, ",") + var/tY = text2list(tX[2], ":") + var/tZ = origin.z + tY = tY[1] + tX = text2list(tX[1], ":") + tX = tX[1] + tX = max(1, min(256, origin.x + (text2num(tX) - (world.view + 1)))) + tY = max(1, min(256, origin.y + (text2num(tY) - (world.view + 1)))) + return locate(tX, tY, tZ) diff --git a/code/_onclick/hud/alien.dm b/code/_onclick/hud/alien.dm index 8c52e9221d5..cad52b60f45 100644 --- a/code/_onclick/hud/alien.dm +++ b/code/_onclick/hud/alien.dm @@ -134,6 +134,7 @@ mymob.blind.name = " " mymob.blind.screen_loc = "CENTER-7,CENTER-7" mymob.blind.layer = 0 + mymob.blind.mouse_opacity = 1 mymob.flash = new /obj/screen() mymob.flash.icon = 'icons/mob/screen_gen.dmi' diff --git a/code/_onclick/hud/alien_larva.dm b/code/_onclick/hud/alien_larva.dm index ab395f371e1..831da83665b 100644 --- a/code/_onclick/hud/alien_larva.dm +++ b/code/_onclick/hud/alien_larva.dm @@ -38,6 +38,7 @@ mymob.blind.name = " " mymob.blind.screen_loc = "CENTER-7,CENTER-7" mymob.blind.layer = 0 + mymob.blind.mouse_opacity = 1 mymob.flash = new /obj/screen() mymob.flash.icon = 'icons/mob/screen_gen.dmi' diff --git a/code/_onclick/hud/human.dm b/code/_onclick/hud/human.dm index 64e8cdc77e9..0ceadec778b 100644 --- a/code/_onclick/hud/human.dm +++ b/code/_onclick/hud/human.dm @@ -282,7 +282,7 @@ mymob.blind.icon_state = "blackimageoverlay" mymob.blind.name = " " mymob.blind.screen_loc = "CENTER-7,CENTER-7" - mymob.blind.mouse_opacity = 0 + mymob.blind.mouse_opacity = 1 mymob.blind.layer = 0 mymob.damageoverlay = new /obj/screen() diff --git a/code/_onclick/hud/monkey.dm b/code/_onclick/hud/monkey.dm index ad2d394d7b3..baf048ebdfd 100644 --- a/code/_onclick/hud/monkey.dm +++ b/code/_onclick/hud/monkey.dm @@ -120,6 +120,7 @@ mymob.blind.name = " " mymob.blind.screen_loc = "CENTER-7,CENTER-7" mymob.blind.layer = 0 + mymob.blind.mouse_opacity = 1 mymob.damageoverlay = new /obj/screen() mymob.damageoverlay.icon = 'icons/mob/screen_full.dmi' diff --git a/code/_onclick/hud/other_mobs.dm b/code/_onclick/hud/other_mobs.dm index c74f1ee7849..340b8a5bfc2 100644 --- a/code/_onclick/hud/other_mobs.dm +++ b/code/_onclick/hud/other_mobs.dm @@ -12,6 +12,7 @@ mymob.blind.name = " " mymob.blind.screen_loc = "CENTER-7,CENTER-7" mymob.blind.layer = 0 + mymob.blind.mouse_opacity = 1 mymob.client.screen = null mymob.client.screen += list(mymob.blind) diff --git a/code/_onclick/hud/robot.dm b/code/_onclick/hud/robot.dm index 878efe59e65..8597089b677 100644 --- a/code/_onclick/hud/robot.dm +++ b/code/_onclick/hud/robot.dm @@ -136,6 +136,7 @@ mymob.blind.name = " " mymob.blind.screen_loc = "CENTER-7,CENTER-7" mymob.blind.layer = 0 + mymob.blind.mouse_opacity = 1 mymob.flash = new /obj/screen() mymob.flash.icon = 'icons/mob/screen_gen.dmi' diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index e15c104de11..96b1f7e54a6 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -276,13 +276,13 @@ /obj/screen/Click(location, control, params) - if(!usr) return 1 - - if(name == "Reset Machine") //I don't know what this is, CTRL+F has the only entry right here in this file, so I'm going to leave it in case it is something important - usr.unset_machine() + var/list/modifiers = params2list(params) + if(modifiers["middle"] && istype(usr, /mob/living/carbon)) + var/mob/living/carbon/C = usr + C.swap_hand() else - return 0 - + var/turf/T = screen_loc2turf(modifiers["screen-loc"], get_turf(usr)) + T.Click(location, control, params) return 1 /obj/screen/inventory/Click() diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 3770501ae60..26464ab9526 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -22,16 +22,15 @@ */ /client/MouseDown(object,location,control,params) - if(mob && prefs && prefs.autoclick_delay && object && istype(mob, /mob/living/carbon)) + if(mob && prefs && prefs.autoclick_delay && object && !istype(object, /obj/screen) && istype(mob, /mob/living/carbon)) var/mob/living/carbon/C = mob - if(!C.get_active_hand()) - return ..() C.is_mouse_down = object spawn() - while(C.is_mouse_down == object) + while(C && C.is_mouse_down == object) + if(!C.get_active_hand()) + return ..() C.ClickOn(C.is_mouse_down, params) - sleep(1) - return + sleep(world.tick_lag) /client/MouseDrag(src_object,over_object,src_location,over_location,src_control,over_control,params) if(over_object) @@ -39,11 +38,6 @@ /client/MouseUp(object,location,control,params) if(mob) - if(!object) - var/list/modifiers = params2list(params) - if(modifiers["middle"]) - mob.MiddleClickOn() - return if(istype(mob, /mob/living/carbon)) var/mob/living/carbon/C = mob C.is_mouse_down = null diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index c3c6db827d9..dc4f25f634a 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -830,10 +830,7 @@ datum/preferences toggles ^= SOUND_ADMINHELP if("autoclick") - if(autoclick_delay) - autoclick_delay = 0 - else - autoclick_delay = AUTOCLICK_DELAY + autoclick_delay = !autoclick_delay if("ui") switch(UI_style) diff --git a/code/modules/client/preferences_toggles.dm b/code/modules/client/preferences_toggles.dm index db9fbce26e5..d9d9e5385b9 100644 --- a/code/modules/client/preferences_toggles.dm +++ b/code/modules/client/preferences_toggles.dm @@ -1,4 +1,13 @@ //toggles +/client/verb/toggle_autoclick() + set name = "Toggle Autoclick" + set category = "Preferences" + set desc = ".Enable or disable autoclick" + prefs.autoclick_delay = !prefs.autoclick_delay + src << "You have [prefs.autoclick_delay ? "enabled" : "disabled"] autoclick." + prefs.save_preferences() + feedback_add_details("admin_verb","TAC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + /client/verb/toggle_ghost_ears() set name = "Show/Hide GhostEars" set category = "Preferences"