///All currently running polls held as datums GLOBAL_LIST_EMPTY(polls) GLOBAL_PROTECT(polls) ///All poll option datums of running polls GLOBAL_LIST_EMPTY(poll_options) GLOBAL_PROTECT(poll_options) /** * Shows a list of currently running polls a player can vote/has voted on * */ /mob/dead/new_player/proc/handle_player_polling() var/list/output = list("
Player polls
") var/rs = REF(src) for(var/p in GLOB.polls) var/datum/poll_question/poll = p if((poll.admin_only && !client.holder) || poll.future_poll) continue output += "" output += "
[poll.question]
" src << browse(jointext(output, ""),"window=playerpolllist;size=500x300") /** * Redirects a player to the correct poll window based on poll type. * */ /mob/dead/new_player/proc/poll_player(datum/poll_question/poll) if(!poll) return if(!SSdbcore.Connect()) to_chat(src, span_danger("Failed to establish database connection.")) return switch(poll.poll_type) if(POLLTYPE_OPTION) poll_player_option(poll) if(POLLTYPE_TEXT) poll_player_text(poll) if(POLLTYPE_RATING) poll_player_rating(poll) if(POLLTYPE_MULTI) poll_player_multi(poll) if(POLLTYPE_IRV) poll_player_irv(poll) /** * Shows voting window for an option type poll, listing its options and relevant details. * * If already voted on, the option a player voted for is pre-selected. * */ /mob/dead/new_player/proc/poll_player_option(datum/poll_question/poll) var/datum/db_query/query_option_get_voted = SSdbcore.NewQuery({" SELECT optionid FROM [format_table_name("poll_vote")] WHERE pollid = :pollid AND ckey = :ckey AND deleted = 0 "}, list("pollid" = poll.poll_id, "ckey" = ckey)) if(!query_option_get_voted.warn_execute()) qdel(query_option_get_voted) return var/voted_option_id = 0 if(query_option_get_voted.NextRow()) voted_option_id = text2num(query_option_get_voted.item[1]) qdel(query_option_get_voted) var/list/output = list("
Player poll
Question: [poll.question]
") if(poll.subtitle) output += "[poll.subtitle]
" output += "Poll runs from [poll.start_datetime] until [poll.end_datetime]
" if(poll.allow_revoting) output += "Revoting is enabled." if(!voted_option_id || poll.allow_revoting) output += {"
"} output += "
" for(var/o in poll.options) var/datum/poll_option/option = o output += "