def save(self, filename = None): # if filename is not none, this is a save-as if not filename: filename = self.filename kv = CKeyValues() self.world.doWriteKeyValues(kv) kv.write(filename, 4) self.filename = filename self.unsaved = False base.actionMgr.documentSaved() self.updateTabText()
def digest(self): """ Returns true/false depending on if the resource pack can be loaded or not """ data = CKeyValues.load(self.configPath) EnvironmentConfiguration.processData(self, data) for key in data: if not isinstance(data[key], dict) and key in self.ConfigModifiers.keys(): entry = self.ConfigModifiers.get(key) modifier = entry[0] returnedData = modifier.digest(data[key]) if key == 'author': self.authors.append(returnedData) else: setattr(self, entry[1], returnedData) elif key != 'environment': self.notify.warning('Unexpected key %s was found.' % key) if not self.name or not self.version: self.notify.warning( 'Must have a name and a version defined in its descriptor file.' ) return False return True
def writeKeyValues(self, keyvalues): MapObject.writeKeyValues(self, keyvalues) # Write or faces or "sides" for face in self.faces: faceKv = CKeyValues("side", keyvalues) face.writeKeyValues(faceKv)
def open(self, filename = None): # if filename is none, this is a new document/map if not filename: self.__newMap() return # opening a map from disk, read through the keyvalues and # generate the objects self.idGenerator.reset() root = CKeyValues.load(filename) for i in range(root.getNumChildren()): self.r_open(root.getChild(i)) self.unsaved = False self.filename = filename self.isOpen = True self.toolMgr.switchToSelectTool() self.updateTabText()
def doWriteKeyValues(self): kv = CKeyValues() for child in self.children.values(): child.doWriteKeyValues(kv) return kv
def doWriteKeyValues(self, parent): kv = CKeyValues(self.ObjectName, parent) self.writeKeyValues(kv) for child in self.children.values(): child.doWriteKeyValues(kv)
def strToQColor(colorStr, alpha=False): pcolor = CKeyValues.to4f(colorStr) return QtGui.QColor(int(pcolor.x), int(pcolor.y), int(pcolor.z), 255 if not alpha else int(pcolor.w))
def writeKeyValues(self, kv): kv.setKeyValue("origin", CKeyValues.toString(self.pos)) kv.setKeyValue("texcoord", CKeyValues.toString(self.uv))
def readKeyValues(self, kv): self.pos = CKeyValues.to3f(kv.getValue("origin")) self.uv = LTexCoord(CKeyValues.to2f(kv.getValue("texcoord")))
def writeEditorValues(self, parent): values = self.getEditorValues() if len(values) > 0: kv = CKeyValues("editor", parent) for key, value in values.items: kv.setKeyValue(key, value)