コード例 #1
0
ファイル: levelcmds.py プロジェクト: xuebai5/TheZombieEngine
    def on_delete_level(self, event):
        """Show a file browser and delete the selected level"""
        # Ask for the level's name
        current_level_name = get_name_of_current_level()
        dlg = filedlg.FileDialog(
                    self.get_frame(), 
                    filedlg.DELETE,
                    'level', 
                    'Level', 
                    "wc:levels", 
                    ["n2"],
                    excluded_files=['default.n2', '%s.n2' % current_level_name]
                    )
        result_ok = dlg.ShowModal() == wx.ID_OK
        level_name = dlg.get_guiname()
        level_path = dlg.get_path_as_string()
        dlg.Destroy()
        if not result_ok:
            return

        # Ask for confirmation
        msg = "All your hard work is going to be removed, deleted, " \
            "cleared, lost forever (ok, you can still revert\n" \
            "your working copy, but your local level is going to be " \
            "erased for sure).\n\nSo, are you sure that you want to " \
            "delete the '%s' level?" % level_name
        result = cjr.warn_yes_no(
                    self.get_frame(), 
                    msg
                    )
        if result != wx.ID_YES:
            return

        # Ask for final confirmation
        msg = "If you have clicked OK because of a tick in your finger, this " \
            "is your last chance to avoid throwing away the whole level.\n\n" \
            "Again, and for last time, are you ABSOLUTELY sure that you " \
            "want to delete the '%s' level?" % level_name
        result = cjr.warn_yes_no(
                        self.get_frame(), 
                        msg
                        )
        if result != wx.ID_YES:
            return

        # Finally delete the level (and the presets configuration)
        try:
            try:
                dlg = waitdlg.WaitDialog(
                            self.get_frame(),
                            "Deleting level %s..." % level_name
                            )
                unassign_preset( level_name )
                servers.get_conjurer().deletelevel(level_path)
            finally:
                dlg.Destroy()
        except:
            # make sure any errors are not hidden
            raise
コード例 #2
0
    def on_delete_level(self, event):
        """Show a file browser and delete the selected level"""
        # Ask for the level's name
        current_level_name = get_name_of_current_level()
        dlg = filedlg.FileDialog(
            self.get_frame(),
            filedlg.DELETE,
            'level',
            'Level',
            "wc:levels", ["n2"],
            excluded_files=['default.n2',
                            '%s.n2' % current_level_name])
        result_ok = dlg.ShowModal() == wx.ID_OK
        level_name = dlg.get_guiname()
        level_path = dlg.get_path_as_string()
        dlg.Destroy()
        if not result_ok:
            return

        # Ask for confirmation
        msg = "All your hard work is going to be removed, deleted, " \
            "cleared, lost forever (ok, you can still revert\n" \
            "your working copy, but your local level is going to be " \
            "erased for sure).\n\nSo, are you sure that you want to " \
            "delete the '%s' level?" % level_name
        result = cjr.warn_yes_no(self.get_frame(), msg)
        if result != wx.ID_YES:
            return

        # Ask for final confirmation
        msg = "If you have clicked OK because of a tick in your finger, this " \
            "is your last chance to avoid throwing away the whole level.\n\n" \
            "Again, and for last time, are you ABSOLUTELY sure that you " \
            "want to delete the '%s' level?" % level_name
        result = cjr.warn_yes_no(self.get_frame(), msg)
        if result != wx.ID_YES:
            return

        # Finally delete the level (and the presets configuration)
        try:
            try:
                dlg = waitdlg.WaitDialog(self.get_frame(),
                                         "Deleting level %s..." % level_name)
                unassign_preset(level_name)
                servers.get_conjurer().deletelevel(level_path)
            finally:
                dlg.Destroy()
        except:
            # make sure any errors are not hidden
            raise
コード例 #3
0
ファイル: nebulagui.py プロジェクト: xuebai5/TheZombieEngine
 def load_window_layout(self):
     dlg = filedlg.FileDialog(self,
                              filedlg.OPEN,
                              'layout file',
                              'Load window layout',
                              self.__window_layout_file_location(),
                              self.__window_layout_file_suffixes(),
                              import_button=False)
     if dlg.ShowModal() == wx.ID_OK:
         # Check that OK to close any open child windows
         ok_to_load = False
         child_views = self.get_child_dialogs()
         if len(child_views) == 0:
             ok_to_load = True
         else:
             msg = "Conjurer will close any open child windows.\n\n" \
                         "Are you sure you want to load the '%s' layout file?" \
                         % dlg.get_guiname()
             result = cjr.warn_yes_no(self, msg)
             if result == wx.ID_YES:
                 for each_child in child_views:
                     each_child.Close()
                 ok_to_load = True
         if ok_to_load:
             # Load the window layout
             self.load_window_layout_from_file(dlg.get_path())
     dlg.Destroy()
コード例 #4
0
ファイル: nebulagui.py プロジェクト: xuebai5/TheZombieEngine
 def load_window_layout(self):
     dlg = filedlg.FileDialog(
                 self, 
                 filedlg.OPEN,
                 'layout file', 
                 'Load window layout', 
                 self.__window_layout_file_location(), 
                 self.__window_layout_file_suffixes(),
                 import_button=False
                 )
     if dlg.ShowModal() == wx.ID_OK:
         # Check that OK to close any open child windows
         ok_to_load = False
         child_views = self.get_child_dialogs()
         if len(child_views) == 0:
             ok_to_load = True
         else:
             msg = "Conjurer will close any open child windows.\n\n" \
                         "Are you sure you want to load the '%s' layout file?" \
                         % dlg.get_guiname()
             result = cjr.warn_yes_no(
                             self, 
                             msg 
                             )
             if result == wx.ID_YES:
                 for each_child in child_views:
                     each_child.Close()
                 ok_to_load = True
         if ok_to_load:
             # Load the window layout
             self.load_window_layout_from_file( dlg.get_path() )
     dlg.Destroy()
コード例 #5
0
 def __on_delete_state(self, event):
     """Ask to confirm the state deletion and delete it if so"""
     state_name = self.list_states.GetStringSelection()
     if state_name != "":
         msg = "Deleting a state cannot be undone.\n"
         msg = msg + "Are you sure that you want to delete the "
         msg = msg + "'" + state_name + "' state?"
         result = cjr.warn_yes_no(self, msg)
         if result == wx.ID_YES:
             # Delete all transition targets pointing to the state to be deleted
             state = self.__get_current_state()
             fsm_ = fsm.get_fsm_of_state( state.getfullname() )
             states = fsm.get_states( fsm_ )
             for s in states:
                 transitions = fsm.get_transitions(s)
                 for t in transitions:
                     t_obj = pynebula.lookup(t)
                     t_obj.removetarget(state)
                     # Delete the transition if it's emmpty after deleting the target
                     if t_obj.gettargetsnumber() == 0:
                         s_obj = pynebula.lookup(s)
                         s_obj.deletetransition(t_obj)
                         t_obj = None
             
             # Delete the state
             self.__get_fsm().deletestate( state )
             state = None
             self.list_states.Delete( self.list_states.GetSelection() )
             self.__on_select_state(None)
             fsmevents.signal_fsm_change(self)
コード例 #6
0
ファイル: cmdmgrdlg.py プロジェクト: xuebai5/TheZombieEngine
    def on_delete_cmd(self, event):
        # Ask for delete confirmation
        cmd_name = self.list_cmds.GetStringSelection()
        if cmd_name == "":
            return
        msg = "Deleting a command cannot be undone.\n\n" \
                    "Are you sure that you want to delete the " \
                    "command '%s'?" % cmd_name
        should_delete = cjr.warn_yes_no(self, msg)
        # Delete the command if the user has confirmed they want to
        if should_delete == wx.ID_YES:
            # Delete the script file
            class_name = self.tree_classes.get_selected_class_name()
            cmd_path = self.__get_cmd_path(class_name, cmd_name)
            os.remove( cmd_path )

            # Delete the class directory if there's no commmands left
            class_path = self.__get_class_path(class_name)
            if len( filedlg.get_file_list( class_path, ['lua'] ) ) == 0:
                try:
                    os.rmdir( class_path )
                except:
                    cjr.show_error_message(
                        "Unable to delete the class commands directory '" + class_path + "'.\n" \
                        "Maybe is it not empty or is another application using it?\n" \
                        "Please, remove it manually."
                        )

            # Delete the command from the nclass in memory
            servers.get_script_server().refreshclass( str(class_name) )

            # Remove the command from the commands list
            self.list_cmds.Delete( self.list_cmds.GetSelection() )
            self.__update_buttons()
コード例 #7
0
ファイル: levelcmds.py プロジェクト: xuebai5/TheZombieEngine
 def on_new_level(self, event):
     """Create a new level replacing the old one, if user confirms"""
     # Ask for the level's name
     dlg = filedlg.FileDialog(
                 self.get_frame(), 
                 filedlg.NEW,
                 'level', 
                 'Level', 
                 "wc:levels", 
                 ["n2"]
                 )
     if dlg.ShowModal() == wx.ID_OK:
         # Check that's a new filename
         if dlg.file_exists():
             msg = "There is already a level called '%s'.\n\n" \
                         "Please enter a new level name." % dlg.get_guiname()
             cjr.show_error_message(msg)
         else:
             # Ask for final confirmation
             msg = "Any previous unsaved level data will be lost.\n\n" \
                     "Are you sure you want to create the new level '%s'?"\
                     % dlg.get_guiname()
             result = cjr.warn_yes_no(
                             self.get_frame(), 
                             msg
                             )
             if result == wx.ID_YES:
                 # Finally create the new level
                 if prelevel_process(True):
                     servers.get_conjurer().newlevel(
                         dlg.get_path_as_string()
                         )
                     postlevel_process(True)
     dlg.Destroy()
コード例 #8
0
ファイル: cmdmgrdlg.py プロジェクト: xuebai5/TheZombieEngine
    def on_delete_cmd(self, event):
        # Ask for delete confirmation
        cmd_name = self.list_cmds.GetStringSelection()
        if cmd_name == "":
            return
        msg = "Deleting a command cannot be undone.\n\n" \
                    "Are you sure that you want to delete the " \
                    "command '%s'?" % cmd_name
        should_delete = cjr.warn_yes_no(self, msg)
        # Delete the command if the user has confirmed they want to
        if should_delete == wx.ID_YES:
            # Delete the script file
            class_name = self.tree_classes.get_selected_class_name()
            cmd_path = self.__get_cmd_path(class_name, cmd_name)
            os.remove(cmd_path)

            # Delete the class directory if there's no commmands left
            class_path = self.__get_class_path(class_name)
            if len(filedlg.get_file_list(class_path, ['lua'])) == 0:
                try:
                    os.rmdir(class_path)
                except:
                    cjr.show_error_message(
                        "Unable to delete the class commands directory '" + class_path + "'.\n" \
                        "Maybe is it not empty or is another application using it?\n" \
                        "Please, remove it manually."
                        )

            # Delete the command from the nclass in memory
            servers.get_script_server().refreshclass(str(class_name))

            # Remove the command from the commands list
            self.list_cmds.Delete(self.list_cmds.GetSelection())
            self.__update_buttons()
コード例 #9
0
 def __on_delete(self, event):
     if self.has_item_selected():
         emitter_name = self.get_selected_emitter_name()
         result = cjr.warn_yes_no(
                         self,
                         "Are you sure you want to delete the "\
                         "'%s' Particle Emitter?" % emitter_name
                         )
         if result == wx.ID_YES:
             self.__delete_emitter(self.get_selected_emitter())
     else:
         cjr.show_error_message(
             "Please select a Particle Emitter to delete.")
コード例 #10
0
ファイル: editcmds.py プロジェクト: xuebai5/TheZombieEngine
 def on_delete_area(self, event):
     """Delete loading area"""
     # select an area and get a name
     dlg = nodelibdlg.NodeLibDialog(self.get_frame(), nodelibdlg.DELETE,
                                    'area', 'Area', "/usr/areas")
     ok_to_continue = dlg.ShowModal() == wx.ID_OK
     if ok_to_continue:
         msg = "Delete area '%s'?" % dlg.get_guiname()
         delete = cjr.warn_yes_no(self.get_frame(), msg)
         if delete == wx.ID_YES:
             # Delete the area from the level
             servers.get_loader_server().deleteloadarea(
                 str(dlg.get_guiname()))
     dlg.Destroy()
コード例 #11
0
 def __on_delete(self, event):
     if self.has_item_selected():
         emitter_name = self.get_selected_emitter_name()
         result = cjr.warn_yes_no(
                         self,
                         "Are you sure you want to delete the "\
                         "'%s' Particle Emitter?" % emitter_name
                         )
         if result == wx.ID_YES:
             self. __delete_emitter(
                 self.get_selected_emitter() 
                 )
     else:
         cjr.show_error_message(
             "Please select a Particle Emitter to delete."
             )
コード例 #12
0
ファイル: stringtree.py プロジェクト: xuebai5/TheZombieEngine
    def create_new_lib (self, position):
        wildcard = "Library files (*.n2)|*.n2"

        # Show file dialog
        dlg = wx.FileDialog(
            self.GetGrandParent(), 
            message="Create library", 
            wildcard=wildcard,
            style=wx.SAVE|wx.CHANGE_DIR|wx.OVERWRITE_PROMPT, 
            pos=position
            )

        # get the selected file
        if dlg.ShowModal() == wx.ID_OK:
            root = app.get_libraries()
            new_library_path = root.getfullname() + "/" + dlg.GetFilename()
            new_library_path, ext = os.path.splitext(new_library_path)

            # test extension
            if ext != ".n2":
                cjr.show_error_message(
                    "Bad extension: must be .n2. Try again."
                )
            else:
                # create object and save to disk
                save = True

                if pynebula.exists(str(new_library_path)):
                    dlg2_result = cjr.warn_yes_no(
                                "You are using a library with the same name."\
                                "\n\n Are you sure you want to delete it?"
                                )

                    if dlg2_result == wx.ID_NO:
                        save = False
                    else:
                        pynebula.delete( str(new_library_path) )

                if save:
                    library = pynebula.new("nstringlist", new_library_path)
                    path_string = str( dlg.GetPath() )
                    library.saveas(path_string)
                    foo, lib_name = os.path.split(new_library_path)
                    self.files[lib_name] = [path_string, False]
                    self.expand_tree(new_library_path.replace('/editor/',''))

        dlg.Destroy()
コード例 #13
0
ファイル: editcmds.py プロジェクト: xuebai5/TheZombieEngine
    def on_delete_stream(self, event):
        """Delete geometry stream"""
        # Ask for the stream name
        if not pynebula.exists(str("/usr/streams")):
            app.get_state("geometrystream").loadstreamlibrary()

        dlg = nodelibdlg.NodeLibDialog(self.get_frame(), nodelibdlg.DELETE,
                                       'stream', 'Stream', "/usr/streams")
        ok_to_continue = dlg.ShowModal() == wx.ID_OK
        if ok_to_continue:
            msg = "Delete stream '%s'?" % dlg.get_guiname()
            delete = cjr.warn_yes_no(self.get_frame(), msg)
            if delete == wx.ID_YES:
                # Delete the stream
                app.get_state("geometrystream").deletestream(
                    str(dlg.get_guiname()))
        dlg.Destroy()
コード例 #14
0
 def __on_delete_transition(self, event):
     """Ask to confirm the transition deletion and delete it if so"""
     transition_name = self.list_transitions.GetStringSelection()
     if transition_name != "":
         msg = "Deleting a transition cannot be undone.\n"
         msg = msg + "Are you sure that you want to delete the "
         msg = msg + "'" + transition_name + "' transition?"
         result = cjr.warn_yes_no(self, msg)
         if dlg.ShowModal() == wx.ID_YES:
             transition = self.__get_current_transition()
             self.__get_state().deletetransition( transition )
             transition = None
             self.list_transitions.Delete(
                 self.list_transitions.GetSelection() )
             self.__on_select_transition(None)
             self.__update_new_button()
             fsmevents.signal_fsm_change(self)
コード例 #15
0
ファイル: levelcmds.py プロジェクト: xuebai5/TheZombieEngine
 def on_open_level(self, event):
     """Show a file browser and open the selected level"""
     # Ask for the level's name
     dlg = filedlg.FileDialog(
                 self.get_frame(), 
                 filedlg.OPEN,
                 'level', 
                 'Level', 
                 "wc:levels", 
                 ["n2"], 
                 import_button=False
                 )
     if dlg.ShowModal() == wx.ID_OK:
         # Check that the filename exists
         level_name = dlg.get_guiname()
         if not dlg.file_exists():
             msg = "So you want to open the '%s' level that doesn't exist?" \
                         "\n<sigh> How curious these humans are..." \
                         % level_name
             cjr.show_error_message(msg)
         else:
             # Ask for final confirmation
             msg = "Any previous unsaved level data will be lost.\n\n" \
                         "Are you sure that you want to load the "\
                         "'%s' level?" % level_name
             result = cjr.warn_yes_no( self.get_frame(), msg )
             if result == wx.ID_YES:
                 # Finally load the level
                 try:
                     try:
                         dlg3 = waitdlg.WaitDialog(
                                     self.get_frame(),
                                     "Loading level %s..." % level_name
                                     )
                         if prelevel_process(True):
                             servers.get_conjurer().loadlevel(
                                                 dlg.get_path_as_string()
                                             )
                             postlevel_process(True)
                     finally:
                         dlg3.Destroy()
                 except:
                     # make sure any errors are not hidden
                     raise
     dlg.Destroy()
コード例 #16
0
ファイル: stringtree.py プロジェクト: xuebai5/TheZombieEngine
    def create_new_lib(self, position):
        wildcard = "Library files (*.n2)|*.n2"

        # Show file dialog
        dlg = wx.FileDialog(self.GetGrandParent(),
                            message="Create library",
                            wildcard=wildcard,
                            style=wx.SAVE | wx.CHANGE_DIR
                            | wx.OVERWRITE_PROMPT,
                            pos=position)

        # get the selected file
        if dlg.ShowModal() == wx.ID_OK:
            root = app.get_libraries()
            new_library_path = root.getfullname() + "/" + dlg.GetFilename()
            new_library_path, ext = os.path.splitext(new_library_path)

            # test extension
            if ext != ".n2":
                cjr.show_error_message(
                    "Bad extension: must be .n2. Try again.")
            else:
                # create object and save to disk
                save = True

                if pynebula.exists(str(new_library_path)):
                    dlg2_result = cjr.warn_yes_no(
                                "You are using a library with the same name."\
                                "\n\n Are you sure you want to delete it?"
                                )

                    if dlg2_result == wx.ID_NO:
                        save = False
                    else:
                        pynebula.delete(str(new_library_path))

                if save:
                    library = pynebula.new("nstringlist", new_library_path)
                    path_string = str(dlg.GetPath())
                    library.saveas(path_string)
                    foo, lib_name = os.path.split(new_library_path)
                    self.files[lib_name] = [path_string, False]
                    self.expand_tree(new_library_path.replace('/editor/', ''))

        dlg.Destroy()
コード例 #17
0
ファイル: cmdmgrdlg.py プロジェクト: xuebai5/TheZombieEngine
 def __add_command(self, class_name, template_name, cmd_proto):
     # Create an empty command for the selected class from a template
     class_path = self.__get_class_path( class_name )
     if not os.path.exists( class_path ):
         os.makedirs( class_path )
     template_path = self.__get_template_path( template_name )
     cmd_path = self.__get_cmd_path( class_name, cmd_proto )
     if os.path.exists( cmd_path ):
         # Give the opportunity to recover an old command (this may
         # happen when a command has been created but the user has forgot
         # to save the class before exiting Conjurer)
         msg = "A previously created command '%s' " \
                     "has been found.\n\n" \
                     "Do you want to recover it?" % cmd_proto
         recover = cjr.warn_yes_no(self, msg)    
         if recover == wx.ID_YES:
             return
     shutil.copy( template_path, cmd_path )
コード例 #18
0
ファイル: cmdmgrdlg.py プロジェクト: xuebai5/TheZombieEngine
 def __add_command(self, class_name, template_name, cmd_proto):
     # Create an empty command for the selected class from a template
     class_path = self.__get_class_path(class_name)
     if not os.path.exists(class_path):
         os.makedirs(class_path)
     template_path = self.__get_template_path(template_name)
     cmd_path = self.__get_cmd_path(class_name, cmd_proto)
     if os.path.exists(cmd_path):
         # Give the opportunity to recover an old command (this may
         # happen when a command has been created but the user has forgot
         # to save the class before exiting Conjurer)
         msg = "A previously created command '%s' " \
                     "has been found.\n\n" \
                     "Do you want to recover it?" % cmd_proto
         recover = cjr.warn_yes_no(self, msg)
         if recover == wx.ID_YES:
             return
     shutil.copy(template_path, cmd_path)
コード例 #19
0
 def on_delete(self, event):
     """Ask to confirm the object deletion and delete it if so"""
     name = self.list.GetStringSelection()
     if name != "":
         msg = "Deleting a %s cannot be undone.\n\n" \
                     "Are you sure you want to delete " \
                     "the '%s' %s?" % ( (self.caption, name, self.caption) )
         delete = cjr.warn_yes_no(self, msg)
         if delete == wx.ID_YES:
             obj_path = format.append_to_path( self.lib_path, name )
             if self.erase_object( pynebula.lookup(obj_path) ):
                 # Close the editor for this object if it's opened
                 editor = self._get_editor( obj_path )
                 if editor != None:
                     editor.Close()
                 # Delete the object
                 pynebula.delete( str(obj_path) )
                 self.list.Delete( self.list.GetSelection() )
                 self.__refresh_editors()
コード例 #20
0
ファイル: editcmds.py プロジェクト: xuebai5/TheZombieEngine
 def on_delete_area(self, event):
     """Delete loading area"""    
     # select an area and get a name
     dlg = nodelibdlg.NodeLibDialog(
                 self.get_frame(), 
                 nodelibdlg.DELETE,
                 'area', 
                 'Area', 
                 "/usr/areas"
                 )
     ok_to_continue = dlg.ShowModal() == wx.ID_OK
     if ok_to_continue:
         msg = "Delete area '%s'?" % dlg.get_guiname()
         delete = cjr.warn_yes_no( self.get_frame(), msg )
         if delete == wx.ID_YES:
             # Delete the area from the level
             servers.get_loader_server().deleteloadarea(
                 str( dlg.get_guiname() ) 
                 )
     dlg.Destroy()
コード例 #21
0
 def on_open_level(self, event):
     """Show a file browser and open the selected level"""
     # Ask for the level's name
     dlg = filedlg.FileDialog(self.get_frame(),
                              filedlg.OPEN,
                              'level',
                              'Level',
                              "wc:levels", ["n2"],
                              import_button=False)
     if dlg.ShowModal() == wx.ID_OK:
         # Check that the filename exists
         level_name = dlg.get_guiname()
         if not dlg.file_exists():
             msg = "So you want to open the '%s' level that doesn't exist?" \
                         "\n<sigh> How curious these humans are..." \
                         % level_name
             cjr.show_error_message(msg)
         else:
             # Ask for final confirmation
             msg = "Any previous unsaved level data will be lost.\n\n" \
                         "Are you sure that you want to load the "\
                         "'%s' level?" % level_name
             result = cjr.warn_yes_no(self.get_frame(), msg)
             if result == wx.ID_YES:
                 # Finally load the level
                 try:
                     try:
                         dlg3 = waitdlg.WaitDialog(
                             self.get_frame(),
                             "Loading level %s..." % level_name)
                         if prelevel_process(True):
                             servers.get_conjurer().loadlevel(
                                 dlg.get_path_as_string())
                             postlevel_process(True)
                     finally:
                         dlg3.Destroy()
                 except:
                     # make sure any errors are not hidden
                     raise
     dlg.Destroy()
コード例 #22
0
ファイル: cmdmgrdlg.py プロジェクト: xuebai5/TheZombieEngine
    def on_delete_class(self, event):
        # Ask for delete confirmation
        class_name = self.tree_classes.get_selected_class_name()
        if class_name is None:
            return
        msg = "Deleting a class cannot be undone.\n\n" \
                    "Are you sure that you want to delete " \
                    "the class '%s'?" % class_name
        should_delete = cjr.warn_yes_no(
                                self, 
                                msg
                                )
        # Delete the class if the user has said they want to go ahead
        if should_delete == wx.ID_YES:
            class_group = self.tree_classes.get_current_top_class_group()
            # Forbid deleting some classes in some situations
            if class_group is not None:
                can_delete_func_name = '_CommandManagerDialog__can_delete_' + class_group
                if CommandManagerDialog.__dict__.has_key(can_delete_func_name):
                    if not CommandManagerDialog.__dict__[can_delete_func_name](self, class_name):
                        return

            # Delete the class
            servers.get_script_server().deleteclass( str(class_name) )
            if not servers.get_entity_class_server().removeclass( str(class_name) ):
                msg = "Couldn't delete the class '" + class_name + "'.\n" \
                      "Causes may be an instantiated object of that class, " \
                      "a class with children or a native class."
                cjr.show_error_message(msg)
                return
            set_nclass_dirty_flag( True )

            # Delete the class directory
            class_path = self.__get_class_path( class_name )
            if os.path.exists( class_path ):
                remove_class_dir( class_path )

            # Refresh the class tree (and indirectly the command list)
            self.tree_classes.on_delete_class()
コード例 #23
0
ファイル: cmdmgrdlg.py プロジェクト: xuebai5/TheZombieEngine
    def on_delete_class(self, event):
        # Ask for delete confirmation
        class_name = self.tree_classes.get_selected_class_name()
        if class_name is None:
            return
        msg = "Deleting a class cannot be undone.\n\n" \
                    "Are you sure that you want to delete " \
                    "the class '%s'?" % class_name
        should_delete = cjr.warn_yes_no(self, msg)
        # Delete the class if the user has said they want to go ahead
        if should_delete == wx.ID_YES:
            class_group = self.tree_classes.get_current_top_class_group()
            # Forbid deleting some classes in some situations
            if class_group is not None:
                can_delete_func_name = '_CommandManagerDialog__can_delete_' + class_group
                if CommandManagerDialog.__dict__.has_key(can_delete_func_name):
                    if not CommandManagerDialog.__dict__[can_delete_func_name](
                            self, class_name):
                        return

            # Delete the class
            servers.get_script_server().deleteclass(str(class_name))
            if not servers.get_entity_class_server().removeclass(
                    str(class_name)):
                msg = "Couldn't delete the class '" + class_name + "'.\n" \
                      "Causes may be an instantiated object of that class, " \
                      "a class with children or a native class."
                cjr.show_error_message(msg)
                return
            set_nclass_dirty_flag(True)

            # Delete the class directory
            class_path = self.__get_class_path(class_name)
            if os.path.exists(class_path):
                remove_class_dir(class_path)

            # Refresh the class tree (and indirectly the command list)
            self.tree_classes.on_delete_class()
コード例 #24
0
ファイル: editcmds.py プロジェクト: xuebai5/TheZombieEngine
    def on_delete_stream(self, event):
        """Delete geometry stream"""
        # Ask for the stream name
        if not pynebula.exists( str("/usr/streams") ):
            app.get_state("geometrystream").loadstreamlibrary()

        dlg = nodelibdlg.NodeLibDialog(
                    self.get_frame(), 
                    nodelibdlg.DELETE,
                    'stream', 
                    'Stream', 
                    "/usr/streams"
                    )
        ok_to_continue = dlg.ShowModal() == wx.ID_OK
        if ok_to_continue:
            msg = "Delete stream '%s'?" % dlg.get_guiname()
            delete = cjr.warn_yes_no( self.get_frame(), msg )
            if delete == wx.ID_YES:
                # Delete the stream
                app.get_state("geometrystream").deletestream(
                    str( dlg.get_guiname() ) 
                    )
        dlg.Destroy()
コード例 #25
0
 def on_new_level(self, event):
     """Create a new level replacing the old one, if user confirms"""
     # Ask for the level's name
     dlg = filedlg.FileDialog(self.get_frame(), filedlg.NEW, 'level',
                              'Level', "wc:levels", ["n2"])
     if dlg.ShowModal() == wx.ID_OK:
         # Check that's a new filename
         if dlg.file_exists():
             msg = "There is already a level called '%s'.\n\n" \
                         "Please enter a new level name." % dlg.get_guiname()
             cjr.show_error_message(msg)
         else:
             # Ask for final confirmation
             msg = "Any previous unsaved level data will be lost.\n\n" \
                     "Are you sure you want to create the new level '%s'?"\
                     % dlg.get_guiname()
             result = cjr.warn_yes_no(self.get_frame(), msg)
             if result == wx.ID_YES:
                 # Finally create the new level
                 if prelevel_process(True):
                     servers.get_conjurer().newlevel(
                         dlg.get_path_as_string())
                     postlevel_process(True)
     dlg.Destroy()