Browse Source

use entry.getText() when possible

Nicolas Cannasse 3 years ago
parent
commit
437697b084
4 changed files with 8 additions and 7 deletions
  1. 1 1
      hxd/res/Any.hx
  2. 1 1
      hxd/res/Atlas.hx
  3. 5 4
      hxd/res/BDFFont.hx
  4. 1 1
      hxd/res/TiledMap.hx

+ 1 - 1
hxd/res/Any.hx

@@ -40,7 +40,7 @@ class Any extends Resource {
 	}
 
 	public function toText() {
-		return entry.getBytes().toString();
+		return entry.getText();
 	}
 
 	public function toImage() {

+ 1 - 1
hxd/res/Atlas.hx

@@ -53,7 +53,7 @@ class Atlas extends Resource {
 			return contents;
 
 		contents = new Map();
-		var lines = entry.getBytes().toString().split("\n");
+		var lines = entry.getText().split("\n");
 
 		var basePath = entry.path.split("/");
 		basePath.pop();

+ 5 - 4
hxd/res/BDFFont.hx

@@ -58,14 +58,15 @@ class BDFFont extends Resource {
 		if ( font != null ) return font;
 
 		// File starts with STARTFONT
-		if ( (entry.getBytes().getInt32(0) != 0x52415453) || (entry.getBytes().getInt32(8) != 0x2E322054) )
+		var text = entry.getText();
+		if( !StringTools.startsWith(text,"STARTFONT") )
 			throw 'File does not appear to be a BDF file. Expecting STARTFONT';
 
 		// Init empty font
 		font = new h2d.Font( null, 0 );
 
 		// Break file into lines
-		var lines = entry.getBytes().toString().split("\n");
+		var lines = text.split("\n");
 		var linenum = 0;
 
 		// Parse the header
@@ -356,7 +357,7 @@ class BDFFont extends Resource {
 			if ( a == null )
 				font.lineHeight = font.size * 2;
 			else
-				font.lineHeight = a.t.height * 2; 
+				font.lineHeight = a.t.height * 2;
 		}
 
 		// Estimate a baseline
@@ -388,7 +389,7 @@ class BDFFont extends Resource {
 	/**
 	 * Each line of the BDF file is split by spaces into an Array. Sometimes the
 	 * line is actually a string and shouldn't be split. This method detects that
-	 * by checking for "quote marks" and joining the string back up. 
+	 * by checking for "quote marks" and joining the string back up.
 	 * @param p The split line
 	 * @return String The resulting string
 	 */

+ 1 - 1
hxd/res/TiledMap.hx

@@ -21,7 +21,7 @@ typedef TiledMapData = {
 class TiledMap extends Resource {
 
 	public function toMap() : TiledMapData {
-		var data = entry.getBytes().toString();
+		var data = entry.getText();
 		var base = new haxe.crypto.BaseCode(haxe.io.Bytes.ofString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"));
 		var x = new Access(Xml.parse(data).firstElement());
 		var layers = [];