From 68140d2fcd41eb934303d077262d5d2dd5143d19 Mon Sep 17 00:00:00 2001
From: DarkGod <darkgod@net-core.org>
Date: Thu, 9 Oct 2014 10:59:08 +0200
Subject: [PATCH] Custom made tiles can now be used (by donators), simply
 follow the howto in the birth dialog

allow for vim regen to work on rest
---
 game/modules/tome/class/Player.lua    |  5 ++++-
 game/modules/tome/dialogs/Birther.lua | 18 +++++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua
index eea6a819a1..6c1795b580 100644
--- a/game/modules/tome/class/Player.lua
+++ b/game/modules/tome/class/Player.lua
@@ -868,6 +868,7 @@ function _M:onRestStart()
 			self:setEffect(self.EFF_SPACETIME_TUNING, duration, {power=power})
 		end
 	end
+	self:fireTalentCheck("callbackOnRest", "start")
 end
 
 --- We stopped resting
@@ -880,6 +881,7 @@ function _M:onRestStop()
 		self:attr("mana_regen", -self.resting.mana_regen)
 		self.resting.mana_regen = nil
 	end
+	self:fireTalentCheck("callbackOnRest", "stop")
 end
 
 --- Can we continue resting ?
@@ -921,6 +923,7 @@ function _M:restCheck()
 		if self:getMana() < self:getMaxMana() and self.mana_regen > 0 then return true end
 		if self:getStamina() < self:getMaxStamina() and self.stamina_regen > 0 then return true end
 		if self:getPsi() < self:getMaxPsi() and self.psi_regen > 0 then return true end
+		if self:getVim() < self:getMaxVim() and self.vim_regen > 0 then return true end
 		if self:getEquilibrium() > self:getMinEquilibrium() and self.equilibrium_regen < 0 then return true end
 		if self.life < self.max_life and self.life_regen> 0 then return true end
 		for act, def in pairs(game.party.members) do if game.level:hasEntity(act) and not act.dead then
@@ -928,7 +931,7 @@ function _M:restCheck()
 		end end
 		if ammo and ammo.combat.shots_left < ammo.combat.capacity then return true end
 
-		if self:fireTalentCheck("callbackOnRest") then return true end
+		if self:fireTalentCheck("callbackOnRest", "check") then return true end
 	else
 		return true
 	end
diff --git a/game/modules/tome/dialogs/Birther.lua b/game/modules/tome/dialogs/Birther.lua
index 9b0212136b..1ab459eee9 100644
--- a/game/modules/tome/dialogs/Birther.lua
+++ b/game/modules/tome/dialogs/Birther.lua
@@ -1401,12 +1401,27 @@ function _M:selectTile()
 		"player/ascii_player_exotic_01.png",
 		"player/ascii_player_shopper_01.png",
 	}
+
+	fs.mkdir("/data/gfx/custom-tiles/")
+	for file in fs.iterate("/data/gfx/custom-tiles/", function(file) return file:find("%.png") end) do
+		list[#list+1] = "custom-tiles/"..file
+	end	
+
 	self:triggerHook{"Birther:donatorTiles", list=list}
-	local remove = Button.new{text="Use default tile", width=500, fct=function()
+	local remove = Button.new{text="Use default tile", width=240, fct=function()
 		game:unregisterDialog(d)
 		self.has_custom_tile = nil
 		self:setTile()
 	end}
+	local custom = Button.new{text="Use custom-made tile", width=240, fct=function()
+		self:simpleLongPopup("Howto: Custom-made tiles", ([[You can use your own custom tiles if you are a donator.
+For the game to use them you must simply respect a few rules:
+- they must be 64x64 or 64x128 tiles
+- they must be saved as PNG files
+- you must place them in folder #LIGHT_BLUE#%s#WHITE#
+
+Once you have done so, simply restart the game and the tiles will be listed at the bottom of the list.]]):format(fs.getRealPath("/data/gfx/custom-tiles/")), 500)
+	end}
 	local list = ImageList.new{width=500, height=500, tile_w=64, tile_h=64, padding=10, scrollbar=true, list=list, fct=function(item)
 		game:unregisterDialog(d)
 		if not self:isDonator() then
@@ -1418,6 +1433,7 @@ function _M:selectTile()
 	d:loadUI{
 		{left=0, top=0, ui=list},
 		{left=0, bottom=0, ui=remove},
+		{left=250, bottom=0, ui=custom},
 	}
 	d:setupUI(true, true)
 	d.key:addBind("EXIT", function() game:unregisterDialog(d) end)
-- 
GitLab