def loadSettings(self): with inFile("settings.ini") as f: if f: settings = mh.parseINI(f.read()) self.settings.update(settings) if 'language' in self.settings: self.setLanguage(self.settings['language'])
def __init__(self, path): self.path = path cachePath = os.path.join(self.path, 'cache.ini') self.cache = {} if os.path.exists(cachePath): try: with open(cachePath, 'r') as f: self.cache = mh.parseINI(f.read()) except ValueError: os.remove(cachePath)
def combine(image, mhstx): f = open(mhstx, 'rU') try: subTextures = mh.parseINI(f.read(), [("(", "["), (")", "]")]) except: log.warning("subtextures.combine(%s)", mhstx, exc_info=True) f.close() return mh.Image() f.close() texdir = os.path.dirname(mhstx) img = mh.Image(data=image.data) for subTexture in subTextures: path = os.path.join(texdir, subTexture['txt']) subImg = mh.Image(path) x, y = subTexture['dst'] img.blit(subImg, x, y) return img
def combine(image, mhstx): f = open(mhstx, 'rU') try: subTextures = mh.parseINI(f.read(), [("(","["), (")","]")]) except: log.warning("subtextures.combine(%s)", mhstx, exc_info=True) f.close() return mh.Image() f.close() texdir = os.path.dirname(mhstx) img = mh.Image(data = image.data) for subTexture in subTextures: path = os.path.join(texdir, subTexture['txt']) subImg = mh.Image(path) x, y = subTexture['dst'] img.blit(subImg, x, y) return img
def loadSettings(self): with inFile("settings.ini") as f: if f: settings = mh.parseINI(f.read()) self.settings.update(settings) if 'language' in self.settings: self.setLanguage(self.settings['language']) gui.Slider.showImages(self.settings['sliderImages']) with inFile("shortcuts.ini") as f: shortcuts = {} for line in f: modifier, key, action = line.strip().split(' ') shortcuts[action] = (int(modifier), int(key)) if shortcuts.get('_versionSentinel') != (0, 0x87654321): log.warning('shortcuts.ini out of date; ignoring') else: self.shortcuts.update(shortcuts) with inFile("mouse.ini") as f: mouseActions = dict([ (method.__name__, shortcut) for shortcut, method in self.mouseActions.iteritems() ]) for line in f: modifier, button, method = line.strip().split(' ') if hasattr(self, method): mouseActions[method] = (int(modifier), int(button)) self.mouseActions = dict([ (shortcut, getattr(self, method)) for method, shortcut in mouseActions.iteritems() ]) with inFile("help.ini") as f: helpIds = set() for line in f: helpIds.add(line.strip()) if self.dialog is not None: self.dialog.helpIds.update(self.helpIds) self.helpIds = helpIds
def setEyes(self, human, mhstx): # TODO this will change, for now eyes might only be compatible with the original skin f = open(mhstx, 'rU') try: subTextures = mh.parseINI(f.read(), [("(","["), (")","]")]) except: log.warning("setEyes(%s)", mhstx, exc_info=True) f.close() return f.close() texture = mh.getTexture(human.getTexture()) img = mh.Image(human.getTexture()) for subTexture in subTextures: path = os.path.join('data/eyes', subTexture['txt']) subImg = mh.Image(path) x, y = subTexture['dst'] img.blit(subImg, x, y) texture.loadSubImage(img, 0, 0) self.eyeTexture = mhstx
def setEyes(self, human, mhstx): # TODO this will change, for now eyes might only be compatible with the original skin f = open(mhstx, 'rU') try: subTextures = mh.parseINI(f.read(), [("(", "["), (")", "]")]) except: log.warning("setEyes(%s)", mhstx, exc_info=True) f.close() return f.close() texture = mh.getTexture(human.getTexture()) img = mh.Image(human.getTexture()) for subTexture in subTextures: path = os.path.join('data/eyes', subTexture['txt']) subImg = mh.Image(path) x, y = subTexture['dst'] img.blit(subImg, x, y) texture.loadSubImage(img, 0, 0) self.eyeTexture = mhstx
def loadSettings(self): with inFile("settings.ini") as f: if f: settings = mh.parseINI(f.read()) self.settings.update(settings) if 'language' in self.settings: self.setLanguage(self.settings['language']) gui.Slider.showImages(self.settings['sliderImages']) with inFile("shortcuts.ini") as f: shortcuts = {} for line in f: modifier, key, action = line.strip().split(' ') shortcuts[action] = (int(modifier), int(key)) if shortcuts.get('_versionSentinel') != (0, 0x87654321): log.warning('shortcuts.ini out of date; ignoring') else: self.shortcuts.update(shortcuts) with inFile("mouse.ini") as f: mouseActions = dict([(method.__name__, shortcut) for shortcut, method in self.mouseActions.iteritems()]) for line in f: modifier, button, method = line.strip().split(' ') if hasattr(self, method): mouseActions[method] = (int(modifier), int(button)) self.mouseActions = dict([(shortcut, getattr(self, method)) for method, shortcut in mouseActions.iteritems()]) with inFile("help.ini") as f: helpIds = set() for line in f: helpIds.add(line.strip()) if self.dialog is not None: self.dialog.helpIds.update(self.helpIds) self.helpIds = helpIds