Ported action button system from Paradise/tg

This commit is contained in:
Zuhayr
2015-05-31 19:03:28 +09:30
parent d4327658ab
commit dadc434f4e
24 changed files with 416 additions and 106 deletions
+6 -11
View File
@@ -250,11 +250,6 @@ BLIND // can't see anything
var/brightness_on
var/on = 0
/obj/item/clothing/head/New()
..()
if(!icon_action_button && brightness_on)
icon_action_button = "[icon_state]"
/obj/item/clothing/head/attack_self(mob/user)
if(brightness_on)
if(!isturf(user.loc))
@@ -382,19 +377,19 @@ BLIND // can't see anything
var/displays_id = 1
var/rolled_down = -1 //0 = unrolled, 1 = rolled, -1 = cannot be toggled
sprite_sheets = list("Vox" = 'icons/mob/species/vox/uniform.dmi')
//convenience var for defining the icon state for the overlay used when the clothing is worn.
//Also used by rolling/unrolling.
var/worn_state = null
/obj/item/clothing/under/New()
if(worn_state)
if(!item_state_slots)
if(!item_state_slots)
item_state_slots = list()
item_state_slots[slot_w_uniform_str] = worn_state
else
worn_state = icon_state
//autodetect rollability
if(rolled_down < 0)
if((worn_state + "_d_s") in icon_states('icons/mob/uniform.dmi'))
@@ -458,10 +453,10 @@ BLIND // can't see anything
if (( usr.restrained() ) || ( usr.stat ))
return
if (!usr.unEquip(src))
return
switch(over_object.name)
if("r_hand")
usr.put_in_r_hand(src)
@@ -544,7 +539,7 @@ BLIND // can't see anything
if(rolled_down < 0)
usr << "<span class='notice'>You cannot roll down [src]!</span>"
return
rolled_down = !rolled_down
if(rolled_down)
body_parts_covered &= LOWER_TORSO|LEGS|FEET
+4 -9
View File
@@ -37,7 +37,7 @@
desc = "Used for seeing walls, floors, and stuff through anything."
icon_state = "meson"
item_state = "glasses"
icon_action_button = "action_meson" //This doesn't actually matter, the action button is generated from the current icon_state. But, this is the only way to get it to show up.
action_button_name = "Toggle Goggles"
origin_tech = list(TECH_MAGNET = 2, TECH_ENGINERING = 2)
toggleable = 1
vision_flags = SEE_TURFS
@@ -57,7 +57,6 @@
icon_state = "purple"
item_state = "glasses"
toggleable = 1
icon_action_button = "action_science"
/obj/item/clothing/glasses/science/New()
..()
@@ -76,7 +75,6 @@
origin_tech = list(TECH_MAGNET = 2)
darkness_view = 7
toggleable = 1
icon_action_button = "action_nvg"
off_state = "denight"
/obj/item/clothing/glasses/night/New()
@@ -102,7 +100,6 @@
desc = "Very confusing glasses."
icon_state = "material"
item_state = "glasses"
icon_action_button = "action_material"
origin_tech = list(TECH_MAGNET = 3, TECH_ENGINERING = 3)
toggleable = 1
vision_flags = SEE_OBJS
@@ -147,7 +144,7 @@
desc = "Protects the eyes from welders, approved by the mad scientist association."
icon_state = "welding-g"
item_state = "welding-g"
icon_action_button = "action_welding_g"
action_button_name = "Flip Welding Goggles"
var/up = 0
/obj/item/clothing/glasses/welding/attack_self()
@@ -182,7 +179,6 @@
desc = "Welding goggles made from more expensive materials, strangely smells like potatoes."
icon_state = "rwelding-g"
item_state = "rwelding-g"
icon_action_button = "action_welding_g"
/obj/item/clothing/glasses/sunglasses/blindfold
name = "blindfold"
@@ -223,7 +219,6 @@
item_state = "glasses"
origin_tech = list(TECH_MAGNET = 3)
toggleable = 1
icon_action_button = "action_thermal"
vision_flags = SEE_MOBS
invisa_view = 2
@@ -249,12 +244,12 @@
name = "Optical Meson Scanner"
desc = "Used for seeing walls, floors, and stuff through anything."
icon_state = "meson"
origin_tech = list(TECH_MAGNET = 3, TECH_ILLEGAL = 4)
origin_tech = list(TECH_MAGNET = 3, TECH_ILLEGAL = 4)
/obj/item/clothing/glasses/thermal/plain
toggleable = 0
activation_sound = null
icon_action_button = ""
action_button_name = null
/obj/item/clothing/glasses/thermal/plain/monocle
name = "Thermoncle"
+2 -2
View File
@@ -22,7 +22,7 @@
armor = list(melee = 10, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 0, rad = 0)
flags_inv = (HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE)
body_parts_covered = HEAD|FACE|EYES
icon_action_button = "action_welding"
action_button_name = "Flip Welding Mask"
siemens_coefficient = 0.9
w_class = 3
@@ -48,7 +48,7 @@
flags_inv &= ~(HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE)
icon_state = "[initial(icon_state)]up"
usr << "You push the [src] up out of your face."
update_clothing_icon() //so our mob-overlays
update_clothing_icon() //so our mob-overlays
usr.update_action_buttons()
+3 -4
View File
@@ -7,11 +7,10 @@
overshoes = 1
var/magpulse = 0
var/icon_base = "magboots"
icon_action_button = "action_blank"
action_button_name = "Toggle the magboots"
action_button_name = "Toggle Magboots"
var/obj/item/clothing/shoes/shoes = null //Undershoes
var/mob/living/carbon/human/wearer = null //For shoe procs
/obj/item/clothing/shoes/magboots/proc/set_slowdown()
slowdown = shoes? max(SHOES_SLOWDOWN, shoes.slowdown): SHOES_SLOWDOWN //So you can't put on magboots to make you walk faster.
if (magpulse)
@@ -37,7 +36,7 @@
/obj/item/clothing/shoes/magboots/mob_can_equip(mob/user)
var/mob/living/carbon/human/H = user
if(H.shoes)
shoes = H.shoes
if(shoes.overshoes)
@@ -20,6 +20,7 @@
var/obj/machinery/camera/camera
var/list/camera_networks
action_button_name = "Toggle Helmet Light"
light_overlay = "helmet_light"
brightness_on = 4
on = 0
@@ -28,9 +29,6 @@
if(!camera && camera_networks)
if(!icon_action_button)
icon_action_button = "[icon_state]"
camera = new /obj/machinery/camera(src)
camera.replace_networks(camera_networks)
camera.c_tag = user.name
@@ -27,6 +27,7 @@
//Status updates, death etc.
handle_regular_status_updates()
handle_actions()
update_canmove()
update_icons()
@@ -27,6 +27,7 @@
//Status updates, death etc.
handle_regular_status_updates()
update_canmove()
handle_actions()
if(client)
handle_regular_hud_updates()
@@ -315,7 +315,7 @@ This saves us from having to call add_fingerprint() any time something is put in
W.layer = 20
if(W.icon_action_button)
if(W.action_button_name)
update_action_buttons()
return 1
+6 -5
View File
@@ -117,6 +117,7 @@
//Status updates, death etc.
handle_regular_status_updates() //Optimized a bit
handle_actions()
update_canmove()
//Update our name based on whether our face is obscured/disfigured
@@ -242,7 +243,7 @@
src << "<span class='danger'>Your hand won't respond properly, you drop what you're holding!</span>"
drop_item()
if(getBrainLoss() >= 45)
if(10 <= rn && rn <= 12)
if(10 <= rn && rn <= 12)
if(prob(50))
src << "<span class='danger'>You suddenly black out!</span>"
Paralyse(10)
@@ -1035,12 +1036,12 @@
blinded = 1
// Check everything else.
//Vision
var/obj/item/organ/vision
if(species.vision_organ)
vision = internal_organs_by_name[species.vision_organ]
if(!vision) // Presumably if a species has no vision organs, they see via some other means.
eye_blind = 0
blinded = 0
@@ -1049,7 +1050,7 @@
eye_blind = 1
blinded = 1
eye_blurry = 1
else
else
//blindness
if(sdisabilities & BLIND) // Disabled-blind, doesn't get better on its own
blinded = 1
@@ -1059,7 +1060,7 @@
else if(istype(glasses, /obj/item/clothing/glasses/sunglasses/blindfold)) //resting your eyes with a blindfold heals blurry eyes faster
eye_blurry = max(eye_blurry-3, 0)
blinded = 1
//blurry sight
if(vision.is_bruised()) // Vision organs impaired? Permablurry.
eye_blurry = 1
@@ -28,6 +28,7 @@
handle_environment(environment) // Handle temperature/pressure differences between body and environment
handle_regular_status_updates() // Status updates, death etc.
handle_actions()
/mob/living/carbon/slime/proc/handle_environment(datum/gas_mixture/environment)
if(!environment)
+75
View File
@@ -247,6 +247,81 @@
//Scale quadratically so that single digit numbers of fire stacks don't burn ridiculously hot.
return round(FIRESUIT_MAX_HEAT_PROTECTION_TEMPERATURE*(fire_stacks/FIRE_MAX_FIRESUIT_STACKS)**2)
/mob/living/regular_hud_updates()
..()
update_action_buttons()
/mob/living/proc/handle_actions()
//Pretty bad, i'd use picked/dropped instead but the parent calls in these are nonexistent
for(var/datum/action/A in actions)
if(A.CheckRemoval(src))
A.Remove(src)
for(var/obj/item/I in src)
if(I.action_button_name)
if(!I.action)
if(I.action_button_is_hands_free)
I.action = new/datum/action/item_action/hands_free
else
I.action = new/datum/action/item_action
I.action.name = I.action_button_name
I.action.target = I
I.action.Grant(src)
return
/mob/living/update_action_buttons()
if(!hud_used) return
if(!client) return
if(hud_used.hud_shown != 1) //Hud toggled to minimal
return
client.screen -= hud_used.hide_actions_toggle
for(var/datum/action/A in actions)
if(A.button)
client.screen -= A.button
if(hud_used.action_buttons_hidden)
if(!hud_used.hide_actions_toggle)
hud_used.hide_actions_toggle = new(hud_used)
hud_used.hide_actions_toggle.UpdateIcon()
if(!hud_used.hide_actions_toggle.moved)
hud_used.hide_actions_toggle.screen_loc = hud_used.ButtonNumberToScreenCoords(1)
//hud_used.SetButtonCoords(hud_used.hide_actions_toggle,1)
client.screen += hud_used.hide_actions_toggle
return
var/button_number = 0
for(var/datum/action/A in actions)
button_number++
if(A.button == null)
var/obj/screen/movable/action_button/N = new(hud_used)
N.owner = A
A.button = N
var/obj/screen/movable/action_button/B = A.button
B.UpdateIcon()
B.name = A.UpdateName()
client.screen += B
if(!B.moved)
B.screen_loc = hud_used.ButtonNumberToScreenCoords(button_number)
//hud_used.SetButtonCoords(B,button_number)
if(button_number > 0)
if(!hud_used.hide_actions_toggle)
hud_used.hide_actions_toggle = new(hud_used)
hud_used.hide_actions_toggle.InitialiseIcon(src)
if(!hud_used.hide_actions_toggle.moved)
hud_used.hide_actions_toggle.screen_loc = hud_used.ButtonNumberToScreenCoords(button_number+1)
//hud_used.SetButtonCoords(hud_used.hide_actions_toggle,button_number+1)
client.screen += hud_used.hide_actions_toggle
//If simple_animals are ever moved under carbon, then this can probably be moved to carbon as well
/mob/living/proc/attack_throat(obj/item/W, obj/item/weapon/grab/G, mob/user)
@@ -34,6 +34,7 @@
var/mob_always_swap = 0
var/mob/living/cameraFollow = null
var/list/datum/action/actions = list()
var/tod = null // Time of death
var/update_slimes = 1
@@ -10,6 +10,7 @@
//Status updates, death etc.
clamp_values()
handle_regular_status_updates()
handle_actions()
if(client)
handle_regular_hud_updates()