Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor poster refactor. #3473

Merged
merged 1 commit into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/datums/supplypacks/nonessent.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/obj/item/chems/glass/paint/purple,
/obj/item/chems/glass/paint/black,
/obj/item/chems/glass/paint/white,
/obj/item/contraband/poster,
/obj/item/poster,
/obj/item/stack/package_wrap/fifty = 2,
/obj/item/stack/package_wrap/gift/fifty = 2
)
Expand Down
8 changes: 0 additions & 8 deletions code/game/objects/effects/decals/contraband.dm

This file was deleted.

18 changes: 11 additions & 7 deletions code/game/objects/effects/decals/posters/_poster.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

///A wall mounted poster
/obj/structure/sign/poster
icon = 'icons/obj/contraband.dmi'
icon = 'icons/obj/items/posters.dmi'
icon_state = "poster0"
anchored = TRUE
directional_offset = "{'NORTH':{'y':32}, 'SOUTH':{'y':-32}, 'EAST':{'x':32}, 'WEST':{'x':-32}}"
material = /decl/material/solid/paper
maxhealth = 10
parts_type = /obj/item/contraband/poster
parts_type = /obj/item/poster
parts_amount = 1

///Whether the poster is too damaged to take off from the wall or not.
Expand Down Expand Up @@ -89,6 +89,7 @@
else
desc = "[base_desc] [poster_design.desc]"
SetName("[base_name] - [poster_design.name]")
icon = poster_design.icon
set_icon_state(poster_design.icon_state)
update_icon()

Expand Down Expand Up @@ -121,23 +122,26 @@
//////////////////////////////////////////////////////////////////////////////////

///A rolled up version of the wall-mounted poster structure
/obj/item/contraband/poster
/obj/item/poster
name = "rolled-up poster"
desc = "The poster comes with its own automatic adhesive mechanism, for easy pinning to any vertical surface."
icon = 'icons/obj/items/posters.dmi'
icon_state = "rolled_poster"
force = 0
material = /decl/material/solid/paper
///The name of the medium, excluding any reference to the design
var/base_name = "rolled-up poster"
///The description for the item/medium without any reference to the design.
var/base_desc = "The poster comes with its own automatic adhesive mechanism, for easy pinning to any vertical surface."
///Type path to the /decl for the design on this poster. At runtime is changed for a reference to the decl
var/decl/poster_design/poster_design

/obj/item/contraband/poster/Initialize(ml, material_key, var/given_poster_type = null)
/obj/item/poster/Initialize(ml, material_key, var/given_poster_type = null)
//Init design
set_design(given_poster_type || poster_design || pick(decls_repository.get_decl_paths_of_subtype(/decl/poster_design)))
return ..(ml, material_key)

/obj/item/contraband/poster/proc/set_design(var/decl/poster_design/_design_path)
/obj/item/poster/proc/set_design(var/decl/poster_design/_design_path)
if(_design_path == poster_design)
return TRUE
if(ispath(_design_path, /decl))
Expand All @@ -150,7 +154,7 @@
SetName("[base_name] - [poster_design.name] - [poster_design.serial_number]")

//Places the poster on a wall
/obj/item/contraband/poster/afterattack(var/atom/A, var/mob/user, var/adjacent, var/clickparams)
/obj/item/poster/afterattack(var/atom/A, var/mob/user, var/adjacent, var/clickparams)
if (!adjacent)
return

Expand Down Expand Up @@ -185,7 +189,7 @@
// We cannot rely on user being on the appropriate turf when placement fails
P.dismantle()

/obj/item/contraband/poster/proc/ArePostersOnWall(var/turf/W, var/placed_poster)
/obj/item/poster/proc/ArePostersOnWall(var/turf/W, var/placed_poster)
//just check if there is a poster on or adjacent to the wall
if (locate(/obj/structure/sign/poster) in W)
return TRUE
Expand Down
14 changes: 13 additions & 1 deletion code/game/objects/effects/decals/posters/_poster_design.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

///Contains information on what a poster displays.
/decl/poster_design
abstract_type = /decl/poster_design
///The display name/title of the design. Suffixed to the name of the medium displaying the design.
var/name
///The description of the design shown to users. This is suffixed to the description of the medium displaying this design.
var/desc
///Collectible serial number string, if any.
var/serial_number
///The icon state to use for this design. The display medium will use this to pick it's icon.
///The icon to use for this design.
var/icon = 'icons/obj/items/posters.dmi'
///The icon state to use for this design. The display medium will use this to pick it's icon state.
var/icon_state

/decl/poster_design/Initialize()
Expand All @@ -21,3 +24,12 @@
if(length(serial_number))
return
serial_number = "serial #[sequential_id(/decl/poster_design)]"

/decl/poster_design/validate()
. = ..()
if(!icon_state)
. += "no icon_state set"
if(!icon)
. += "no icon set"
if(icon && icon_state && !check_state_in_icon(icon_state, icon))
. += "icon state [icon_state] not present in [icon]"
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/gift_wrappaper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
/obj/random/lipstick,
/obj/item/grenade/smokebomb,
/obj/item/corncob,
/obj/item/contraband/poster,
/obj/item/poster,
/obj/item/book/manual/barman_recipes,
/obj/item/book/manual/chef_recipes,
/obj/item/bikehorn,
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/random/subtypes/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/obj/item/storage/pill_bottle/zoom = 2,
/obj/item/chems/glass/beaker/vial/random/toxin = 1,
/obj/item/chems/glass/beaker/sulphuric = 1,
/obj/item/contraband/poster = 5,
/obj/item/poster = 5,
/obj/item/butterflyblade = 3,
/obj/item/butterflyhandle = 3,
/obj/item/baton/cattleprod = 1,
Expand Down
33 changes: 14 additions & 19 deletions code/unit_tests/icon_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,6 @@
name = "ICON STATE template"
template = /datum/unit_test/icon_test

/datum/unit_test/icon_test/posters_shall_have_icon_states
name = "ICON STATE - Posters Shall Have Icon States"

/datum/unit_test/icon_test/posters_shall_have_icon_states/start_test()
var/contraband_icons = icon_states('icons/obj/contraband.dmi')
var/list/invalid_posters = list()

var/list/all_posters = decls_repository.get_decls_of_subtype(/decl/poster_design)
for(var/poster_design in all_posters)
var/decl/poster_design/P = all_posters[poster_design]
if(!(P.icon_state in contraband_icons))
invalid_posters += poster_design

if(invalid_posters.len)
fail("/decl/poster_design with missing icon states: [english_list(invalid_posters)]")
else
pass("All /decl/poster_design subtypes have valid icon states.")
return 1

/datum/unit_test/icon_test/item_modifiers_shall_have_icon_states
name = "ICON STATE - Item Modifiers Shall Have Icon Sates"
var/list/icon_states_by_type
Expand Down Expand Up @@ -51,13 +32,27 @@

/datum/unit_test/icon_test/signs_shall_have_existing_icon_states
name = "ICON STATE - Signs shall have existing icon states"
var/list/skip_types = list(
// Posters use a decl to set their icon and handle their own validation.
/obj/structure/sign/poster
)

/datum/unit_test/icon_test/signs_shall_have_existing_icon_states/start_test()
var/list/failures = list()
for(var/sign_type in typesof(/obj/structure/sign))

var/obj/structure/sign/sign = sign_type
if(TYPE_IS_ABSTRACT(sign))
continue

var/skip = FALSE
for(var/skip_type in skip_types)
if(ispath(sign_type, skip_type))
skip = TRUE
break
if(skip)
continue

var/check_state = initial(sign.icon_state)
if(!check_state)
failures += "[sign] - null icon_state"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion maps/away/bearcat/bearcat-1.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@
},
/obj/structure/closet/coffin,
/obj/random/drinkbottle,
/obj/item/contraband/poster,
/obj/item/poster,
/turf/simulated/floor/tiled/usedup,
/area/ship/scrap/cargo/lower)
"bJ" = (
Expand Down
12 changes: 6 additions & 6 deletions maps/away/liberia/liberia.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -738,12 +738,12 @@
req_access = newlist()
},
/obj/item/storage/secure/briefcase,
/obj/item/contraband/poster,
/obj/item/contraband/poster,
/obj/item/contraband/poster,
/obj/item/contraband/poster,
/obj/item/contraband/poster,
/obj/item/contraband/poster,
/obj/item/poster,
/obj/item/poster,
/obj/item/poster,
/obj/item/poster,
/obj/item/poster,
/obj/item/poster,
/obj/item/knife/folding/combat/balisong,
/obj/item/knife/folding/combat/balisong,
/turf/simulated/floor/tiled/steel_grid,
Expand Down
2 changes: 1 addition & 1 deletion maps/away/slavers/slavers_base.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -2323,7 +2323,7 @@
icon_state = "1-2"
},
/obj/item/stock_parts/circuitboard/broken,
/obj/item/contraband/poster,
/obj/item/poster,
/obj/item/radio/shortwave,
/obj/machinery/light/small{
dir = 4
Expand Down
2 changes: 1 addition & 1 deletion maps/away/unishi/unishi-3.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@
/area/unishi/living)
"eb" = (
/obj/structure/table/woodentable,
/obj/item/contraband/poster,
/obj/item/poster,
/obj/item/haircomb/random,
/obj/random/advdevice,
/turf/simulated/floor/tiled,
Expand Down
2 changes: 1 addition & 1 deletion maps/tradeship/tradeship-1.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@
/obj/structure/railing/mapped,
/obj/structure/closet/coffin,
/obj/random/drinkbottle,
/obj/item/contraband/poster,
/obj/item/poster,
/turf/simulated/floor/tiled/monotile,
/area/ship/trade/cargo/lower)
"it" = (
Expand Down
6 changes: 3 additions & 3 deletions mods/content/corporate/away_sites/lar_maria/lar_maria-1.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
/area/lar_maria/cells)
"aV" = (
/obj/structure/bed/padded,
/obj/item/contraband/poster,
/obj/item/poster,
/turf/simulated/floor/tiled,
/area/lar_maria/cells)
"aW" = (
Expand Down Expand Up @@ -2529,7 +2529,7 @@
/area/lar_maria/cells)
"gC" = (
/obj/structure/closet/crate,
/obj/item/contraband/poster,
/obj/item/poster,
/obj/item/inflatable_duck,
/turf/simulated/floor/plating,
/area/lar_maria/cells)
Expand Down Expand Up @@ -3058,7 +3058,7 @@
/area/lar_maria/cells)
"hW" = (
/obj/structure/table/steel_reinforced,
/obj/item/contraband/poster,
/obj/item/poster,
/turf/simulated/floor/plating,
/area/lar_maria/cells)
"hX" = (
Expand Down
Binary file added mods/valsalia/icons/posters.dmi
Binary file not shown.
1 change: 0 additions & 1 deletion nebula.dme
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,6 @@
#include "code\game\objects\effects\chem\foam.dm"
#include "code\game\objects\effects\chem\water.dm"
#include "code\game\objects\effects\decals\cleanable.dm"
#include "code\game\objects\effects\decals\contraband.dm"
#include "code\game\objects\effects\decals\crayon.dm"
#include "code\game\objects\effects\decals\decal.dm"
#include "code\game\objects\effects\decals\misc.dm"
Expand Down