diff --git a/baystation12.dme b/baystation12.dme index c79c80a5664..c74aec4f2c2 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -80,6 +80,7 @@ #define FILE_DIR "code/game/objects/stacks" #define FILE_DIR "code/game/objects/storage" #define FILE_DIR "code/game/objects/tanks" +#define FILE_DIR "code/game/player" #define FILE_DIR "code/game/verbs" #define FILE_DIR "code/js" #define FILE_DIR "code/modules" @@ -518,7 +519,7 @@ #include "code\game\machinery\computer\id.dm" #include "code\game\machinery\computer\lockdown.dm" #include "code\game\machinery\computer\medical.dm" -#include "code\game\machinery\computer\operating.dm" +#include "code\game\machinery\computer\Operating.dm" #include "code\game\machinery\computer\power.dm" #include "code\game\machinery\computer\robot.dm" #include "code\game\machinery\computer\security.dm" @@ -725,6 +726,7 @@ #include "code\game\objects\tanks\emergency.dm" #include "code\game\objects\tanks\jetpack.dm" #include "code\game\objects\tanks\oxygen.dm" +#include "code\game\player\news.dm" #include "code\game\verbs\AI_status.dm" #include "code\game\verbs\checkkarma.dm" #include "code\game\verbs\ooc.dm" diff --git a/code/game/player/desc.txt.txt b/code/game/player/desc.txt.txt new file mode 100644 index 00000000000..39552c123ff --- /dev/null +++ b/code/game/player/desc.txt.txt @@ -0,0 +1,2 @@ +directory: player +content: Anything relating to out-of-character, player related features, including saves, announcements and so on. \ No newline at end of file diff --git a/code/game/player/news.dm b/code/game/player/news.dm new file mode 100644 index 00000000000..b4c5cdd26e9 --- /dev/null +++ b/code/game/player/news.dm @@ -0,0 +1,172 @@ +// a single news datum +datum/news/var + ID // the ID of the news + title // the title of the news + body // a body with an exact explanation + author // key of the author + date // date on which this was created + +datum/news_topic_handler + Topic(href,href_list) + var/client/C = locate(href_list["client"]) + if(href_list["action"] == "show_all_news") + C.display_all_news_list() + else if(href_list["action"] == "show_news") + C.display_news_list() + else if(href_list["action"] == "add_news") + C.add_news() + +var/datum/news_topic_handler/news_topic_handler + +world/New() + ..() + news_topic_handler = new + +proc/savefile_path(mob/user) + return "data/player_saves/[copytext(user.ckey, 1, 2)]/[user.ckey]/preferences.sav" + +// add a new news datums +proc/make_news(title, body, author) + var/savefile/News = new("data/news.sav") + var/list/news + var/lastID + + News["news"] >> news + News["lastID"] >> lastID + + if(!news) news = list() + if(!lastID) lastID = 0 + + var/datum/news/created = new() + created.ID = ++lastID + created.title = title + created.body = body + created.author = author + created.date = world.realtime + + news.Insert(1, created) + + News["news"] << news + News["lastID"] << lastID + +// load the news from disk +proc/load_news() + var/savefile/News = new("data/news.sav") + var/list/news + + News["news"] >> news + + if(!news) news = list() + + return news + +// save the news to disk +proc/save_news(var/list/news) + var/savefile/News = new("data/news.sav") + News << news + +// check if there are any news in the player's "inbox" +client/proc/has_news() + var/list/news = load_news() + + // load the list of news already read by this player + var/path = savefile_path(src.mob) + if(!fexists(path)) + return + + var/savefile/F = new(path) + var/list/read_news = list() + F["read_news"] >> read_news + + for(var/datum/news/N in news) + if(N.ID in read_news) + continue + else return 1 + + return 0 + +// display only the news that haven't been read yet +client/proc/display_news_list() + var/list/news = load_news() + + var/output = "" + if(has_news()) + // load the list of news already read by this player + var/path = savefile_path(src.mob) + if(!fexists(path)) + return + + var/savefile/F = new(path) + var/list/read_news + F["read_news"] >> read_news + if(!read_news) read_news = list() + + for(var/datum/news/N in news) + if(N.ID in read_news) + continue + read_news += N.ID + output += "[N.title]
" + output += "[N.body]
" + output += "authored by [N.author]
" + output += "
" + + F["read_news"] << read_news + else + output += "Nothing new!

" + + output += "Display All
" + if(src.holder && istype(src.holder, /obj/admins)) + output += "Add Guidelines
" + + usr << browse(output, "window=news;size=600x400") + + +// display all news, even the ones read already +client/proc/display_all_news_list() + var/list/news = load_news() + + // load the list of news already read by this player + var/path = savefile_path(src.mob) + if(!fexists(path)) + return + + var/savefile/F = new(path) + var/list/read_news + F["read_news"] >> read_news + if(!read_news) read_news = list() + + var/output = "" + for(var/datum/news/N in news) + if(!(N.ID in read_news)) + read_news += N.ID + var/date = time2text(N.date,"MM/DD") + output += "[date] [N.title]
" + output += "[N.body]
" + output += "authored by [N.author]
" + output += "
" + F["read_news"] << read_news + if(src.holder && istype(src.holder, /obj/admins)) + output += "Add Guidelines
" + usr << browse(output, "window=news;size=600x400") + + +client/proc/add_news() + if(!istype(src.holder, /obj/admins)) + src << "You tried to modify the news, but you're not an admin!" + return + + var/title = input(src.mob, "Select a title for the news", "Title") as null|text + if(!title) return + + var/body = input(src.mob, "Enter a body for the news", "Body") as null|message + if(!body) return + + make_news(title, body, key) + + display_all_news_list() + +client/verb/read_news() + set name = "Read News" + set category = "OOC" + set desc = "Read important news and updates" + display_all_news_list() \ No newline at end of file diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 83694262cca..9e9d52bc227 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -48,6 +48,9 @@ if(preferences.pregame_music) spawn() Playmusic() // git some tunes up in heeyaa~ + if(client.has_news()) + src << "There are some unread news for you! Please make sure to read all news, as they may contain important updates about roleplay rules or canon." + new_player_panel() //PDA Resource Initialisation =======================================================> /*