Beispiel #1
0
    private WorldEntry generateDirectoryWorld(string world_dir)
    {
        KnyttWorldInfo world_info;
        string         cache_dir        = "user://Cache/" + GDKnyttAssetManager.extractFilename(world_dir);
        string         ini_cache_name   = cache_dir + "/World.ini";
        string         played_flag_name = cache_dir + "/LastPlayed.flag";

        if (new File().FileExists(ini_cache_name))
        {
            world_info = getWorldInfo(GDKnyttAssetManager.loadFile(ini_cache_name));
        }
        else
        {
            var ini_bin  = GDKnyttAssetManager.loadFile(world_dir + "/world.ini");
            var ini_data = new IniData();
            world_info = getWorldInfo(ini_bin, merge_to: ini_data["World"]);
            GDKnyttAssetManager.ensureDirExists(cache_dir);
            var f = new File();
            f.Open(ini_cache_name, File.ModeFlags.Write);
            f.StoreString(ini_data.ToString());
            f.Close();
        }

        Texture icon        = GDKnyttAssetManager.loadExternalTexture(world_dir + "/icon.png");
        var     last_played = new File().FileExists(played_flag_name) ? new File().GetModifiedTime(played_flag_name) : 0;

        return(new WorldEntry(icon, world_info, world_dir, last_played));
    }
    protected override object getExternalTexture(string filepath)
    {
        var full_path = this.WorldDirectory + "/" + filepath.ToLower();
        var f         = new File();

        if (!f.FileExists(full_path))
        {
            return(null);
        }
        return(GDKnyttAssetManager.loadExternalTexture(full_path));
    }
Beispiel #3
0
    private KnyttWorldManager <Texture> .WorldEntry generateDirectoryWorld(string world_dir, string name)
    {
        Texture icon;
        string  txt;

        lock (file_lock) { icon = GDKnyttAssetManager.loadExternalTexture(world_dir + "/Icon.png"); }
        lock (file_lock) { txt = GDKnyttAssetManager.loadTextFile(world_dir + "/World.ini"); }
        GDKnyttWorldImpl world = new GDKnyttWorldImpl();

        world.setDirectory(world_dir, name);
        world.loadWorldConfig(txt);
        return(new KnyttWorldManager <Texture> .WorldEntry(world, icon));
    }