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

update

git-svn-id: http://svn.net-core.org/repos/t-engine4@1466 51575b47-30f0-44d4-a5cc-537603b46e54
parent 67095626
No related branches found
No related tags found
No related merge requests found
......@@ -359,72 +359,6 @@ function _M:checkFirstTime()
end
end
function _M:selectStepInstall()
local linda, th = Module:loadRemoteList()
local rawdllist = linda:receive("moduleslist")
th:join()
local dllist = {}
for i, mod in ipairs(rawdllist) do
if not self.mod_list[mod.short_name] then
dllist[#dllist+1] = mod
else
local lmod = self.mod_list[mod.short_name]
if mod.version[1] * 1000000 + mod.version[2] * 1000 + mod.version[3] > lmod.version[1] * 1000000 + lmod.version[2] * 1000 + lmod.version[3] then
dllist[#dllist+1] = mod
end
end
end
if #dllist == 0 then
Dialog:simplePopup("No modules available", "There are no modules to install or upgrade.")
return
end
local display_module = Dialog.new("", self.w * 0.73, self.h, self.w * 0.26, 0, 255)
for i, mod in ipairs(dllist) do
mod.fct = function()
local d = DownloadDialog.new("Downloading: "..mod.long_name, mod.download, function(di, data)
fs.mkdir("/modules")
local f = fs.open("/modules/"..mod.short_name..".team", "w")
for i, v in ipairs(data) do f:write(v) end
f:close()
-- Relist modules and savefiles
self.mod_list = Module:listModules()
self.save_list = Module:listSavefiles()
if self.mod_list[mod.short_name] then
Dialog:simplePopup("Success!", "Your new game is now installed, you can play!", function() self:unregisterDialog(display_module) self:selectStepMain() end)
else
Dialog:simplePopup("Error!", "The downloaded game does not seem to respond to the test. Please contact contact@te4.org")
end
end)
self:registerDialog(d)
d:startDownload()
end
mod.onSelect = function()
display_module.title = mod.long_name
display_module.changed = true
end
end
display_module.drawDialog = function(self, s)
local lines = dllist[game.step.selected].description:splitLines(self.w - 8, self.font)
local r, g, b
for i = 1, #lines do
r, g, b = s:drawColorStringBlended(self.font, lines[i], 0, i * self.font:lineSkip(), r, g, b)
end
end
self:registerDialog(display_module)
self.step = ButtonList.new(dllist, 10, 10, self.w * 0.24, (5 + 35) * #dllist, nil, 5)
self.step:setKeyHandling()
self.step:setMouseHandling()
self.step.key:addBind("EXIT", function() self:unregisterDialog(display_module) self:selectStepMain() end)
end
function _M:createProfile(loginItem)
if self.justlogin then
profile:performlogin(loginItem.login, loginItem.pass)
......@@ -441,24 +375,4 @@ function _M:createProfile(loginItem)
else
Dialog:simplePopup("Profile Failed to authenticate!", "Try logging in in a few moments", function() end )
end
end
function _M:installNewEngine()
local eversion = self.latest_engine_version
if not eversion then return end
print("te4.org told us latest engine is", eversion[4], eversion[5], eversion[1], eversion[2], eversion[3])
if engine.version_check(eversion) == "newer" then
local url = ("http://te4.org/dl/engines/%s_%d:%d.%d.%d.teae"):format(eversion[4], eversion[5], eversion[1], eversion[2], eversion[3])
local d = DownloadDialog.new(("Downloading: T-Engine 4 %d.%d.%d"):format(eversion[1], eversion[2], eversion[3]), url, function(di, data)
fs.mkdir("/engines")
local f = fs.open(("/engines/%s-%d_%d.%d.%d.teae"):format(eversion[4], eversion[5], eversion[1], eversion[2], eversion[3]), "w")
for i, v in ipairs(data) do f:write(v) end
f:close()
Dialog:simplePopup("Success!", "The new engine is installed, it will now restart using it.", function() util.showMainMenu() end)
end)
self:registerDialog(d)
d:startDownload()
end
end
......@@ -34,6 +34,7 @@ function _M:init()
{name="Load Game", fct=function() game:registerDialog(require("mod.dialogs.LoadGame").new()) end},
{name="Player Profile", fct=function() game:registerDialog(require("mod.dialogs.Profile").new()) end},
-- {name="Install Module", fct=function() end},
{name="Update", fct=function() game:registerDialog(require("mod.dialogs.UpdateAll").new()) end},
{name="Options", fct=function()
local menu menu = require("engine.dialogs.GameMenu").new{
"resume",
......
-- TE4 - T-Engine 4
-- Copyright (C) 2009, 2010 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
require "engine.class"
local Module = require "engine.Module"
local Dialog = require "engine.ui.Dialog"
local ListColumns = require "engine.ui.ListColumns"
local Textzone = require "engine.ui.Textzone"
local Button = require "engine.ui.Button"
local DownloadDialog = require "engine.dialogs.DownloadDialog"
module(..., package.seeall, class.inherit(Dialog))
function _M:init()
Dialog.init(self, "Update all modules", game.w / 3, game.h * 0.5)
self:generateList()
self.c_desc = Textzone.new{width=self.iw, auto_height=1, text=[[
All those components will be updated:
]]}
self.c_list = ListColumns.new{width=self.iw, height=self.ih - self.c_desc.h, scrollbar=true, columns={
{name="Compoment", width=80, display_prop="name"},
{name="Version", width=20, display_prop="version_string"},
}, list=self.list, fct=function(item) end, select=function(item, sel) end}
self.c_ok = Button.new{width=self.iw - 20, text="Update All", fct=function() self:updateAll() end}
self:loadUI{
{left=0, top=0, ui=self.c_desc},
{left=0, top=self.c_desc.h, ui=self.c_list},
{left=0, bottom=0, ui=self.c_ok},
}
self:setFocus(self.c_list)
self:setupUI(false, true)
self.key:addBinds{
EXIT = function() game:unregisterDialog(self) end,
}
end
function _M:generateList()
local linda, th = Module:loadRemoteList()
local rawdllist = linda:receive("moduleslist")
th:join()
local dllist = {}
for i, mod in ipairs(rawdllist) do
if game.mod_list[mod.short_name] then
local lmod = game.mod_list[mod.short_name]
if mod.version[1] * 1000000 + mod.version[2] * 1000 + mod.version[3] > lmod.version[1] * 1000000 + lmod.version[2] * 1000 + lmod.version[3] then
dllist[#dllist+1] = mod
end
end
end
if #dllist == 0 then
Dialog:simplePopup("No modules available", "There are no modules to install or upgrade.")
return
end
local engs = {}
local list = {}
for i, mod in ipairs(dllist) do
list[#list+1] = { name="Game: #{bold}##GOLD#"..mod.name.."#{normal}##WHITE#", mod=mod, version_string=("%d.%d.%d"):format(mod.version[1], mod.version[2], mod.version[3]) }
-- Check for the required engine
local ename, ev1, ev2, ev3 = mod.engine[4] or "te4", mod.engine[1], mod.engine[2], mod.engine[3]
local efound = false
for i, eng in ipairs(__available_engines[ename]) do
if eng[1] == ev1 and eng[2] == ev2 and eng[3] == ev3 then
efound = true
break
end
end
if efound then
print(" * require installed engine", ename, ev1, ev2, ev3)
else
print(" * require download engine", ename, ev1, ev2, ev3)
engs[("%s:%d.%d.%d"):format(ename, ev1, ev2, ev3)] = {ev1, ev2, ev3, ename}
end
end
for name, eng in pairs(engs) do
list[#list+1] = { name="Engine: #{italic}##LIGHT_BLUE#"..eng[4].."#{normal}##WHITE#", eng=eng, version_string=("%d.%d.%d"):format(eng[1], eng[2], eng[3]) }
end
self.list = list
end
function _M:updateAll()
local do_next, done
local files = {}
local restore = fs.getWritePath()
fs.setWritePath(engine.homepath)
do_next = function()
local next = table.remove(self.list, 1)
if not next then done() return end
if next.eng then
local eversion = next.eng
local url = ("http://te4.org/dl/engines/%s-%d_%d.%d.%d.teae"):format(eversion[4], eversion[5] or 5, eversion[1], eversion[2], eversion[3])
local d = DownloadDialog.new(("Downloading engine: %s"):format(next.name), url, function(di, data)
fs.mkdir("/tmp-dl/engines")
local fname = ("/tmp-dl/engines/%s-%d_%d.%d.%d.teae"):format(eversion[4], eversion[5] or 5, eversion[1], eversion[2], eversion[3])
files[#files+1] = fname
local f = fs.open(fname, "w")
for i, v in ipairs(data) do f:write(v) end
f:close()
do_next()
end)
game:registerDialog(d)
d:startDownload()
elseif next.mod then
local mod = next.mod
local d = DownloadDialog.new("Downloading game: "..next.name, mod.download, function(di, data)
fs.mkdir("/tmp-dl/modules")
local fname = ("/tmp-dl/modules/%s-%d.%d.%d.team"):format(mod.short_name, mod.version[1], mod.version[2], mod.version[3])
files[#files+1] = fname
local f = fs.open(fname, "w")
for i, v in ipairs(data) do f:write(v) end
f:close()
do_next()
end)
game:registerDialog(d)
d:startDownload()
end
end
done = function()
for i, file in ipairs(files) do
local real = file:gsub("^/tmp%-dl/", "/")
print("Installing", file, "=>", real)
fs.rename(file, real)
end
if restore then fs.setWritePath(restore) end
Dialog:simplePopup("Update", "All update installed, the game will now restart", function()
util.showMainMenu()
end)
end
do_next()
end
......@@ -64,6 +64,8 @@ local load load = function(...)
end
end
__available_engines = engines
local use_engine = nil
if req_version == "LATEST" then
-- Sort engines
......
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