Skip to content

Commit

Permalink
that
Browse files Browse the repository at this point in the history
  • Loading branch information
silicons committed Sep 21, 2024
1 parent a99feec commit ca58d07
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 167 deletions.
28 changes: 12 additions & 16 deletions code/__DEFINES/screen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,27 @@
//* These should be widescreen-agnostic and use anchorings *//
//* to the sides of the screen / center. *//

//* Mob HUD - Inventory *//

/// the bottom-left hand of hands HUD
#define SCREEN_LOC_MOB_HANDS_HUD_ANCHOR "CENTER-1:16,BOTTOM+1:5"
#define SCREEN_LOC_MOB_HUD_INVENTORY_HANDS_BOTTOM_LEFT "CENTER-1:16,BOTTOM+1:5"
#define SCREEN_LOC_MOB_HUD_INVENTORY_HAND(HAND) "CENTER[index % 2? "" : "-1"]:16,BOTTOM[index < 2? "" : "+[(round(index / 2) - 1)]"]:5"
#warn fill these in

Check warning on line 35 in code/__DEFINES/screen.dm

View workflow job for this annotation

GitHub Actions / Run Linters

#warn fill these in
#define SCREEN_LOC_MOB_HUD_INVENTORY_HAND_SWAP(TOTAL_HANDS) ""
#define SCREEN_LOC_MOB_HUD_INVENTORY_EQUIP_HAND(TOTAL_HANDS) ""

/// the bottom-left drawer position of inventory HUD
#define SCREEN_LOC_MOB_INVENTORY_HUD_ANCHOR "LEFT:6,BOTTOM:5"
#define SCREEN_LOC_MOB_HUD_INVENTORY_DRAWER "LEFT:6,BOTTOM:5"

#warn fill these in

Check warning on line 42 in code/__DEFINES/screen.dm

View workflow job for this annotation

GitHub Actions / Run Linters

#warn fill these in
#define SCREEN_LOC_MOB_HUD_INVENTORY_SLOT_DRAWER_ALIGNED(MAIN_AXIS, CROSS_AXIS) ""
#define SCREEN_LOC_MOB_HUD_INVENTORY_SLOT_HANDS_ALIGNED(MAIN_AXIS, CROSS_AXIS) ""

#warn deal with this crap

Check warning on line 46 in code/__DEFINES/screen.dm

View workflow job for this annotation

GitHub Actions / Run Linters

#warn deal with this crap

/// Hands
#define SCREEN_LOC_INV_HAND(index) "CENTER[index % 2? "" : "-1"]:16,BOTTOM[index < 2? "" : "+[(round(index / 2) - 1)]"]:5"
#define ui_swaphand1 "CENTER-1:16,BOTTOM+1:5"
#define ui_swaphand2 "CENTER:16,BOTTOM+1:5"

//Lower left, persistant menu
#define ui_inventory "LEFT:6,BOTTOM:5"

//Lower center, persistant menu
#define ui_sstore1 "LEFT+2:10,BOTTOM:5"
#define ui_id "LEFT+3:12,BOTTOM:5"
#define ui_belt "LEFT+4:14,BOTTOM:5"
#define ui_back "CENTER-2:14,BOTTOM:5"

#define ui_equip "CENTER-1:16,BOTTOM+1:5"
#define ui_storage1 "CENTER+1:16,BOTTOM:5"
#define ui_storage2 "CENTER+2:16,BOTTOM:5"
#define ui_smallquad "RIGHT-4:18,BOTTOM:4"

///aliens
Expand Down
74 changes: 49 additions & 25 deletions code/game/rendering/mob_huds/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
/// ordered hand objects
var/list/atom/movable/screen/inventory/plate/hand/hands

/// drawer object
var/atom/movable/screen/inventory/drawer/button_drawer
/// swap hand object
var/atom/movable/screen/inventory/swap_hand/swap_hand
var/atom/movable/screen/inventory/swap_hand/button_swap_hand
/// equip object
var/atom/movable/screen/inventory/equip_hand/equip_hand
/// use hand on self object
var/atom/movable/screen/inventory/use_self_hand/use_self_hand
#warn add the drawer.
var/atom/movable/screen/inventory/equip_hand/button_equip_hand

/datum/mob_hud/inventory/New(mob/owner, datum/inventory/host)
src.host = host
Expand Down Expand Up @@ -75,9 +74,9 @@
cleanup()

// buttons
add_screen((swap_hand = new))
add_screen((equip_hand = new))
add_screen((use_self_hand = new))
add_screen((button_swap_hand = new))
add_screen((button_equip_hand = new))
add_screen((button_drawer = new))

// slots
rebuild_slots(inventory_slots_with_mappings)
Expand Down Expand Up @@ -138,6 +137,9 @@
qdel(hands[i])
hands.len = number_of_hands

button_equip_hand?.screen_loc = SCREEN_LOC_MOB_HUD_INVENTORY_EQUIP_HAND(number_of_hands)
button_swap_hand?.screen_loc = SCREEN_LOC_MOB_HUD_INVENTORY_HAND_SWAP(number_of_hands)

/datum/mob_hud/inventory/proc/all_slot_screen_objects(filter_by_class)
RETURN_TYPE(/list)
. = list()
Expand Down Expand Up @@ -165,12 +167,22 @@
/datum/mob_hud/inventory/proc/all_button_screen_objects()
RETURN_TYPE(/list)
. = list()
if(swap_hand)
. += swap_hand
if(equip_hand)
. += equip_hand
if(use_self_hand)
. += use_self_hand
if(button_swap_hand)
. += button_swap_hand
if(button_equip_hand)
. += button_equip_hand
if(button_drawer)
. += button_drawer

/datum/mob_hud/inventory/proc/toggle_hidden_class(class)
var/list/atom/movable/screen/inventory/affected = all_slot_screen_objects(class)
if(class in hidden_classes)
LAZYREMOVE(hidden_classes, class)
add_screen(affected)
else
LAZYADD(hidden_classes, class)
remove_screen(affected)
button_drawer?.update_icon()

/datum/mob_hud/inventory/proc/add_item(obj/item/item, datum/inventory_slot/slot_or_index)
var/atom/movable/screen/inventory/plate/screen_obj = isnum(slot_or_index) ? hands[slot_or_index] : slot_by_id[slot_or_index.id]
Expand All @@ -193,6 +205,9 @@
old_hand.cut_overlay("[old_hand.icon_state]-active")
new_hand.add_overlay("[new_hand.icon_state]-active")

/**
* Base type of inventory screen objects.
*/
/atom/movable/screen/inventory
name = "inventory"
icon = 'icons/screen/hud/midnight/inventory.dmi'
Expand Down Expand Up @@ -298,7 +313,7 @@
/atom/movable/screen/inventory/plate/hand/handle_inventory_click(mob/user, slot_or_index, obj/item/with_item)

/atom/movable/screen/inventory/plate/hand/proc/sync_index(index = hand_index)
screen_loc = SCREEN_LOC_INV_HAND(index)
screen_loc = SCREEN_LOC_MOB_HUD_INVENTORY_HAND(index)
var/index_of_side = round(index / 2)
name = "[index % 2? "left" : "right"] hand[index > 1? " #[index]" : ""]"
icon_state = "hand-[index % 2? "left" : "right"]"
Expand All @@ -315,6 +330,24 @@
if(handcuffed)
. += image('icons/mob/screen_gen.dmi', "[hand_index % 2 ? "r_hand" : "l_hand"]_hud_handcuffs")

/**
* Button: 'swap hand'
*/
/atom/movable/screen/inventory/drawer
icon_state = "drawer"

/atom/movable/screen/inventory/drawer/sync_style(datum/hud_style/style, style_alpha, style_color)
..()
icon = style.inventory_icons_wide

/atom/movable/screen/inventory/drawer/on_click(mob/user, list/params)
// todo: remote control
hud.toggle_hidden_class(INVENTORY_HUD_CLASS_DRAWER)

/atom/movable/screen/inventory/drawer/update_icon_state()
icon_state = "[INVENTORY_HUD_CLASS_DRAWER in hud.hidden_classes ? "drawer" : "drawer-active"]"
return ..()

/**
* Button: 'swap hand'
*/
Expand All @@ -325,7 +358,7 @@
..()
icon = style.inventory_icons_wide

/atom/movable/screen/inventory/swap_hands/on_click(mob/user, list/params)
/atom/movable/screen/inventory/swap_hand/on_click(mob/user, list/params)
// todo: remote control
user.swap_hand()

Expand All @@ -342,12 +375,3 @@
/atom/movable/screen/inventory/equip_hand/on_click(mob/user, list/params)
// todo: remote control
user.attempt_smart_equip(user.get_active_held_item())

/**
* Button: 'activate inhand'
*/
/atom/movable/screen/inventory/use_self_hand
#warn does main have this?

/atom/movable/screen/inventory/use_self_hand/on_click(mob/user, list/params)
// todo: remote control
90 changes: 45 additions & 45 deletions code/modules/flufftext/Hallucination.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,51 +35,51 @@ Gunshots/explosions/opening doors/less rare audio (done)
if(16 to 25)
//Strange items
//to_chat(src, "Traitor Items")
if(!halitem)
halitem = new
var/list/slots_free = list()
for(var/i in get_empty_hand_indices())
slots_free += SCREEN_LOC_INV_HAND(i)
if(istype(src,/mob/living/carbon/human))
var/mob/living/carbon/human/H = src
if(!H.belt) slots_free += ui_belt
if(!H.l_store) slots_free += ui_storage1
if(!H.r_store) slots_free += ui_storage2
if(slots_free.len)
halitem.screen_loc = pick(slots_free)
halitem.hud_layerise()
switch(rand(1,6))
if(1) //revolver
halitem.icon = 'icons/obj/gun/ballistic.dmi'
halitem.icon_state = "revolver"
halitem.name = "Revolver"
if(2) //c4
halitem.icon = 'icons/obj/assemblies.dmi'
halitem.icon_state = "plastic-explosive0"
halitem.name = "Mysterious Package"
if(prob(25))
halitem.icon_state = "c4small_1"
if(3) //sword
halitem.icon = 'icons/obj/weapons.dmi'
halitem.icon_state = "sword1"
halitem.name = "Sword"
if(4) //stun baton
halitem.icon = 'icons/obj/weapons.dmi'
halitem.icon_state = "stunbaton"
halitem.name = "Stun Baton"
if(5) //emag
halitem.icon = 'icons/obj/card.dmi'
halitem.icon_state = "emag"
halitem.name = "Cryptographic Sequencer"
if(6) //flashbang
halitem.icon = 'icons/obj/grenade.dmi'
halitem.icon_state = "flashbang1"
halitem.name = "Flashbang"
if(client) client.screen += halitem
spawn(rand(100,250))
if(client)
client.screen -= halitem
halitem = null
// if(!halitem)
// halitem = new
// var/list/slots_free = list()
// for(var/i in get_empty_hand_indices())
// slots_free += SCREEN_LOC_INV_HAND(i)
// if(istype(src,/mob/living/carbon/human))
// var/mob/living/carbon/human/H = src
// if(!H.belt) slots_free += ui_belt
// if(!H.l_store) slots_free += ui_storage1
// if(!H.r_store) slots_free += ui_storage2
// if(slots_free.len)
// halitem.screen_loc = pick(slots_free)
// halitem.hud_layerise()
// switch(rand(1,6))
// if(1) //revolver
// halitem.icon = 'icons/obj/gun/ballistic.dmi'
// halitem.icon_state = "revolver"
// halitem.name = "Revolver"
// if(2) //c4
// halitem.icon = 'icons/obj/assemblies.dmi'
// halitem.icon_state = "plastic-explosive0"
// halitem.name = "Mysterious Package"
// if(prob(25))
// halitem.icon_state = "c4small_1"
// if(3) //sword
// halitem.icon = 'icons/obj/weapons.dmi'
// halitem.icon_state = "sword1"
// halitem.name = "Sword"
// if(4) //stun baton
// halitem.icon = 'icons/obj/weapons.dmi'
// halitem.icon_state = "stunbaton"
// halitem.name = "Stun Baton"
// if(5) //emag
// halitem.icon = 'icons/obj/card.dmi'
// halitem.icon_state = "emag"
// halitem.name = "Cryptographic Sequencer"
// if(6) //flashbang
// halitem.icon = 'icons/obj/grenade.dmi'
// halitem.icon_state = "flashbang1"
// halitem.name = "Flashbang"
// if(client) client.screen += halitem
// spawn(rand(100,250))
// if(client)
// client.screen -= halitem
// halitem = null
if(26 to 40)
//Flashes of danger
//to_chat(src, "Danger Flash")
Expand Down
36 changes: 0 additions & 36 deletions code/modules/mob/living/simple_mob/simple_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,6 @@

var/list/hud_elements = list()
var/atom/movable/screen/using
var/atom/movable/screen/inventory/plate/slot/inv_box

var/has_hidden_gear
if(LAZYLEN(hud_gears))
for(var/gear_slot in hud_gears)
inv_box = new /atom/movable/screen/inventory()
inv_box.icon = ui_style
inv_box.color = ui_color
inv_box.alpha = ui_alpha

var/list/slot_data = hud_gears[gear_slot]
inv_box.name = gear_slot
inv_box.screen_loc = slot_data["loc"]
inv_box.slot_id = slot_data["slot"]
inv_box.icon_state = slot_data["state"]
slot_info["[inv_box.slot_id]"] = inv_box.screen_loc

if(slot_data["dir"])
inv_box.setDir(slot_data["dir"])

if(slot_data["toggle"])
other += inv_box
has_hidden_gear = 1
else
adding += inv_box

if(has_hidden_gear)
using = new /atom/movable/screen()
using.name = "toggle"
using.icon = ui_style
using.icon_state = "other"
using.screen_loc = ui_inventory
using.hud_layerise()
using.color = ui_color
using.alpha = ui_alpha
adding += using

//Intent Backdrop
using = new /atom/movable/screen()
Expand Down
Loading

0 comments on commit ca58d07

Please sign in to comment.