From 53d087ebb4d302bf4330c0908439c2b0e1fc64d2 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Thu, 23 Feb 2012 13:48:45 +0000
Subject: [PATCH] Some game options disappear when using the new UI; they are
 useless

git-svn-id: http://svn.net-core.org/repos/t-engine4@4917 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/uiset/Minimalist.lua |   6 ++
 game/modules/tome/class/uiset/UISet.lua      |   4 +
 game/modules/tome/dialogs/GameOptions.lua    | 108 +++++++++----------
 game/modules/tome/load.lua                   |   1 +
 4 files changed, 62 insertions(+), 57 deletions(-)

diff --git a/game/modules/tome/class/uiset/Minimalist.lua b/game/modules/tome/class/uiset/Minimalist.lua
index 79ed1e5e9c..ef47d5e603 100644
--- a/game/modules/tome/class/uiset/Minimalist.lua
+++ b/game/modules/tome/class/uiset/Minimalist.lua
@@ -212,6 +212,12 @@ function _M:init()
 	self.buffs_base = UI:makeFrame("ui/icon-frame/frame", 40, 40)
 end
 
+--- Forbid some options from showing up, they are useless for this ui
+function _M:checkGameOption(name)
+	local list = table.reverse{"icons_temp_effects", "icons_hotkeys", "hotkeys_rows", "log_lines"}
+	return not list[name]
+end
+
 function _M:boundPlaces(w, h)
 	w = w or game.w
 	h = h or game.h
diff --git a/game/modules/tome/class/uiset/UISet.lua b/game/modules/tome/class/uiset/UISet.lua
index 04bca68522..f6f32dda4e 100644
--- a/game/modules/tome/class/uiset/UISet.lua
+++ b/game/modules/tome/class/uiset/UISet.lua
@@ -46,3 +46,7 @@ end
 function _M:toggleUI()
 	self.no_ui = not self.no_ui
 end
+
+function _M:checkGameOption(name)
+	return true
+end
\ No newline at end of file
diff --git a/game/modules/tome/dialogs/GameOptions.lua b/game/modules/tome/dialogs/GameOptions.lua
index ac0f3ea851..ee935ed121 100644
--- a/game/modules/tome/dialogs/GameOptions.lua
+++ b/game/modules/tome/dialogs/GameOptions.lua
@@ -188,33 +188,21 @@ function _M:generateList()
 		self.c_list:drawItem(item)
 	end,}
 
-	local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"How many log and chat lines to show at the screen's bottom."}
-	list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Log lines#WHITE##{normal}#", status=function(item)
-		return tostring(config.settings.tome.log_lines)
-	end, fct=function(item)
-		game:registerDialog(GetQuantity.new("Number of lines", "From 2 to 20", config.settings.tome.log_lines, 20, function(qty)
-			qty = util.bound(qty, 2, 20)
-			game:saveSettings("tome.log_lines", ("tome.log_lines = %d\n"):format(qty))
-			config.settings.tome.log_lines = qty
-			game.logdisplay.resizeToLines()
-			profile.chat.resizeToLines()
-			self.c_list:drawItem(item)
-		end, 2))
-	end,}
-
-	local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"How many seconds before log and chat lines begin to fade away.\nIf set to 0 the logs will never fade away."}
-	list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Log fade time#WHITE##{normal}#", status=function(item)
-		return tostring(config.settings.tome.log_fade)
-	end, fct=function(item)
-		game:registerDialog(GetQuantity.new("Fade time (in seconds)", "From 0 to 20", config.settings.tome.log_fade, 20, function(qty)
-			qty = util.bound(qty, 0, 20)
-			game:saveSettings("tome.log_fade", ("tome.log_fade = %d\n"):format(qty))
-			config.settings.tome.log_fade = qty
-			game.logdisplay:enableFading(config.settings.tome.log_fade)
-			profile.chat:enableFading(config.settings.tome.log_fade)
-			self.c_list:drawItem(item)
-		end, 0))
-	end,}
+	if game.uiset:checkGameOption("log_lines") then
+		local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"How many seconds before log and chat lines begin to fade away.\nIf set to 0 the logs will never fade away."}
+		list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Log fade time#WHITE##{normal}#", status=function(item)
+			return tostring(config.settings.tome.log_fade)
+		end, fct=function(item)
+			game:registerDialog(GetQuantity.new("Fade time (in seconds)", "From 0 to 20", config.settings.tome.log_fade, 20, function(qty)
+				qty = util.bound(qty, 0, 20)
+				game:saveSettings("tome.log_fade", ("tome.log_fade = %d\n"):format(qty))
+				config.settings.tome.log_fade = qty
+				game.logdisplay:enableFading(config.settings.tome.log_fade)
+				profile.chat:enableFading(config.settings.tome.log_fade)
+				self.c_list:drawItem(item)
+			end, 0))
+		end,}
+	end
 
 	local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Configure the chat filters to select what kind of messages to see.#WHITE#"}
 	list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Chat message filters#WHITE##{normal}#", status=function(item)
@@ -226,39 +214,45 @@ function _M:generateList()
 		}))
 	end,}
 
-	local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Uses the icons for status effects instead of text.#WHITE#"}
-	list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Icons status effects#WHITE##{normal}#", status=function(item)
-		return tostring(config.settings.tome.effects_icons and "enabled" or "disabled")
-	end, fct=function(item)
-		config.settings.tome.effects_icons = not config.settings.tome.effects_icons
-		game:saveSettings("tome.effects_icons", ("tome.effects_icons = %s\n"):format(tostring(config.settings.tome.effects_icons)))
-		game.player.changed = true
-		self.c_list:drawItem(item)
-	end,}
-
-	local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Uses the icons hotkeys toolbar or the textual one.#WHITE#"}
-	list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Icons hotkey toolbar#WHITE##{normal}#", status=function(item)
-		return tostring(config.settings.tome.hotkey_icons and "enabled" or "disabled")
-	end, fct=function(item)
-		config.settings.tome.hotkey_icons = not config.settings.tome.hotkey_icons
-		game:saveSettings("tome.hotkey_icons", ("tome.hotkey_icons = %s\n"):format(tostring(config.settings.tome.hotkey_icons)))
-		game.player.changed = true
-		game:resizeIconsHotkeysToolbar()
-		self.c_list:drawItem(item)
-	end,}
+	if game.uiset:checkGameOption("icons_temp_effects") then
+		local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Uses the icons for status effects instead of text.#WHITE#"}
+		list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Icons status effects#WHITE##{normal}#", status=function(item)
+			return tostring(config.settings.tome.effects_icons and "enabled" or "disabled")
+		end, fct=function(item)
+			config.settings.tome.effects_icons = not config.settings.tome.effects_icons
+			game:saveSettings("tome.effects_icons", ("tome.effects_icons = %s\n"):format(tostring(config.settings.tome.effects_icons)))
+			game.player.changed = true
+			self.c_list:drawItem(item)
+		end,}
+	end
 
-	local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Number of rows to show in the icons hotkeys toolbar.#WHITE#"}
-	list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Icons hotkey toolbar rows#WHITE##{normal}#", status=function(item)
-		return tostring(config.settings.tome.hotkey_icons_rows)
-	end, fct=function(item)
-		game:registerDialog(GetQuantity.new("Number of icons rows", "From 1 to 4", config.settings.tome.hotkey_icons_rows, 4, function(qty)
-			qty = util.bound(qty, 1, 4)
-			game:saveSettings("tome.hotkey_icons_rows", ("tome.hotkey_icons_rows = %d\n"):format(qty))
-			config.settings.tome.hotkey_icons_rows = qty
+	if game.uiset:checkGameOption("icons_hotkeys") then
+		local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Uses the icons hotkeys toolbar or the textual one.#WHITE#"}
+		list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Icons hotkey toolbar#WHITE##{normal}#", status=function(item)
+			return tostring(config.settings.tome.hotkey_icons and "enabled" or "disabled")
+		end, fct=function(item)
+			config.settings.tome.hotkey_icons = not config.settings.tome.hotkey_icons
+			game:saveSettings("tome.hotkey_icons", ("tome.hotkey_icons = %s\n"):format(tostring(config.settings.tome.hotkey_icons)))
+			game.player.changed = true
 			game:resizeIconsHotkeysToolbar()
 			self.c_list:drawItem(item)
-		end, 1))
-	end,}
+		end,}
+	end
+
+	if game.uiset:checkGameOption("hotkeys_rows") then
+		local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Number of rows to show in the icons hotkeys toolbar.#WHITE#"}
+		list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Icons hotkey toolbar rows#WHITE##{normal}#", status=function(item)
+			return tostring(config.settings.tome.hotkey_icons_rows)
+		end, fct=function(item)
+			game:registerDialog(GetQuantity.new("Number of icons rows", "From 1 to 4", config.settings.tome.hotkey_icons_rows, 4, function(qty)
+				qty = util.bound(qty, 1, 4)
+				game:saveSettings("tome.hotkey_icons_rows", ("tome.hotkey_icons_rows = %d\n"):format(qty))
+				config.settings.tome.hotkey_icons_rows = qty
+				game:resizeIconsHotkeysToolbar()
+				self.c_list:drawItem(item)
+			end, 1))
+		end,}
+	end
 
 	local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Size of the icons in the hotkeys toolbar.#WHITE#"}
 	list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Icons hotkey toolbar icon size#WHITE##{normal}#", status=function(item)
diff --git a/game/modules/tome/load.lua b/game/modules/tome/load.lua
index c80fba9939..eae921d07a 100644
--- a/game/modules/tome/load.lua
+++ b/game/modules/tome/load.lua
@@ -70,6 +70,7 @@ if type(config.settings.tome.chat_log) == "nil" then config.settings.tome.chat_l
 if type(config.settings.tome.actor_based_movement_mode) == "nil" then config.settings.tome.actor_based_movement_mode = true end
 if not config.settings.tome.fonts then config.settings.tome.fonts = {type="fantasy", size="normal"} end
 if not config.settings.tome.ui_theme2 then config.settings.tome.ui_theme2 = "metal" end
+if not config.settings.tome.uiset_mode then config.settings.tome.uiset_mode = "Minimalist" end
 if not config.settings.tome.log_lines then config.settings.tome.log_lines = 5 end
 if not config.settings.tome.log_fade then config.settings.tome.log_fade = 3 end
 if not config.settings.tome.scroll_dist then config.settings.tome.scroll_dist = 20 end
-- 
GitLab