Skip to content

Commit

Permalink
new handler.lua + base LuaIntro enviroment with a few examples
Browse files Browse the repository at this point in the history
new handler.lua is just used for LuaIntro, technically it's ready for LuaUI too
but it would break a few widgets (that did dirty things on the old handler), so I want to give games a bit more time to fix those
  • Loading branch information
jK committed Jul 7, 2013
1 parent 5b894df commit 3b2483a
Show file tree
Hide file tree
Showing 27 changed files with 4,657 additions and 0 deletions.
26 changes: 26 additions & 0 deletions cont/base/springcontent/CMakeLists.txt
Expand Up @@ -154,6 +154,32 @@ set(FILES
LuaGadgets/colors.h.lua
LuaGadgets/setupdefs.lua
LuaGadgets/gadgets.lua
LuaHandler/config.lua
LuaHandler/doc/gpl-2.0.txt
LuaHandler/doc/changelog.txt
LuaHandler/handler.lua
LuaHandler/SystemAddons/watchdog.lua
LuaHandler/Utilities/vector.lua
LuaHandler/Utilities/setupdefs.lua
LuaHandler/Utilities/ctrlpanel.lua
LuaHandler/Utilities/keysym.lua
LuaHandler/Utilities/list.lua
LuaHandler/Utilities/cache.lua
LuaHandler/Utilities/colors.lua
LuaHandler/Utilities/table.lua
LuaHandler/Utilities/savetable.lua
LuaHandler/Utilities/VFS_GetFileChecksum.lua
LuaHandler/Utilities/utils.lua
LuaHandler/Utilities/crashHandler.lua
LuaHandler/Utilities/specialCallinHandlers.lua
LuaHandler/Utilities/actions.lua
LuaHandler/Utilities/addonRevisions.lua
LuaIntro/config.lua
LuaIntro/main.lua
LuaIntro/Addons/bg_logo.lua
LuaIntro/Addons/loadprogress.lua
LuaIntro/Addons/main.lua
LuaIntro/Addons/bg_texture.lua
)

CreateBaseContentArchive("base" "springcontent.sdz" "${FILES}")
Expand Down
38 changes: 38 additions & 0 deletions cont/base/springcontent/LuaHandler/SystemAddons/watchdog.lua
@@ -0,0 +1,38 @@

if addon.InGetInfo then
return {
name = "Watchdog";
desc = "";
version = 0.1;
author = "jK";
date = "2013";
license = "GNU GPL, v2 or later";

layer = math.huge;
hidden = not true; -- don't show in the widget selector
api = true; -- load before all others?

enabled = not true; -- loaded by default?
}
end


local i=0
local function hook(event)
i = i + 1
if ((i % (10^4)) < 1) then
i = 0
Spring.Echo(Spring.GetGameFrame(), event, debug.getinfo(2).name)
Spring.Echo(debug.traceback())
end
end


function addon.Initialize()
debug.sethook(hook,"r",10^100)
end


function addon.Shutdown()
debug.sethook(nil,"r")
end
@@ -0,0 +1,42 @@
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
-- file: VFS_GetFileChecksum.lua
-- brief:
-- author: jK
--
-- Copyright (C) 2007-2013.
-- Licensed under the terms of the GNU GPL, v2 or later.
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

if (not VFS.GetFileChecksum) then
function VFS.GetFileChecksum(file, _VFSMODE)
local data = VFS.LoadFile(file, _VFSMODE)
if (data) then
local datalen = data:len()/4 --// 'x/4' cause we use UnpackU32
local striplength = 2 * 1024 --// 2kB

if (striplength >= datalen) then
local bytes = VFS.UnpackU32(data,nil,datalen)
local checksum = math.bit_xor(0,unpack(bytes))
return checksum
end

--// stack is limited, so split up the data
local start = 1
local crcs = {}
repeat
local strip = data:sub(start,start+striplength)
local bytes = VFS.UnpackU32(strip,nil,strip:len()/4)
local checksum = math.bit_xor(0,unpack(bytes))
crcs[#crcs+1] = checksum
start = start + striplength
until (start >= datalen)

local checksum = math.bit_xor(0,unpack(crcs))
return checksum
end
end
end

4 comments on commit 3b2483a

@abma
Copy link
Contributor

@abma abma commented on 3b2483a Jul 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, we have a progress bar! 👯

@abma
Copy link
Contributor

@abma abma commented on 3b2483a Jul 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can LuaIntro be reused for a custom menu?

thats what the setting "MenuArchive" is meant for, too..

also it seems to use "description" from modinfo.lua, shouldn't it use "name"?

for BA it shows "Moooooo!": http://imolarpg.dyndns.org/trac/balatest/browser/trunk/modinfo.lua
for zk its ok: http://code.google.com/p/zero-k/source/browse/trunk/mods/zk/modinfo.lua

@jk3064
Copy link
Contributor

@jk3064 jk3064 commented on 3b2483a Jul 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| can LuaIntro be reused for a custom menu?
that's why it is named LuaIntro and not LuaLoadscreen
there are no callins for such yet, would need a lot work to get that (first a callout that accepts map & script.txt to start spring similar to Spring.Restart() just w/o restart, new callouts to iterate available maps & ais, and maybe a callout to get the minimap of arbitrary maps).

@jk3064
Copy link
Contributor

@jk3064 jk3064 commented on 3b2483a Jul 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mehhhh
Game.modDesc cause I wanted "Zero-K" without (!) version appendix, engine seems to miss such one then ....

Please sign in to comment.