Find right sized texture
Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
parent
accf495a9e
commit
9764819178
1 changed files with 15 additions and 9 deletions
|
@ -604,16 +604,16 @@ var res2str = func(resolution) {
|
||||||
# than the given limit
|
# than the given limit
|
||||||
var findTexByRes = func(path, file, maxRes) {
|
var findTexByRes = func(path, file, maxRes) {
|
||||||
res = maxRes;
|
res = maxRes;
|
||||||
# TODO fix
|
checkFile = os.path.new(getprop("/sim/aircraft-dir") ~ "/" ~ path);
|
||||||
# os.path: file operation on 'Path "Aircraft/A320-family/Models/Liveries/A320/CFM/4k/SWR-fuselage.png"' access denied (relative paths not accepted; use realpath() to make a path absolute)
|
|
||||||
checkFile = os.path.new(path);
|
|
||||||
while (res >= 1024) {
|
while (res >= 1024) {
|
||||||
checkFile.set(path ~ "/" ~ res2str(res) ~ "/" ~ file);
|
checkFile.set(getprop("/sim/aircraft-dir") ~ "/" ~ path ~ "/" ~ res2str(res) ~ "/" ~ file);
|
||||||
if (checkFile.isFile()) {
|
if (checkFile.isFile()) {
|
||||||
return res2str(res);
|
return res2str(res);
|
||||||
}
|
}
|
||||||
res = res / 2;
|
res = res / 2;
|
||||||
}
|
}
|
||||||
|
print("No suiting texture found");
|
||||||
|
return nil;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -625,12 +625,11 @@ var findTexByRes = func(path, file, maxRes) {
|
||||||
var canvas_livery = {
|
var canvas_livery = {
|
||||||
new: func(liveriesdir, interval = 10.01, callback = nili, resolution=4096) {
|
new: func(liveriesdir, interval = 10.01, callback = nili, resolution=4096) {
|
||||||
var m = { parents: [canvas_livery, overlay_update.new()] };
|
var m = { parents: [canvas_livery, overlay_update.new()] };
|
||||||
m.parents[1].add(liveriesdir, "sim/model/livery/file", callback);
|
m.parents[1].add(getprop("/sim/aircraft-dir") ~ "/" ~ liveriesdir, "sim/model/livery/file", callback);
|
||||||
m.parents[1].interval = interval;
|
m.parents[1].interval = interval;
|
||||||
m.liveriesdir = liveriesdir;
|
m.liveriesdir = liveriesdir;
|
||||||
m.resolution = resolution;
|
m.resolution = resolution;
|
||||||
m.targets = {};
|
m.targets = {};
|
||||||
m.targetsByProperty = {};
|
|
||||||
return m;
|
return m;
|
||||||
},
|
},
|
||||||
stop: func {
|
stop: func {
|
||||||
|
@ -661,11 +660,18 @@ var canvas_livery = {
|
||||||
me.targets[name].canvas.addPlacement({"node": object});
|
me.targets[name].canvas.addPlacement({"node": object});
|
||||||
}
|
}
|
||||||
me.targets[name].groups["base"] = me.targets[name].canvas.createGroup("base");
|
me.targets[name].groups["base"] = me.targets[name].canvas.createGroup("base");
|
||||||
me.targets[name].layers["base"] = me.targets[name].groups["base"].createChild("image").setFile(me.liveriesdir ~ "/" ~ findTexByRes(me.liveriesdir, getprop(property), resolution) ~ "/" ~ getprop(property)).setSize(resolution,resolution);
|
resStr = findTexByRes(me.liveriesdir, getprop(property), resolution);
|
||||||
me.targetsByProperty[property] = name;
|
if (resStr == nil) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
me.targets[name].layers["base"] = me.targets[name].groups["base"].createChild("image").setFile(me.liveriesdir ~ "/" ~ resStr ~ "/" ~ getprop(property)).setSize(resolution,resolution);
|
||||||
me.targets[name].listener = setlistener(property, func(property) {
|
me.targets[name].listener = setlistener(property, func(property) {
|
||||||
|
resStr = findTexByRes(me.liveriesdir, property.getValue(), resolution);
|
||||||
|
if (resStr == nil) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
me.targets[name].groups["base"].removeAllChildren();
|
me.targets[name].groups["base"].removeAllChildren();
|
||||||
me.targets[name].layers["base"] = me.targets[name].groups["base"].createChild("image").setFile(me.liveriesdir ~ "/" ~ findTexByRes(me.liveriesdir, getprop(property), resolution) ~ "/" ~ getprop(property)).setSize(resolution,resolution);
|
me.targets[name].layers["base"] = me.targets[name].groups["base"].createChild("image").setFile(me.liveriesdir ~ "/" ~ resStr ~ "/" ~ property.getValue()).setSize(resolution,resolution);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addLayer: func(target, name, file) {
|
addLayer: func(target, name, file) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue