Example #1
0
 def showLevelDialog(self):
     byamlPath = QtGui.QFileDialog.getOpenFileName(
         self, 'Open Level', 'course_muunt.byaml',
         'Level Archive (*.byaml)')
     print "path is: " + byamlPath
     with open(byamlPath, 'rb') as f:
         self.levelData = byml.BYML(f.read(), True)
     self.loadLevel(self.levelData.rootNode.subNodes())
Example #2
0
 def showLevelDialog(self):
     if self.levelSelect.exec_():
         with open(
                 self.gamePath + '/StageData/' +
                 self.levelSelect.currentLevel + 'Map1.szs', 'rb') as f:
             data = f.read()
         self.levelData = byml.BYML(
             sarc.extract(yaz0.decompress(data),
                          self.levelSelect.currentLevel + 'Map.byml'))
         self.loadLevel(self.levelData.rootNode)
Example #3
0
    def loadStageList(self):
        """
        Loads MapInfo.byaml, to get the list of levels for the level choosing dialog
        """
        with open(self.gamePath + '\Pack\Static\Mush\MapInfo.byaml',
                  'rb') as f:
            data = f.read()

        # no need to compress or anything, it's as-is
        self.levelList = byml.BYML(data).rootNode
Example #4
0
    def showLevelDialog(self):
        """
        Loads the level choosing dialog, along with sending the level data to loadLevel()
        """
        levelSelect = ChooseLevelDialog(self.levelList)
        if levelSelect.exec_():
            if levelSelect.absolutePath:
                path = levelSelect.stageName
                name = levelSelect.stageNamePath
                print('ok so path is ' + path)
                print('and our name is ' + name)
                custom = 1
            else:
                path = self.gamePath + '/Pack/Static/Map/' + levelSelect.stageName + '.szs'
                custom = 0

            if os.path.isfile(path):
                with open(path, 'rb') as f:
                    data = f.read()
                if custom == 0:
                    self.levelData = byml.BYML(
                        sarc.extract(yaz0.decompress(data),
                                     levelSelect.stageName + '.byaml'))
                    self.loadLevel(self.levelData.rootNode)
                    self.setWindowTitle('Splat3D ALPHA v0.2 ' +
                                        os.path.basename(path) + ' (' +
                                        levelName(levelSelect.stageName) + ')')
                if custom == 1:
                    self.levelData = byml.BYML(
                        sarc.extract(yaz0.decompress(data),
                                     levelSelect.stageNamePath + '.byaml'))
                    self.loadLevel(self.levelData.rootNode)
                    self.setWindowTitle('Splat3D ALPHA v0.2 ' +
                                        os.path.basename(path) + ' (' +
                                        levelName(levelSelect.stageName[:-4]) +
                                        ')')
Example #5
0
    def loadLevel(self, levelData):

        global modelNameMapping

        modelNameMapping = {}
        with open(window.gamePath + '/data/objflow.byaml', 'rb'
                  ) as f:  # load objflow to get the model names, and load them
            b = byml.BYML(f.read(), True)
            for thing in b.rootNode.subNodes():
                resName = thing.subNodes()['ResName'].subNodes()[0].val
                id = thing['ObjId']
                modelNameMapping[id] = resName

        stime = now()
        self.glWidget.reset()
        self.settings.reset()
        amount = len(levelData['Obj'])
        progress = QtGui.QProgressDialog(self)
        progress.setCancelButton(None)
        progress.setMinimumDuration(0)
        progress.setRange(0, amount)
        progress.setWindowModality(QtCore.Qt.WindowModal)

        progress.setWindowTitle('Loading...')
        i = 1
        for obj in levelData['Obj'].subNodes():
            progress.setLabelText('Loading object ' + str(i) + '/' +
                                  str(amount))
            print "loading object " + str(obj)
            progress.setValue(i)
            self.loadObject(obj)
            self.glWidget.updateGL()
            i += 1
        self.saveAction.setEnabled(True)
        print now() - stime
        print str(amount) + ' Objects loaded'
Example #6
0
    def showSettings(self, obj):
        # this was slapped together, is getting ObjID from objflow.byaml and displaying that as the config_lbl
        modelNameMapping = {}
        with open(window.gamePath + '/data/objflow.byaml', 'rb') as f:
            b = byml.BYML(f.read(), True)
            for thing in b.rootNode.subNodes():
                resName = thing.subNodes()['ResName'].subNodes()[0].val
                id = thing['ObjId']
                modelNameMapping[id] = resName

        self.current = obj

        self.config_lbl = QtGui.QLabel(obj.fileName)  # int to a string
        self.config_lbl.setStyleSheet('font-size: 16px')
        self.layout.addWidget(self.config_lbl)

        self.config_lbl = QtGui.QLabel(str(
            obj.data['ObjId']))  # int to a string
        self.config_lbl.setStyleSheet('font-size: 16px')
        self.layout.addWidget(self.config_lbl)

        lbl = QtGui.QLabel('Translate:')
        lbl.setStyleSheet('font-size: 14px')
        self.layout.addWidget(lbl)
        self.transx = FloatEdit(obj.posx, self.changed)
        self.transy = FloatEdit(obj.posy, self.changed)
        self.transz = FloatEdit(obj.posz, self.changed)
        self.layout.addWidget(self.transx)
        self.layout.addWidget(self.transy)
        self.layout.addWidget(self.transz)

        lbl = QtGui.QLabel('Rotate:')
        lbl.setStyleSheet('font-size: 14px')
        self.layout.addWidget(lbl)
        self.rotx = FloatEdit(obj.rotx, self.changed)
        self.roty = FloatEdit(obj.roty, self.changed)
        self.rotz = FloatEdit(obj.rotz, self.changed)
        self.layout.addWidget(self.rotx)
        self.layout.addWidget(self.roty)
        self.layout.addWidget(self.rotz)

        lbl = QtGui.QLabel('Scale:')
        lbl.setStyleSheet('font-size: 14px')
        self.layout.addWidget(lbl)
        self.sclx = FloatEdit(obj.sclx, self.changed)
        self.scly = FloatEdit(obj.scly, self.changed)
        self.sclz = FloatEdit(obj.sclz, self.changed)
        self.layout.addWidget(self.sclx)
        self.layout.addWidget(self.scly)
        self.layout.addWidget(self.sclz)

        for key in obj.data.dict:
            vnode = obj.data.getSubNode(key)
            if not key in ['Scale', 'Translate', 'Rotate']:
                lbl = QtGui.QLabel(SettingName(key) + ':')
                if isinstance(vnode, byml.FloatNode):
                    box = FloatEdit(obj.data[key], self.changed2)
                    box.node = vnode
                elif isinstance(vnode, byml.IntegerNode):
                    box = IntEdit(obj.data[key], self.changed2)
                    box.node = vnode
                elif isinstance(vnode, byml.BooleanNode):
                    box = CheckBox(vnode)
                    if obj.data[key]:
                        box.toggle()
                elif isinstance(vnode, byml.StringNode):
                    box = LineEdit(str(obj.data[key]), self.changed2)
                    box.node = vnode
                    box.setEnabled(False)
                else:
                    box = QtGui.QLineEdit(str(obj.data[key]))
                    box.setEnabled(False)
                self.layout.addWidget(lbl)
                self.layout.addWidget(box)

            elif key == 'ObjId':
                lbl = QtGui.QLabel(key + ':')
                #box = LineEdit(str(obj.data['UnitConfigName']),self.configNameChanged)
                #box.node = vnode
                box = QtGui.QLineEdit(str(obj.data[key]))
                box.setEnabled(False)
                self.layout.addWidget(lbl)
                self.layout.addWidget(box)

            elif key == 'UnitIdNum':
                lbl = QtGui.QLabel(key + ':')
                if isinstance(vnode, byml.StringNode):
                    box = LineEdit(str(obj.data['UnitIdNum']),
                                   self.modelNameChanged)
                    box.node = vnode
                else:
                    box = QtGui.QLineEdit(str(obj.data['UnitIdNum']))
                    box.setEnabled(False)
                self.layout.addWidget(lbl)
                self.layout.addWidget(box)
Example #7
0
    def loadStageList(self):
        with open(self.gamePath+'/SystemData/StageList.szs','rb') as f:
            data = f.read()

        self.worldList = byml.BYML(sarc.extract(yaz0.decompress(data),'StageList.byml')).rootNode