Beispiel #1
0
    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'])
Beispiel #2
0
 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 __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
Beispiel #5
0
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
Beispiel #6
0
    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
Beispiel #8
0
    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
Beispiel #9
0
    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