def __init__( self, aParentWindow, pointOfAttach ):

        # call superclass
        ViewComponent.__init__( self,  pointOfAttach, 'attachment_box' , 'ObjectEditor.glade' )
        self.theParentWindow = aParentWindow
        self.updateInProgress = False
        self.theInfoBuffer = gtk.TextBuffer()
        self.theDescriptionBuffer = gtk.TextBuffer()
        self['classname_desc'].set_buffer( self.theDescriptionBuffer )
        self['user_info'].set_buffer( self.theInfoBuffer )

        # add handlers
        self.addHandlers({
                'on_combo-entry_changed' : self.__change_class, \
                'on_editor_notebook_switch_page' : self.__select_page,
                'on_ID_entry_editing_done' : self.__change_name,
                'on_user_info_move_focus' : self.__change_info
                })
        

        # initate Editors
        self.thePropertyList = PropertyList( self.theParentWindow, self['PropertyListFrame'] )
            
        self['vbox4'].remove( self['hbox3'] ) 
        #self['hbox3'] = None

        # make sensitive change class button for process
        self['class_combo'].set_sensitive( True )

        self.theModelEditor = self.theParentWindow.theModelEditor
        self.setDisplayedStepper( None )
    def __init__( self, aParentWindow, pointOfAttach ):

        # call superclass
        ViewComponent.__init__( self,  pointOfAttach, 'attachment_box' , 'ObjectEditor.glade' )
        self.theParentWindow = aParentWindow
        self.updateInProgress = False
        self.theInfoBuffer = gtk.TextBuffer()
        self.theDescriptionBuffer = gtk.TextBuffer()
        self['classname_desc'].set_buffer( self.theDescriptionBuffer )
        self['user_info'].set_buffer( self.theInfoBuffer )

        # add handlers
        self.addHandlers({
                'on_combo-entry_changed' : self.__change_class, \
                'on_editor_notebook_switch_page' : self.__select_page,
                'on_ID_entry_editing_done' : self.__change_name,
                'on_user_info_move_focus' : self.__change_info
                })
        

        # initate Editors
        self.thePropertyList = PropertyList( self.theParentWindow, self['PropertyListFrame'] )
        aNoteBook=ViewComponent.getWidget(self,'editor_notebook')

        self['ids'].remove( self['hbox3'] ) 
        #self['hbox3'] = None
        aNoteBook.set_tab_pos( gtk.POS_TOP )
        desc_horizontal = self['desc_horizontal']
        desc_vertical = self['desc_vertical']
        proplist = self['PropertyListFrame']
        infoDesc = self['info_desc']
        vertical = self['vertical_holder']
        horizontal = self['horizontal_holder']
        horizontal.remove( proplist)
        desc_horizontal.remove( infoDesc )
        vertical.pack_end( proplist)
        vertical.child_set_property( proplist, "expand", True )
        vertical.child_set_property( proplist, "fill", True )
        vertical.child_set_property( horizontal, "expand", False )

        desc_vertical.pack_end( infoDesc )
        vertical.show_all()
        desc_vertical.show_all()
        # make sensitive change class button for process
        self['class_combo'].set_sensitive( True )

        self.theModelEditor = self.theParentWindow.theModelEditor
        self.setDisplayedStepper( None )
Beispiel #3
0
	def __init__(self, eng, mobs, host, sec):
		self.engine = eng
		self.specific = mobs
		self.dir = "./data/mobster/"
		self.bot_name = mobs.nick
		self.host_channel = host
		self.prop_list = PropertyList.PropertyList(self.import_file(self.dir + "data/property_list.l"))
		self.item_list = ItemList.ItemList(self.import_file(self.dir + "data/item_list.l"))
		self.game = MobstersGame.MobstersGame(self)
		self.timer = 0
		self.security = sec
		self.public_toggle = False
		self.mobCredLevelUp = 3 # Points granted per level up
		self.msgb = MessageBuffer.MessageBuffer()
		#easy number reading
		locale.setlocale(locale.LC_ALL, "")
class StepperEditor(ViewComponent):
    def __init__( self, aParentWindow, pointOfAttach ):

        # call superclass
        ViewComponent.__init__( self,  pointOfAttach, 'attachment_box' , 'ObjectEditor.glade' )
        self.theParentWindow = aParentWindow
        self.updateInProgress = False
        self.theInfoBuffer = gtk.TextBuffer()
        self.theDescriptionBuffer = gtk.TextBuffer()
        self['classname_desc'].set_buffer( self.theDescriptionBuffer )
        self['user_info'].set_buffer( self.theInfoBuffer )

        # add handlers
        self.addHandlers({
                'on_combo-entry_changed' : self.__change_class, \
                'on_editor_notebook_switch_page' : self.__select_page,
                'on_ID_entry_editing_done' : self.__change_name,
                'on_user_info_move_focus' : self.__change_info
                })
        

        # initate Editors
        self.thePropertyList = PropertyList( self.theParentWindow, self['PropertyListFrame'] )
        aNoteBook=ViewComponent.getWidget(self,'editor_notebook')

        self['ids'].remove( self['hbox3'] ) 
        #self['hbox3'] = None
        aNoteBook.set_tab_pos( gtk.POS_TOP )
        desc_horizontal = self['desc_horizontal']
        desc_vertical = self['desc_vertical']
        proplist = self['PropertyListFrame']
        infoDesc = self['info_desc']
        vertical = self['vertical_holder']
        horizontal = self['horizontal_holder']
        horizontal.remove( proplist)
        desc_horizontal.remove( infoDesc )
        vertical.pack_end( proplist)
        vertical.child_set_property( proplist, "expand", True )
        vertical.child_set_property( proplist, "fill", True )
        vertical.child_set_property( horizontal, "expand", False )

        desc_vertical.pack_end( infoDesc )
        vertical.show_all()
        desc_vertical.show_all()
        # make sensitive change class button for process
        self['class_combo'].set_sensitive( True )

        self.theModelEditor = self.theParentWindow.theModelEditor
        self.setDisplayedStepper( None )

    def close( self ):
        """
        closes subcomponenets
        """
        self.thePropertyList.close()
        ViewComponent.close(self)

    def getDisplayedStepper( self ):
        """
        returns displayed Stepper
        """
        return self.theDisplayedStepper

    def update ( self ):
        """
        """

        # update Name
        self.updateEditor()

        # update propertyeditor

        self.thePropertyList.update()

    def updateEditor( self ):
        self.updateInProgress = True
        editableFlag = False
        if self.theDisplayedStepper != None:
            editableFlag = True
        self['ID_entry'].set_sensitive ( editableFlag )
        self['user_info'].set_sensitive( editableFlag )     

        if self.theDisplayedStepper !=None:
            nameText = self.theDisplayedStepper
        else:
            nameText = ''
        self['ID_entry'].set_text( nameText )
        # delete class list from combo
        self['class_combo'].entry.set_text('')
        self['class_combo'].set_popdown_strings([''])
        self['class_combo'].set_sensitive( False )
        self['class_combo'].set_data( 'selection', '' )
        descText = ''

        if self.theDisplayedStepper != None:
            self['class_combo'].set_sensitive( True )

            # get class list
            classStore = ecell.util.copyValue ( self.theModelEditor.getDMInfo().getClassList( DM_STEPPER_TYPE) )

        
            # get actual class

            actualclass = self.theModelEditor.getModel().getStepperClassName( self.theDisplayedStepper )
            self['class_combo'].set_popdown_strings(classStore)
        
            # select class
            self['class_combo'].entry.set_text( actualclass )

            self['class_combo'].set_data( 'selection', actualclass )
            descText = self.theModelEditor.getDMInfo().getClassInfo( actualclass, DM_DESCRIPTION )

        self.__setDescriptionText( descText )


        infoText = ''
        if self.theDisplayedStepper != None:
            infoText = self.theModelEditor.theModel.getStepperInfo( self.theDisplayedStepper)
        self.__setInfoText( infoText )
        self.updateInProgress = False

    def setDisplayedStepper ( self, selectedID ):
        """
        """

        self.theDisplayedStepper = selectedID 

        # sets displayed Stepper for Property Editor
        self.thePropertyList.setDisplayedEntity(DM_STEPPER_TYPE,  self.theDisplayedStepper )
        self.updateEditor()

    def addLayoutEditor( self, aLayoutEditor ):
        pass

    def changeClass( self, newClass ):
        currentClass = self.theModelEditor.getModel().getStepperClassName( self.theDisplayedStepper )
        if currentClass == newClass:
            return
        aCommand = ChangeStepperClass( self.theModelEditor, newClass, self.theDisplayedStepper )
        self.theModelEditor.doCommandList( [ aCommand ] )

    def changeName ( self, newName ):
        if not ecell.util.validateIDString( newName ):
            utils.showPopupMessage(
                utils.OK_MODE,
                "Only alphanumeric characters and _ are allowed in stepper ids!",
                ME_ERROR )
            self.updateEditor()
            return
        aCommand = RenameStepper( self.theModelEditor, self.theDisplayedStepper, newName )
        if aCommand.isExecutable:
            self.theDisplayedStepper = newName
            self.noActivate = True
            self.theModelEditor.doCommandList ( [ aCommand ] )
            self.noActivate = False
            self.theParentWindow.selectStepper( [newName ] )
        else:
            utils.showPopupMessage(
                utils.OK_MODE,
                "%s cannot be renamed to %s" % (
                    self.theDisplayedStepper,newName ),
                ME_ERROR )
            self.updateEditor()

    def changeInfo( self, newInfo ):
        oldInfo = self.theModelEditor.theModel.getStepperInfo( self.theDisplayedStepper )
        if oldInfo == newInfo:
            return
        aCommand = SetStepperInfo( self.theModelEditor, self.theDisplayedStepper, newInfo )
        self.theModelEditor.doCommandList( [ aCommand ] )

    # -- Private methods/Signal Handlers
    def __change_class( self, *args ):
        """
        called when class is to be changed
        """
        if args[0].get_text() == '':
            return
        if self.updateInProgress:
            return
        newClass = self['class_combo'].entry.get_text()

        self.changeClass( newClass )

    def __select_page( self, *args ):
        """
        called when editor pages are selected
        """
        pass

    def __change_name ( self, *args ):
        
        if self.updateInProgress:
            return

        newName = self['ID_entry'].get_text()
        self.changeName( newName )

    def __change_info( self, *args ):
        if self.updateInProgress:
            return
        newInfo = self.__getInfoText()
        self.changeInfo( newInfo )

    def __setDescriptionText( self, textString ):
        self.theDescriptionBuffer.set_text( textString )

    def __getInfoText( self ):
        endIter = self.theInfoBuffer.get_end_iter()
        startIter = self.theInfoBuffer.get_start_iter()
        return self.theInfoBuffer.get_text( startIter, endIter, True )

    def __setInfoText( self, textString ):
        self.theInfoBuffer.set_text( textString )