def loadTextures(self):
        self.terrainTextures = {}

        def makeTerrainTexture(mats):
            w, h = 1, 1
            teximage = numpy.zeros((w, h, 4), dtype='uint8')
            teximage[:] = 127, 127, 127, 255

            GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA8, w, h, 0,
                            GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, teximage)

        textures = ((pymclevel.classicMaterials, 'terrain-classic.png'),
                    (pymclevel.indevMaterials, 'terrain-classic.png'),
                    (pymclevel.alphaMaterials, ResourcePackHandler.Instance().
                     get_selected_resource_pack().terrain_path()),
                    (pymclevel.pocketMaterials, 'terrain-pocket.png'))

        for mats, matFile in textures:
            try:
                if mats.name == 'Alpha':
                    tex = mceutils.loadAlphaTerrainTexture()
                else:
                    tex = mceutils.loadPNGTexture(matFile)
                self.terrainTextures[mats.name] = tex
            except Exception as e:
                logging.warning(
                    'Unable to load terrain from {0}, using flat colors.'
                    'Error was: {1!r}'.format(matFile, e))
                self.terrainTextures[mats.name] = glutils.Texture(
                    functools.partial(makeTerrainTexture, mats))
            mats.terrainTexture = self.terrainTextures[mats.name]
Beispiel #2
0
def loadAlphaTerrainTexture():
    #texW, texH, terraindata = loadPNGFile(os.path.join(directories.getDataDir(),  ResourcePackHandler.Instance().get_selected_resource_pack().terrain_path()))
    texW, texH, terraindata = loadPNGFile(directories.getDataFile(ResourcePackHandler.Instance().get_selected_resource_pack().terrain_path()))

    def _loadFunc():
        loadTextureFunc(texW, texH, terraindata)

    tex = glutils.Texture(_loadFunc)
    tex.data = terraindata
    return tex
Beispiel #3
0
 def change_texture(self):
     ResourcePackHandler.Instance().set_selected_resource_pack_name(
         self.resourcePackButton.selectedChoice)
     self.mcedit.displayContext.loadTextures()
Beispiel #4
0
    def __init__(self, mcedit):
        Dialog.__init__(self)

        self.mcedit = mcedit

        self.saveOldConfig = {
            config.settings.fov:
            config.settings.fov.get(),
            config.settings.targetFPS:
            config.settings.targetFPS.get(),
            config.settings.vertexBufferLimit:
            config.settings.vertexBufferLimit.get(),
            config.settings.fastLeaves:
            config.settings.fastLeaves.get(),
            config.settings.roughGraphics:
            config.settings.roughGraphics.get(),
            config.settings.enableMouseLag:
            config.settings.enableMouseLag.get(),
            config.settings.maxViewDistance:
            config.settings.maxViewDistance.get()
        }

        self.saveOldResourcePack = ResourcePackHandler.Instance(
        ).get_selected_resource_pack_name()

        self.fieldOfViewRow = albow.FloatInputRow("Field of View: ",
                                                  ref=config.settings.fov,
                                                  width=100,
                                                  min=25,
                                                  max=120)

        self.targetFPSRow = albow.IntInputRow("Target FPS: ",
                                              ref=config.settings.targetFPS,
                                              width=100,
                                              min=1,
                                              max=60)

        self.bufferLimitRow = albow.IntInputRow(
            "Vertex Buffer Limit (MB): ",
            ref=config.settings.vertexBufferLimit,
            width=100,
            min=0)

        fastLeavesRow = albow.CheckBoxLabel(
            "Fast Leaves",
            ref=config.settings.fastLeaves,
            tooltipText="Leaves are solid, like Minecraft's 'Fast' graphics")

        roughGraphicsRow = albow.CheckBoxLabel(
            "Rough Graphics",
            ref=config.settings.roughGraphics,
            tooltipText=
            "All blocks are drawn the same way (overrides 'Fast Leaves')")

        enableMouseLagRow = albow.CheckBoxLabel(
            "Enable Mouse Lag",
            ref=config.settings.enableMouseLag,
            tooltipText="Enable choppy mouse movement for faster loading.")

        playerSkins = albow.CheckBoxLabel(
            "Show Player Skins",
            ref=config.settings.downloadPlayerSkins,
            tooltipText="Show player skins while editing the world")

        self.maxView = albow.IntInputRow(
            "Max View Distance",
            ref=config.settings.maxViewDistance,
            tooltipText=
            "Sets the maximum view distance for the renderer. Values over 32 can possibly be unstable, so use it at your own risk"
        )
        self.maxView.subwidgets[1]._increment = 2

        packs = ResourcePackHandler.Instance().get_available_resource_packs()
        packs.remove('Default Resource Pack')
        packs.sort()
        packs.insert(0, 'Default Resource Pack')
        self.resourcePackButton = albow.ChoiceButton(
            packs, choose=self.change_texture, doNotTranslate=True)
        self.resourcePackButton.selectedChoice = self.saveOldResourcePack

        settingsColumn = albow.Column(
            (
                fastLeavesRow,
                roughGraphicsRow,
                enableMouseLagRow,
                #                                  texturePackRow,
                self.fieldOfViewRow,
                self.targetFPSRow,
                self.bufferLimitRow,
                self.maxView,
                playerSkins,
                self.resourcePackButton,
            ),
            align='r')

        settingsColumn = albow.Column(
            (albow.Label("Graphics Settings"), settingsColumn))

        settingsRow = albow.Row((settingsColumn, ))

        buttonsRow = albow.Row((albow.Button("OK", action=self.dismiss),
                                albow.Button("Cancel", action=self.cancel)))

        resetToDefaultRow = albow.Row(
            (albow.Button("Reset to default", action=self.resetDefault), ))

        optionsColumn = albow.Column(
            (settingsRow, buttonsRow, resetToDefaultRow))

        self.add(optionsColumn)
        self.shrink_wrap()