# Path: omnitool/database.py
# def get_custom_db(txt):
# def parse():


import sys
import io
import os
import tempfile
import appdirs
        import binarysplit as bs  # aka bullshit
    import pygame
    import os
        import ctypes
        import winreg
    import pygame
from pathlib import Path
from itertools import count, chain
from .database import multitiles, multitilestrides
from .tlib import *
    # with open(n , "wb") as a:#write the tile data
    for x in range(header["width"]):
        y = 0
        while y < header["height"]:
            c = pxarray[x, y]
            amount = 0
            while y < header["height"] - 1 - amount and c == pxarray[x, y + 1 + amount]:
                amount += 1

            c = pygame.Color(c)[1:]
            if c in cache:
                a.write(cache[c])
            else:
                tiledata = io.BytesIO()
                if c[0] == 255:
                    set_tile_no_amount(tiledata, (None, None, 0, None))
                elif c[0] == 254:  #liquid
                    if c[1]:  #if lava
                        set_tile_no_amount(tiledata, (None, None, -c[2], None))
                    else:
                        set_tile_no_amount(tiledata, (None, None, c[2], None))
                elif c[0] == 253:  #liquid
                    if c[1]:  #if lava
                        set_tile_no_amount(tiledata, (None, 1, -c[2], None))
                    else:
                        set_tile_no_amount(tiledata, (None, 1, c[2], None))
                elif c[0] == 252:#just Wall
                    set_tile_no_amount(tiledata, (None, c[1], 0, None))
                elif c[0] > 230:  #only have a wall
                    set_tile_no_amount(tiledata, (None, c[0] - 230, 0, None))

# Path: omnitool/database.py
# def get_custom_db(txt):
# def parse():


# Path: omnitool/tinterface.py
import sys
import io
import os
import tempfile
import appdirs
        import binarysplit as bs  # aka bullshit
    import pygame
    import os
        import ctypes
        import winreg
    import pygame
from pathlib import Path
from itertools import count, chain
from .database import multitiles, multitilestrides
from .tlib import *

    # with open(n , "wb") as a:#write the tile data
    for x in range(header["width"]):
        y = 0
        while y < header["height"]:
            c = pxarray[x, y]
            amount = 0
            while y < header["height"] - 1 - amount and c == pxarray[x, y + 1 + amount]:
                amount += 1

            c = pygame.Color(c)[1:]
            if c in cache:
                a.write(cache[c])
            else:
                tiledata = io.BytesIO()
                if c[0] == 255:
                    set_tile_no_amount(tiledata, (None, None, 0, None))
                elif c[0] == 254:  #liquid
                    if c[1]:  #if lava
                        set_tile_no_amount(tiledata, (None, None, -c[2], None))
                    else:
                        set_tile_no_amount(tiledata, (None, None, c[2], None))
                elif c[0] == 253:  #liquid
                    if c[1]:  #if lava
                        set_tile_no_amount(tiledata, (None, 1, -c[2], None))
                    else:
                        set_tile_no_amount(tiledata, (None, 1, c[2], None))
                elif c[0] == 252:#just Wall
                    set_tile_no_amount(tiledata, (None, c[1], 0, None))
                elif c[0] > 230:  #only have a wall
                    set_tile_no_amount(tiledata, (None, c[0] - 230, 0, None))

                elif c[0] in multitiles and c[0] not in overwrite_no_mt:  #if it has multitiledata.. i hate those