2009-09-20 13:21:11 +03:00
|
|
|
game.hinting = true;
|
|
|
|
game.showlast = true;
|
|
|
|
|
|
|
|
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-01-25 16:53:33 +02:00
|
|
|
if not isObject(o) or isStatus(o) or not o.id then
|
|
|
|
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
|
|
|
|
cmd = 'use ';
|
|
|
|
end
|
2010-06-16 22:31:15 +03:00
|
|
|
return stead.cat('<a:'..cmd..'0'..tostring(o.id)..'>',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;
|
|
|
|
|
|
|
|
iface.inv = function(self, str)
|
|
|
|
if str then
|
2010-02-19 22:22:20 +02:00
|
|
|
str = stead.string.gsub(str,'\\,','<,>');
|
|
|
|
str = stead.string.gsub(str,',','^');
|
|
|
|
str = stead.string.gsub(str,'<,>',',');
|
2009-09-20 13:21:11 +03:00
|
|
|
end
|
|
|
|
return str
|
|
|
|
end;
|
|
|
|
|
|
|
|
iface.ways = function(self, str)
|
|
|
|
if str then
|
2010-02-19 22:22:20 +02:00
|
|
|
str = stead.string.gsub(str,'\\,','<,>');
|
|
|
|
str = stead.string.gsub(str,',',' | ');
|
|
|
|
str = stead.string.gsub(str,'<,>',',');
|
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-02-16 20:05:36 +02:00
|
|
|
function get_title()
|
|
|
|
local s = call(here(), 'nam');
|
|
|
|
return stead.string.gsub(s, '\\,',',');
|
|
|
|
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-06-22 14:04:12 +03:00
|
|
|
error ("Menu "..name.." can not be saved!");
|
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
|