2009-09-20 13:21:11 +03:00
|
|
|
game.hinting = true;
|
|
|
|
game.showlast = true;
|
2010-09-21 16:55:03 +03:00
|
|
|
|
|
|
|
game.gui = {
|
|
|
|
fading = 4;
|
|
|
|
ways_delim = ' | ';
|
|
|
|
inv_delim = '\n';
|
|
|
|
hinv_delim = ' | ';
|
|
|
|
}
|
2009-09-20 13:21:11 +03:00
|
|
|
|
2010-06-24 12:33:59 +03:00
|
|
|
iface.xref = function(self, str, obj, ...)
|
2010-01-25 16:53:33 +02:00
|
|
|
local o = ref(obj);
|
|
|
|
local cmd=''
|
2009-10-06 21:22:52 +03:00
|
|
|
|
2010-09-16 12:09:02 +03:00
|
|
|
if not isObject(o) or isStatus(o) or (not o.id and not isXaction(o)) then
|
2010-01-25 16:53:33 +02:00
|
|
|
return str;
|
|
|
|
end
|
2009-10-06 21:22:52 +03:00
|
|
|
|
2010-01-25 16:53:33 +02:00
|
|
|
if ref(ways():srch(obj)) then
|
|
|
|
cmd = 'go ';
|
|
|
|
elseif isMenu(o) then
|
|
|
|
cmd = 'act ';
|
|
|
|
elseif isSceneUse(o) then
|
2010-09-16 12:09:02 +03:00
|
|
|
cmd = 'use ';
|
|
|
|
elseif isXaction(o) then
|
|
|
|
cmd = 'act ';
|
2010-01-25 16:53:33 +02:00
|
|
|
end
|
2010-06-24 12:33:59 +03:00
|
|
|
local a = ''
|
|
|
|
local i
|
|
|
|
for i = 1, stead.table.maxn(arg) do
|
|
|
|
a = a..','..arg[i]
|
|
|
|
end
|
2010-09-16 12:09:02 +03:00
|
|
|
if isXaction(o) and not o.id then
|
|
|
|
return stead.cat('<a:'..cmd..deref(obj)..a..'>',str,'</a>');
|
|
|
|
end
|
2010-06-24 12:33:59 +03:00
|
|
|
return stead.cat('<a:'..cmd..'0'..tostring(o.id)..a..'>',str,'</a>');
|
2009-09-20 13:21:11 +03:00
|
|
|
end;
|
|
|
|
|
2010-01-26 11:25:01 +02:00
|
|
|
iface.enum = function(self, n, str)
|
|
|
|
if str == nil or n == nil then return nil; end;
|
|
|
|
return n..self:nb(' - ')..str;
|
|
|
|
end
|
|
|
|
|
2009-09-20 13:21:11 +03:00
|
|
|
iface.title = function(self, str)
|
2010-01-25 16:53:33 +02:00
|
|
|
return nil
|
|
|
|
end;
|
|
|
|
|
|
|
|
iface.img = function(self, str)
|
|
|
|
if str == nil then return nil; end;
|
|
|
|
return "<g:"..str..">";
|
|
|
|
end;
|
|
|
|
|
|
|
|
iface.nb = function(self, str)
|
|
|
|
if str == nil then return nil; end;
|
2010-06-16 11:36:19 +03:00
|
|
|
if str == '' then return ''; end
|
2010-01-25 16:53:33 +02:00
|
|
|
return "<w:"..str..">";
|
2009-09-20 13:21:11 +03:00
|
|
|
end;
|
|
|
|
|
|
|
|
iface.under = function(self, str)
|
2010-01-25 16:53:33 +02:00
|
|
|
if str == nil then return nil; end;
|
2010-06-16 22:31:15 +03:00
|
|
|
return stead.cat('<u>',str,'</u>');
|
2009-09-20 13:21:11 +03:00
|
|
|
end;
|
|
|
|
|
|
|
|
iface.em = function(self, str)
|
2010-01-25 16:53:33 +02:00
|
|
|
if str == nil then return nil; end;
|
2010-06-16 22:31:15 +03:00
|
|
|
return stead.cat('<i>',str,'</i>');
|
2009-09-20 13:21:11 +03:00
|
|
|
end;
|
|
|
|
|
|
|
|
iface.right = function(self, str)
|
2010-01-25 16:53:33 +02:00
|
|
|
if str == nil then return nil; end;
|
2010-06-16 22:31:15 +03:00
|
|
|
return stead.cat('<r>',str,'</r>');
|
2009-09-20 13:21:11 +03:00
|
|
|
end;
|
|
|
|
|
|
|
|
iface.left = function(self, str)
|
2010-01-25 16:53:33 +02:00
|
|
|
if str == nil then return nil; end;
|
2010-06-16 22:31:15 +03:00
|
|
|
return stead.cat('<l>',str,'</l>');
|
2009-09-20 13:21:11 +03:00
|
|
|
end;
|
|
|
|
|
|
|
|
iface.center = function(self, str)
|
2010-01-25 16:53:33 +02:00
|
|
|
if str == nil then return nil; end;
|
2010-06-16 22:31:15 +03:00
|
|
|
return stead.cat('<c>',str,'</c>');
|
2009-09-20 13:21:11 +03:00
|
|
|
end;
|
|
|
|
|
|
|
|
iface.bold = function(self, str)
|
2010-01-25 16:53:33 +02:00
|
|
|
if str == nil then return nil; end;
|
2010-06-16 22:31:15 +03:00
|
|
|
return stead.cat('<b>',str,'</b>');
|
2009-09-20 13:21:11 +03:00
|
|
|
end;
|
|
|
|
|
2010-09-02 11:03:06 +03:00
|
|
|
iface.top = function(self, str)
|
|
|
|
if str == nil then return nil; end;
|
|
|
|
return stead.cat('<t>',str,'</t>');
|
|
|
|
end;
|
|
|
|
|
|
|
|
iface.bottom = function(self, str)
|
|
|
|
if str == nil then return nil; end;
|
|
|
|
return stead.cat('<d>',str,'</d>');
|
|
|
|
end;
|
|
|
|
|
|
|
|
iface.middle = function(self, str)
|
|
|
|
if str == nil then return nil; end;
|
|
|
|
return stead.cat('<m>',str,'</m>');
|
|
|
|
end;
|
|
|
|
|
2009-09-20 13:21:11 +03:00
|
|
|
iface.inv = function(self, str)
|
|
|
|
return str
|
|
|
|
end;
|
|
|
|
|
|
|
|
iface.ways = function(self, str)
|
|
|
|
if str then
|
2010-07-26 09:55:56 +03:00
|
|
|
str = stead.string.gsub(str, '\\'..stead.delim, '<&delim;>');
|
2010-09-21 16:55:03 +03:00
|
|
|
str = stead.string.gsub(str, stead.delim, game.gui.ways_delim);
|
2010-07-26 09:55:56 +03:00
|
|
|
str = stead.string.gsub(str, '<&delim;>', stead.delim);
|
2010-02-16 20:00:45 +02:00
|
|
|
return '<c>'..str..'</c>';
|
2009-09-20 13:21:11 +03:00
|
|
|
end
|
|
|
|
return str
|
|
|
|
end;
|
|
|
|
|
2010-09-21 16:55:03 +03:00
|
|
|
function normalize_inv(str, horiz)
|
|
|
|
str = stead.string.gsub(str, '\\'..stead.delim, '<&delim;>'):gsub(stead.delim..'$', '')
|
|
|
|
if not horiz then
|
|
|
|
str = stead.string.gsub(str, stead.delim, game.gui.inv_delim);
|
|
|
|
else
|
|
|
|
str = stead.string.gsub(str, stead.delim, game.gui.hinv_delim);
|
|
|
|
end
|
|
|
|
str = stead.string.gsub(str, '<&delim;>', stead.delim);
|
|
|
|
return str
|
|
|
|
end
|
|
|
|
|
2010-02-16 20:05:36 +02:00
|
|
|
function get_title()
|
2010-08-31 19:48:22 +03:00
|
|
|
local s
|
|
|
|
if stead.api_version >= "1.2.0" then
|
|
|
|
s = call(here(), 'disp');
|
|
|
|
end
|
|
|
|
if type(s) ~= 'string' then
|
|
|
|
s = call(here(), 'nam');
|
|
|
|
end
|
2010-07-08 20:54:29 +03:00
|
|
|
if type(s) == 'string' then
|
2010-07-26 09:55:56 +03:00
|
|
|
s = stead.string.gsub(s, '\\'..stead.delim, stead.delim);
|
2010-07-08 20:54:29 +03:00
|
|
|
end
|
|
|
|
return s
|
2010-02-16 20:05:36 +02:00
|
|
|
end
|
|
|
|
|
2009-09-20 13:21:11 +03:00
|
|
|
-- here is gui staff only
|
|
|
|
function stat(v)
|
|
|
|
v.status_type = true
|
|
|
|
return obj(v);
|
|
|
|
end
|
|
|
|
|
|
|
|
function isStatus(v)
|
|
|
|
if type(v) ~= 'table' then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
if v.status_type then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
function menu_save(self, name, h, need)
|
|
|
|
local dsc;
|
|
|
|
if need then
|
2010-07-03 15:38:27 +03:00
|
|
|
print ("Warning: menu "..name.." can not be saved!");
|
|
|
|
return
|
2009-09-20 13:21:11 +03:00
|
|
|
end
|
|
|
|
savemembers(h, self, name, need);
|
|
|
|
end
|
|
|
|
|
2009-09-25 11:21:58 +03:00
|
|
|
MENU_TAG_ID = 10000
|
|
|
|
|
2009-09-20 13:21:11 +03:00
|
|
|
function menu(v)
|
|
|
|
v.menu_type = true
|
2009-09-20 13:37:00 +03:00
|
|
|
if v.inv == nil then
|
|
|
|
v.inv = function(s)
|
2010-06-05 18:02:10 +03:00
|
|
|
local r,v
|
|
|
|
r,v = call(s, 'menu');
|
|
|
|
if v == nil then v = true end
|
2009-09-25 12:00:15 +03:00
|
|
|
if r == nil then
|
|
|
|
obj_tag(me(), MENU_TAG_ID); -- retag menu field
|
|
|
|
end
|
2010-06-05 18:02:10 +03:00
|
|
|
return r, v
|
2009-09-20 13:37:00 +03:00
|
|
|
end
|
|
|
|
end
|
2009-10-02 22:04:34 +03:00
|
|
|
if v.act == nil then
|
|
|
|
v.act = function(s)
|
2010-06-05 18:02:10 +03:00
|
|
|
local r,v
|
|
|
|
r,v = call(s, 'menu');
|
|
|
|
if v == nil then v = true end
|
2009-10-02 22:04:34 +03:00
|
|
|
if r == nil then
|
|
|
|
obj_tag(me(), MENU_TAG_ID); -- retag menu field
|
|
|
|
end
|
2010-06-05 18:02:10 +03:00
|
|
|
return r, v
|
2009-10-02 22:04:34 +03:00
|
|
|
end
|
|
|
|
end
|
2009-09-20 13:21:11 +03:00
|
|
|
if v.save == nil then
|
|
|
|
v.save = menu_save;
|
|
|
|
end
|
|
|
|
return obj(v);
|
|
|
|
end
|
|
|
|
|
|
|
|
function isMenu(v)
|
|
|
|
if type(v) ~= 'table' then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
if v.menu_type then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
2009-10-15 10:06:45 +03:00
|
|
|
|
2010-06-16 22:31:15 +03:00
|
|
|
fmt = function(...)
|
2010-06-16 21:29:11 +03:00
|
|
|
local i, res
|
|
|
|
if arg == nil then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
for i=1,stead.table.maxn(arg) do
|
|
|
|
if type(arg[i]) == 'string' then
|
2010-06-22 13:03:24 +03:00
|
|
|
local s = stead.string.gsub(arg[i],'\t', ' '):gsub('[\n]+', ' '):gsub('%^','\n');
|
2010-06-21 22:33:38 +03:00
|
|
|
res = stead.par('', res, s);
|
2010-06-16 21:29:11 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return res
|
|
|
|
end
|
2010-06-16 22:31:15 +03:00
|
|
|
|
|
|
|
stead.fmt = fmt
|
2010-07-06 13:15:27 +03:00
|
|
|
|
2010-07-10 09:39:29 +03:00
|
|
|
game.fading = function(s)
|
|
|
|
local rc = false
|
2010-07-11 13:20:04 +03:00
|
|
|
local p = call(here(), 'pic');
|
2010-07-10 09:39:29 +03:00
|
|
|
if stead.cmd == 'load' then
|
2010-07-11 13:20:04 +03:00
|
|
|
game.lastpic = p;
|
2010-07-10 09:39:29 +03:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
if not stead.state then --only for states!!!
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
if game._time == 1 then -- first cmd
|
2010-08-28 18:48:17 +03:00
|
|
|
game.lastpic = p;
|
2010-07-10 09:39:29 +03:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
if PLAYER_MOVED or game.lastpic ~= p then
|
|
|
|
rc = true
|
|
|
|
end
|
|
|
|
game.lastpic = p
|
|
|
|
return rc
|
|
|
|
end
|
|
|
|
|
|
|
|
function isFading() --to check fading from sdl gui
|
|
|
|
local r,g,v
|
|
|
|
local h = here()
|
|
|
|
if not isRoom(h) then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
r,v = call_bool(h, 'fading');
|
|
|
|
if r then
|
|
|
|
return true, v
|
|
|
|
end
|
|
|
|
g,v = call_bool(game, 'fading', h);
|
|
|
|
return g and r ~= false, v
|
|
|
|
end
|
|
|
|
|
|
|
|
function get_fading()
|
|
|
|
local r, v
|
|
|
|
r, v = isFading()
|
|
|
|
if v == nil then v = game.gui.fading end
|
|
|
|
return r,v
|
|
|
|
end
|
2010-07-06 13:15:27 +03:00
|
|
|
-- vim:ts=4
|