Skip to content

Commit

Permalink
The Evolution of Bar RP
Browse files Browse the repository at this point in the history
  • Loading branch information
thgvr committed Nov 10, 2023
1 parent 8022d29 commit 4813505
Show file tree
Hide file tree
Showing 9 changed files with 337 additions and 5 deletions.
44 changes: 39 additions & 5 deletions code/_onclick/hud/radial.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,18 @@ GLOBAL_LIST_EMPTY(radial_menus)
parent.finished = TRUE

/datum/radial_menu
var/list/choices = list() //List of choice id's
var/list/choices_icons = list() //choice_id -> icon
var/list/choices_values = list() //choice_id -> choice
/// List of choice IDs
var/list/choices = list()

/// choice_id -> icon
var/list/choices_icons = list()

/// choice_id -> choice
var/list/choices_values = list()

/// choice_id -> /datum/radial_menu_choice
var/list/choice_datums = list()

var/list/page_data = list() //list of choices per page


Expand Down Expand Up @@ -199,6 +208,7 @@ GLOBAL_LIST_EMPTY(radial_menus)
E.alpha = 255
E.mouse_opacity = MOUSE_OPACITY_ICON
E.cut_overlays()
E.vis_contents.Cut()
if(choice_id == NEXT_PAGE_ID)
E.name = "Next Page"
E.next_page = TRUE
Expand All @@ -217,6 +227,12 @@ GLOBAL_LIST_EMPTY(radial_menus)
E.next_page = FALSE
if(choices_icons[choice_id])
E.add_overlay(choices_icons[choice_id])
if (choice_datums[choice_id])
var/datum/radial_menu_choice/choice_datum = choice_datums[choice_id]
if (choice_datum.info)
var/obj/effect/abstract/info/info_button = new(E, choice_datum.info)

Check failure on line 233 in code/_onclick/hud/radial.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined type: /obj/effect/abstract/info

Check failure on line 233 in code/_onclick/hud/radial.dm

View workflow job for this annotation

GitHub Actions / Run Linters

no type hint available on implicit new()
info_button.layer = ABOVE_HUD_LAYER

Check warning on line 234 in code/_onclick/hud/radial.dm

View workflow job for this annotation

GitHub Actions / Run Linters

field access requires static type: "layer"
E.vis_contents += info_button

/datum/radial_menu/New()
close_button = new
Expand Down Expand Up @@ -245,11 +261,17 @@ GLOBAL_LIST_EMPTY(radial_menus)
var/I = extract_image(new_choices[E])
if(I)
choices_icons[id] = I
if (istype(new_choices[E], /datum/radial_menu_choice))
choice_datums[id] = new_choices[E]
setup_menu(use_tooltips)


/datum/radial_menu/proc/extract_image(E)
var/mutable_appearance/MA = new /mutable_appearance(E)
/datum/radial_menu/proc/extract_image(to_extract_from)
if (istype(to_extract_from, /datum/radial_menu_choice))
var/datum/radial_menu_choice/choice = to_extract_from
to_extract_from = choice.image

var/mutable_appearance/MA = new /mutable_appearance(to_extract_from)
if(MA)
MA.layer = ABOVE_HUD_LAYER
MA.appearance_flags |= RESET_TRANSFORM
Expand Down Expand Up @@ -332,3 +354,15 @@ GLOBAL_LIST_EMPTY(radial_menus)
if(!custom_check.Invoke())
return
return answer

/// Can be provided to choices in radial menus if you want to provide more information
/datum/radial_menu_choice
/// Required -- what to display for this button
var/image

/// If provided, will display an info button that will put this text in your chat
var/info

/datum/radial_menu_choice/Destroy(force, ...)
. = ..()
QDEL_NULL(image)
1 change: 1 addition & 0 deletions code/game/objects/items/stacks/sheets/sheet_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ GLOBAL_LIST_INIT(wood_recipes, list ( \
new/datum/stack_recipe("coffin", /obj/structure/closet/crate/coffin, 5, time = 15, one_per_turf = TRUE, on_floor = TRUE), \
new/datum/stack_recipe("book case", /obj/structure/bookcase, 4, time = 15, one_per_turf = TRUE, on_floor = TRUE), \
new/datum/stack_recipe("drying rack", /obj/machinery/smartfridge/drying_rack, 10, time = 15, one_per_turf = TRUE, on_floor = TRUE), \
new/datum/stack_recipe("sauna oven", /obj/structure/sauna_oven, 30, time = 15, one_per_turf = TRUE, on_floor = TRUE), \
new/datum/stack_recipe("wooden barrel", /obj/structure/fermenting_barrel, 8, time = 50, one_per_turf = TRUE, on_floor = TRUE), \
new/datum/stack_recipe("dog bed", /obj/structure/bed/dogbed, 10, time = 10, one_per_turf = TRUE, on_floor = TRUE), \
new/datum/stack_recipe("dresser", /obj/structure/dresser, 10, time = 15, one_per_turf = TRUE, on_floor = TRUE), \
Expand Down
108 changes: 108 additions & 0 deletions code/game/objects/structures/sauna.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#define SAUNA_H2O_TEMP T20C + 80
#define SAUNA_LOG_FUEL 150
#define SAUNA_MAXIMUM_FUEL 3000
#define SAUNA_WATER_PER_WATER_UNIT 3

/obj/structure/sauna_oven
name = "sauna oven"
desc = "A modest sauna oven with rocks. Add some fuel, pour some water and enjoy the moment."
icon_state = "sauna"
density = TRUE
anchored = TRUE
resistance_flags = FIRE_PROOF
var/lit = FALSE
var/fuel_amount = 0
var/water_amount = 0

/obj/structure/sauna_oven/examine(mob/user)
. = ..()
. += "<span class='notice'>The rocks are [water_amount ? "moist" : "dry"].</span>"
. += "<span class='notice'>There's [fuel_amount ? "some fuel" : "no fuel"] in the oven.</span>"

/obj/structure/sauna_oven/Initialize()
. = ..()
RegisterSignal(src, COMSIG_ATOM_EXPOSE_REAGENTS, PROC_REF(add_water))

/obj/structure/sauna_oven/proc/add_water(atom/source, list/reagents, datum/reagents/source_reagents, method, volume_modifier, show_message)
SIGNAL_HANDLER

if(method != TOUCH) // Only splashing/pouring
return

for(var/reagent in reagents)
if(istype(reagent, /datum/reagent/water))
water_amount += reagents[reagent] * SAUNA_WATER_PER_WATER_UNIT

/obj/structure/sauna_oven/Destroy()
if(lit)
STOP_PROCESSING(SSobj, src)
return ..()

/obj/structure/sauna_oven/attack_hand(mob/user)
. = ..()
if(.)
return
if(lit)
lit = FALSE
STOP_PROCESSING(SSobj, src)
user.visible_message("<span class='notice'>[user] turns on [src].</span>", "<span class='notice'>You turn on [src].</span>")
else if (fuel_amount)
lit = TRUE
START_PROCESSING(SSobj, src)
user.visible_message("<span class='notice'>[user] turns off [src].</span>", "<span class='notice'>You turn off [src].</span>")
update_icon()

/obj/structure/sauna_oven/update_overlays()
. = ..()
if(lit)
. += "sauna_on_overlay"

/obj/structure/sauna_oven/update_icon()
..()
icon_state = "[lit ? "sauna_on" : initial(icon_state)]"

/obj/structure/sauna_oven/attackby(obj/item/T, mob/user)
if(T.tool_behaviour == TOOL_WRENCH)
to_chat(user, "<span class='notice'>You begin to deconstruct [src].</span>")
if(T.use_tool(src, user, 60, volume=50))
to_chat(user, "<span class='notice'>You successfully deconstructed [src].</span>")
new /obj/item/stack/sheet/mineral/wood(get_turf(src), 30)
qdel(src)

else if(istype(T, /obj/item/stack/sheet/mineral/wood))
var/obj/item/stack/sheet/mineral/wood/wood = T
if(fuel_amount > SAUNA_MAXIMUM_FUEL)
to_chat(user, "<span class='warning'>You can't fit any more of [T] in [src]!</span>")
return
fuel_amount += SAUNA_LOG_FUEL * wood.amount
wood.use(wood.amount)
user.visible_message("<span class='notice'>[user] tosses some \
wood into [src].</span>", "<span class='notice'>You add \
some fuel to [src].</span>")
return ..()

/obj/structure/sauna_oven/process()
if(water_amount)
var/used_amt
if(water_amount >= 10)
used_amt = water_amount/10
else if(water_amount >= 1)
used_amt = 1
else
used_amt = water_amount
// The above is equal to used_amt = max(water_amount/10, min(1, water_amount)
water_amount -= used_amt
var/turf/pos = get_turf(src)
if(pos)
pos.atmos_spawn_air("water_vapor=[used_amt];TEMP=[SAUNA_H2O_TEMP]")
fuel_amount--

if(fuel_amount <= 0)
lit = FALSE
STOP_PROCESSING(SSobj, src)
update_icon()

#undef SAUNA_H2O_TEMP
#undef SAUNA_LOG_FUEL
#undef SAUNA_MAXIMUM_FUEL
#undef SAUNA_WATER_PER_WATER_UNIT
187 changes: 187 additions & 0 deletions code/modules/clothing/towels.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/// Default shape of the towel, when it's folded.
#define TOWEL_FOLDED ""
/// Chest-down variant of the towel.
#define TOWEL_FULL "chest"
/// Waist-down variant of the towel.
#define TOWEL_WAIST "waist"
/// Head variant of the towel.
#define TOWEL_HEAD "head"
/// Shape of the towel when it has been used, and is no longer neatly folded.
#define TOWEL_USED "used"

/// Icon path to the obj icon of the towel.
#define TOWEL_OBJ_ICON 'icons/obj/clothing/towel.dmi'
/// Icon path to the worn icon of the towel.
#define TOWEL_WORN_ICON 'icons/mob/clothing/towel.dmi'

/// How much cloth goes into a towel.
#define TOWEL_CLOTH_AMOUNT 2

/obj/item/towel
name = "towel"
desc = "Everyone knows what a towel is. Use it to dry yourself, or wear it around your chest, your waist or even your head!"
icon = TOWEL_OBJ_ICON
mob_overlay_icon = TOWEL_WORN_ICON
icon_state = "towel"
base_icon_state = "towel"
force = 0
throwforce = 0
throw_speed = 1
throw_range = 3 // They're not very aerodynamic.
w_class = WEIGHT_CLASS_SMALL // Don't ask me why other cloth-related items are considered tiny, and not small like this one.
item_flags = NOBLUDGEON
resistance_flags = FLAMMABLE
flags_inv = HIDEHAIR // Only relevant when in head shape, but useful to keep around regardless.
supports_variations = DIGITIGRADE_VARIATION_NO_NEW_ICON
/// The shape we're currently in.
var/shape = TOWEL_FOLDED

/obj/item/towel/examine(mob/user)
. = ..()

if(!ishuman(user) && !iscyborg(user))
return

. += "" // Just for an empty line

var/in_hands = TRUE
if(ishuman(user))
in_hands = user.get_active_held_item() == src || user.get_inactive_held_item() == src

if(in_hands)
. += span_notice("<b>Use in hand</b> to shape [src] into something different.")

if(iscyborg(user))
return

if(shape == TOWEL_FULL || shape == TOWEL_WAIST)
. += span_notice("<b>Alt-click</b> to adjust the fit of [src].")

/obj/item/towel/attack_self(mob/user, modifiers)
. = ..()

/// Initializing this only once to avoid having to do it every time
var/static/list/datum/radial_menu_choice/worn_options = list()

if(!length(worn_options))
for(var/variant in list(TOWEL_FULL, TOWEL_WAIST, TOWEL_HEAD))
var/datum/radial_menu_choice/option = new
var/image/variant_image = image(icon = TOWEL_OBJ_ICON, icon_state = "[base_icon_state]-[variant]")

option.image = variant_image
worn_options[capitalize(variant)] = option

var/choice = show_radial_menu(user, src, worn_options, require_near = TRUE, tooltips = TRUE)

if(!choice)
return

change_towel_shape(user, lowertext(choice))

/obj/item/towel/attackby(obj/item/I, mob/user, params)
if(I.tool_behaviour == TOOL_WIRECUTTER || I.get_sharpness())
var/obj/item/stack/sheet/cotton/cloth/shreds = new (get_turf(src), 3)
if(!QDELETED(shreds)) //stacks merged
transfer_fingerprints_to(shreds)
shreds.add_fingerprint(user)
qdel(src)
to_chat(user, "<span class='notice'>You tear [src] up.</span>")
else
return ..()

/obj/item/towel/AltClick(mob/user)
. = ..()

if(. == FALSE)
return

if(!(shape == TOWEL_FULL || shape == TOWEL_WAIST))
return FALSE

if(!ishuman(user))
return FALSE

var/mob/living/carbon/human/towel_user = user
var/worn = towel_user.wear_suit == src

change_towel_shape(user, shape == TOWEL_FULL ? TOWEL_WAIST : TOWEL_FULL, silent = worn)

// No need to display the different message if they're not wearing it.
if(!worn)
return

to_chat(user, span_notice(shape == TOWEL_FULL ? "You raise \the [src] over your [shape]." : "You lower \the [src] down to your [shape]."))

/obj/item/towel/machine_wash(obj/machinery/washing_machine/washer)
. = ..() // This isn't really needed, including it in case we ever get dyeable towels.
make_used(null, silent = TRUE)

/obj/item/towel/dropped(mob/user, silent)
. = ..()
if(!ishuman(loc))
make_used(user, silent = TRUE)

/*
* Helper to change the shape of the towel, so that it updates its look both
* in-hand and on the body of the wearer.
*
* Arguments:
* * user - Mob that's trying to change the shape of the towel.
* * new_shape - The new shape that the towel can be in.
* * silent (optional) - Whether we produce a to_chat to the user to elaborate on
* the new shape it is now in. Requires `user` to be non-null if `TRUE` in order to
* do anything. Defaults to `FALSE`.
*/
/obj/item/towel/proc/change_towel_shape(mob/user, new_shape, silent = FALSE)
if(new_shape == shape)
return

shape = new_shape

icon_state = "[base_icon_state][shape ? "-[shape]" : ""]"

if(shape == TOWEL_HEAD)
flags_inv |= HIDEHAIR
else
flags_inv &= ~HIDEHAIR

update_appearance()
update_slot_related_flags()

if(!silent && user)
to_chat(user, span_notice(shape ? "You adjust [src] so that it can be worn over your [shape]." : "You fold [src] neatly."))

/*
* Helper proc to change the slot flags of the towel based on its shape.
*/
/obj/item/towel/proc/update_slot_related_flags()
switch(shape)
if(TOWEL_FULL)
slot_flags = ITEM_SLOT_OCLOTHING
body_parts_covered = CHEST | GROIN | LEGS

if(TOWEL_WAIST)
slot_flags = ITEM_SLOT_OCLOTHING
body_parts_covered = GROIN | LEGS

if(TOWEL_HEAD)
slot_flags = ITEM_SLOT_HEAD
body_parts_covered = HEAD

else
slot_flags = NONE
body_parts_covered = NONE

update_slot_icon()

/*
* Simple helper to make the towel into a used towel shape.
*
* Arguments:
* * user - Mob that's making the towel used. Can be null if `silent` is `FALSE`.
* * silent (optional) - Whether we produce a to_chat to the user to elaborate on
* the new shape it is now in. Requires `user` to be non-null if `TRUE` in order to
* do anything. Defaults to `FALSE`.
*/
/obj/item/towel/proc/make_used(mob/user, silent = FALSE)
change_towel_shape(user, TOWEL_USED, silent)
Binary file modified icons/effects/effects.dmi
Binary file not shown.
Binary file added icons/mob/clothing/towel.dmi
Binary file not shown.
Binary file added icons/obj/clothing/towel.dmi
Binary file not shown.
Binary file modified icons/obj/structures.dmi
Binary file not shown.
2 changes: 2 additions & 0 deletions shiptest.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,7 @@
#include "code\game\objects\structures\reflector.dm"
#include "code\game\objects\structures\safe.dm"
#include "code\game\objects\structures\salvaging.dm"
#include "code\game\objects\structures\sauna.dm"
#include "code\game\objects\structures\showcase.dm"
#include "code\game\objects\structures\shower.dm"
#include "code\game\objects\structures\signs.dm"
Expand Down Expand Up @@ -1919,6 +1920,7 @@
#include "code\modules\client\verbs\who.dm"
#include "code\modules\clothing\chameleon.dm"
#include "code\modules\clothing\clothing.dm"
#include "code\modules\clothing\towels.dm"
#include "code\modules\clothing\ears\_ears.dm"
#include "code\modules\clothing\factions\gezena.dm"
#include "code\modules\clothing\glasses\_glasses.dm"
Expand Down

0 comments on commit 4813505

Please sign in to comment.