From 69807ab08d1c1f7b4c2672b4b979ac36e5643a02 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sat, 11 Jun 2011 10:04:14 +0000
Subject: [PATCH] fast character creation in cheat mode to make debugging
 easier (just press enter on the name field)

git-svn-id: http://svn.net-core.org/repos/t-engine4@3616 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Game.lua      |  2 +-
 game/modules/tome/dialogs/Birther.lua | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua
index 7f93ea65b4..2d376e64a6 100644
--- a/game/modules/tome/class/Game.lua
+++ b/game/modules/tome/class/Game.lua
@@ -254,7 +254,7 @@ function _M:newGame()
 					if __module_extra_info.birth_done_script then loadstring(__module_extra_info.birth_done_script)() end
 				end, true)
 				self:registerDialog(d)
-				if __module_extra_info.no_birth_popup then d.key:triggerVirtual("ACCEPT") end
+				if __module_extra_info.no_birth_popup then d.key:triggerVirtual("EXIT") end
 			end
 
 			if self.player.no_birth_levelup or __module_extra_info.no_birth_popup then birthend()
diff --git a/game/modules/tome/dialogs/Birther.lua b/game/modules/tome/dialogs/Birther.lua
index ef651fe716..1b48c384df 100644
--- a/game/modules/tome/dialogs/Birther.lua
+++ b/game/modules/tome/dialogs/Birther.lua
@@ -57,7 +57,9 @@ function _M:init(title, actor, order, at_end, quickbirth, w, h)
 	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_name = Textbox.new{title="Name: ", text=game.player_name, chars=30, max_len=50, fct=function() end, on_change=function() self:setDescriptor() end}
+	self.c_name = Textbox.new{title="Name: ", text=game.player_name, chars=30, max_len=50, fct=function()
+		if config.settings.cheat then self:makeDefault() end
+	end, on_change=function() self:setDescriptor() end}
 
 	self.c_female = Checkbox.new{title="Female", default=true,
 		fct=function() end,
@@ -181,6 +183,19 @@ function _M:atEnd(v)
 	end
 end
 
+--- Make a default character when using cheat mode, for easier testing
+function _M:makeDefault()
+	self:setDescriptor("sex", "Female")
+	self:setDescriptor("world", "Maj'Eyal")
+	self:setDescriptor("difficulty", "Normal")
+	self:setDescriptor("race", "Human")
+	self:setDescriptor("subrace", "Higher")
+	self:setDescriptor("class", "Warrior")
+	self:setDescriptor("subclass", "Fighter")
+	__module_extra_info.no_birth_popup = true
+	self:atEnd("created")
+end
+
 function _M:randomBirth()
 	-- Random sex
 	local sex = rng.percent(50)
-- 
GitLab