From c5a947728c5ec0d9ccf3a4c09164be7270349deb Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Mon, 14 Nov 2011 09:47:04 +0000
Subject: [PATCH] Tutorial is now a special button in the birth UI, and both
 the basic and the stats tutorial are availavble

git-svn-id: http://svn.net-core.org/repos/t-engine4@4648 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engines/default/engine/ui/Button.lua     | 13 +++++-
 .../tome/class/interface/TooltipsData.lua     |  2 +-
 game/modules/tome/data/birth/descriptors.lua  |  9 +++--
 .../tome/data/birth/races/tutorial.lua        | 19 ++++++++-
 .../tome/data/texts/tutorial/stats/stats9.lua |  2 +-
 game/modules/tome/dialogs/Birther.lua         | 40 ++++++++++++++++++-
 6 files changed, 76 insertions(+), 9 deletions(-)

diff --git a/game/engines/default/engine/ui/Button.lua b/game/engines/default/engine/ui/Button.lua
index 5d51e52c61..c790d4828f 100644
--- a/game/engines/default/engine/ui/Button.lua
+++ b/game/engines/default/engine/ui/Button.lua
@@ -74,12 +74,21 @@ function _M:display(x, y, nb_keyframes, ox, oy)
 	if self.focused then
 			if button == 1 and mx > ox and mx < ox+self.w and my > oy and my < oy+self.h then
 				self:drawFrame(self.frame, x, y, 0, 1, 0, 1)
+			elseif self.glow then
+			local v = self.glow + (1 - self.glow) * (1 + math.cos(core.game.getTime() / 300)) / 2
+				self:drawFrame(self.frame, x, y, v*0.8, v, 0, 1)
 			else
 				self:drawFrame(self.frame_sel, x, y)
 			end
 	else
-		self:drawFrame(self.frame, x, y)
-		if self.focus_decay then
+		if self.glow then
+			local v = self.glow + (1 - self.glow) * (1 + math.cos(core.game.getTime() / 300)) / 2
+			self:drawFrame(self.frame, x, y, v*0.8, v, 0, 1)
+		else
+			self:drawFrame(self.frame, x, y)
+		end
+
+		if self.focus_decay and not self.glow then
 			self:drawFrame(self.frame_sel, x, y, 1, 1, 1, self.focus_decay / self.focus_decay_max_d)
 			self.focus_decay = self.focus_decay - nb_keyframes
 			if self.focus_decay <= 0 then self.focus_decay = nil end
diff --git a/game/modules/tome/class/interface/TooltipsData.lua b/game/modules/tome/class/interface/TooltipsData.lua
index 657b5f1adf..0216752c1c 100644
--- a/game/modules/tome/class/interface/TooltipsData.lua
+++ b/game/modules/tome/class/interface/TooltipsData.lua
@@ -273,7 +273,7 @@ The lower it is the faster it is.
 ]]
 TOOLTIP_MINDPOWER = [[#GOLD#Mindpower#LAST#
 Your mindpower value represents how powerful your mental abilities are.
-In addition, when you use mental abilities inflict temporary detrimental effects, every five points of mindpower counteracts a single turn of duration reduction granted by the enemy's saving throws.
+In addition, when your mental abilities inflict temporary detrimental effects, every five points of mindpower counteracts a single turn of duration reduction granted by the enemy's saving throws.In addition, when your mental abilities inflict temporary detrimental effects, every five points of mindpower counteracts a single turn of duration reduction granted by the enemy's saving throws.
 ]]
 
 -------------------------------------------------------------
diff --git a/game/modules/tome/data/birth/descriptors.lua b/game/modules/tome/data/birth/descriptors.lua
index 7d7c18c48f..06f146bb95 100644
--- a/game/modules/tome/data/birth/descriptors.lua
+++ b/game/modules/tome/data/birth/descriptors.lua
@@ -35,9 +35,12 @@ newBirthDescriptor{
 	},
 	descriptor_choices =
 	{
-		world =
+		difficulty =
 		{
 			Tutorial = "disallow",
+		},
+		world =
+		{
 			["Maj'Eyal"] = "allow",
 			Infinite = "allow",
 			Arena = "allow",
@@ -90,7 +93,7 @@ newBirthDescriptor{
 newBirthDescriptor{
 	type = "difficulty",
 	name = "Tutorial",
-	selection_default = not profile.mod.allow_build.tutorial_done,
+	never_show = true,
 	desc =
 	{
 		"#GOLD##{bold}#Tutorial mode",
@@ -154,7 +157,7 @@ newBirthDescriptor{
 newBirthDescriptor{
 	type = "difficulty",
 	name = "Normal",
-	selection_default = profile.mod.allow_build.tutorial_done,
+	selection_default = true,
 	desc =
 	{
 		"#GOLD##{bold}#Adventure mode#WHITE##{normal}#",
diff --git a/game/modules/tome/data/birth/races/tutorial.lua b/game/modules/tome/data/birth/races/tutorial.lua
index 7b26b53faf..08e12e2343 100644
--- a/game/modules/tome/data/birth/races/tutorial.lua
+++ b/game/modules/tome/data/birth/races/tutorial.lua
@@ -45,7 +45,24 @@ newBirthDescriptor{
 newBirthDescriptor
 {
 	type = "subrace",
-	name = "Tutorial Human",
+	name = "Tutorial Basic",
+	desc = {
+		"A Human hailing from the northern town of Derth. A common kind of man, unremarkable in all respects.",
+	},
+	copy = {
+		default_wilderness = {1, 1, "wilderness"},
+		starting_zone = "tutorial",
+		starting_quest = "tutorial",
+		starting_intro = "tutorial",
+		moddable_tile = "human_#sex#",
+		moddable_tile_base = "base_cornac_01.png",
+	},
+}
+
+newBirthDescriptor
+{
+	type = "subrace",
+	name = "Tutorial Stats",
 	desc = {
 		"A Human hailing from the northern town of Derth. A common kind of man, unremarkable in all respects.",
 	},
diff --git a/game/modules/tome/data/texts/tutorial/stats/stats9.lua b/game/modules/tome/data/texts/tutorial/stats/stats9.lua
index aec4188880..f9d658e9c6 100644
--- a/game/modules/tome/data/texts/tutorial/stats/stats9.lua
+++ b/game/modules/tome/data/texts/tutorial/stats/stats9.lua
@@ -18,7 +18,7 @@
 -- darkgod@te4.org
 
 return [[
-Now you know the basics: what these seven #GOLD#combat stats#WHITE# mean and when they're used. It's time to look at some numbers. 
+Now you know the basics: what these eight #GOLD#combat stats#WHITE# mean and when they're used. It's time to look at some numbers.
 
 Head north to the stairs, and descend into the #GOLD#Dungeon of Adventurer Enlightenment.#WHITE#
 ]]
diff --git a/game/modules/tome/dialogs/Birther.lua b/game/modules/tome/dialogs/Birther.lua
index 6a3bb317c8..572bad082d 100644
--- a/game/modules/tome/dialogs/Birther.lua
+++ b/game/modules/tome/dialogs/Birther.lua
@@ -63,6 +63,7 @@ function _M:init(title, actor, order, at_end, quickbirth, w, h)
 	self.c_premade = Button.new{text="Load premade", fct=function() self:loadPremadeUI() end}
 	self.c_tile = Button.new{text="Select custom tile", fct=function() self:selectTile() end}
 	self.c_cancel = Button.new{text="Cancel", fct=function() self:atEnd("quit") end}
+	self.c_tut = Button.new{text="Tutorial", fct=function() self:tutorial() end}
 
 	self.c_name = Textbox.new{title="Name: ", text=(not config.settings.cheat and game.player_name == "player") and "" or game.player_name, chars=30, max_len=50, fct=function()
 		if config.settings.cheat then self:makeDefault() end
@@ -135,6 +136,7 @@ function _M:init(title, actor, order, at_end, quickbirth, w, h)
 		{left=self.c_difficulty_text, top=self.c_campaign, ui=self.c_difficulty},
 		{left=self.c_difficulty, top=self.c_campaign, ui=self.c_permadeath_text},
 		{left=self.c_permadeath_text, top=self.c_campaign, ui=self.c_permadeath},
+		{right=0, top=self.c_name, ui=self.c_tut},
 
 		-- Lists
 		{left=0, top=self.c_permadeath, ui=self.c_race},
@@ -162,6 +164,11 @@ function _M:init(title, actor, order, at_end, quickbirth, w, h)
 	for i, item in ipairs(self.c_permadeath.c_list.list) do if self.default_permadeath == item.id then self.c_permadeath.c_list.sel = i break end end
 	self:setFocus(self.c_campaign)
 	self:setFocus(self.c_name)
+
+	if not profile.mod.allow_build.tutorial_done then
+		self:setFocus(self.c_tut)
+		self.c_tut.glow = 0.70
+	end
 end
 
 function _M:checkNew(fct)
@@ -279,6 +286,37 @@ function _M:makeDefault()
 	self:atEnd("created")
 end
 
+--- Run one of the tutorials
+function _M:tutorial()
+	local run = function(t)
+		self:setDescriptor("sex", "Female")
+		self:setDescriptor("world", "Maj'Eyal")
+		self:setDescriptor("difficulty", "Tutorial")
+		self:setDescriptor("permadeath", "Adventure")
+		self:setDescriptor("race", "Tutorial Human")
+		self:setDescriptor("subrace", "Tutorial "..t)
+		self:setDescriptor("class", "Tutorial Adventurer")
+		self:setDescriptor("subclass", "Tutorial Adventurer")
+		self:atEnd("created")
+	end
+
+	local d = Dialog.new("Tutorials", 170, 100)
+	local basic = Button.new{text="Basic Gameplay", fct=function() run("Basic") d.key:triggerVirtual("EXIT") end}
+	local stats = Button.new{text="Advanced Stats", fct=function() run("Stats") d.key:triggerVirtual("EXIT") end}
+	local cancel = Button.new{text="Cancel", fct=function() d.key:triggerVirtual("EXIT") end}
+	local sep = Separator.new{dir="vertical", size=150}
+
+	d:loadUI{
+		{hcenter=0, top=0, ui=basic},
+		{hcenter=0, top=basic.h, ui=stats},
+		{hcenter=0, bottom=cancel.h, ui=sep},
+		{hcenter=0, bottom=0, ui=cancel},
+	}
+	d:setupUI(false, true)
+	d.key:addBind("EXIT", function() game:unregisterDialog(d) end)
+	game:registerDialog(d)
+end
+
 function _M:randomBirth()
 	-- Random sex
 	local sex = rng.percent(50)
@@ -527,7 +565,7 @@ function _M:isDescriptorAllowed(d, ignore_type)
 	end
 
 	-- Check it is allowed
-	return allowed
+	return allowed and not d.never_show
 end
 
 function _M:getLock(d)
-- 
GitLab