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

small poster rewrite #6884

Merged
merged 16 commits into from
Nov 27, 2024
18 changes: 12 additions & 6 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
#include "code\__DEFINES\misc\attack_animations.dm"
#include "code\__DEFINES\misc\message_ranges.dm"
#include "code\__DEFINES\misc\nightshift.dm"
#include "code\__DEFINES\misc\posters.dm"
#include "code\__DEFINES\mobs\actions.dm"
#include "code\__DEFINES\mobs\biology.dm"
#include "code\__DEFINES\mobs\characteristics.dm"
Expand Down Expand Up @@ -545,6 +546,7 @@
#include "code\controllers\repository\languages.dm"
#include "code\controllers\repository\material_traits.dm"
#include "code\controllers\repository\materials.dm"
#include "code\controllers\repository\poster_designs.dm"
#include "code\controllers\repository\structs.dm"
#include "code\controllers\subsystem\ai_holders.dm"
#include "code\controllers\subsystem\ai_legacy.dm"
Expand Down Expand Up @@ -1561,9 +1563,6 @@
#include "code\game\objects\effects\decals\misc.dm"
#include "code\game\objects\effects\decals\remains.dm"
#include "code\game\objects\effects\decals\warning_stripes.dm"
#include "code\game\objects\effects\decals\posters\bs12.dm"
#include "code\game\objects\effects\decals\posters\citadel.dm"
#include "code\game\objects\effects\decals\posters\polarisposters.dm"
#include "code\game\objects\effects\map_effects\beam_point.dm"
#include "code\game\objects\effects\map_effects\effect_emitter.dm"
#include "code\game\objects\effects\map_effects\map_effects.dm"
Expand Down Expand Up @@ -1925,7 +1924,6 @@
#include "code\game\objects\structures\morgue.dm"
#include "code\game\objects\structures\noticeboard.dm"
#include "code\game\objects\structures\plasticflaps.dm"
#include "code\game\objects\structures\poster.dm"
#include "code\game\objects\structures\railing.dm"
#include "code\game\objects\structures\safe.dm"
#include "code\game\objects\structures\salvageable.dm"
Expand Down Expand Up @@ -2289,12 +2287,21 @@
#include "code\modules\alarm\fire_alarm.dm"
#include "code\modules\alarm\motion_alarm.dm"
#include "code\modules\alarm\power_alarm.dm"
#include "code\modules\artwork\crayon.dm"
#include "code\modules\artwork\crayon_decal_meta.dm"
#include "code\modules\artwork\poster_design.dm"
#include "code\modules\artwork\debris\crayon.dm"
#include "code\modules\artwork\items\chalk.dm"
#include "code\modules\artwork\items\crayon.dm"
#include "code\modules\artwork\items\marker.dm"
#include "code\modules\artwork\items\poster.dm"
#include "code\modules\artwork\items\spraycan.dm"
#include "code\modules\artwork\poster_designs\baystation.dm"
#include "code\modules\artwork\poster_designs\citadel.dm"
#include "code\modules\artwork\poster_designs\nanotrasen.dm"
#include "code\modules\artwork\poster_designs\polaris.dm"
#include "code\modules\artwork\poster_designs\tgstation.dm"
#include "code\modules\artwork\structures\poster.dm"
#include "code\modules\artwork\structures\sculpting_block.dm"
#include "code\modules\assembly\assembly.dm"
#include "code\modules\assembly\helpers.dm"
#include "code\modules\assembly\holder.dm"
Expand Down Expand Up @@ -4773,7 +4780,6 @@
#include "code\modules\rogueminer_vr\zone_console.dm"
#include "code\modules\rogueminer_vr\zonemaster.dm"
#include "code\modules\roles\role.dm"
#include "code\modules\sculpting\sculpting_block.dm"
#include "code\modules\security levels\keycard authentication.dm"
#include "code\modules\security levels\security levels.dm"
#include "code\modules\shieldgen\emergency_shield.dm"
Expand Down
23 changes: 23 additions & 0 deletions code/__DEFINES/misc/posters.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

//* Helpers *//

#define DECLARE_POSTER_DESIGN(TYPEPATH) \
/obj/item/poster/preset##TYPEPATH { \
name = /obj/item/poster::name + " - " + /datum/prototype/poster_design##TYPEPATH::name; \
desc = /obj/item/poster::desc + " " + /datum/prototype/poster_design##TYPEPATH::desc; \
poster_design_id = /datum/prototype/poster_design##TYPEPATH; \
}; \
/obj/structure/poster/preset##TYPEPATH {; \
name = /datum/prototype/poster_design##TYPEPATH::name; \
desc = /obj/structure/poster::desc + " " + /datum/prototype/poster_design##TYPEPATH::desc; \
icon = /datum/prototype/poster_design##TYPEPATH::icon; \
icon_state = /datum/prototype/poster_design##TYPEPATH::icon_state; \
poster_design_id = /datum/prototype/poster_design##TYPEPATH; \
}; \
/datum/prototype/poster_design##TYPEPATH

//* Tags *//

#define POSTER_TAG_NANOTRASEN "nanotrasen"
16 changes: 0 additions & 16 deletions code/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ var/global/list/mechas_list = list()
/// Times that players are allowed to respawn ("ckey" = world.time)
GLOBAL_LIST_EMPTY(respawn_timers)

//* Posters
var/global/list/poster_designs = list()
var/global/list/NT_poster_designs = list()

//* Uplinks
var/list/obj/item/uplink/world_uplinks = list()

Expand Down Expand Up @@ -118,18 +114,6 @@ GLOBAL_LIST_EMPTY(mannequins)

var/list/paths

//Posters
paths = typesof(/datum/poster) - /datum/poster
paths -= typesof(/datum/poster/nanotrasen)
for(var/T in paths)
var/datum/poster/P = new T
poster_designs += P

paths = typesof(/datum/poster/nanotrasen)
for(var/T in paths)
var/datum/poster/P = new T
NT_poster_designs += P

// Custom species traits
paths = typesof(/datum/trait) - /datum/trait - /datum/trait/negative - /datum/trait/neutral - /datum/trait/positive
for(var/path in paths)
Expand Down
9 changes: 8 additions & 1 deletion code/controllers/repository.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
* lists returned should never, ever be modified.
* this fetches subtypes, not the first type on purpose.
*/
/datum/controller/repository/proc/fetch_subtypes(path)
/datum/controller/repository/proc/fetch_subtypes_immutable(path) as /list
RETURN_TYPE(/list)
ASSERT(ispath(path, /datum/prototype))
if(subtype_lists[path])
Expand All @@ -169,6 +169,13 @@
generating += instance
return generating

/**
* lists returned may be modified
*/
/datum/controller/repository/proc/fetch_subtypes_mutable(path) as /list
RETURN_TYPE(/list)
return fetch_subtypes_immutable(path).Copy()

/**
* Registers a prototype created midround.
*
Expand Down
39 changes: 39 additions & 0 deletions code/controllers/repository/poster_designs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

REPOSITORY_DEF(poster_designs)
name = "Repository - Poster Designs"
expected_type = /datum/prototype/poster_design

/// by tag
var/list/tag_lookup = list()

/datum/controller/repository/poster_designs/load(datum/prototype/poster_design/instance)
. = ..()
if(!.)
return
for(var/the_tag in instance.poster_tags)
LAZYADD(tag_lookup[the_tag], instance)

/datum/controller/repository/poster_designs/unload(datum/prototype/poster_design/instance)
. = ..()
if(!.)
return
for(var/the_tag in instance.poster_tags)
tag_lookup[the_tag] -= instance
if(!length(tag_lookup[the_tag]))
tag_lookup -= the_tag

/**
* @params
* * tags - POSTER_TAG_*, list of POSTER_TAG_*, or null for **fetch all**.
*/
/datum/controller/repository/poster_designs/proc/fetch_by_tag_mutable(tags)
if(islist(tags))
. = list()
for(var/the_tag in tags)
. |= tag_lookup[the_tag]
else if(tags)
. = tag_lookup[tags]?:Copy() || list()
else
. = fetch_subtypes_mutable(/datum/prototype/poster_design)
2 changes: 1 addition & 1 deletion code/controllers/subsystem/materials.dm
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ SUBSYSTEM_DEF(materials)
*/
/datum/controller/subsystem/materials/proc/all_materials()
RETURN_TYPE(/list)
return RSmaterials.fetch_subtypes(/datum/prototype/material):Copy()
return RSmaterials.fetch_subtypes_immutable(/datum/prototype/material):Copy()

/**
* drop a material sheet
Expand Down
2 changes: 1 addition & 1 deletion code/datums/prototype.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

/// Globally unique ID for usage with the repository this is stored in.
///
/// * IDs should be named like "kebab-case-abcd-1234".
/// * IDs should be named like "CamelCase" as per prototype standards in many ECS games.
/// * IDs should be globally unique across rounds.
/// * Hardcoded prototypes should always be referred to via type instead of ID where possible
/// * All persistent prototypes bear the burden of not colliding with hardcoded prototypes.
Expand Down
1 change: 1 addition & 0 deletions code/game/atoms/_atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/// Prototype ID; persistence uses this to know what atom to load, even if the path changes in a refactor.
///
/// * this is very much a 'set this on type and all subtypes or don't set it at all' situation.
/// * should be `FormattedLikeThis`.
var/prototype_id

//? Interaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
/obj/item/reagent_containers/glass/paint/purple,
/obj/item/reagent_containers/glass/paint/black,
/obj/item/reagent_containers/glass/paint/white,
/obj/item/contraband/poster,
/obj/item/poster,
/obj/item/wrapping_paper = 3,
)
worth = 350
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
/datum/supply_pack/nanotrasen/security/posters
name = "Gear - Morale Posters"
contains = list(
/obj/item/contraband/poster/nanotrasen = 6,
/obj/item/poster/nanotrasen = 6,
)
worth = 100 // YEAAAH NANOTRASEN PROPAGANDA WOO
container_type = /obj/structure/closet/crate/secure/corporate/nanotrasen
Expand Down
Loading
Loading