forked from ParadiseSS13/Paradise
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TM] Make credits toggleable (#1431)
## Что этот PR делает Добавляет возможность отключить автоматическое воспроизведение титров в настройках игры. Администратор все равно может зафорсить титры в текущем раунде, если считает нужным. Добавляет ***новую таблицу с префами***, надо будет так и другие фичи сделать. ## Почему это хорошо для игры Можно не прожимать "Прекратить смотреть синематик" каждый раунд. ## Изображения изменений ![image](https://github.com/user-attachments/assets/e50fbe28-ee32-4304-a16c-c8c6b73b77b5) ## Тестирование - [x] Свойство в настройках реально влияет на воспроизведение титров. - [x] Админ реально может зафорсить титры, никакие настройки от этого не спасут. - [x] Настройки сохранились в тестовой БД и подсосались после перезапуска сервера. ## Changelog :cl: Maxiemar add: Автоматическое воспроизведение титров в конце раунда теперь можно отключить в настройках игры. add: Администрация может зафорсить титры на конец раунда, если захочет всем напомнить, как они выглядят. Server -> Toggle Credits. /:cl:
- Loading branch information
1 parent
449920f
commit 4d7d93a
Showing
17 changed files
with
182 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/datum/modpack/preferences | ||
name = "Кастомные настройки" | ||
desc = "Игровые настройки, разработанные для проекта" | ||
author = "Maxiemar" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include "_preferences.dm" | ||
|
||
#include "code/preferences.dm" | ||
#include "code/preferences_toggles.dm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, "<span class='notice'>[(our_prefs.toggles220 & preftoggle_bitflag) ? enable_message : disable_message]</span>") | ||
. = ..() | ||
|
||
/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |