Example #1
0
File: level.py Project: onze/Weld
 def load(self):
     """
     Overloads Savable.load, just to add sync with steel-sided level.
     """
     if self.qsteelwidget is not None:
         self.qsteelwidget.loadLevel()
     Savable.load(self)
Example #2
0
 def load(self):
     """
     Overloads Savable.load, just to add sync with steel-sided level.
     """
     if self.qsteelwidget is not None:
         self.qsteelwidget.loadLevel()
     Savable.load(self)
Example #3
0
File: weld.py Project: onze/Weld
    def __init__(self, parent=None):
        if Weld.__instance is None:
            Weld.__instance = self
        else:
            raise Exception('can\'t declare new Weld instance. Weld is a singleton.')
        Savable.__init__(self, savepath=os.path.join(user.home, '.weld', 'weld.cache'))
        self.savelist += ['current_project_path']
        # this is used to reload last opened project
        self.current_project_path = None

        Ui(self)

        # setup internal resource handlers
        self.project = None
        
        # list of resources we can ask steel to load
        self.resMan = ResourceManager(os.path.join(Config.instance().weld_data_path, 'resources'))
        self.resMan.attach_to_Ui(Ui.instance().res_browser['library'])

        # entity responsible for behavior trees manipulations
        self.BTMan = BTManager()

        # ready
        Ui.instance().show_status('ready', 1000)
        self.load()
        if Config.instance().on_weld_start_reopen_last_project:
            if self.current_project_path is not None:
                print 'auto reopening project \'%s\'.' % self.current_project_path
                p, f = os.path.split(self.current_project_path)
                self.open_project(self.current_project_path, f)
            else:
                print 'no project to reopen.'
        else:
            print 'skipping project reopening.'
Example #4
0
File: project.py Project: onze/Weld
 def load(self):
     Savable.load(self)
     Ui.instance().project_name = self.name
     print debug.curr_f(), ': Config.on_project_opening_reopen_last_level = True'
     if Config.instance().on_project_opening_reopen_last_level:
         print 'trying to reopen level named \'%s\'' % (self.level_name)
         if self.level_name:
             self.open_level(self.level_name)
         else:
             print >> sys.stderr, 'could not reopen such level.'
     else:
         print 'level auto reload skipped.'
Example #5
0
File: level.py Project: onze/Weld
 def save(self):
     """
     Retrieve some data before saving them.
     """
     self.camera_position = self.qsteelwidget.cameraPosition()
     self.camera_rotation = self.qsteelwidget.cameraRotation()
     Savable.save(self)
     if self.qsteelwidget.saveCurrentLevel():
         s='%(self)s saved successfuly'
     else:
         s='%(self)s failed to save'
     Ui.instance().show_status(s)
Example #6
0
 def save(self):
     """
     Retrieve some data before saving them.
     """
     self.camera_position = self.qsteelwidget.cameraPosition()
     self.camera_rotation = self.qsteelwidget.cameraRotation()
     Savable.save(self)
     if self.qsteelwidget.saveCurrentLevel():
         s = '%(self)s saved successfuly'
     else:
         s = '%(self)s failed to save'
     Ui.instance().show_status(s)
Example #7
0
File: project.py Project: onze/Weld
 def load(self):
     Savable.load(self)
     Ui.instance().project_name = self.name
     print debug.curr_f(
     ), ': Config.on_project_opening_reopen_last_level = True'
     if Config.instance().on_project_opening_reopen_last_level:
         print 'trying to reopen level named \'%s\'' % (self.level_name)
         if self.level_name:
             self.open_level(self.level_name)
         else:
             print >> sys.stderr, 'could not reopen such level.'
     else:
         print 'level auto reload skipped.'
Example #8
0
File: project.py Project: onze/Weld
    def __init__(self, rootdir):
        """
        rootdir: path to the root folder of the project. The project holds the
        directory name.
        """
        if not os.path.exists(rootdir):
            raise Exception('path %s does not exist.')
        self.rootdir = rootdir
        self.name = os.path.split(rootdir)[-1]
        Ui.instance()._project_name = self.name
        Savable.__init__(self, savepath=os.path.join(rootdir, self.name + Project.file_extension))

        self.level = None
        self.level_name = None

        # list of commands (as custom strings to execute at next call to on_steel_ready)
        self.on_steel_ready_actions = []
        #
        self.savelist += ['rootdir', 'name', 'level_name']
Example #9
0
File: level.py Project: onze/Weld
    def __init__(self, project, name, levelpath):
        """
        Holds material paths and keep the level browser sync with steel.
        params:
        name: level name
        levelpath: root path of resources used in the level (no sharing yet)
        """
        self.project = project
        self.name = name
        self.path = levelpath
        # list of AgentId's (int's)
        self.agents = []
        self.camera_position = QtGui.QVector3D()
        self.camera_rotation = QtGui.QVector4D()
        self.resMan = None
        self.qsteelwidget = None

        Savable.__init__(self, savepath=os.path.join(self.path, self.name + '.lvl.weld'))
        self.savelist += ['camera_position', 'camera_rotation']
        self.resources = {'meshes':[]}
Example #10
0
File: project.py Project: onze/Weld
    def __init__(self, rootdir):
        """
        rootdir: path to the root folder of the project. The project holds the
        directory name.
        """
        if not os.path.exists(rootdir):
            raise Exception('path %s does not exist.')
        self.rootdir = rootdir
        self.name = os.path.split(rootdir)[-1]
        Ui.instance()._project_name = self.name
        Savable.__init__(self,
                         savepath=os.path.join(
                             rootdir, self.name + Project.file_extension))

        self.level = None
        self.level_name = None

        # list of commands (as custom strings to execute at next call to on_steel_ready)
        self.on_steel_ready_actions = []
        #
        self.savelist += ['rootdir', 'name', 'level_name']
Example #11
0
    def __init__(self, project, name, levelpath):
        """
        Holds material paths and keep the level browser sync with steel.
        params:
        name: level name
        levelpath: root path of resources used in the level (no sharing yet)
        """
        self.project = project
        self.name = name
        self.path = levelpath
        # list of AgentId's (int's)
        self.agents = []
        self.camera_position = QtGui.QVector3D()
        self.camera_rotation = QtGui.QVector4D()
        self.resMan = None
        self.qsteelwidget = None

        Savable.__init__(self,
                         savepath=os.path.join(self.path,
                                               self.name + '.lvl.weld'))
        self.savelist += ['camera_position', 'camera_rotation']
        self.resources = {'meshes': []}
Example #12
0
    def __init__(self, parent=None):
        if Weld.__instance is None:
            Weld.__instance = self
        else:
            raise Exception(
                'can\'t declare new Weld instance. Weld is a singleton.')
        Savable.__init__(self,
                         savepath=os.path.join(user.home, '.weld',
                                               'weld.cache'))
        self.savelist += ['current_project_path']
        # this is used to reload last opened project
        self.current_project_path = None

        Ui(self)

        # setup internal resource handlers
        self.project = None

        # list of resources we can ask steel to load
        self.resMan = ResourceManager(
            os.path.join(Config.instance().weld_data_path, 'resources'))
        self.resMan.attach_to_Ui(Ui.instance().res_browser['library'])

        # entity responsible for behavior trees manipulations
        self.BTMan = BTManager()

        # ready
        Ui.instance().show_status('ready', 1000)
        self.load()
        if Config.instance().on_weld_start_reopen_last_project:
            if self.current_project_path is not None:
                print 'auto reopening project \'%s\'.' % self.current_project_path
                p, f = os.path.split(self.current_project_path)
                self.open_project(self.current_project_path, f)
            else:
                print 'no project to reopen.'
        else:
            print 'skipping project reopening.'
Example #13
0
File: project.py Project: onze/Weld
 def save(self):
     Savable.save(self)
     if self.level is not None:
         self.level.save()
Example #14
0
File: project.py Project: onze/Weld
 def save(self):
     Savable.save(self)
     if self.level is not None:
         self.level.save()