One click queue system added, which affects gameplay completely.

Previously: After clicking on one thing, you could not click on another thing before 1 second had passed, and had to spam until 1 second had passed.
Now: After one click, if there's a second click right after, it will be queued and executed automatically after the 1 second has passed.

Tried to remove redundant DblClick() entries and changed them to QueueClick() where appropriate. Report for bugs.

Updated change log. :-)

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@1019 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
Skiedrake
2011-02-11 15:38:34 +00:00
parent a697428db7
commit 098a5b73e2
10 changed files with 100 additions and 50 deletions

View File

@@ -200,3 +200,8 @@ var
sqlpass = ""
sqllogging = 0 // Should we log deaths, population stats, etc?
// Changing this will affect on how quickly players are allowed to click on things.
// Measured in 1/10th of a second. Defaults to 10 = 1 sec. -- Skie
// TODO: Make changable by admin command? I dunno.
ClickDelay = 10

View File

@@ -93,7 +93,8 @@
var/a_intent = "help"
var/m_int = null
var/m_intent = "run"
var/lastDblClick = 0
var/lastClick = 0
var/next_click_queued = 0 // For one UI-click buffer system
var/lastKnownIP = null
var/obj/stool/buckled = null
var/obj/item/weapon/handcuffs/handcuffed = null

View File

@@ -195,16 +195,43 @@
build_click(usr, usr.client.buildmode, location, control, params, src)
return
return DblClick()
// One click buffer implementation -- Skie
/atom/DblClick() //TODO: DEFERRED: REWRITE
// world << "checking if this shit gets called at all"
if (world.time <= usr:lastDblClick+2)
// world << "BLOCKED atom.DblClick() on [src] by [usr] : src.type is [src.type]"
return
// If we have clicked recently and there's no click action queued
if ( (world.time < usr.lastClick+ClickDelay) && (usr.next_click_queued == 0) )
//world << "Queuing next click action on [src] by [usr]"
usr.next_click_queued = 1 // It's now queued
spawn(world.time - usr.lastClick+ClickDelay) // Spawn the click action soon
usr.next_click_queued = 0 // It's not queued anymore
//world << "Proceeding on queued action on [src] by [usr]"
return QueueClick()
// Otherwise if enough time has passed from the last click action, let the click proceed.
else
return QueueClick()
// This replaces the old method where Click() would return DblClick()... which makes no sense.
// Basically contains what DblClick used to, but it can't be accessed by actually double clicking.
/atom/proc/QueueClick()
//TODO: DEFERRED: REWRITE
// world << "checking if this shit gets called at all"
// if (world.time <= usr:lastClick+2)
// world << "BLOCKED atom.DblClick() on [src] by [usr] : src.type is [src.type]"
// return
// else
// world << "atom.DblClick() on [src] by [usr] : src.type is [src.type]"
usr:lastDblClick = world.time
if(usr.next_click_queued == 1)
return
usr.lastClick = world.time
if (istype(usr, /mob/living/silicon/ai))
var/mob/living/silicon/ai/ai = usr
if (ai.control_disabled)
@@ -256,11 +283,11 @@
// world << "according to dblclick(), t5 is [t5]"
if (((t5 || (W && (W.flags & 16))) && !( istype(src, /obj/screen) )))
if (usr.next_move < world.time)
usr.prev_move = usr.next_move
usr.next_move = world.time + 10
else
return
//if (usr.next_move < world.time) -- Removed due to Click Queue implementation -- Skie
// usr.prev_move = usr.next_move
// usr.next_move = world.time + 1 // Was 10
//else
// return
if ((src.loc && (get_dist(src, usr) < 2 || src.loc == usr.loc)))
var/direct = get_dir(usr, src)
var/obj/item/weapon/dummy/D = new /obj/item/weapon/dummy( usr.loc )
@@ -371,10 +398,10 @@
else
if (istype(src, /obj/screen))
usr.prev_move = usr.next_move
if (usr.next_move < world.time)
usr.next_move = world.time + 10
else
return
//if (usr.next_move < world.time) -- Removed due to Click Queue implementation -- Skie
// usr.next_move = world.time + 1 // was 10
//else
// return
if (!( usr.restrained() ))
if ((W && !( istype(src, /obj/screen) )))
src.attackby(W, usr)
@@ -402,6 +429,10 @@
return
/atom/DblClick() // Does nothing.
return
/atom/proc/get_global_map_pos()
if(!global_map.len) return
var/cur_x = null

View File

@@ -3,7 +3,7 @@
/turf/proc/move_camera_by_click()
if (usr.stat)
return ..()
if (world.time <= usr:lastDblClick+2)
if (world.time <= usr:lastClick+2)
return ..()
//try to find the closest working camera in the same area, switch to it
@@ -24,7 +24,7 @@
if(!best_cam)
return ..()
usr:lastDblClick = world.time
usr:lastClick = world.time
usr:switchCamera(best_cam)
/mob/living/silicon/ai/proc/ai_camera_list()

View File

@@ -363,7 +363,7 @@
var/emptyHand = (W == null)
if(emptyHand)
src.id.DblClick()
src.id.QueueClick()
if(!istype(src.id.loc, /obj/item/device/pda))
src.id = null

View File

@@ -97,15 +97,15 @@
largest_move_time = M.next_move - world.time
else
largest_move_time = 1
if(M.lastDblClick >= largest_click_time)
if(M.lastClick >= largest_click_time)
largest_click_mob = M
if(M.lastDblClick > world.time)
largest_click_time = M.lastDblClick - world.time
if(M.lastClick > world.time)
largest_click_time = M.lastClick - world.time
else
largest_click_time = 0
log_admin("DEBUG: [key_name(M)] next_move = [M.next_move] lastDblClick = [M.lastDblClick] world.time = [world.time]")
log_admin("DEBUG: [key_name(M)] next_move = [M.next_move] lastClick = [M.lastClick] world.time = [world.time]")
M.next_move = 1
M.lastDblClick = 0
M.lastClick = 0
message_admins("[key_name_admin(largest_move_mob)] had the largest move delay with [largest_move_time] frames / [largest_move_time/10] seconds!", 1)
message_admins("[key_name_admin(largest_click_mob)] had the largest click delay with [largest_click_time] frames / [largest_click_time/10] seconds!", 1)
message_admins("world.time = [world.time]", 1)

View File

@@ -256,7 +256,7 @@
return
if (emptyHand)
usr.next_move = usr.prev_move
usr:lastDblClick -= 3 //permit the double-click redirection to proceed.
usr:lastClick -= 3 //permit the double-click redirection to proceed.
switch(text)
//if emptyhand then wear the suit, no bedsheet clothes for the alien
@@ -264,7 +264,7 @@
if("o_clothing")
if (src.wear_suit)
if (emptyHand)
src.wear_suit.DblClick()
src.wear_suit.QueueClick()
return
if (( istype(W, /obj/alien/skin_suit) ))
src.u_equip(W)
@@ -280,7 +280,7 @@
if("head")
if (src.head)
if (emptyHand)
src.head.DblClick()
src.head.QueueClick()
return
if (( istype(W, /obj/alien/head) ))
src.u_equip(W)
@@ -296,7 +296,7 @@
if("storage1")
if (src.l_store)
if (emptyHand)
src.l_store.DblClick()
src.l_store.QueueClick()
return
if ((!( istype(W, /obj/item) ) || W.w_class > 3))
return
@@ -305,7 +305,7 @@
if("storage2")
if (src.r_store)
if (emptyHand)
src.r_store.DblClick()
src.r_store.QueueClick()
return
if ((!( istype(W, /obj/item) ) || W.w_class > 3))
return

View File

@@ -89,8 +89,8 @@
if(istype(src.equipped(), /obj/item/weapon/baton)) // add any other item paths you think are necessary
if(src.loc:sd_lumcount < 3 || src.blinded)
var/obj/item/weapon/W = src.equipped()
if (world.time > src.lastDblClick+2)
src.lastDblClick = world.time
if (world.time > src.lastClick+2)
src.lastClick = world.time
if((prob(40)) || (prob(95) && src.mutations & 16))
//src << "\red You accidentally stun yourself with the [W.name]."
src.visible_message("\red [src] accidentally stun \himself with the [W.name].", \
@@ -697,12 +697,12 @@
return
if (emptyHand)
usr.next_move = usr.prev_move
usr:lastDblClick -= 3 //permit the double-click redirection to proceed.
usr:lastClick -= 3 //permit the double-click redirection to proceed.
switch(text)
if("mask")
if (src.wear_mask)
if (emptyHand)
src.wear_mask.DblClick()
src.wear_mask.QueueClick()
return
if (!( istype(W, /obj/item/clothing/mask) ))
return
@@ -712,7 +712,7 @@
if("back")
if (src.back)
if (emptyHand)
src.back.DblClick()
src.back.QueueClick()
return
if (!istype(W, /obj/item))
return
@@ -725,7 +725,7 @@
/* if("headset")
if (src.ears)
if (emptyHand)
src.ears.DblClick()
src.ears.QueueClick()
return
if (!( istype(W, /obj/item/device/radio/headset) ))
return
@@ -735,7 +735,7 @@
if("o_clothing")
if (src.wear_suit)
if (emptyHand)
src.wear_suit.DblClick()
src.wear_suit.QueueClick()
return
if (!( istype(W, /obj/item/clothing/suit) ))
return
@@ -748,7 +748,7 @@
if("gloves")
if (src.gloves)
if (emptyHand)
src.gloves.DblClick()
src.gloves.QueueClick()
return
if (!( istype(W, /obj/item/clothing/gloves) ))
return
@@ -758,7 +758,7 @@
if("shoes")
if (src.shoes)
if (emptyHand)
src.shoes.DblClick()
src.shoes.QueueClick()
return
if (!( istype(W, /obj/item/clothing/shoes) ))
return
@@ -768,7 +768,7 @@
if("belt")
if (src.belt)
if (emptyHand)
src.belt.DblClick()
src.belt.QueueClick()
return
if (!W || !W.flags || !( W.flags & ONBELT ))
return
@@ -778,7 +778,7 @@
if("eyes")
if (src.glasses)
if (emptyHand)
src.glasses.DblClick()
src.glasses.QueueClick()
return
if (!( istype(W, /obj/item/clothing/glasses) ))
return
@@ -788,7 +788,7 @@
if("head")
if (src.head)
if (emptyHand)
src.head.DblClick()
src.head.QueueClick()
return
if (( istype(W, /obj/item/weapon/paper) ))
src.u_equip(W)
@@ -801,7 +801,7 @@
if("ears")
if (src.ears)
if (emptyHand)
src.ears.DblClick()
src.ears.QueueClick()
return
if (!( istype(W, /obj/item/clothing/ears) ) && !( istype(W, /obj/item/device/radio/headset) ))
return
@@ -811,7 +811,7 @@
if("i_clothing")
if (src.w_uniform)
if (emptyHand)
src.w_uniform.DblClick()
src.w_uniform.QueueClick()
return
if (!( istype(W, /obj/item/clothing/under) ))
return
@@ -824,7 +824,7 @@
if("id")
if (src.wear_id)
if (emptyHand)
src.wear_id.DblClick()
src.wear_id.QueueClick()
return
if (!src.w_uniform)
return
@@ -836,7 +836,7 @@
if("storage1")
if (src.l_store)
if (emptyHand)
src.l_store.DblClick()
src.l_store.QueueClick()
return
if ((!( istype(W, /obj/item) ) || W.w_class > 2 || !( src.w_uniform )))
return
@@ -845,7 +845,7 @@
if("storage2")
if (src.r_store)
if (emptyHand)
src.r_store.DblClick()
src.r_store.QueueClick()
return
if ((!( istype(W, /obj/item) ) || W.w_class > 2 || !( src.w_uniform )))
return
@@ -854,7 +854,7 @@
if("suit storage")
if (src.s_store)
if (emptyHand)
src.s_store.DblClick()
src.s_store.QueueClick()
return
var/confirm
if (src.wear_suit)
@@ -875,7 +875,7 @@
if("hat storage")
if (src.h_store)
if (emptyHand)
src.h_store.DblClick()
src.h_store.QueueClick()
return
var/confirm
if (src.head)

View File

@@ -935,7 +935,7 @@
usr:module_active = null
else
src.DblClick()
src.QueueClick()
return
/obj/screen/attack_hand(mob/user as mob, using)