Skip to content
Snippets Groups Projects
Commit 6f22fa7b authored by echicken's avatar echicken
Browse files

Added method 'Frame.load_bin(contents,width,height,offset)'

Allows loading a whole or partial bin 'graphic' from a string;
decouples bin loading from file reading if desired.
Frame.load() calls Frame.load_bin() in case of a .bin file.
parent 964b7129
No related branches found
No related tags found
No related merge requests found
...@@ -787,9 +787,22 @@ Frame.prototype.load = function(filename,width,height) { ...@@ -787,9 +787,22 @@ Frame.prototype.load = function(filename,width,height) {
} }
break; break;
case "BIN": case "BIN":
if (!this.load_bin(contents, width, height, 0)) return false;
break;
case "TXT":
var lines=contents.split(/\r\n/);
while(lines.length > 0)
this.putmsg(lines.shift() + "\r\n");
break;
default:
throw("unsupported filetype");
break;
}
}
Frame.prototype.load_bin = function(contents, width, height, offset) {
if(width == undefined || height == undefined) if(width == undefined || height == undefined)
throw("unknown graphic dimensions"); throw("unknown graphic dimensions");
var offset = 0; if(offset == undefined) offset = 0;
for(var y=0; y<height; y++) { for(var y=0; y<height; y++) {
for(var x=0; x<width; x++) { for(var x=0; x<width; x++) {
var c = new Char(); var c = new Char();
...@@ -805,16 +818,7 @@ Frame.prototype.load = function(filename,width,height) { ...@@ -805,16 +818,7 @@ Frame.prototype.load = function(filename,width,height) {
this.__properties__.data[y][x] = c; this.__properties__.data[y][x] = c;
} }
} }
break; return true;
case "TXT":
var lines=contents.split(/\r\n/);
while(lines.length > 0)
this.putmsg(lines.shift() + "\r\n");
break;
default:
throw("unsupported filetype");
break;
}
} }
Frame.prototype.scroll = function(x,y) { Frame.prototype.scroll = function(x,y) {
var update = false; var update = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment