Skip to content

Commit

Permalink
DEF_ENC defaults to UTF-8.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhanzik committed Dec 17, 2014
1 parent 5501715 commit 477fcc2
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions albow/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def key_down(self, event):
try:
t = pygame.scrap.get(SCRAP_TEXT).replace('\0', '')
DEF_ENC = locale.getdefaultlocale()[1]
if DEF_ENC is None:
DEF_ENC = "UTF-8"
if type(t) == unicode and DEF_ENC != "UTF-8":
t = t.encode(DEF_ENC)
self.text = t
Expand Down
2 changes: 2 additions & 0 deletions albow/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def getPlatInfo(**kwargs):


enc = locale.getdefaultlocale()[1]
if enc is None:
enc = "UTF-8"

string_cache = {}
font_lang_cache = {}
Expand Down
5 changes: 3 additions & 2 deletions editortools/brush.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
from __builtin__ import __import__
from locale import getdefaultlocale
DEF_ENC = getdefaultlocale()[1]

if DEF_ENC is None:
DEF_ENC = "UTF-8"

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -568,7 +569,7 @@ def loadBrushPreset(self, name):
if key.endswith('blockID'):
key = key[:-7]
self.options[key] = self.editor.level.materials.blockWithID(loadedBrushOptions[key + 'blockID'], loadedBrushOptions[key+ 'blockData'])
if key + 'recentBlocks' in loadedBrushOptions:
if key + 'recentBlocks' in loadedBrushOptions:
list = []
blockList = loadedBrushOptions[key + 'recentBlocks']
for b in blockList:
Expand Down
8 changes: 4 additions & 4 deletions editortools/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def undo(self):
self.tool.panel.players.append(version_utils.getPlayerNameFromUUID(self.player))
else:
self.tool.panel.players.append("Player")

if "[No players]" in self.tool.panel.players:
self.tool.panel.players.remove("[No players]")
self.tool.hidePanel()
Expand Down Expand Up @@ -149,7 +149,7 @@ def perform(self, recordUndo=True):
self.level.playerTagCache[self.level.getPlayerPath(self.player)] = self.playerTag

self.level.players.append(self.player)
if self.tool.panel:
if self.tool.panel:
self.tool.panel.player_UUID[self.player] = self.player

else:
Expand Down Expand Up @@ -196,7 +196,7 @@ def newPlayer(self):
if b != 0 and not done:
i = index
done = True
spawnY = self.level.Height - i
spawnY = self.level.Height - i
playerTag['Pos'] = nbt.TAG_List([nbt.TAG_Double([spawnX, spawnY, spawnZ][i]) for i in range(3)])
playerTag['Rotation'] = nbt.TAG_List([nbt.TAG_Float(0), nbt.TAG_Float(0)])

Expand Down Expand Up @@ -471,7 +471,7 @@ def movePlayerToCamera(self):
self.editor.addOperation(op)
if op.canUndo:
self.editor.addUnsavedEdit()

def delete_skin(self, uuid):
del self.playerTexture[uuid]
self.playerTexture[uuid] = loadPNGTexture('char.png')
Expand Down
2 changes: 2 additions & 0 deletions mcedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def format(self, record):
import albow
import locale
DEF_ENC = locale.getdefaultlocale()[1]
if DEF_ENC is None:
DEF_ENC = "UTF-8"
from albow.translate import _, getPlatInfo

from albow.dialogs import Dialog
Expand Down
4 changes: 3 additions & 1 deletion resource_packs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import locale
DEF_ENC = locale.getdefaultlocale()[1]
if DEF_ENC is None:
DEF_ENC = "UTF-8"

try:
import resource # @UnresolvedImport
Expand Down Expand Up @@ -732,7 +734,7 @@ def setup_resource_packs():
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")))
Expand Down

0 comments on commit 477fcc2

Please sign in to comment.