diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index fd82b52d1cc0..ed435e3be7f6 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -711,3 +711,31 @@ CREATE TABLE `budget` ( # Adds species whitelist ~legendaxe ALTER TABLE `player` ADD `species_whitelist` LONGTEXT COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ('["human"]'); + +# Updating DB from 59.220.6 to 59.220.7 +# Adds SS220 toggle prefs ~Maxiemar + +DROP TABLE IF EXISTS `player_220`; +CREATE TABLE `player_220` ( + `ckey` VARCHAR(32) NOT NULL COLLATE utf8mb4_unicode_ci, + `toggles` int(11) DEFAULT NULL, + PRIMARY KEY (`ckey`) USING BTREE +) COLLATE = utf8mb4_unicode_ci ENGINE = InnoDB; + +ALTER TABLE `player_220` +ADD CONSTRAINT `fk_player_220_ckey` +FOREIGN KEY (`ckey`) REFERENCES `player`(`ckey`) +ON DELETE CASCADE +ON UPDATE CASCADE; + +DROP TRIGGER IF EXISTS `player_insert`; +DELIMITER // +CREATE TRIGGER `player_insert` +AFTER INSERT ON `player` +FOR EACH ROW +BEGIN + INSERT INTO `player_220` (`ckey`) + VALUES (NEW.ckey); +END; +// +DELIMITER ; diff --git a/SQL/updates220/59.220.6-59.220.7.sql b/SQL/updates220/59.220.6-59.220.7.sql new file mode 100644 index 000000000000..12a4f9a529ec --- /dev/null +++ b/SQL/updates220/59.220.6-59.220.7.sql @@ -0,0 +1,31 @@ +# Updating DB from 59.220.6 to 59.220.7 +# Adds SS220 toggle prefs ~Maxiemar + +DROP TABLE IF EXISTS `player_220`; +CREATE TABLE `player_220` ( + `ckey` VARCHAR(32) NOT NULL COLLATE utf8mb4_unicode_ci, + `toggles` int(11) DEFAULT NULL, + PRIMARY KEY (`ckey`) USING BTREE +) COLLATE = utf8mb4_unicode_ci ENGINE = InnoDB; + +ALTER TABLE `player_220` +ADD CONSTRAINT `fk_player_220_ckey` +FOREIGN KEY (`ckey`) REFERENCES `player`(`ckey`) +ON DELETE CASCADE +ON UPDATE CASCADE; + +DROP TRIGGER IF EXISTS `player_insert`; +DELIMITER // +CREATE TRIGGER `player_insert` +AFTER INSERT ON `player` +FOR EACH ROW +BEGIN + INSERT INTO `player_220` (`ckey`) + VALUES (NEW.ckey); +END; +// +DELIMITER ; + +INSERT INTO `player_220` (`ckey`) +SELECT `ckey` +FROM `player`; diff --git a/code/__DEFINES/_ss220.dm b/code/__DEFINES/_ss220.dm index 203e016a313f..0cf3257d7da9 100644 --- a/code/__DEFINES/_ss220.dm +++ b/code/__DEFINES/_ss220.dm @@ -1 +1,5 @@ #define MODPACK_CHAT_BADGES + +// TODO: someday preferences will use TGUI and you will probably be able to move it to modular_ss220\_defines220\code\preferences_defines.dm +/// Interacts with the toggles220 bitflag +#define PREFTOGGLE_TOGGLE220 220 diff --git a/code/__DEFINES/misc_defines.dm b/code/__DEFINES/misc_defines.dm index 12c0b6362d41..1fb1b2e1dc6b 100644 --- a/code/__DEFINES/misc_defines.dm +++ b/code/__DEFINES/misc_defines.dm @@ -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) diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index dfc1daf5746f..44b17907e2a5 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -658,6 +658,10 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts dat += "[(toggles & toggle.preftoggle_bitflag) ? "Enabled" : "Disabled"]" if(PREFTOGGLE_TOGGLE2) dat += "[(toggles2 & toggle.preftoggle_bitflag) ? "Enabled" : "Disabled"]" + // SS220 ADDITION - START + if(PREFTOGGLE_TOGGLE220) + dat += "[(toggles220 & toggle.preftoggle_bitflag) ? "Enabled" : "Disabled"]" + // SS220 ADDITION - END if(PREFTOGGLE_SOUND) dat += "[(sound & toggle.preftoggle_bitflag) ? "Enabled" : "Disabled"]" if(PREFTOGGLE_LIGHT) diff --git a/config/example/config.toml b/config/example/config.toml index 7956ba0c4353..51de589eaafd 100644 --- a/config/example/config.toml +++ b/config/example/config.toml @@ -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 diff --git a/modular_ss220/_defines220/_defines220.dme b/modular_ss220/_defines220/_defines220.dme index 3c297f31f9fb..777827a0cb81 100644 --- a/modular_ss220/_defines220/_defines220.dme +++ b/modular_ss220/_defines220/_defines220.dme @@ -19,3 +19,4 @@ #include "code/emote.dm" #include "code/lists_TG.dm" #include "code/species.dm" +#include "code/preferences_defines.dm" diff --git a/modular_ss220/_defines220/code/preferences_defines.dm b/modular_ss220/_defines220/code/preferences_defines.dm new file mode 100644 index 000000000000..fef827769a2b --- /dev/null +++ b/modular_ss220/_defines220/code/preferences_defines.dm @@ -0,0 +1,5 @@ +#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) diff --git a/modular_ss220/cinematics/code/_cinematics.dm b/modular_ss220/cinematics/code/_cinematics.dm index 1a1e11ad558b..c2c3fc4f74dc 100644 --- a/modular_ss220/cinematics/code/_cinematics.dm +++ b/modular_ss220/cinematics/code/_cinematics.dm @@ -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 diff --git a/modular_ss220/credits/_credits.dm b/modular_ss220/credits/_credits.dm index 429b361afbf2..ddace1d105dc 100644 --- a/modular_ss220/credits/_credits.dm +++ b/modular_ss220/credits/_credits.dm @@ -2,3 +2,8 @@ name = "Credits" desc = "Добавление титров в конце раунда, основа кода была взята из данного репозитория https://github.com/Baystation12/Baystation12" author = "Legendaxe" + +/datum/modpack/credits/initialize() + GLOB.admin_verbs_admin += list( + /client/proc/toggle_credits + ) diff --git a/modular_ss220/credits/_credits.dme b/modular_ss220/credits/_credits.dme index 4a58d90cf3c9..7d1b97946084 100644 --- a/modular_ss220/credits/_credits.dme +++ b/modular_ss220/credits/_credits.dme @@ -1,5 +1,6 @@ #include "code\SScredits.dm" #include "code\credits.dm" +#include "code\admin_procs.dm" #include "code\halloween_credits.dm" #include "code\new_year_credits.dm" #include "code\aprils_fool_credits.dm" diff --git a/modular_ss220/credits/code/admin_procs.dm b/modular_ss220/credits/code/admin_procs.dm new file mode 100644 index 000000000000..42c90fdc8f9e --- /dev/null +++ b/modular_ss220/credits/code/admin_procs.dm @@ -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, "Все будут смотреть титры по окончании раунда.") + message_admins("[key_name_admin(usr)] устанавливает принудительные титры.", 1) + else + to_chat(world, "Игроки будут смотреть титры в зависимости от своих настроек.") + message_admins("[key_name_admin(usr)] устанавливает титры по умолчанию.", 1) + log_admin("[key_name(usr)] toggled credits.") + SSblackbox.record_feedback("tally", "admin_verb", 1, "Toggle Credits") diff --git a/modular_ss220/modular_ss220.dme b/modular_ss220/modular_ss220.dme index 53c82fc422f6..3a61d9ef6079 100644 --- a/modular_ss220/modular_ss220.dme +++ b/modular_ss220/modular_ss220.dme @@ -39,6 +39,7 @@ // --- MISC --- // #include "administration/_administration.dme" +#include "preferences/_preferences.dme" #include "aesthetics_sounds/_aesthetics_sounds.dme" #include "agent_id_tgui/_agent_id_tgui.dme" #include "balance/_balance.dme" diff --git a/modular_ss220/preferences/_preferences.dm b/modular_ss220/preferences/_preferences.dm new file mode 100644 index 000000000000..13404d8e8a5a --- /dev/null +++ b/modular_ss220/preferences/_preferences.dm @@ -0,0 +1,4 @@ +/datum/modpack/preferences + name = "Кастомные настройки" + desc = "Игровые настройки, разработанные для проекта" + author = "Maxiemar" diff --git a/modular_ss220/preferences/_preferences.dme b/modular_ss220/preferences/_preferences.dme new file mode 100644 index 000000000000..4a65419c8dd1 --- /dev/null +++ b/modular_ss220/preferences/_preferences.dme @@ -0,0 +1,4 @@ +#include "_preferences.dm" + +#include "code/preferences.dm" +#include "code/preferences_toggles.dm" diff --git a/modular_ss220/preferences/code/preferences.dm b/modular_ss220/preferences/code/preferences.dm new file mode 100644 index 000000000000..cc4df2865aa0 --- /dev/null +++ b/modular_ss220/preferences/code/preferences.dm @@ -0,0 +1,59 @@ +/datum/preferences + var/toggles220 = TOGGLES_220_DEFAULT + +/datum/preferences/load_preferences(datum/db_query/query) + . = ..() + if(!.) + return + + return load_custom_preferences() + +/datum/preferences/save_preferences(client/C) + . = ..() + if(!.) + return + + return save_custom_preferences(C) + +/datum/preference_toggle/set_toggles(client/user) + var/datum/preferences/our_prefs = user.prefs + switch(preftoggle_toggle) + if(PREFTOGGLE_TOGGLE220) + our_prefs.toggles220 ^= preftoggle_bitflag + to_chat(user, "[(our_prefs.toggles220 & preftoggle_bitflag) ? enable_message : disable_message]") + . = ..() + +/datum/preferences/proc/load_custom_preferences() + var/datum/db_query/preferences_query = SSdbcore.NewQuery({"SELECT + toggles + FROM player_220 + WHERE ckey=:ckey"}, list( + "ckey" = parent.ckey + )) + + if(!preferences_query.warn_execute()) + qdel(preferences_query) + return FALSE + + while(preferences_query.NextRow()) + toggles220 = preferences_query.item[1] + + toggles220 = sanitize_integer(toggles220, 0, TOGGLES_220_TOTAL, initial(toggles220)) + + qdel(preferences_query) + return TRUE + +/datum/preferences/proc/save_custom_preferences(client/C) + var/datum/db_query/query = SSdbcore.NewQuery({"UPDATE player_220 SET + toggles=:toggles + WHERE ckey=:ckey"}, list( + "toggles" = num2text(toggles220, CEILING(log(10, (TOGGLES_220_TOTAL)), 1)), + "ckey" = C.ckey, + )) + + if(!query.warn_execute()) + qdel(query) + return FALSE + + qdel(query) + return TRUE diff --git a/modular_ss220/preferences/code/preferences_toggles.dm b/modular_ss220/preferences/code/preferences_toggles.dm new file mode 100644 index 000000000000..473738f2bdc0 --- /dev/null +++ b/modular_ss220/preferences/code/preferences_toggles.dm @@ -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"