Ejemplo n.º 1
0
def print_stats():
    """
    Print statistics about used ids.
    """
    num_used = total_numbers - len(free_numbers)
    if num_used > 0:
        generic.print_info("Town names: {}/{}".format(num_used, total_numbers))
Ejemplo n.º 2
0
def print_stats():
    """
    Print statistics about used ids.
    """
    if param_stats[0] > 0:
        generic.print_info("GRF parameter registers: {}/{}".format(
            param_stats[0], param_stats[1]))
Ejemplo n.º 3
0
def print_stats():
    """
    Print statistics about used ids.
    """
    if len(registered_sounds) > 0:
        # Currently NML does not optimise the order of sound effects. So we assume NUM_ANIMATION_SOUNDS as the maximum.
        generic.print_info("Sound effects: {}/{}".format(len(registered_sounds), NUM_ANIMATION_SOUNDS))
Ejemplo n.º 4
0
def print_stats():
    """
    Print statistics about used ids.
    """
    if free_labels.stats[0] > 0:
        generic.print_info("Concurrent Action10 labels: {}/{} ({})".format(
            free_labels.stats[0], free_labels.total_amount,
            str(free_labels.stats[1])))
Ejemplo n.º 5
0
def print_stats():
    """
    Print statistics about used ids.
    """
    for feature in used_ids:
        used = feature.get_num_allocated()
        if used > 0 and feature.dynamic_allocation:
            generic.print_info("{} items: {}/{}".format(feature.name, used, feature.get_max_allocated()))
Ejemplo n.º 6
0
def print_stats():
    """
    Print statistics about used ids.
    """
    for t, l in string_ranges.items():
        if l['random_id']:
            num_used = l['total'] - len(l['ids'])
            if num_used > 0:
                generic.print_info("{:02X}xx strings: {}/{}".format(t, num_used, l['total']))
Ejemplo n.º 7
0
def print_stats():
    """
    Print statistics about used ids.
    """
    if spriteset_stats[0] > 0:
        # NML uses as many concurrent spritesets as possible to prevent sprite duplication.
        # So, instead of the actual amount, we rather print the biggest unsplittable block, since that is what matters.
        generic.print_info("Concurrent spritesets: {}/{} ({})".format(
            spriteset_stats[0], max_sprite_block_size,
            str(spriteset_stats[1])))
Ejemplo n.º 8
0
def print_stats():
    """
    Print statistics about used ids.
    """
    if spritegroup_stats[0] > 0:
        generic.print_info("Concurrent spritegroups: {}/{} ({})".format(
            spritegroup_stats[0], total_action2_ids,
            str(spritegroup_stats[1])))
    if a2register_stats[0] > 0:
        generic.print_info("Concurrent Action2 registers: {}/{} ({})".format(
            a2register_stats[0], total_tmp_locations,
            str(a2register_stats[1])))
Ejemplo n.º 9
0
    def open(self, sprite_files):
        """
        Start the encoder, read caches, and stuff.

        @param sprite_files: List of sprites per source image file.
        @type  sprite_files: C{dict} that maps (C{tuple} of C{str}) to (C{RealSprite})
        """
        num_sprites = sum(
            len(sprite_list) for sprite_list in sprite_files.values())

        generic.print_progress("Encoding ...")

        num_cached = 0
        num_dup = 0
        num_enc = 0
        num_orphaned = 0
        count_sprites = 0
        for sources, sprite_list in sprite_files.items():
            # Iterate over sprites grouped by source image file.
            #  - Open source files only once. (speed)
            #  - Do not keep files around for long. (memory)

            source_name = "_".join(src for src in sources if src is not None)

            local_cache = spritecache.SpriteCache(sources)
            local_cache.read_cache()

            for sprite_info in sprite_list:
                count_sprites += 1
                generic.print_progress("Encoding {}/{}: {}".format(
                    count_sprites, num_sprites, source_name),
                                       incremental=True)

                cache_key = sprite_info.get_cache_key(self.crop_sprites)
                cache_item = local_cache.get_item(cache_key, self.palette)

                in_use = False
                in_old_cache = False
                if cache_item is not None:
                    # Write a sprite from the cached data
                    compressed_data, info_byte, crop_rect, pixel_stats, in_old_cache, in_use = cache_item
                    if in_use:
                        num_dup += 1
                    else:
                        num_cached += 1
                else:
                    (
                        size_x,
                        size_y,
                        xoffset,
                        yoffset,
                        compressed_data,
                        info_byte,
                        crop_rect,
                        pixel_stats,
                    ) = self.encode_sprite(sprite_info)
                    num_enc += 1

                # Store sprite in cache, unless already up-to-date
                if not in_use:
                    cache_item = (compressed_data, info_byte, crop_rect,
                                  pixel_stats, in_old_cache, True)
                    local_cache.add_item(cache_key, self.palette, cache_item)

            # Delete all files from dictionary to free memory
            self.cached_image_files.clear()

            num_orphaned += local_cache.count_orphaned()

            # Only write cache if compression is enabled. Uncompressed data is not worth to be cached.
            if self.compress_grf:
                local_cache.write_cache()

            # Transfer data to global cache for later usage
            self.sprite_cache.cached_sprites.update(local_cache.cached_sprites)

        generic.print_progress("Encoding ...", incremental=True)
        generic.clear_progress()
        generic.print_info(
            "{} sprites, {} cached, {} orphaned, {} duplicates, {} newly encoded ({})"
            .format(num_sprites, num_cached, num_orphaned, num_dup, num_enc,
                    "native" if lz77.is_native else "python"))