Merge pull request #9595 from Zuhayr/actionbuttons

Ported action button system from Paradise/tg
This commit is contained in:
Chinsky
2015-06-02 12:24:42 +03:00
22 changed files with 423 additions and 108 deletions

View File

@@ -46,10 +46,12 @@
#include "code\_onclick\rig.dm" #include "code\_onclick\rig.dm"
#include "code\_onclick\telekinesis.dm" #include "code\_onclick\telekinesis.dm"
#include "code\_onclick\hud\_defines.dm" #include "code\_onclick\hud\_defines.dm"
#include "code\_onclick\hud\action.dm"
#include "code\_onclick\hud\alien_larva.dm" #include "code\_onclick\hud\alien_larva.dm"
#include "code\_onclick\hud\hud.dm" #include "code\_onclick\hud\hud.dm"
#include "code\_onclick\hud\human.dm" #include "code\_onclick\hud\human.dm"
#include "code\_onclick\hud\monkey.dm" #include "code\_onclick\hud\monkey.dm"
#include "code\_onclick\hud\movable_screen_objects.dm"
#include "code\_onclick\hud\other_mobs.dm" #include "code\_onclick\hud\other_mobs.dm"
#include "code\_onclick\hud\robot.dm" #include "code\_onclick\hud\robot.dm"
#include "code\_onclick\hud\screen_objects.dm" #include "code\_onclick\hud\screen_objects.dm"

View File

@@ -13,13 +13,6 @@
Therefore, the top right corner (except during admin shenanigans) is at "15,15" Therefore, the top right corner (except during admin shenanigans) is at "15,15"
*/ */
//Upper left action buttons, displayed when you pick up an item that has this enabled.
#define ui_action_slot1 "1:6,14:26"
#define ui_action_slot2 "2:8,14:26"
#define ui_action_slot3 "3:10,14:26"
#define ui_action_slot4 "4:12,14:26"
#define ui_action_slot5 "5:14,14:26"
//Lower left, persistant menu //Lower left, persistant menu
#define ui_inventory "1:6,1:5" #define ui_inventory "1:6,1:5"

222
code/_onclick/hud/action.dm Normal file
View File

@@ -0,0 +1,222 @@
#define AB_ITEM 1
#define AB_SPELL 2
#define AB_INNATE 3
#define AB_GENERIC 4
#define AB_CHECK_RESTRAINED 1
#define AB_CHECK_STUNNED 2
#define AB_CHECK_LYING 4
#define AB_CHECK_ALIVE 8
#define AB_CHECK_INSIDE 16
/datum/action
var/name = "Generic Action"
var/action_type = AB_ITEM
var/procname = null
var/atom/movable/target = null
var/check_flags = 0
var/processing = 0
var/active = 0
var/obj/screen/movable/action_button/button = null
var/button_icon = 'icons/mob/actions.dmi'
var/button_icon_state = "default"
var/background_icon_state = "bg_default"
var/mob/living/owner
/datum/action/New(var/Target)
target = Target
/datum/action/Destroy()
if(owner)
Remove(owner)
/datum/action/proc/Grant(mob/living/T)
if(owner)
if(owner == T)
return
Remove(owner)
owner = T
owner.actions.Add(src)
owner.update_action_buttons()
return
/datum/action/proc/Remove(mob/living/T)
if(button)
if(T.client)
T.client.screen -= button
del(button)
T.actions.Remove(src)
T.update_action_buttons()
owner = null
return
/datum/action/proc/Trigger()
if(!Checks())
return
switch(action_type)
if(AB_ITEM)
if(target)
var/obj/item/item = target
item.ui_action_click()
//if(AB_SPELL)
// if(target)
// var/obj/effect/proc_holder/spell = target
// spell.Click()
if(AB_INNATE)
if(!active)
Activate()
else
Deactivate()
if(AB_GENERIC)
if(target && procname)
call(target,procname)(usr)
return
/datum/action/proc/Activate()
return
/datum/action/proc/Deactivate()
return
/datum/action/proc/Process()
return
/datum/action/proc/CheckRemoval(mob/living/user) // 1 if action is no longer valid for this mob and should be removed
return 0
/datum/action/proc/IsAvailable()
return Checks()
/datum/action/proc/Checks()// returns 1 if all checks pass
if(!owner)
return 0
if(check_flags & AB_CHECK_RESTRAINED)
if(owner.restrained())
return 0
if(check_flags & AB_CHECK_STUNNED)
if(owner.stunned)
return 0
if(check_flags & AB_CHECK_LYING)
if(owner.lying)
return 0
if(check_flags & AB_CHECK_ALIVE)
if(owner.stat)
return 0
if(check_flags & AB_CHECK_INSIDE)
if(!(target in owner))
return 0
return 1
/datum/action/proc/UpdateName()
return name
/obj/screen/movable/action_button
var/datum/action/owner
screen_loc = "WEST,NORTH"
/obj/screen/movable/action_button/Click(location,control,params)
var/list/modifiers = params2list(params)
if(modifiers["shift"])
moved = 0
return 1
if(usr.next_move >= world.time) // Is this needed ?
return
owner.Trigger()
return 1
/obj/screen/movable/action_button/proc/UpdateIcon()
if(!owner)
return
icon = owner.button_icon
icon_state = owner.background_icon_state
overlays.Cut()
var/image/img
if(owner.action_type == AB_ITEM && owner.target)
var/obj/item/I = owner.target
img = image(I.icon, src , I.icon_state)
else if(owner.button_icon && owner.button_icon_state)
img = image(owner.button_icon,src,owner.button_icon_state)
img.pixel_x = 0
img.pixel_y = 0
overlays += img
if(!owner.IsAvailable())
color = rgb(128,0,0,128)
else
color = rgb(255,255,255,255)
//Hide/Show Action Buttons ... Button
/obj/screen/movable/action_button/hide_toggle
name = "Hide Buttons"
icon = 'icons/mob/actions.dmi'
icon_state = "bg_default"
var/hidden = 0
/obj/screen/movable/action_button/hide_toggle/Click()
usr.hud_used.action_buttons_hidden = !usr.hud_used.action_buttons_hidden
hidden = usr.hud_used.action_buttons_hidden
if(hidden)
name = "Show Buttons"
else
name = "Hide Buttons"
UpdateIcon()
usr.update_action_buttons()
/obj/screen/movable/action_button/hide_toggle/proc/InitialiseIcon(var/mob/living/user)
if(isalien(user))
icon_state = "bg_alien"
else
icon_state = "bg_default"
UpdateIcon()
return
/obj/screen/movable/action_button/hide_toggle/UpdateIcon()
overlays.Cut()
var/image/img = image(icon,src,hidden?"show":"hide")
overlays += img
return
//This is the proc used to update all the action buttons. Properly defined in /mob/living/
/mob/proc/update_action_buttons()
return
#define AB_WEST_OFFSET 4
#define AB_NORTH_OFFSET 26
#define AB_MAX_COLUMNS 10
/datum/hud/proc/ButtonNumberToScreenCoords(var/number) // TODO : Make this zero-indexed for readabilty
var/row = round((number-1)/AB_MAX_COLUMNS)
var/col = ((number - 1)%(AB_MAX_COLUMNS)) + 1
var/coord_col = "+[col-1]"
var/coord_col_offset = AB_WEST_OFFSET+2*col
var/coord_row = "[-1 - row]"
var/coord_row_offset = AB_NORTH_OFFSET
return "WEST[coord_col]:[coord_col_offset],NORTH[coord_row]:[coord_row_offset]"
/datum/hud/proc/SetButtonCoords(var/obj/screen/button,var/number)
var/row = round((number-1)/AB_MAX_COLUMNS)
var/col = ((number - 1)%(AB_MAX_COLUMNS)) + 1
var/x_offset = 32*(col-1) + AB_WEST_OFFSET + 2*col
var/y_offset = -32*(row+1) + AB_NORTH_OFFSET
var/matrix/M = matrix()
M.Translate(x_offset,y_offset)
button.transform = M
//Presets for item actions
/datum/action/item_action
check_flags = AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_LYING|AB_CHECK_ALIVE|AB_CHECK_INSIDE
/datum/action/item_action/CheckRemoval(mob/living/user)
return !(target in user)
/datum/action/item_action/hands_free
check_flags = AB_CHECK_ALIVE|AB_CHECK_INSIDE
#undef AB_WEST_OFFSET
#undef AB_NORTH_OFFSET
#undef AB_MAX_COLUMNS

View File

@@ -133,7 +133,8 @@ var/list/global_huds = list(
var/list/other var/list/other
var/list/obj/screen/hotkeybuttons var/list/obj/screen/hotkeybuttons
var/list/obj/screen/item_action/item_action_list = list() //Used for the item action ui buttons. var/obj/screen/movable/action_button/hide_toggle/hide_actions_toggle
var/action_buttons_hidden = 0
datum/hud/New(mob/owner) datum/hud/New(mob/owner)
mymob = owner mymob = owner
@@ -279,8 +280,6 @@ datum/hud/New(mob/owner)
src.client.screen -= src.hud_used.other src.client.screen -= src.hud_used.other
if(src.hud_used.hotkeybuttons) if(src.hud_used.hotkeybuttons)
src.client.screen -= src.hud_used.hotkeybuttons src.client.screen -= src.hud_used.hotkeybuttons
if(src.hud_used.item_action_list)
src.client.screen -= src.hud_used.item_action_list
//Due to some poor coding some things need special treatment: //Due to some poor coding some things need special treatment:
//These ones are a part of 'adding', 'other' or 'hotkeybuttons' but we want them to stay //These ones are a part of 'adding', 'other' or 'hotkeybuttons' but we want them to stay
@@ -338,8 +337,6 @@ datum/hud/New(mob/owner)
src.client.screen -= src.hud_used.other src.client.screen -= src.hud_used.other
if(src.hud_used.hotkeybuttons) if(src.hud_used.hotkeybuttons)
src.client.screen -= src.hud_used.hotkeybuttons src.client.screen -= src.hud_used.hotkeybuttons
if(src.hud_used.item_action_list)
src.client.screen -= src.hud_used.item_action_list
src.client.screen -= src.internals src.client.screen -= src.internals
src.client.screen += src.hud_used.action_intent //we want the intent swticher visible src.client.screen += src.hud_used.action_intent //we want the intent swticher visible
else else

View File

@@ -385,52 +385,6 @@
client.screen -= hud_used.hotkeybuttons client.screen -= hud_used.hotkeybuttons
hud_used.hotkey_ui_hidden = 1 hud_used.hotkey_ui_hidden = 1
/mob/living/carbon/human/update_action_buttons()
var/num = 1
if(!hud_used) return
if(!client) return
if(!hud_used.hud_shown) //Hud toggled to minimal
return
client.screen -= hud_used.item_action_list
hud_used.item_action_list = list()
for(var/obj/item/I in src)
if(I.icon_action_button)
var/obj/screen/item_action/A = new(hud_used)
//A.icon = 'icons/mob/screen1_action.dmi'
//A.icon_state = I.icon_action_button
A.icon = ui_style2icon(client.prefs.UI_style)
A.icon_state = "template"
var/image/img = image(I.icon, A, I.icon_state)
img.pixel_x = 0
img.pixel_y = 0
A.overlays += img
if(I.action_button_name)
A.name = I.action_button_name
else
A.name = "Use [I.name]"
A.owner = I
hud_used.item_action_list += A
switch(num)
if(1)
A.screen_loc = ui_action_slot1
if(2)
A.screen_loc = ui_action_slot2
if(3)
A.screen_loc = ui_action_slot3
if(4)
A.screen_loc = ui_action_slot4
if(5)
A.screen_loc = ui_action_slot5
break //5 slots available, so no more can be added.
num++
src.client.screen += src.hud_used.item_action_list
//Used for new human mobs created by cloning/goleming/etc. //Used for new human mobs created by cloning/goleming/etc.
/mob/living/carbon/human/proc/set_cloned_appearance() /mob/living/carbon/human/proc/set_cloned_appearance()
f_style = "Shaved" f_style = "Shaved"

View File

@@ -0,0 +1,84 @@
//////////////////////////
//Movable Screen Objects//
// By RemieRichards //
//////////////////////////
//Movable Screen Object
//Not tied to the grid, places it's center where the cursor is
/obj/screen/movable
var/snap2grid = FALSE
var/moved = FALSE
//Snap Screen Object
//Tied to the grid, snaps to the nearest turf
/obj/screen/movable/snap
snap2grid = TRUE
/obj/screen/movable/MouseDrop(over_object, src_location, over_location, src_control, over_control, params)
var/list/PM = params2list(params)
//No screen-loc information? abort.
if(!PM || !PM["screen-loc"])
return
//Split screen-loc up into X+Pixel_X and Y+Pixel_Y
var/list/screen_loc_params = text2list(PM["screen-loc"], ",")
//Split X+Pixel_X up into list(X, Pixel_X)
var/list/screen_loc_X = text2list(screen_loc_params[1],":")
//Split Y+Pixel_Y up into list(Y, Pixel_Y)
var/list/screen_loc_Y = text2list(screen_loc_params[2],":")
if(snap2grid) //Discard Pixel Values
screen_loc = "[screen_loc_X[1]],[screen_loc_Y[1]]"
else //Normalise Pixel Values (So the object drops at the center of the mouse, not 16 pixels off)
var/pix_X = text2num(screen_loc_X[2]) - 16
var/pix_Y = text2num(screen_loc_Y[2]) - 16
screen_loc = "[screen_loc_X[1]]:[pix_X],[screen_loc_Y[1]]:[pix_Y]"
moved = TRUE
//Debug procs
/client/proc/test_movable_UI()
set category = "Debug"
set name = "Spawn Movable UI Object"
var/obj/screen/movable/M = new()
M.name = "Movable UI Object"
M.icon_state = "block"
M.maptext = "Movable"
M.maptext_width = 64
var/screen_l = input(usr,"Where on the screen? (Formatted as 'X,Y' e.g: '1,1' for bottom left)","Spawn Movable UI Object") as text
if(!screen_l)
return
M.screen_loc = screen_l
screen += M
/client/proc/test_snap_UI()
set category = "Debug"
set name = "Spawn Snap UI Object"
var/obj/screen/movable/snap/S = new()
S.name = "Snap UI Object"
S.icon_state = "block"
S.maptext = "Snap"
S.maptext_width = 64
var/screen_l = input(usr,"Where on the screen? (Formatted as 'X,Y' e.g: '1,1' for bottom left)","Spawn Snap UI Object") as text
if(!screen_l)
return
S.screen_loc = screen_l
screen += S

View File

@@ -61,11 +61,6 @@
owner.ui_action_click() owner.ui_action_click()
return 1 return 1
//This is the proc used to update all the action buttons. It just returns for all mob types except humans.
/mob/proc/update_action_buttons()
return
/obj/screen/grab /obj/screen/grab
name = "grab" name = "grab"

View File

@@ -21,8 +21,9 @@
var/max_heat_protection_temperature //Set this variable to determine up to which temperature (IN KELVIN) the item protects against heat damage. Keep at null to disable protection. Only protects areas set by heat_protection flags var/max_heat_protection_temperature //Set this variable to determine up to which temperature (IN KELVIN) the item protects against heat damage. Keep at null to disable protection. Only protects areas set by heat_protection flags
var/min_cold_protection_temperature //Set this variable to determine down to which temperature (IN KELVIN) the item protects against cold damage. 0 is NOT an acceptable number due to if(varname) tests!! Keep at null to disable protection. Only protects areas set by cold_protection flags var/min_cold_protection_temperature //Set this variable to determine down to which temperature (IN KELVIN) the item protects against cold damage. 0 is NOT an acceptable number due to if(varname) tests!! Keep at null to disable protection. Only protects areas set by cold_protection flags
var/icon_action_button //If this is set, The item will make an action button on the player's HUD when picked up. The button will have the icon_action_button sprite from the screen1_action.dmi file. var/datum/action/item_action/action = null
var/action_button_name //This is the text which gets displayed on the action button. If not set it defaults to 'Use [name]'. Note that icon_action_button needs to be set in order for the action button to appear. var/action_button_name //It is also the text which gets displayed on the action button. If not set it defaults to 'Use [name]'. If it's not set, there'll be no button.
var/action_button_is_hands_free = 0 //If 1, bypass the restrained, lying, and stunned checks action buttons normally test for
//Since any item can now be a piece of clothing, this has to be put here so all items share it. //Since any item can now be a piece of clothing, this has to be put here so all items share it.
var/flags_inv //This flag is used to determine when items in someone's inventory cover others. IE helmets making it so you can't see glasses, etc. var/flags_inv //This flag is used to determine when items in someone's inventory cover others. IE helmets making it so you can't see glasses, etc.
@@ -398,9 +399,7 @@ var/list/global/slot_flags_enumeration = list(
//The default action is attack_self(). //The default action is attack_self().
//Checks before we get to here are: mob is alive, mob is not restrained, paralyzed, asleep, resting, laying, item is on the mob. //Checks before we get to here are: mob is alive, mob is not restrained, paralyzed, asleep, resting, laying, item is on the mob.
/obj/item/proc/ui_action_click() /obj/item/proc/ui_action_click()
if( src in usr ) attack_self(usr)
attack_self(usr)
/obj/item/proc/IsShield() /obj/item/proc/IsShield()
return 0 return 0

View File

@@ -10,7 +10,7 @@
matter = list(DEFAULT_WALL_MATERIAL = 50,"glass" = 20) matter = list(DEFAULT_WALL_MATERIAL = 50,"glass" = 20)
icon_action_button = "action_flashlight" action_button_name = "Toggle Flashlight"
var/on = 0 var/on = 0
var/brightness_on = 4 //luminosity when on var/brightness_on = 4 //luminosity when on
@@ -141,7 +141,7 @@
light_color = "#e58775" light_color = "#e58775"
icon_state = "flare" icon_state = "flare"
item_state = "flare" item_state = "flare"
icon_action_button = null //just pull it manually, neckbeard. action_button_name = null //just pull it manually, neckbeard.
var/fuel = 0 var/fuel = 0
var/on_damage = 7 var/on_damage = 7
var/produce_heat = 1500 var/produce_heat = 1500

View File

@@ -11,7 +11,7 @@
var/on = 0.0 var/on = 0.0
var/stabilization_on = 0 var/stabilization_on = 0
var/volume_rate = 500 //Needed for borg jetpack transfer var/volume_rate = 500 //Needed for borg jetpack transfer
icon_action_button = "action_jetpack" action_button_name = "Toggle Jetpack"
/obj/item/weapon/tank/jetpack/New() /obj/item/weapon/tank/jetpack/New()
..() ..()

View File

@@ -250,11 +250,6 @@ BLIND // can't see anything
var/brightness_on var/brightness_on
var/on = 0 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) /obj/item/clothing/head/attack_self(mob/user)
if(brightness_on) if(brightness_on)
if(!isturf(user.loc)) if(!isturf(user.loc))
@@ -382,19 +377,19 @@ BLIND // can't see anything
var/displays_id = 1 var/displays_id = 1
var/rolled_down = -1 //0 = unrolled, 1 = rolled, -1 = cannot be toggled var/rolled_down = -1 //0 = unrolled, 1 = rolled, -1 = cannot be toggled
sprite_sheets = list("Vox" = 'icons/mob/species/vox/uniform.dmi') 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. //convenience var for defining the icon state for the overlay used when the clothing is worn.
//Also used by rolling/unrolling. //Also used by rolling/unrolling.
var/worn_state = null var/worn_state = null
/obj/item/clothing/under/New() /obj/item/clothing/under/New()
if(worn_state) if(worn_state)
if(!item_state_slots) if(!item_state_slots)
item_state_slots = list() item_state_slots = list()
item_state_slots[slot_w_uniform_str] = worn_state item_state_slots[slot_w_uniform_str] = worn_state
else else
worn_state = icon_state worn_state = icon_state
//autodetect rollability //autodetect rollability
if(rolled_down < 0) if(rolled_down < 0)
if((worn_state + "_d_s") in icon_states('icons/mob/uniform.dmi')) 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 )) if (( usr.restrained() ) || ( usr.stat ))
return return
if (!usr.unEquip(src)) if (!usr.unEquip(src))
return return
switch(over_object.name) switch(over_object.name)
if("r_hand") if("r_hand")
usr.put_in_r_hand(src) usr.put_in_r_hand(src)
@@ -544,7 +539,7 @@ BLIND // can't see anything
if(rolled_down < 0) if(rolled_down < 0)
usr << "<span class='notice'>You cannot roll down [src]!</span>" usr << "<span class='notice'>You cannot roll down [src]!</span>"
return return
rolled_down = !rolled_down rolled_down = !rolled_down
if(rolled_down) if(rolled_down)
body_parts_covered &= LOWER_TORSO|LEGS|FEET body_parts_covered &= LOWER_TORSO|LEGS|FEET

View File

@@ -37,7 +37,7 @@
desc = "Used for seeing walls, floors, and stuff through anything." desc = "Used for seeing walls, floors, and stuff through anything."
icon_state = "meson" icon_state = "meson"
item_state = "glasses" 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) origin_tech = list(TECH_MAGNET = 2, TECH_ENGINERING = 2)
toggleable = 1 toggleable = 1
vision_flags = SEE_TURFS vision_flags = SEE_TURFS
@@ -57,7 +57,6 @@
icon_state = "purple" icon_state = "purple"
item_state = "glasses" item_state = "glasses"
toggleable = 1 toggleable = 1
icon_action_button = "action_science"
/obj/item/clothing/glasses/science/New() /obj/item/clothing/glasses/science/New()
..() ..()
@@ -76,7 +75,6 @@
origin_tech = list(TECH_MAGNET = 2) origin_tech = list(TECH_MAGNET = 2)
darkness_view = 7 darkness_view = 7
toggleable = 1 toggleable = 1
icon_action_button = "action_nvg"
off_state = "denight" off_state = "denight"
/obj/item/clothing/glasses/night/New() /obj/item/clothing/glasses/night/New()
@@ -102,7 +100,6 @@
desc = "Very confusing glasses." desc = "Very confusing glasses."
icon_state = "material" icon_state = "material"
item_state = "glasses" item_state = "glasses"
icon_action_button = "action_material"
origin_tech = list(TECH_MAGNET = 3, TECH_ENGINERING = 3) origin_tech = list(TECH_MAGNET = 3, TECH_ENGINERING = 3)
toggleable = 1 toggleable = 1
vision_flags = SEE_OBJS vision_flags = SEE_OBJS
@@ -147,7 +144,7 @@
desc = "Protects the eyes from welders, approved by the mad scientist association." desc = "Protects the eyes from welders, approved by the mad scientist association."
icon_state = "welding-g" icon_state = "welding-g"
item_state = "welding-g" item_state = "welding-g"
icon_action_button = "action_welding_g" action_button_name = "Flip Welding Goggles"
var/up = 0 var/up = 0
/obj/item/clothing/glasses/welding/attack_self() /obj/item/clothing/glasses/welding/attack_self()
@@ -182,7 +179,6 @@
desc = "Welding goggles made from more expensive materials, strangely smells like potatoes." desc = "Welding goggles made from more expensive materials, strangely smells like potatoes."
icon_state = "rwelding-g" icon_state = "rwelding-g"
item_state = "rwelding-g" item_state = "rwelding-g"
icon_action_button = "action_welding_g"
/obj/item/clothing/glasses/sunglasses/blindfold /obj/item/clothing/glasses/sunglasses/blindfold
name = "blindfold" name = "blindfold"
@@ -223,7 +219,6 @@
item_state = "glasses" item_state = "glasses"
origin_tech = list(TECH_MAGNET = 3) origin_tech = list(TECH_MAGNET = 3)
toggleable = 1 toggleable = 1
icon_action_button = "action_thermal"
vision_flags = SEE_MOBS vision_flags = SEE_MOBS
invisa_view = 2 invisa_view = 2
@@ -249,12 +244,12 @@
name = "Optical Meson Scanner" name = "Optical Meson Scanner"
desc = "Used for seeing walls, floors, and stuff through anything." desc = "Used for seeing walls, floors, and stuff through anything."
icon_state = "meson" 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 /obj/item/clothing/glasses/thermal/plain
toggleable = 0 toggleable = 0
activation_sound = null activation_sound = null
icon_action_button = "" action_button_name = null
/obj/item/clothing/glasses/thermal/plain/monocle /obj/item/clothing/glasses/thermal/plain/monocle
name = "Thermoncle" name = "Thermoncle"

View File

@@ -22,7 +22,7 @@
armor = list(melee = 10, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 0, rad = 0) armor = list(melee = 10, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 0, rad = 0)
flags_inv = (HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE) flags_inv = (HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE)
body_parts_covered = HEAD|FACE|EYES body_parts_covered = HEAD|FACE|EYES
icon_action_button = "action_welding" action_button_name = "Flip Welding Mask"
siemens_coefficient = 0.9 siemens_coefficient = 0.9
w_class = 3 w_class = 3
@@ -48,7 +48,7 @@
flags_inv &= ~(HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE) flags_inv &= ~(HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE)
icon_state = "[initial(icon_state)]up" icon_state = "[initial(icon_state)]up"
usr << "You push the [src] up out of your face." 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() usr.update_action_buttons()

View File

@@ -7,11 +7,10 @@
overshoes = 1 overshoes = 1
var/magpulse = 0 var/magpulse = 0
var/icon_base = "magboots" var/icon_base = "magboots"
icon_action_button = "action_blank" action_button_name = "Toggle Magboots"
action_button_name = "Toggle the magboots"
var/obj/item/clothing/shoes/shoes = null //Undershoes var/obj/item/clothing/shoes/shoes = null //Undershoes
var/mob/living/carbon/human/wearer = null //For shoe procs var/mob/living/carbon/human/wearer = null //For shoe procs
/obj/item/clothing/shoes/magboots/proc/set_slowdown() /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. slowdown = shoes? max(SHOES_SLOWDOWN, shoes.slowdown): SHOES_SLOWDOWN //So you can't put on magboots to make you walk faster.
if (magpulse) if (magpulse)
@@ -37,7 +36,7 @@
/obj/item/clothing/shoes/magboots/mob_can_equip(mob/user) /obj/item/clothing/shoes/magboots/mob_can_equip(mob/user)
var/mob/living/carbon/human/H = user var/mob/living/carbon/human/H = user
if(H.shoes) if(H.shoes)
shoes = H.shoes shoes = H.shoes
if(shoes.overshoes) if(shoes.overshoes)

View File

@@ -20,6 +20,7 @@
var/obj/machinery/camera/camera var/obj/machinery/camera/camera
var/list/camera_networks var/list/camera_networks
action_button_name = "Toggle Helmet Light"
light_overlay = "helmet_light" light_overlay = "helmet_light"
brightness_on = 4 brightness_on = 4
on = 0 on = 0
@@ -28,9 +29,6 @@
if(!camera && camera_networks) if(!camera && camera_networks)
if(!icon_action_button)
icon_action_button = "[icon_state]"
camera = new /obj/machinery/camera(src) camera = new /obj/machinery/camera(src)
camera.replace_networks(camera_networks) camera.replace_networks(camera_networks)
camera.c_tag = user.name camera.c_tag = user.name

View File

@@ -315,7 +315,7 @@ This saves us from having to call add_fingerprint() any time something is put in
W.layer = 20 W.layer = 20
if(W.icon_action_button) if(W.action_button_name)
update_action_buttons() update_action_buttons()
return 1 return 1

View File

@@ -242,7 +242,7 @@
src << "<span class='danger'>Your hand won't respond properly, you drop what you're holding!</span>" src << "<span class='danger'>Your hand won't respond properly, you drop what you're holding!</span>"
drop_item() drop_item()
if(getBrainLoss() >= 45) if(getBrainLoss() >= 45)
if(10 <= rn && rn <= 12) if(10 <= rn && rn <= 12)
if(prob(50)) if(prob(50))
src << "<span class='danger'>You suddenly black out!</span>" src << "<span class='danger'>You suddenly black out!</span>"
Paralyse(10) Paralyse(10)
@@ -1035,12 +1035,12 @@
blinded = 1 blinded = 1
// Check everything else. // Check everything else.
//Vision //Vision
var/obj/item/organ/vision var/obj/item/organ/vision
if(species.vision_organ) if(species.vision_organ)
vision = internal_organs_by_name[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. if(!vision) // Presumably if a species has no vision organs, they see via some other means.
eye_blind = 0 eye_blind = 0
blinded = 0 blinded = 0
@@ -1049,7 +1049,7 @@
eye_blind = 1 eye_blind = 1
blinded = 1 blinded = 1
eye_blurry = 1 eye_blurry = 1
else else
//blindness //blindness
if(sdisabilities & BLIND) // Disabled-blind, doesn't get better on its own if(sdisabilities & BLIND) // Disabled-blind, doesn't get better on its own
blinded = 1 blinded = 1
@@ -1059,7 +1059,7 @@
else if(istype(glasses, /obj/item/clothing/glasses/sunglasses/blindfold)) //resting your eyes with a blindfold heals blurry eyes faster 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) eye_blurry = max(eye_blurry-3, 0)
blinded = 1 blinded = 1
//blurry sight //blurry sight
if(vision.is_bruised()) // Vision organs impaired? Permablurry. if(vision.is_bruised()) // Vision organs impaired? Permablurry.
eye_blurry = 1 eye_blurry = 1

View File

@@ -1,3 +1,8 @@
/mob/living/Life()
..()
if(stat != DEAD)
handle_actions()
//mob verbs are faster than object verbs. See mob/verb/examine. //mob verbs are faster than object verbs. See mob/verb/examine.
/mob/living/verb/pulled(atom/movable/AM as mob|obj in oview(1)) /mob/living/verb/pulled(atom/movable/AM as mob|obj in oview(1))
set name = "Pull" set name = "Pull"
@@ -609,7 +614,7 @@ default behaviour is:
/mob/living/proc/escape_inventory(obj/item/weapon/holder/H) /mob/living/proc/escape_inventory(obj/item/weapon/holder/H)
if(H != src.loc) return if(H != src.loc) return
var/mob/M = H.loc //Get our mob holder (if any). var/mob/M = H.loc //Get our mob holder (if any).
if(istype(M)) if(istype(M))
@@ -794,5 +799,5 @@ default behaviour is:
inertia_dir = 2 inertia_dir = 2
src << "<span class='warning>Something you are carrying is preventing you from leaving.</span>" src << "<span class='warning>Something you are carrying is preventing you from leaving.</span>"
return return
..() ..()

View File

@@ -247,6 +247,81 @@
//Scale quadratically so that single digit numbers of fire stacks don't burn ridiculously hot. //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) 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 //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) /mob/living/proc/attack_throat(obj/item/W, obj/item/weapon/grab/G, mob/user)

View File

@@ -34,6 +34,7 @@
var/mob_always_swap = 0 var/mob_always_swap = 0
var/mob/living/cameraFollow = null var/mob/living/cameraFollow = null
var/list/datum/action/actions = list()
var/tod = null // Time of death var/tod = null // Time of death
var/update_slimes = 1 var/update_slimes = 1

View File

@@ -10,6 +10,7 @@
//Status updates, death etc. //Status updates, death etc.
clamp_values() clamp_values()
handle_regular_status_updates() handle_regular_status_updates()
handle_actions()
if(client) if(client)
handle_regular_hud_updates() handle_regular_hud_updates()

BIN
icons/mob/actions.dmi Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB