Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
Conflicts:
	leveleditor.py
  • Loading branch information
Rubisk committed Nov 28, 2014
2 parents a797d6b + 369b8ae commit 5a4e844
Show file tree
Hide file tree
Showing 16 changed files with 3,127 additions and 2,535 deletions.
1 change: 1 addition & 0 deletions Items/minecraft/blocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -1528,3 +1528,4 @@
"maxdamage": 0,
"stacksize": 64
}
}
2 changes: 1 addition & 1 deletion Items/minecraft/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@
"chicken": {
"id": 365,
"name": "Raw Chicken",
"texture": "chicked_raw.png",
"texture": "chicken_raw.png",
"optainable": true,
"maxdamage": 0,
"stacksize": 64
Expand Down
2 changes: 1 addition & 1 deletion RELEASE-VERSION.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Fork v{tag_name} for Minecraft 1.8",
"tag_name": "1.2.0.0",
"tag_name": "1.2.1.1",
"development": false
}
25 changes: 20 additions & 5 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

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

import directories
import weakref
Expand All @@ -36,14 +38,15 @@ def __init__(self, definitions):
for (sectionKey, sectionName), items in definitions.iteritems():
self._sections[sectionKey] = ConfigSection(self.config, sectionName, items)
setattr(self, sectionKey, self._sections[sectionKey])
self.save()

def __getitem__(self, section):
return self._sections[section]

def getPath(self):
return directories.configFilePath

def transformKey(value, i=0):
def transformKey(self, value, i=0):
if 'left' in value and len(value) > 5:
value = value[5:]
elif 'right' in value and len(value) > 6:
Expand All @@ -68,8 +71,18 @@ def convert(self, key):
vals = key.replace('-', ' ').translate(None, '()').lower().split(' ')
return vals[0] + "".join(x.title() for x in vals[1:])

def reset(self):
for section in self.config.sections():
self.config.remove_section(section)

def transformConfig(self):
if self.config.has_section("Version") and self.config.get("Version", "version") == "1.1.1.1":
if self.config.has_section("Version") and self.config.has_option("Version", "version"):
version = self.config.get("Version", "version")
else:
self.reset()
return

if version == "1.1.1.1":
i = 1
for (name, value) in self.config.items("Keys"):
if name != "Swap View" and name != "Toggle Fps Counter":
Expand All @@ -82,9 +95,10 @@ def transformConfig(self):
self.config.set("Keys", "Toggle Fps Counter", "None")
i += 1
if self.config.get("Keys", "Brake") == "Space":
self.config.set("Version", "version", "1.1.2.0-update")
version = "1.1.2.0-update"
else:
self.config.set("Version", "version", "1.1.2.0-new")
version = "1.1.2.0-new"
self.config.set("Version", "version", version)
self.save()

def load(self):
Expand Down Expand Up @@ -126,6 +140,7 @@ def __init__(self, config, section, items):
value.config = config
value.section = section
self._items[value.key] = value
value.get()

def __getitem__(self, key):
return self._items[key]
Expand Down Expand Up @@ -293,7 +308,7 @@ def __init__(self, key, name, default=None):

def get(self):
values = super(ColorValue, self).get()
return (min(max(x, 0.0), 1.0) for x in values)
return tuple(min(max(x, 0.0), 1.0) for x in values)


class ConfigDict(collections.MutableMapping):
Expand Down
12 changes: 10 additions & 2 deletions editortools/brush.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
from pymclevel.mclevelbase import exhaust
import random
from __builtin__ import __import__
from locale import getdefaultlocale
DEF_ENC = getdefaultlocale()[1]


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -482,7 +484,10 @@ def tryStockImport(self, name):
:param name, name of the module to import.
"""
try:
globals()[name] = m = imp.load_source(name, os.path.join(directories.getDataDir(), u'stock-brushes', (name+ ".py")))
path = os.path.join(directories.getDataDir(), u'stock-brushes', (name+ ".py"))
if type(path) == unicode and DEF_ENC != "UTF-8":
path = path.encode(DEF_ENC)
globals()[name] = m = imp.load_source(name, path)
m.materials = self.editor.level.materials
m.createInputs(m)
return m
Expand All @@ -498,7 +503,10 @@ def tryImport(self, name):
:param name, name of the module to import.
"""
try:
globals()[name] = m = imp.load_source(name, os.path.join(directories.brushesDir, (name+ ".py")))
path = os.path.join(directories.brushesDir, (name+ ".py"))
if type(path) == unicode and DEF_END != "UTF-8":
path = path.encode(DEF_ENC)
globals()[name] = m = imp.load_source(name, path)
m.materials = self.editor.level.materials
m.createInputs(m)
return m
Expand Down
20 changes: 5 additions & 15 deletions editortools/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from pymclevel import nbt
import logging
import keys
from config import config

log = logging.getLogger(__name__)

Expand All @@ -51,19 +50,7 @@ def GetSelectionColor(colorWord=None):

colorWord = config.convert(colorWord)

colorValues = config.selectionColors[colorWord].get()
try:
values = colorValues.translate(None, '[]()').split(',')
# Fix default values generated by versions prior to list support
# this 'if' block may be removed once new version is widespread
if len(values) > 3:
values = tuple(float(x) for x in colorValues.replace("', '", "").translate(None, "[]()'").split(','))
ColorValue.defaultColors[colorWord.lower()].set(values)
log.debug("Fixing color %r {%r => %r}", colorWord, colorValues, values)
values = tuple((min(max(float(x), 0.0), 1.0)) for x in values)
except:
values = (1.0, 1.0, 1.0)

values = config.selectionColors[colorWord].get()
return values


Expand Down Expand Up @@ -94,7 +81,7 @@ def _set(val):
choice = self.colorPopupButton.selectedChoice
values = GetSelectionColor(choice)
values = values[:i] + (val / 255.0,) + values[i + 1:]
config.selectionColors[choice].set(str(values))
config.selectionColors[config.convert(choice)].set(str(values))
self.colorChanged()

return _set
Expand Down Expand Up @@ -465,6 +452,9 @@ def updateSelectionColor(self):
from albow import theme

theme.root.sel_color = tuple(int(x * 112) for x in self.selectionColor)
if self.nudgePanel is not None:
self.hideNudgePanel()
self.showPanel()

# --- Nudge functions ---

Expand Down
Loading

0 comments on commit 5a4e844

Please sign in to comment.