From bc303a85bdfede55cb9bbe530e9cc8b478a2ed61 Mon Sep 17 00:00:00 2001 From: HMBGERDO <61080616+HMBGERDO@users.noreply.github.com> Date: Tue, 2 Jul 2024 01:14:45 +0200 Subject: [PATCH] Adds cult action bar (#26052) * cult actions list * moved blood spear a little to the side * pixel offset * Update code/__DEFINES/action_button_defines.dm Co-authored-by: Spaghetti-bit Signed-off-by: HMBGERDO <61080616+HMBGERDO@users.noreply.github.com> * review * eh, why not --------- Signed-off-by: HMBGERDO <61080616+HMBGERDO@users.noreply.github.com> Co-authored-by: Spaghetti-bit --- code/__DEFINES/action_button_defines.dm | 2 ++ code/_onclick/hud/action_button.dm | 11 +++++++++++ code/_onclick/hud/action_group.dm | 18 +++++++++++++++--- code/_onclick/hud/hud_datum.dm | 4 ++++ code/datums/action.dm | 3 --- code/game/gamemodes/cult/blood_magic.dm | 24 ++---------------------- code/game/gamemodes/cult/cult_actions.dm | 2 +- code/game/gamemodes/cult/cult_items.dm | 2 +- 8 files changed, 36 insertions(+), 30 deletions(-) diff --git a/code/__DEFINES/action_button_defines.dm b/code/__DEFINES/action_button_defines.dm index 4fdfa32f98b..1903a9aa56f 100644 --- a/code/__DEFINES/action_button_defines.dm +++ b/code/__DEFINES/action_button_defines.dm @@ -27,3 +27,5 @@ #define SCRN_OBJ_IN_LIST "list" /// In the collapseable palette #define SCRN_OBJ_IN_PALETTE "palette" +/// In cult spell list +#define SCRN_OBJ_CULT_LIST "cult_list" diff --git a/code/_onclick/hud/action_button.dm b/code/_onclick/hud/action_button.dm index a8303d46fb8..f7cf1f8c448 100644 --- a/code/_onclick/hud/action_button.dm +++ b/code/_onclick/hud/action_button.dm @@ -508,6 +508,8 @@ GLOBAL_LIST_INIT(palette_removed_matrix, list(1.4,0,0,0, 0.7,0.4,0,0, 0.4,0,0.6, listed_actions.insert_action(button) if(SCRN_OBJ_IN_PALETTE) palette_actions.insert_action(button) + if(SCRN_OBJ_CULT_LIST) + cult_actions.insert_action(button) else // If we don't have it as a define, this is a screen_loc, and we should be floating floating_actions += button button.screen_loc = position @@ -523,6 +525,8 @@ GLOBAL_LIST_INIT(palette_removed_matrix, list(1.4,0,0,0, 0.7,0.4,0,0, 0.4,0,0.6, listed_actions.insert_action(button, listed_actions.index_of(relative_to)) if(SCRN_OBJ_IN_PALETTE) palette_actions.insert_action(button, palette_actions.index_of(relative_to)) + if(SCRN_OBJ_CULT_LIST) + cult_actions.insert_action(button, cult_actions.index_of(relative_to)) if(SCRN_OBJ_FLOATING) // If we don't have it as a define, this is a screen_loc, and we should be floating floating_actions += button var/client/our_client = mymob.client @@ -543,6 +547,8 @@ GLOBAL_LIST_INIT(palette_removed_matrix, list(1.4,0,0,0, 0.7,0.4,0,0, 0.4,0,0.6, floating_actions -= button if(SCRN_OBJ_IN_LIST) listed_actions.remove_action(button) + if(SCRN_OBJ_CULT_LIST) + cult_actions.remove_action(button) if(SCRN_OBJ_IN_PALETTE) palette_actions.remove_action(button) button.screen_loc = null @@ -551,11 +557,13 @@ GLOBAL_LIST_INIT(palette_removed_matrix, list(1.4,0,0,0, 0.7,0.4,0,0, 0.4,0,0.6, /datum/hud/proc/generate_landings(atom/movable/screen/movable/action_button/button) listed_actions.generate_landing() palette_actions.generate_landing() + cult_actions.generate_landing() /// Clears all currently visible landings /datum/hud/proc/hide_landings() listed_actions.clear_landing() palette_actions.clear_landing() + cult_actions.clear_landing() // Updates any existing "owned" visuals, ensures they continue to be visible /datum/hud/proc/update_our_owner() @@ -563,6 +571,7 @@ GLOBAL_LIST_INIT(palette_removed_matrix, list(1.4,0,0,0, 0.7,0.4,0,0, 0.4,0,0.6, palette_down.refresh_owner() palette_up.refresh_owner() listed_actions.update_landing() + cult_actions.update_landing() palette_actions.update_landing() /// Ensures all of our buttons are properly within the bounds of our client's view, moves them if they're not @@ -570,6 +579,7 @@ GLOBAL_LIST_INIT(palette_removed_matrix, list(1.4,0,0,0, 0.7,0.4,0,0, 0.4,0,0.6, var/our_view = mymob?.client?.view if(!our_view) return + cult_actions.check_against_view() listed_actions.check_against_view() palette_actions.check_against_view() for(var/atom/movable/screen/movable/action_button/floating_button as anything in floating_actions) @@ -579,6 +589,7 @@ GLOBAL_LIST_INIT(palette_removed_matrix, list(1.4,0,0,0, 0.7,0.4,0,0, 0.4,0,0.6, /// Generates and fills new action groups with our mob's current actions /datum/hud/proc/build_action_groups() + cult_actions = new(src) listed_actions = new(src) palette_actions = new(src) floating_actions = list() diff --git a/code/_onclick/hud/action_group.dm b/code/_onclick/hud/action_group.dm index f4bdc06c8cb..40b1ae8d582 100644 --- a/code/_onclick/hud/action_group.dm +++ b/code/_onclick/hud/action_group.dm @@ -5,6 +5,8 @@ var/list/atom/movable/screen/movable/action_button/actions /// The initial vertical offset of our action buttons var/north_offset = 0 + /// The initial horizontal offset of our action buttons + var/west_offset = 0 /// The pixel vertical offset of our action buttons var/pixel_north_offset = 0 /// The pixel horizontal offset of our action buttons @@ -88,10 +90,10 @@ var/visual_row = row + north_offset var/coord_row = visual_row ? "-[visual_row]" : "+0" - var/visual_column = number % column_max + var/visual_column = west_offset + number % column_max var/coord_col = "+[visual_column]" - var/coord_col_offset = 4 + 2 * (visual_column + 1) - var/coord_row_offset = pixel_north_offset + 2 * (1 * visual_row) + var/coord_col_offset = pixel_horiz_offset + 2 * (number % column_max + 1) + var/coord_row_offset = pixel_north_offset + 2 * (1 * row) return "WEST[coord_col]:[coord_col_offset],NORTH[coord_row]:-[coord_row_offset]" /datum/action_group/proc/check_against_view() @@ -214,6 +216,7 @@ /datum/action_group/listed + pixel_horiz_offset = 4 pixel_north_offset = 6 column_max = 10 location = SCRN_OBJ_IN_LIST @@ -221,3 +224,12 @@ /datum/action_group/listed/refresh_actions() . = ..() owner?.palette_actions.refresh_actions() // We effect them, so we gotta refresh em + +/datum/action_group/listed/cult + north_offset = 11 + pixel_north_offset = 2 + west_offset = 6 + pixel_horiz_offset = -29 + column_max = 4 + location = SCRN_OBJ_CULT_LIST + max_rows = 2 diff --git a/code/_onclick/hud/hud_datum.dm b/code/_onclick/hud/hud_datum.dm index be2bb5aaea1..d9a434ec361 100644 --- a/code/_onclick/hud/hud_datum.dm +++ b/code/_onclick/hud/hud_datum.dm @@ -39,6 +39,8 @@ var/atom/movable/screen/palette_scroll/up/palette_up /// the groups of actions, such as palette (previously normal) actions var/datum/action_group/palette/palette_actions + /// action group for cult spell actions + var/datum/action_group/listed/cult/cult_actions /// action group for expanded actions, the normal action set var/datum/action_group/listed/listed_actions /// A list of action buttons which aren't owned by any action group, and are just floating somewhere on the hud. @@ -77,6 +79,7 @@ var/list/all_action_buttons = list() all_action_buttons += palette_actions.actions all_action_buttons += listed_actions.actions + all_action_buttons += cult_actions.actions return all_action_buttons /datum/hud/New(mob/owner) @@ -110,6 +113,7 @@ QDEL_NULL(palette_up) QDEL_NULL(palette_actions) QDEL_NULL(listed_actions) + QDEL_NULL(cult_actions) QDEL_LIST_CONTENTS(floating_actions) QDEL_NULL(module_store_icon) diff --git a/code/datums/action.dm b/code/datums/action.dm index 3ebe3af28fa..197f3476388 100644 --- a/code/datums/action.dm +++ b/code/datums/action.dm @@ -96,9 +96,6 @@ Trigger() return FALSE -/datum/action/proc/override_location() // Override to set coordinates manually - return - /datum/action/proc/IsAvailable()// returns 1 if all checks pass if(!owner) return FALSE diff --git a/code/game/gamemodes/cult/blood_magic.dm b/code/game/gamemodes/cult/blood_magic.dm index 1582129897d..a00e4b8a064 100644 --- a/code/game/gamemodes/cult/blood_magic.dm +++ b/code/game/gamemodes/cult/blood_magic.dm @@ -3,32 +3,15 @@ name = "Prepare Blood Magic" button_overlay_icon_state = "carve" desc = "Prepare blood magic by carving runes into your flesh. This is easier with an empowering rune." + default_button_position = DEFAULT_BLOODSPELLS var/list/spells = list() var/channeling = FALSE - default_button_position = DEFAULT_BLOODSPELLS /datum/action/innate/cult/blood_magic/Remove() for(var/X in spells) qdel(X) ..() -/datum/action/innate/cult/blood_magic/proc/Positioning() - for(var/datum/hud/hud as anything in viewers) - var/our_view = hud.mymob?.client?.view || "15x15" - var/atom/movable/screen/movable/action_button/button = viewers[hud] - var/position = screen_loc_to_offset(button.screen_loc) - var/spells_iterated = 0 - for(var/datum/action/innate/cult/blood_spell/blood_spell in spells) - spells_iterated += 1 - if(blood_spell.positioned) - continue - var/atom/movable/screen/movable/action_button/moving_button = blood_spell.viewers[hud] - if(!moving_button) - continue - var/our_x = position[1] + spells_iterated * world.icon_size // Offset any new buttons into our list - hud.position_action(moving_button, offset_to_screen_loc(our_x, position[2], our_view)) - blood_spell.positioned = TRUE - /datum/action/innate/cult/blood_magic/Activate() var/rune = FALSE var/limit = RUNELESS_MAX_BLOODCHARGE @@ -93,6 +76,7 @@ name = "Blood Magic" button_overlay_icon_state = "telerune" desc = "Fear the Old Blood." + default_button_position = SCRN_OBJ_CULT_LIST var/charges = 1 var/magic_path = null var/obj/item/melee/blood_magic/hand_magic @@ -129,10 +113,6 @@ // button.ordered = FALSE ..() -/datum/action/innate/cult/blood_spell/override_location() - // button.locked = TRUE - all_magic.Positioning() - /datum/action/innate/cult/blood_spell/Remove() if(all_magic) all_magic.spells -= src diff --git a/code/game/gamemodes/cult/cult_actions.dm b/code/game/gamemodes/cult/cult_actions.dm index 6625546b7a6..71fc8388bc9 100644 --- a/code/game/gamemodes/cult/cult_actions.dm +++ b/code/game/gamemodes/cult/cult_actions.dm @@ -112,7 +112,7 @@ name = "Draw Blood Rune" desc = "Use the ritual dagger to create a powerful blood rune" button_overlay_icon_state = "blood_dagger" - default_button_position = "6:157,4:-2" + default_button_position = "10:29,4:-2" /datum/action/innate/cult/use_dagger/Grant() button_overlay_icon_state = GET_CULT_DATA(dagger_icon, "blood_dagger") diff --git a/code/game/gamemodes/cult/cult_items.dm b/code/game/gamemodes/cult/cult_items.dm index 3e5cf8d46e7..f3ef2d5ef90 100644 --- a/code/game/gamemodes/cult/cult_items.dm +++ b/code/game/gamemodes/cult/cult_items.dm @@ -647,9 +647,9 @@ desc = "Call the blood spear back to your hand!" button_background_icon_state = "bg_cult" button_overlay_icon_state = "bloodspear" + default_button_position = "11:31,4:-2" var/obj/item/cult_spear/spear var/cooldown = 0 - default_button_position = "6:157,4:-2" /datum/action/innate/cult/spear/Grant(mob/user, obj/blood_spear) . = ..()