def setup_resource_packs():
    terrains = {}
    try:
        os.mkdir("terrain-textures")
    except OSError:
        pass
    terrains["Default"] = DefaultResourcePack()
    if os.path.exists(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks")):
        zipResourcePacks = directories.getAllOfAFile(unicode(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks")), ".zip")
        folderResourcePacks = os.listdir(unicode(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks")))
        for zip_tex_pack in zipResourcePacks:
            zrp = ZipResourcePack(zip_tex_pack)
            if not zrp.isEmpty:
                if not zrp.tooBig:
                    terrains[zrp.pack_name] = zrp
        for folder_tex_pack in folderResourcePacks:
            if os.path.isdir(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks", folder_tex_pack)):
                frp = FolderResourcePack(folder_tex_pack)
                if not frp.isEmpty:
                    if not frp.tooBig:
                        terrains[frp.pack_name] = frp
    for tex in terrains.keys():
        pack = terrains[tex]
        if not os.path.exists(pack.terrain_path()):
            del terrains[tex]
    try:
        shutil.rmtree(os.path.join(directories.parentDir, "textures"))
    except:
        print "Could not remove \"textures\" directory"
        pass
    return terrains
def setup_resource_packs():
    terrains = {}
    try:
        os.mkdir("terrain-textures")
    except OSError:
        pass
    terrains["Default"] = DefaultResourcePack()

    if os.path.exists(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks")):
        zipResourcePacks = directories.getAllOfAFile(unicode(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks")), ".zip")
        folderResourcePacks = os.listdir(unicode(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks")))
        for zip_tex_pack in zipResourcePacks:
            zrp = ZipResourcePack(zip_tex_pack)
            if not zrp.isEmpty:
                if not zrp.tooBig:
                    terrains[zrp.pack_name] = zrp
        for folder_tex_pack in folderResourcePacks:
            if os.path.isdir(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks", folder_tex_pack)):
                frp = FolderResourcePack(folder_tex_pack)
                if not frp.isEmpty:
                    if not frp.tooBig:
                        terrains[frp.pack_name] = frp
    for tex in terrains.keys():
        pack = terrains[tex]
        if not os.path.exists(pack.terrain_path()):
            del terrains[tex]
    try:
        shutil.rmtree(os.path.join(directories.parentDir, "textures"))
    except:
        print "Could not remove \"textures\" directory"
        pass
    return terrains
Exemple #3
0
def setup_resource_packs():
    '''
    Handles parsing of Resource Packs and removing ones that are either have to0 high of a resolution, or don't replace any textures
    '''
    log.debug("Setting up the resource packs.")
    terrains = {}
    try:
        os.mkdir("terrain-textures")
    except OSError:
        pass
    terrains["Default Resource Pack"] = DefaultResourcePack()

    if os.path.exists(
            os.path.join(
                directories.getMinecraftProfileDirectory(
                    directories.getSelectedProfile()), "resourcepacks")):
        log.debug("Gathering zipped packs...")
        zipResourcePacks = directories.getAllOfAFile(
            unicode(
                os.path.join(
                    directories.getMinecraftProfileDirectory(
                        directories.getSelectedProfile()), "resourcepacks")),
            ".zip")
        log.debug("Gatering folder packs...")
        folderResourcePacks = os.listdir(
            unicode(
                os.path.join(
                    directories.getMinecraftProfileDirectory(
                        directories.getSelectedProfile()), "resourcepacks")))
        log.debug("Processing zipped packs...")
        for zip_tex_pack in zipResourcePacks:
            zrp = ZipResourcePack(zip_tex_pack)
            if not zrp.isEmpty:
                if not zrp.tooBig:
                    terrains[zrp.pack_name] = zrp
        log.debug("Processing folder packs...")
        for folder_tex_pack in folderResourcePacks:
            if os.path.isdir(
                    os.path.join(
                        directories.getMinecraftProfileDirectory(
                            directories.getSelectedProfile()), "resourcepacks",
                        folder_tex_pack)):
                frp = FolderResourcePack(folder_tex_pack)
                if not frp.isEmpty:
                    if not frp.tooBig:
                        terrains[frp.pack_name] = frp
    for tex in terrains.keys():
        pack = terrains[tex]
        if not os.path.exists(pack.terrain_path()):
            del terrains[tex]
    try:
        shutil.rmtree(os.path.join(directories.parentDir, "textures"))
    except:
        print "Could not remove \"textures\" directory"
        pass
    return terrains
Exemple #4
0
def getSelectedMinecraftVersion():
    profile = directories.getMinecraftProfileJSON()[
        directories.getSelectedProfile()]
    if 'lastVersionId' in profile:
        return profile['lastVersionId']
    else:
        return '1.8'
 def __init__(self, folder, noEncConvert=False):
     self._folder = folder
     self._pack_name = self._folder.replace(" ", "_")
     IResourcePack.__init__(self)
     self._full_path = os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks", self._folder)
     self.texture_path = os.path.join(directories.parentDir, "textures", self._pack_name)
     if not os.path.exists(self._terrain_path):
         self.add_textures()
 def __init__(self, folder, noEncConvert=False):
     self._folder = folder
     self._pack_name = self._folder.replace(" ", "_")
     IResourcePack.__init__(self)
     self._full_path = os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks", self._folder)
     self.texture_path = os.path.join(directories.parentDir, "textures", self._pack_name)
     if not os.path.exists(self._terrain_path):
         self.add_textures()
def setup_resource_packs():
    '''
    Handles parsing of Resource Packs and removing ones that are either have to0 high of a resolution, or don't replace any textures
    '''
    log.debug("Setting up the resource packs.")
    terrains = {}
    try:
        os.mkdir("terrain-textures")
    except OSError:
        pass
    terrains["Default Resource Pack"] = DefaultResourcePack()

    if os.path.exists(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks")):
        log.debug("Gathering zipped packs...")
        zipResourcePacks = directories.getAllOfAFile(unicode(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks")), ".zip")
        log.debug("Gatering folder packs...")
        folderResourcePacks = os.listdir(unicode(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks")))
        log.debug("Processing zipped packs...")
        for zip_tex_pack in zipResourcePacks:
            zrp = ZipResourcePack(zip_tex_pack)
            if not zrp.isEmpty:
                if not zrp.tooBig:
                    terrains[zrp.pack_name] = zrp
        log.debug("Processing folder packs...")
        for folder_tex_pack in folderResourcePacks:
            if os.path.isdir(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks", folder_tex_pack)):
                frp = FolderResourcePack(folder_tex_pack)
                if not frp.isEmpty:
                    if not frp.tooBig:
                        terrains[frp.pack_name] = frp
    for tex in terrains.keys():
        pack = terrains[tex]
        if not os.path.exists(pack.terrain_path()):
            del terrains[tex]
    try:
        shutil.rmtree(os.path.join(directories.parentDir, "textures"))
    except:
        print "Could not remove \"textures\" directory"
        pass
    return terrains
def getSelectedMinecraftVersion():
    profile = directories.getMinecraftProfileJSON()[directories.getSelectedProfile()]
    if 'lastVersionId' in profile:
        return profile['lastVersionId']
    else:
        return '1.8'
def setup_resource_packs():
    terrains = {}
    try:
        os.mkdir("terrain-textures")
    except OSError:
        pass
    terrains["Default"] = DefaultResourcePack()
    resourcePacks = directories.getAllOfAFile(os.path.join(directories.getMinecraftProfileDirectory(directories.getSelectedProfile()), "resourcepacks"), ".zip")
    for tex_pack in resourcePacks:
        rp = ResourcePack(tex_pack)
        if not rp.isEmpty:
            if not rp.tooBig:
                terrains[rp.pack_name] = rp
    try:
        shutil.rmtree(directories.parentDir+os.path.sep+"textures")
    except:
        print "Could not remove \"textures\" directory"
        pass
    return terrains
Exemple #10
0
def getSelectedMinecraftVersion():
    profile = directories.getMinecraftProfileJSON()[directories.getSelectedProfile()]
    if "lastVersionId" in profile:
        return profile["lastVersionId"]
    else:
        return "1.8"
Exemple #11
0
import subprocess

try:
    import pygtk

    pygtk.require('2.0')
    import gtk

    if gtk.pygtk_version < (2, 3, 90):
        raise ImportError
    hasGtk = True
except ImportError:
    hasGtk = False  # Using old method as fallback

texturePacksDir = os.path.join(
    getMinecraftProfileDirectory(getSelectedProfile()), "texturepacks")
# Compatibility layer for filters:
filtersDir = directories.filtersDir
schematicsDir = directories.schematicsDir

# !# Disabling platform specific file chooser:
# !# Please, don't touch these two lines and the 'platChooser' stuff. -- D.C.-G.
# platChooser = sys.platform in ('linux2', 'darwin')
platChooser = sys.platform == 'darwin'


def dynamic_arguments(func_to_replace, askFile_func):
    def wrapper(initialDir, displayName, fileFormat):
        if isinstance(fileFormat, tuple):
            return func_to_replace(initialDir, displayName, fileFormat)
        else: