logic over disabled objs

This commit is contained in:
p.kosyh 2010-06-14 08:10:59 +00:00
parent fa1bcc8133
commit d2c2d63a5b
2 changed files with 61 additions and 11 deletions

4
debian/changelog vendored
View file

@ -4,6 +4,7 @@ instead (1.2.0) unstable; urgency=low
* browse feature (win32 and gtk); * browse feature (win32 and gtk);
* clever game/themes sorting; * clever game/themes sorting;
* remove games; * remove games;
* aligned width for themes/games dialog;
* local appdata mode (portable app); * local appdata mode (portable app);
* prefs object; * prefs object;
* init() function; * init() function;
@ -12,10 +13,11 @@ instead (1.2.0) unstable; urgency=low
* entered/left human friendly actions; * entered/left human friendly actions;
* stead.cmd, stead.args added; * stead.cmd, stead.args added;
* require added (modules: goto, xobj, input, click); * require added (modules: goto, xobj, input, click);
* aligned width for themes/games dialog;
* time of save slots; * time of save slots;
* check_version added; * check_version added;
* taketo/takef added; * taketo/takef added;
* disable/enable/disable_all/enable_all added;
* exist() added (seen over disabled objects);
* many small bugfixes... * many small bugfixes...
-- Peter Kosyh <p.kosyh@gmail.com> Tue, 01 Jun 2010 17:40:00 +0300 -- Peter Kosyh <p.kosyh@gmail.com> Tue, 01 Jun 2010 17:40:00 +0300

View file

@ -544,29 +544,31 @@ function list_name(self, name)
end end
return nil return nil
end end
function list_id(self, id) function list_id(self, id, dis)
local n,o,ii local n,o,ii
for n,o,ii in opairs(self) do for n,o,ii in opairs(self) do
o = ref(o); o = ref(o);
if isObject(o) and not isDisabled(o) and id == o.id then if dis or not isDisabled(o) then
return ii; if isObject(o) and id == o.id then
return ii;
end
end end
end end
end end
function list_search(self, n) function list_search(self, n, dis)
local i; local i;
i = self:look(n); i = self:look(n);
if not i then if not i then
i = self:name(n); i = self:name(n);
end end
if not i and tonumber(n) then if not i and tonumber(n) then
i = self:byid(tonumber(n)); i = self:byid(tonumber(n), dis);
if not i then if not i then
return nil return nil
end end
end end
if isDisabled(ref(self[i])) then if not dis and isDisabled(ref(self[i])) then
return nil; return nil;
end end
return self[i], i; return self[i], i;
@ -696,20 +698,20 @@ function room_look(self)
return cat(vv,' '); return cat(vv,' ');
end end
function obj_search(v, n) function obj_search(v, n, dis)
local i; local i;
local o; local o;
if isDisabled(v) then if not dis and isDisabled(v) then
return return
end end
o = v.obj:srch(n); o = v.obj:srch(n, dis);
if o then if o then
return o, v; return o, v;
end end
for i,o in opairs(v.obj) do for i,o in opairs(v.obj) do
o = ref(o); o = ref(o);
if isObject(o) then if isObject(o) then
local r,rr = obj_search(o, n); local r,rr = obj_search(o, n, dis);
if r then if r then
return r, rr; return r, rr;
end end
@ -2146,6 +2148,20 @@ function seen(obj, wh)
return nil return nil
end end
function exist(obj, wh)
if not wh then
wh = here();
else
wh = ref(wh);
end
local o,w = wh:srch(obj, true);
o = ref(o);
if isObject(o) then
return o,w
end
return nil
end
function have(obj) function have(obj)
local o = inv():srch(obj); local o = inv():srch(obj);
o = ref(o); o = ref(o);
@ -2289,6 +2305,38 @@ function disabled(o)
return isDisabled(ref(o)) return isDisabled(ref(o))
end end
function disable(o)
o = ref(o)
if isObject(o) then
o:disable()
end
return o
end
function enable(o)
o = ref(o)
if isObject(o) then
o:enable()
end
return o
end
function disable_all(o)
o = ref(o)
if isObject(o) then
o:disable_all()
end
return o
end
function enable_all(o)
o = ref(o)
if isObject(o) then
o:enable_all()
end
return o
end
function isForSave(k, v, s) -- k - key, v - value, s -- parent table function isForSave(k, v, s) -- k - key, v - value, s -- parent table
return stead.string.find(k, '_') == 1 or stead.string.match(k,'^%u') return stead.string.find(k, '_') == 1 or stead.string.match(k,'^%u')
end end