Skip to content
Snippets Groups Projects
Commit bea5919c authored by dg's avatar dg
Browse files

Add an option to the New Game menu to start older versions of the modules

git-svn-id: http://svn.net-core.org/repos/t-engine4@1468 51575b47-30f0-44d4-a5cc-537603b46e54
parent 8aba9c55
No related branches found
No related tags found
No related merge requests found
......@@ -23,34 +23,20 @@ local Dialog = require "engine.ui.Dialog"
local ListColumns = require "engine.ui.ListColumns"
local Textzone = require "engine.ui.Textzone"
local Separator = require "engine.ui.Separator"
local Button = require "engine.ui.Button"
module(..., package.seeall, class.inherit(Dialog))
function _M:init()
Dialog.init(self, "New Game", game.w, game.h)
local list = Module:listModules()
self.c_desc = Textzone.new{width=math.floor(self.iw / 3 * 2 - 10), height=self.ih, text=""}
self.list = {}
for i = #list, 1, -1 do
local mod = list[i].versions[1]
if not mod.is_boot then
mod.name = "#{bold}##GOLD#"..mod.name.."#{normal}##WHITE#"
mod.fct = function(mod)
game:registerDialog(require('engine.dialogs.GetText').new("Enter your character's name", "Name", 2, 25, function(text)
Module:instanciate(mod, text, true)
end))
end
mod.version_txt = ("%d.%d.%d"):format(mod.version[1], mod.version[2], mod.version[3])
mod.zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text="#{bold}##GOLD#"..mod.long_name.."#WHITE##{normal}#\n\n"..mod.description}
self.c_switch = Button.new{width=math.floor(self.iw / 3 - 40), text="Show all versions", fct=function() self:switchVersions() end}
table.insert(self.list, 1, mod)
end
end
self:generateList()
self.c_list = ListColumns.new{width=math.floor(self.iw / 3 - 10), height=self.ih - 10, scrollbar=true, columns={
self.c_list = ListColumns.new{width=math.floor(self.iw / 3 - 10), height=self.ih - 10 - self.c_switch.h, scrollbar=true, columns={
{name="Game Module", width=80, display_prop="name"},
{name="Version", width=20, display_prop="version_txt"},
}, list=self.list, fct=function(item) end, select=function(item, sel) self:select(item) end}
......@@ -58,6 +44,7 @@ function _M:init()
self:loadUI{
{left=0, top=0, ui=self.c_list},
{right=0, top=0, ui=self.c_desc},
{left=0, bottom=0, ui=self.c_switch},
{left=self.c_list.w + 5, top=5, ui=Separator.new{dir="horizontal", size=self.ih - 10}},
}
self:setFocus(self.c_list)
......@@ -73,3 +60,34 @@ function _M:select(item)
self.uis[2].ui = item.zone
end
end
function _M:generateList()
local list = Module:listModules()
self.list = {}
for i = 1, #list do
for j, mod in ipairs(list[i].versions) do
if not self.all_versions and j > 1 then break end
if not mod.is_boot then
mod.name = "#{bold}##GOLD#"..mod.name.."#{normal}##WHITE#"
mod.fct = function(mod)
game:registerDialog(require('engine.dialogs.GetText').new("Enter your character's name", "Name", 2, 25, function(text)
Module:instanciate(mod, text, true)
end))
end
mod.version_txt = ("%d.%d.%d"):format(mod.version[1], mod.version[2], mod.version[3])
mod.zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text="#{bold}##GOLD#"..mod.long_name.."#WHITE##{normal}#\n\n"..mod.description}
table.insert(self.list, mod)
end
end
end
end
function _M:switchVersions()
self.all_versions = not self.all_versions
self:generateList()
self.c_list.list = self.list
self.c_list:generate()
self.c_switch.text = self.all_versions and "Show only new versions" or "Show all versions"
self.c_switch:generate()
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment