<commit_before>package luxe;

import luxe.Resource;


#if (!parcel_thread_disabled && luxe_native)
    #if neko
        import neko.vm.Thread;
        import neko.vm.Mutex;
    #else
        import cpp.vm.Thread;
        import cpp.vm.Mutex;
    #end
#end //parcel_thread_disabled


typedef ShaderInfo = {
    ps_id : String,
    vs_id : String
}

typedef FontInfo = {
    id : String,
    path : String
}

typedef SoundInfo = {
    id : String,
    name : String,
    is_music : Bool
}

typedef ParcelOptions = {
    ? sequential : Bool,
    ? threaded : Bool,
    ? load_spacing : Float,
    ? start_spacing : Float,
    ? oncomplete : Parcel->Void,
    ? onprogress : Resource->Void
}

class Parcel extends luxe.ResourceManager {

    public var time_to_load : Float = 0;
    var time_start_load : Float = 0;

    var texture_list : Array<String>;
    var shader_list : Array<ShaderInfo>;
    var font_list : Array<FontInfo>;
    var sound_list : Array<SoundInfo>;
    var text_list : Array<String>;
    var data_list : Array<String>;

    public var total_items : Int = 0;
    public var current_count : Int = 0;
    public var options : ParcelOptions;

    public function new( ?_options:ParcelOptions ) {

        super();

        options = _options != null ? _options : {};

        if( options.load_spacing == null ) { options.load_spacing = 0.1; }
        if( options.start_spacing == null ) { options.start_spacing = 0.4; }
        if( options.sequential == null ) { options.sequential = false; }
        if( options.threaded == null ) { options.threaded = false; }

        texture_list    = [];
        font_list       = [];
        shader_list     = [];
        sound_list      = [];
        text_list       = [];
        data_list       = [];

    } //new

//Load the parcel up

    var index_textures  : Int = 0;
    var index_fonts     : Int = 0;
    var index_shaders   : Int = 0;
    var index_sounds    : Int = 0;
    var index_datas     : Int = 0;
    var index_texts     : Int = 0;


    public function load() {

        time_start_load = Luxe.time;

        total_items =
            texture_list.length +
            shader_list.length  +
            font_list.length    +
            sound_list.length   +
            text_list.length    +
            data_list.length;

        Luxe.timer.schedule(options.start_spacing, function(){

        #if (luxe_native && !parcel_thread_disabled)
            Thread.create(function(){
                // Sys.println('background thread loading ' + options);
        #end
                if( !options.sequential ) {

                    start_textures_load();<commit_msg>Parcel; reset current count on load<commit_after>package luxe;

import luxe.Resource;


#if (!parcel_thread_disabled && luxe_native)
    #if neko
        import neko.vm.Thread;
        import neko.vm.Mutex;
    #else
        import cpp.vm.Thread;
        import cpp.vm.Mutex;
    #end
#end //parcel_thread_disabled


typedef ShaderInfo = {
    ps_id : String,
    vs_id : String
}

typedef FontInfo = {
    id : String,
    path : String
}

typedef SoundInfo = {
    id : String,
    name : String,
    is_music : Bool
}

typedef ParcelOptions = {
    ? sequential : Bool,
    ? threaded : Bool,
    ? load_spacing : Float,
    ? start_spacing : Float,
    ? oncomplete : Parcel->Void,
    ? onprogress : Resource->Void
}

class Parcel extends luxe.ResourceManager {

    public var time_to_load : Float = 0;
    var time_start_load : Float = 0;

    var texture_list : Array<String>;
    var shader_list : Array<ShaderInfo>;
    var font_list : Array<FontInfo>;
    var sound_list : Array<SoundInfo>;
    var text_list : Array<String>;
    var data_list : Array<String>;

    public var total_items : Int = 0;
    public var current_count : Int = 0;
    public var options : ParcelOptions;

    public function new( ?_options:ParcelOptions ) {

        super();

        options = _options != null ? _options : {};

        if( options.load_spacing == null ) { options.load_spacing = 0.1; }
        if( options.start_spacing == null ) { options.start_spacing = 0.4; }
        if( options.sequential == null ) { options.sequential = false; }
        if( options.threaded == null ) { options.threaded = false; }

        texture_list    = [];
        font_list       = [];
        shader_list     = [];
        sound_list      = [];
        text_list       = [];
        data_list       = [];

    } //new

//Load the parcel up

    var index_textures  : Int = 0;
    var index_fonts     : Int = 0;
    var index_shaders   : Int = 0;
    var index_sounds    : Int = 0;
    var index_datas     : Int = 0;
    var index_texts     : Int = 0;


    public function load() {

        time_start_load = Luxe.time;
        current_count = 0;

        total_items =
            texture_list.length +
            shader_list.length  +
            font_list.length    +
            sound_list.length   +
            text_list.length    +
            data_list.length;

        Luxe.timer.schedule(options.start_spacing, function(){

        #if (luxe_native && !parcel_thread_disabled)
            Thread.create(function(){
                // Sys.println('background thread loading ' + options);
        #end
                if( !options.sequential ) {

                    start_textures_load();
{'fraction_non_alphanumeric': 0.1039278331140763, 'fraction_numerical': 0.0054501033640293175, 'mean_word_length': 2.0016920473773268, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1594586', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1613, 'n_words': 386}