From 8bc511f50fd9117b2d1cd395730a7d40dd7af6c6 Mon Sep 17 00:00:00 2001 From: Couls Date: Fri, 1 Mar 2019 17:07:14 -0500 Subject: [PATCH 1/5] Make karma toggleable Add in feedback message Update client defines.dm keep it as bool I guess Update karma.dm Make it persistent Update karma.dm Update karma.dm Update preferences.dm make it compile, include kyet's suggestions fix some things with the help of dtx --- code/__DEFINES/preferences.dm | 3 ++- code/modules/client/client defines.dm | 1 + code/modules/client/client procs.dm | 6 +++++- .../client/preference/preferences_mysql.dm | 2 +- .../client/preference/preferences_toggles.dm | 16 +++++++++++++++- code/modules/karma/karma.dm | 3 +++ 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/code/__DEFINES/preferences.dm b/code/__DEFINES/preferences.dm index 5fa1c2e587a..f8f9609aced 100644 --- a/code/__DEFINES/preferences.dm +++ b/code/__DEFINES/preferences.dm @@ -27,6 +27,7 @@ #define DONATOR_PUBLIC 32768 #define CHAT_NO_TICKETLOGS 65536 #define UI_DARKMODE 131072 +#define DISABLE_KARMA 262144 #define TOGGLES_DEFAULT (CHAT_OOC|CHAT_DEAD|CHAT_GHOSTEARS|CHAT_GHOSTSIGHT|CHAT_PRAYER|CHAT_RADIO|CHAT_LOOC|MEMBER_PUBLIC|DONATOR_PUBLIC) @@ -53,4 +54,4 @@ #define EXP_TYPE_SERVICE "Service" #define EXP_TYPE_WHITELIST "Whitelist" -#define EXP_DEPT_TYPE_LIST list(EXP_TYPE_SERVICE, EXP_TYPE_MEDICAL, EXP_TYPE_ENGINEERING, EXP_TYPE_SCIENCE, EXP_TYPE_SECURITY, EXP_TYPE_COMMAND, EXP_TYPE_SILICON, EXP_TYPE_SPECIAL) \ No newline at end of file +#define EXP_DEPT_TYPE_LIST list(EXP_TYPE_SERVICE, EXP_TYPE_MEDICAL, EXP_TYPE_ENGINEERING, EXP_TYPE_SCIENCE, EXP_TYPE_SECURITY, EXP_TYPE_COMMAND, EXP_TYPE_SILICON, EXP_TYPE_SPECIAL) diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index c88347a305b..9739d142f9c 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -60,6 +60,7 @@ var/karma = 0 var/karma_spent = 0 var/karma_tab = 0 + var/wants_karma = TRUE // let's just keep it true as default for obvious reasons ///////////////////////////////////////////// // /vg/: MEDIAAAAAAAA // Set on login. diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index f02a5ac6b12..b68a0584eb6 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -374,7 +374,11 @@ if(establish_db_connection()) to_chat(src, "Changelog has changed since your last visit.") update_changelog_button() - + + if(prefs.toggles & DISABLE_KARMA) // activates if karma is disabled + if(establish_db_connection()) + wants_karma = FALSE + to_chat(src,"You have disabled karma gains.") // reminds those who have it disabled if(!void) void = new() diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm index 9a75c5a8bb9..6800a63f669 100644 --- a/code/modules/client/preference/preferences_mysql.dm +++ b/code/modules/client/preference/preferences_mysql.dm @@ -55,7 +55,7 @@ ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor)) UI_style = sanitize_inlist(UI_style, list("White", "Midnight"), initial(UI_style)) default_slot = sanitize_integer(default_slot, 1, max_save_slots, initial(default_slot)) - toggles = sanitize_integer(toggles, 0, 262143, initial(toggles)) + toggles = sanitize_integer(toggles, 0, 524287, initial(toggles)) 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)) diff --git a/code/modules/client/preference/preferences_toggles.dm b/code/modules/client/preference/preferences_toggles.dm index 7d3994681b9..69d6e8f97b5 100644 --- a/code/modules/client/preference/preferences_toggles.dm +++ b/code/modules/client/preference/preferences_toggles.dm @@ -218,4 +218,18 @@ activate_darkmode() else deactivate_darkmode() - feedback_add_details("admin_verb","TDarkmode") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! \ No newline at end of file + feedback_add_details("admin_verb","TDarkmode") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + +/client/verb/toggle_karma() + set name = "Toggle Karma Gains" + set category = "Special Verbs" + set desc = "This button will allow you to stop other people giving you karma." + if (prefs.toggles & DISABLE_KARMA) + wants_karma = FALSE + to_chat(usr, "You have disabled karma gains.") + else + wants_karma = TRUE + to_chat(usr, "You have enabled karma gains.") + prefs.toggles ^= DISABLE_KARMA + prefs.save_preferences(src) + return diff --git a/code/modules/karma/karma.dm b/code/modules/karma/karma.dm index d148276d4d6..ae12f93090d 100644 --- a/code/modules/karma/karma.dm +++ b/code/modules/karma/karma.dm @@ -85,6 +85,9 @@ var/list/karma_spenders = list() log_game("Illegal karma spending attempt detected from [key] to [M.key]. Using the same IP!") to_chat(src, "You can't spend karma on someone connected from the same IP.") return FALSE + if(!M.client.wants_karma) + to_chat(src, "That player has turned off incoming karma.") + return FALSE return TRUE From a76e7c40608831a30d82dfd99ddea54fcc80ae63 Mon Sep 17 00:00:00 2001 From: Couls Date: Wed, 6 Mar 2019 12:52:26 -0500 Subject: [PATCH 2/5] Update preferences_toggles.dm --- code/modules/client/preference/preferences_toggles.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/client/preference/preferences_toggles.dm b/code/modules/client/preference/preferences_toggles.dm index 69d6e8f97b5..9e1ddc19347 100644 --- a/code/modules/client/preference/preferences_toggles.dm +++ b/code/modules/client/preference/preferences_toggles.dm @@ -224,7 +224,7 @@ set name = "Toggle Karma Gains" set category = "Special Verbs" set desc = "This button will allow you to stop other people giving you karma." - if (prefs.toggles & DISABLE_KARMA) + if(prefs.toggles & DISABLE_KARMA) wants_karma = FALSE to_chat(usr, "You have disabled karma gains.") else From ddb335fe2c14b93f3431ef724824a21a2467c2bd Mon Sep 17 00:00:00 2001 From: Couls Date: Thu, 7 Mar 2019 15:45:58 -0500 Subject: [PATCH 3/5] remove redundant var --- code/modules/client/client defines.dm | 1 - code/modules/client/client procs.dm | 11 +++++------ code/modules/client/preference/preferences_toggles.dm | 2 -- code/modules/karma/karma.dm | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index 9739d142f9c..c88347a305b 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -60,7 +60,6 @@ var/karma = 0 var/karma_spent = 0 var/karma_tab = 0 - var/wants_karma = TRUE // let's just keep it true as default for obvious reasons ///////////////////////////////////////////// // /vg/: MEDIAAAAAAAA // Set on login. diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index b68a0584eb6..0d942a3a485 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -377,7 +377,6 @@ if(prefs.toggles & DISABLE_KARMA) // activates if karma is disabled if(establish_db_connection()) - wants_karma = FALSE to_chat(src,"You have disabled karma gains.") // reminds those who have it disabled if(!void) @@ -669,7 +668,7 @@ /client/proc/on_varedit() var_edited = TRUE - + ///////////////// // DARKMODE UI // ///////////////// @@ -706,7 +705,7 @@ /* Infowindow */ winset(src, "infowindow", "background-color=#272727;text-color=#FFFFFF") winset(src, "infowindow.info", "background-color=#272727;text-color=#FFFFFF;highlight-color=#009900;tab-text-color=#FFFFFF;tab-background-color=#272727") - // NOTIFY USER + // NOTIFY USER to_chat(src, "Darkmode Enabled") /client/proc/deactivate_darkmode() @@ -747,15 +746,15 @@ // Better changelog button handling /client/proc/update_changelog_button() if(establish_db_connection()) - if(prefs.lastchangelog != changelog_hash) + if(prefs.lastchangelog != changelog_hash) winset(src, "rpane.changelog", "background-color=#bb7700;text-color=#FFFFFF;font-style=bold") else - if(prefs.toggles & UI_DARKMODE) + if(prefs.toggles & UI_DARKMODE) winset(src, "rpane.changelog", "background-color=#40628a;text-color=#FFFFFF") else winset(src, "rpane.changelog", "background-color=none;text-color=#000000") else - if(prefs.toggles & UI_DARKMODE) + if(prefs.toggles & UI_DARKMODE) winset(src, "rpane.changelog", "background-color=#40628a;text-color=#FFFFFF") else winset(src, "rpane.changelog", "background-color=none;text-color=#000000") diff --git a/code/modules/client/preference/preferences_toggles.dm b/code/modules/client/preference/preferences_toggles.dm index 69d6e8f97b5..307f018f73c 100644 --- a/code/modules/client/preference/preferences_toggles.dm +++ b/code/modules/client/preference/preferences_toggles.dm @@ -225,10 +225,8 @@ set category = "Special Verbs" set desc = "This button will allow you to stop other people giving you karma." if (prefs.toggles & DISABLE_KARMA) - wants_karma = FALSE to_chat(usr, "You have disabled karma gains.") else - wants_karma = TRUE to_chat(usr, "You have enabled karma gains.") prefs.toggles ^= DISABLE_KARMA prefs.save_preferences(src) diff --git a/code/modules/karma/karma.dm b/code/modules/karma/karma.dm index ae12f93090d..107ec3c4f3f 100644 --- a/code/modules/karma/karma.dm +++ b/code/modules/karma/karma.dm @@ -85,7 +85,7 @@ var/list/karma_spenders = list() log_game("Illegal karma spending attempt detected from [key] to [M.key]. Using the same IP!") to_chat(src, "You can't spend karma on someone connected from the same IP.") return FALSE - if(!M.client.wants_karma) + if(M.get_preference(DISABLE_KARMA)) to_chat(src, "That player has turned off incoming karma.") return FALSE return TRUE From bed368d1c91fe598a624e05f5ce593a84b18c9af Mon Sep 17 00:00:00 2001 From: Couls Date: Thu, 7 Mar 2019 17:42:53 -0500 Subject: [PATCH 4/5] Revert "Merge branch 'toggle_karma2' of https://github.com/Couls/Paradise into toggle_karma2" This reverts commit 79777f441e8406fa9ef1530a1261879c2e09ff4d, reversing changes made to a76e7c40608831a30d82dfd99ddea54fcc80ae63. --- code/modules/client/client defines.dm | 1 + code/modules/client/client procs.dm | 11 ++++++----- code/modules/client/preference/preferences_toggles.dm | 4 +++- code/modules/karma/karma.dm | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index c88347a305b..9739d142f9c 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -60,6 +60,7 @@ var/karma = 0 var/karma_spent = 0 var/karma_tab = 0 + var/wants_karma = TRUE // let's just keep it true as default for obvious reasons ///////////////////////////////////////////// // /vg/: MEDIAAAAAAAA // Set on login. diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 0d942a3a485..b68a0584eb6 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -377,6 +377,7 @@ if(prefs.toggles & DISABLE_KARMA) // activates if karma is disabled if(establish_db_connection()) + wants_karma = FALSE to_chat(src,"You have disabled karma gains.") // reminds those who have it disabled if(!void) @@ -668,7 +669,7 @@ /client/proc/on_varedit() var_edited = TRUE - + ///////////////// // DARKMODE UI // ///////////////// @@ -705,7 +706,7 @@ /* Infowindow */ winset(src, "infowindow", "background-color=#272727;text-color=#FFFFFF") winset(src, "infowindow.info", "background-color=#272727;text-color=#FFFFFF;highlight-color=#009900;tab-text-color=#FFFFFF;tab-background-color=#272727") - // NOTIFY USER + // NOTIFY USER to_chat(src, "Darkmode Enabled") /client/proc/deactivate_darkmode() @@ -746,15 +747,15 @@ // Better changelog button handling /client/proc/update_changelog_button() if(establish_db_connection()) - if(prefs.lastchangelog != changelog_hash) + if(prefs.lastchangelog != changelog_hash) winset(src, "rpane.changelog", "background-color=#bb7700;text-color=#FFFFFF;font-style=bold") else - if(prefs.toggles & UI_DARKMODE) + if(prefs.toggles & UI_DARKMODE) winset(src, "rpane.changelog", "background-color=#40628a;text-color=#FFFFFF") else winset(src, "rpane.changelog", "background-color=none;text-color=#000000") else - if(prefs.toggles & UI_DARKMODE) + if(prefs.toggles & UI_DARKMODE) winset(src, "rpane.changelog", "background-color=#40628a;text-color=#FFFFFF") else winset(src, "rpane.changelog", "background-color=none;text-color=#000000") diff --git a/code/modules/client/preference/preferences_toggles.dm b/code/modules/client/preference/preferences_toggles.dm index 307f018f73c..9e1ddc19347 100644 --- a/code/modules/client/preference/preferences_toggles.dm +++ b/code/modules/client/preference/preferences_toggles.dm @@ -224,9 +224,11 @@ set name = "Toggle Karma Gains" set category = "Special Verbs" set desc = "This button will allow you to stop other people giving you karma." - if (prefs.toggles & DISABLE_KARMA) + if(prefs.toggles & DISABLE_KARMA) + wants_karma = FALSE to_chat(usr, "You have disabled karma gains.") else + wants_karma = TRUE to_chat(usr, "You have enabled karma gains.") prefs.toggles ^= DISABLE_KARMA prefs.save_preferences(src) diff --git a/code/modules/karma/karma.dm b/code/modules/karma/karma.dm index 107ec3c4f3f..ae12f93090d 100644 --- a/code/modules/karma/karma.dm +++ b/code/modules/karma/karma.dm @@ -85,7 +85,7 @@ var/list/karma_spenders = list() log_game("Illegal karma spending attempt detected from [key] to [M.key]. Using the same IP!") to_chat(src, "You can't spend karma on someone connected from the same IP.") return FALSE - if(M.get_preference(DISABLE_KARMA)) + if(!M.client.wants_karma) to_chat(src, "That player has turned off incoming karma.") return FALSE return TRUE From 5d839252239963c7d9b3a2dd3a53854220ec054b Mon Sep 17 00:00:00 2001 From: Couls Date: Thu, 7 Mar 2019 17:43:19 -0500 Subject: [PATCH 5/5] Revert "Revert "Merge branch 'toggle_karma2' of https://github.com/Couls/Paradise into toggle_karma2"" This reverts commit bed368d1c91fe598a624e05f5ce593a84b18c9af. --- code/modules/client/client defines.dm | 1 - code/modules/client/client procs.dm | 11 +++++------ code/modules/client/preference/preferences_toggles.dm | 4 +--- code/modules/karma/karma.dm | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index 9739d142f9c..c88347a305b 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -60,7 +60,6 @@ var/karma = 0 var/karma_spent = 0 var/karma_tab = 0 - var/wants_karma = TRUE // let's just keep it true as default for obvious reasons ///////////////////////////////////////////// // /vg/: MEDIAAAAAAAA // Set on login. diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index b68a0584eb6..0d942a3a485 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -377,7 +377,6 @@ if(prefs.toggles & DISABLE_KARMA) // activates if karma is disabled if(establish_db_connection()) - wants_karma = FALSE to_chat(src,"You have disabled karma gains.") // reminds those who have it disabled if(!void) @@ -669,7 +668,7 @@ /client/proc/on_varedit() var_edited = TRUE - + ///////////////// // DARKMODE UI // ///////////////// @@ -706,7 +705,7 @@ /* Infowindow */ winset(src, "infowindow", "background-color=#272727;text-color=#FFFFFF") winset(src, "infowindow.info", "background-color=#272727;text-color=#FFFFFF;highlight-color=#009900;tab-text-color=#FFFFFF;tab-background-color=#272727") - // NOTIFY USER + // NOTIFY USER to_chat(src, "Darkmode Enabled") /client/proc/deactivate_darkmode() @@ -747,15 +746,15 @@ // Better changelog button handling /client/proc/update_changelog_button() if(establish_db_connection()) - if(prefs.lastchangelog != changelog_hash) + if(prefs.lastchangelog != changelog_hash) winset(src, "rpane.changelog", "background-color=#bb7700;text-color=#FFFFFF;font-style=bold") else - if(prefs.toggles & UI_DARKMODE) + if(prefs.toggles & UI_DARKMODE) winset(src, "rpane.changelog", "background-color=#40628a;text-color=#FFFFFF") else winset(src, "rpane.changelog", "background-color=none;text-color=#000000") else - if(prefs.toggles & UI_DARKMODE) + if(prefs.toggles & UI_DARKMODE) winset(src, "rpane.changelog", "background-color=#40628a;text-color=#FFFFFF") else winset(src, "rpane.changelog", "background-color=none;text-color=#000000") diff --git a/code/modules/client/preference/preferences_toggles.dm b/code/modules/client/preference/preferences_toggles.dm index 9e1ddc19347..307f018f73c 100644 --- a/code/modules/client/preference/preferences_toggles.dm +++ b/code/modules/client/preference/preferences_toggles.dm @@ -224,11 +224,9 @@ set name = "Toggle Karma Gains" set category = "Special Verbs" set desc = "This button will allow you to stop other people giving you karma." - if(prefs.toggles & DISABLE_KARMA) - wants_karma = FALSE + if (prefs.toggles & DISABLE_KARMA) to_chat(usr, "You have disabled karma gains.") else - wants_karma = TRUE to_chat(usr, "You have enabled karma gains.") prefs.toggles ^= DISABLE_KARMA prefs.save_preferences(src) diff --git a/code/modules/karma/karma.dm b/code/modules/karma/karma.dm index ae12f93090d..107ec3c4f3f 100644 --- a/code/modules/karma/karma.dm +++ b/code/modules/karma/karma.dm @@ -85,7 +85,7 @@ var/list/karma_spenders = list() log_game("Illegal karma spending attempt detected from [key] to [M.key]. Using the same IP!") to_chat(src, "You can't spend karma on someone connected from the same IP.") return FALSE - if(!M.client.wants_karma) + if(M.get_preference(DISABLE_KARMA)) to_chat(src, "That player has turned off incoming karma.") return FALSE return TRUE