delete trash code

This commit is contained in:
2025-04-10 04:33:28 +02:00
parent 27c5503173
commit f4bbbb9454
6 changed files with 240 additions and 756 deletions
+5 -102
View File
@@ -1,12 +1,8 @@
package;
import openfl.utils.AssetType;
import openfl.display.Sprite;
import openfl.events.Event;
import openfl.Assets;
import openfl.display.Bitmap;
import openfl.display.BitmapData;
import openfl.text.TextField;
import openfl.text.TextFormat;
class Main extends Sprite {
public function new() {
@@ -16,102 +12,9 @@ class Main extends Sprite {
graphics.beginFill(0x3498db, 1);
graphics.drawRect(0, 0, 800, 600);
graphics.endFill();
// Create title
var title = new TextField();
title.defaultTextFormat = new TextFormat("Arial", 24, 0xFFFFFF, true);
title.text = "OpenFL Asset Test";
title.width = 400;
title.x = 20;
title.y = 20;
addChild(title);
// Display info about available assets
displayAssetInfo();
// Try to load and display a text asset
loadTextAsset();
// Debug manifest content
debugManifestInfo();
}
private function displayAssetInfo():Void {
var info = new TextField();
info.defaultTextFormat = new TextFormat("Arial", 16, 0xFFFFFF);
info.width = 760;
info.height = 300;
info.x = 20;
info.y = 60;
info.multiline = true;
info.wordWrap = true;
var assetList = openfl.Assets.list();
info.text = "Available Assets (" + assetList.length + "):\n";
for (asset in assetList) {
var extension = asset.substr(asset.lastIndexOf(".") + 1).toLowerCase();
var typeStr = getAssetTypeFromExtension(extension);
info.text += " " + asset + " [" + typeStr + "]\n";
}
addChild(info);
}
private function getAssetTypeFromExtension(extension:String):String {
return switch(extension) {
case "jpg", "jpeg", "png", "gif", "bmp": "IMAGE";
case "mp3", "ogg", "wav": "SOUND";
case "ttf", "otf": "FONT";
case "txt", "json", "xml", "csv", "tsv": "TEXT";
default: "BINARY";
};
}
private function loadTextAsset():Void {
var textDisplay = new TextField();
textDisplay.defaultTextFormat = new TextFormat("Arial", 14, 0xFFFFFF);
textDisplay.width = 760;
textDisplay.height = 200;
textDisplay.x = 20;
textDisplay.y = 380;
textDisplay.multiline = true;
textDisplay.wordWrap = true;
textDisplay.border = true;
textDisplay.borderColor = 0xFFFFFF;
textDisplay.background = true;
textDisplay.backgroundColor = 0x333333;
var textPath = "data/img/placeholder.txt";
if (Assets.exists(textPath)) {
// Synchronous loading
var content = Assets.getText(textPath);
textDisplay.text = "Loaded text content from '" + textPath + "':\n\n" + content;
} else {
// Try alternative paths
var altPath = "assets/data/img/placeholder.txt";
if (Assets.exists(altPath)) {
var content = Assets.getText(altPath);
textDisplay.text = "Loaded text content from '" + altPath + "':\n\n" + content;
} else {
textDisplay.text = "Could not find text asset '" + textPath + "' or '" + altPath + "'";
}
}
addChild(textDisplay);
}
private function debugManifestInfo():Void {
var debug = new TextField();
debug.defaultTextFormat = new TextFormat("Arial", 12, 0xFF0000);
debug.width = 760;
debug.height = 100;
debug.x = 20;
debug.y = 540;
debug.multiline = true;
debug.wordWrap = true;
debug.text = Assets.debugManifest();
addChild(debug);
var testAsset = Assets.getText("assets/data/img/placeholder.txt");
trace(testAsset);
}
}