From 5840a58ad5872f601a254294b815c6b25482fcf7 Mon Sep 17 00:00:00 2001
From: DarkGod <darkgod@net-core.org>
Date: Thu, 19 Apr 2018 18:53:40 +0200
Subject: [PATCH] moar

---
 game/engines/default/engine/init.lua         |  1 +
 game/modules/tome/class/Game.lua             |  2 +-
 game/modules/tome/dialogs/CharacterSheet.lua |  2 +-
 game/modules/tome/dialogs/GameOptions.lua    | 10 ++++++++++
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/game/engines/default/engine/init.lua b/game/engines/default/engine/init.lua
index 616b60d2ed..dc59f42f19 100644
--- a/game/engines/default/engine/init.lua
+++ b/game/engines/default/engine/init.lua
@@ -82,6 +82,7 @@ chat.ignores = {}
 addons = {}
 allow_online_events = true
 disable_all_connectivity = false
+upload_charsheet = true
 upgrades { v1_0_5=true }
 ]]
 for i, file in ipairs(fs.list("/settings/")) do
diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua
index 914d1d13c3..de9e8761cf 100644
--- a/game/modules/tome/class/Game.lua
+++ b/game/modules/tome/class/Game.lua
@@ -2659,7 +2659,7 @@ function _M:saveGame()
 	-- savefile_pipe is created as a global by the engine
 	local clone = savefile_pipe:push(self.save_name, "game", self)
 	world:saveWorld()
-	if not self.creating_player then
+	if not self.creating_player and config.settings.tome.upload_charsheet then
 		local oldplayer = self.player
 		self.party:setPlayer(self:getPlayer(true), true)
 
diff --git a/game/modules/tome/dialogs/CharacterSheet.lua b/game/modules/tome/dialogs/CharacterSheet.lua
index 94e7e79975..800c1be3f3 100644
--- a/game/modules/tome/dialogs/CharacterSheet.lua
+++ b/game/modules/tome/dialogs/CharacterSheet.lua
@@ -477,7 +477,7 @@ function _M:drawDialog(kind, actor_to_compare)
 	local text = ""
 	local dur_text = ""
 
-	if player.__te4_uuid and profile.auth and profile.auth.drupid and not config.settings.disable_all_connectivity then
+	if player.__te4_uuid and profile.auth and profile.auth.drupid and not config.settings.disable_all_connectivity and config.settings.tome.upload_charsheet then
 		local path = "https://te4.org/characters/"..profile.auth.drupid.."/tome/"..player.__te4_uuid
 		local LinkTxt = "Online URL: #LIGHT_BLUE##{underline}#"..path.."#{normal}#"
 		local Link_w, Link_h = self.font:size(LinkTxt)
diff --git a/game/modules/tome/dialogs/GameOptions.lua b/game/modules/tome/dialogs/GameOptions.lua
index 3b1e30cf80..e16e637bf5 100644
--- a/game/modules/tome/dialogs/GameOptions.lua
+++ b/game/modules/tome/dialogs/GameOptions.lua
@@ -586,6 +586,16 @@ function _M:generateListOnline()
 		self.c_list:drawItem(item)
 	end,}
 
+	local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Keep a copy of your character sheets (not the whole savefile) on the online vault at te4.org.\nFor each characters you will be given a link to this online character sheet so that you drag about your heroic deeds or sad deaths to your friends or the whole community.#WHITE#"}
+	list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Upload characters sheets to the online vault#WHITE##{normal}#", status=function(item)
+		return tostring(config.settings.upload_charsheet and "enabled" or "disabled")
+	end, fct=function(item)
+		config.settings.upload_charsheet = not config.settings.upload_charsheet
+		game:saveSettings("tome.upload_charsheet", ("tome.upload_charsheet = %s\n"):format(tostring(config.settings.upload_charsheet)))
+		self.c_list:drawItem(item)
+
+	end,}
+
 	local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Allow various events that are pushed by the server when playing online\n#{bold}#All#{normal}#: Allow all server events (bonus zones, random events, ...)\n#{bold}#Technical help only#{normal}#: Allow administrator to help in case of bugs or weirdness and allows website services (data reset, steam achievements push, ...) to work.\n#{bold}#Disabled#{normal}#: Disallow all.\n#WHITE#"}
 	list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Allow online events#WHITE##{normal}#", status=function(item)
 		return tostring(config.settings.allow_online_events == true and "all" or (config.settings.allow_online_events == "limited" and "technical help only" or "disabled"))
-- 
GitLab