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

[TM] Make credits toggleable #1431

Merged
merged 10 commits into from
Aug 23, 2024
4 changes: 4 additions & 0 deletions SQL/paradise_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -681,3 +681,7 @@ CREATE TABLE `admin_wl` (
KEY `ckey` (`ckey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

# Updating DB from 59.220.6 to 59.220.7
# Adds SS220 toggle prefs ~Maxiemar

ALTER TABLE `player` ADD `toggles_220` int(11) DEFAULT NULL;
4 changes: 4 additions & 0 deletions SQL/updates220/59.220.6-59.220.7.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Updating DB from 59.220.6 to 59.220.7
# Adds SS220 toggle prefs ~Maxiemar

ALTER TABLE `player` ADD `toggles_220` int(11) DEFAULT NULL;
9 changes: 9 additions & 0 deletions code/__DEFINES/_ss220.dm
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
#define MODPACK_CHAT_BADGES

/// Interacts with the toggles220 bitflag
#define PREFTOGGLE_TOGGLE220 220

#define PREFTOGGLE_220_WATCH_CREDITS (1<<0) // 1

#define TOGGLES_220_TOTAL 1 // If you add or remove a preference toggle above, make sure you update this define with the total value of the toggles combined.

#define TOGGLES_220_DEFAULT (PREFTOGGLE_220_WATCH_CREDITS)
2 changes: 1 addition & 1 deletion code/__DEFINES/misc_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
#define INVESTIGATE_HOTMIC "hotmic"

// The SQL version required by this version of the code
#define SQL_VERSION 592206
#define SQL_VERSION 592207

// Vending machine stuff
#define CAT_NORMAL (1<<0)
Expand Down
3 changes: 2 additions & 1 deletion code/modules/client/login_processing/10-load_preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
keybindings,
server_region,
muted_adminsounds_ckeys,
viewrange
viewrange,
toggles_220
FROM player
WHERE ckey=:ckey"}, list(
"ckey" = C.ckey
Expand Down
5 changes: 5 additions & 0 deletions code/modules/client/preference/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/UI_style = "Midnight"
var/toggles = TOGGLES_DEFAULT
var/toggles2 = TOGGLES_2_DEFAULT // Created because 1 column has a bitflag limit of 24 (BYOND limitation not MySQL)
var/toggles220 = TOGGLES_220_DEFAULT // SS220 ADDITION
m-dzianishchyts marked this conversation as resolved.
Show resolved Hide resolved
var/sound = SOUND_DEFAULT
var/light = LIGHT_DEFAULT
/// Glow level for the lighting. Takes values from GLOW_HIGH to GLOW_DISABLE.
Expand Down Expand Up @@ -658,6 +659,10 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
dat += "<td style='width: 20%'><a href='byond://?_src_=prefs;preference=preference_toggles;toggle=[toggle.UID()];'>[(toggles & toggle.preftoggle_bitflag) ? "<span class='good'>Enabled</span>" : "<span class='bad'>Disabled</span>"]</a></td>"
if(PREFTOGGLE_TOGGLE2)
dat += "<td style='width: 20%'><a href='byond://?_src_=prefs;preference=preference_toggles;toggle=[toggle.UID()];'>[(toggles2 & toggle.preftoggle_bitflag) ? "<span class='good'>Enabled</span>" : "<span class='bad'>Disabled</span>"]</a></td>"
// SS220 ADDITION - START
if(PREFTOGGLE_TOGGLE220)
dat += "<td style='width: 20%'><a href='byond://?_src_=prefs;preference=preference_toggles;toggle=[toggle.UID()];'>[(toggles220 & toggle.preftoggle_bitflag) ? "<span class='good'>Enabled</span>" : "<span class='bad'>Disabled</span>"]</a></td>"
// SS220 ADDITION - END
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо будет придумать что-то дабы не влезать в кор ради префов

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь поражение, остается слезно молить о тотальном рефакторе в рамках перехода на тгуи

if(PREFTOGGLE_SOUND)
dat += "<td style='width: 20%'><a href='byond://?_src_=prefs;preference=preference_toggles;toggle=[toggle.UID()];'>[(sound & toggle.preftoggle_bitflag) ? "<span class='good'>Enabled</span>" : "<span class='bad'>Disabled</span>"]</a></td>"
if(PREFTOGGLE_LIGHT)
Expand Down
8 changes: 6 additions & 2 deletions code/modules/client/preference/preferences_mysql.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
server_region = query.item[25]
raw_muted_admins = query.item[26]
viewrange = query.item[27]
toggles220 = text2num(query.item[28]) // SS220 ADDITTION

lastchangelog_2 = lastchangelog // Clone please

Expand All @@ -41,6 +42,7 @@
default_slot = sanitize_integer(default_slot, 1, max_save_slots, initial(default_slot))
toggles = sanitize_integer(toggles, 0, TOGGLES_TOTAL, initial(toggles))
toggles2 = sanitize_integer(toggles2, 0, TOGGLES_2_TOTAL, initial(toggles2))
toggles220 = sanitize_integer(toggles220, 0, TOGGLES_220_TOTAL, initial(toggles220))
sound = sanitize_integer(sound, 0, 65535, initial(sound))
UI_style_color = sanitize_hexcolor(UI_style_color, initial(UI_style_color))
UI_style_alpha = sanitize_integer(UI_style_alpha, 0, 255, initial(UI_style_alpha))
Expand Down Expand Up @@ -104,7 +106,8 @@
keybindings=:keybindings,
server_region=:server_region,
muted_adminsounds_ckeys=:muted_adminsounds_ckeys,
viewrange=:viewrange
viewrange=:viewrange,
toggles_220=:toggles220
WHERE ckey=:ckey"}, list(
// OH GOD THE PARAMETERS
"ooccolour" = ooccolor,
Expand Down Expand Up @@ -133,7 +136,8 @@
"ckey" = C.ckey,
"server_region" = server_region,
"muted_adminsounds_ckeys" = json_encode(admin_sound_ckey_ignore),
"viewrange" = viewrange
"viewrange" = viewrange,
"toggles220" = num2text(toggles220, CEILING(log(10, (TOGGLES_220_TOTAL)), 1)) // SS220 ADDITION
))

if(!query.warn_execute())
Expand Down
5 changes: 5 additions & 0 deletions code/modules/client/preference/preferences_toggles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
if(PREFTOGGLE_TOGGLE2)
our_prefs.toggles2 ^= preftoggle_bitflag
to_chat(user, "<span class='notice'>[(our_prefs.toggles2 & preftoggle_bitflag) ? enable_message : disable_message]</span>")
// SS220 ADDITION - START
if(PREFTOGGLE_TOGGLE220)
our_prefs.toggles220 ^= preftoggle_bitflag
to_chat(user, "<span class='notice'>[(our_prefs.toggles220 & preftoggle_bitflag) ? enable_message : disable_message]</span>")
// SS220 ADDITION - END
if(PREFTOGGLE_SOUND)
our_prefs.sound ^= preftoggle_bitflag
to_chat(user, "<span class='notice'>[(our_prefs.sound & preftoggle_bitflag) ? enable_message : disable_message]</span>")
Expand Down
2 changes: 1 addition & 1 deletion config/example/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ ipc_screens = [
# Enable/disable the database on a whole
sql_enabled = false
# SQL version. If this is a mismatch, round start will be delayed
sql_version = 592206
sql_version = 592207
# SQL server address. Can be an IP or DNS name
sql_address = "127.0.0.1"
# SQL server port
Expand Down
4 changes: 4 additions & 0 deletions modular_ss220/cinematics/code/_cinematics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
if(!watching_client || (watching_client in watching))
return

// Do not show credits if it's disabled for the client and not forced.
if(istype(src, /datum/cinematic/credits) && !GLOB.credits_forced && !(watching_client.prefs.toggles220 & PREFTOGGLE_220_WATCH_CREDITS))
return

watching += watching_client
watching_mob.overlay_fullscreen("cinematic", backdrop_type)
watching_client.screen += screen
Expand Down
10 changes: 10 additions & 0 deletions modular_ss220/credits/_credits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@
name = "Credits"
desc = "Добавление титров в конце раунда, основа кода была взята из данного репозитория https://github.com/Baystation12/Baystation12"
author = "Legendaxe"

/datum/modpack/credits/initialize()
GLOB.admin_verbs_admin += list(
/client/proc/toggle_credits
)
// Update verbs for admins who connected before subsystem initialization.
for(var/client/player in GLOB.clients)
if(!player.holder)
continue
player.add_admin_verbs()

Check failure on line 14 in modular_ss220/credits/_credits.dm

View workflow job for this annotation

GitHub Actions / Run Linters

Check Grep

modular_ss220/credits/_credits.dm:14: Missing a trailing newline
2 changes: 2 additions & 0 deletions modular_ss220/credits/_credits.dme
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "code\SScredits.dm"
#include "code\credits.dm"
#include "code\admin_procs.dm"
#include "code\preferences.dm"
#include "code\halloween_credits.dm"
#include "code\new_year_credits.dm"
#include "code\aprils_fool_credits.dm"
Expand Down
20 changes: 20 additions & 0 deletions modular_ss220/credits/code/admin_procs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Force everyone to watch credits?
GLOBAL_VAR_INIT(credits_forced, FALSE)

/client/proc/toggle_credits()
set category = "Server"
set desc = "Просмотр титров по окончании раунда"
set name = "Toggle Credits"

if(!check_rights(R_ADMIN))
return

GLOB.credits_forced = !GLOB.credits_forced
if(GLOB.credits_forced)
to_chat(world, "<B>Все будут смотреть титры по окончании раунда.</B>")
message_admins("[key_name_admin(usr)] устанавливает принудительные титры.", 1)
else
to_chat(world, "<B>Игроки будут смотреть титры в зависимости от своих настроек.</B>")
message_admins("[key_name_admin(usr)] устанавливает титры по умолчанию.", 1)
log_admin("[key_name(usr)] toggled credits.")
SSblackbox.record_feedback("tally", "admin_verb", 1, "Toggle Credits")

Check failure on line 20 in modular_ss220/credits/code/admin_procs.dm

View workflow job for this annotation

GitHub Actions / Run Linters

Check Grep

modular_ss220/credits/code/admin_procs.dm:20: Missing a trailing newline
9 changes: 9 additions & 0 deletions modular_ss220/credits/code/preferences.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/datum/preference_toggle/toggle_credits
name = "Показывать титры"
description = "Показывать титры по окончании раунда"
preftoggle_bitflag = PREFTOGGLE_220_WATCH_CREDITS
preftoggle_toggle = PREFTOGGLE_TOGGLE220
preftoggle_category = PREFTOGGLE_CATEGORY_LIVING
enable_message = "Вы будете видеть титры в конце раундов."
disable_message = "Вы не будете видеть титры в конце раундов."
blackbox_message = "Toggle Credits"

Check failure on line 9 in modular_ss220/credits/code/preferences.dm

View workflow job for this annotation

GitHub Actions / Run Linters

Check Grep

modular_ss220/credits/code/preferences.dm:9: Missing a trailing newline
Loading