Esempio n. 1
0
    def updateState(self, pgEvent):
        # self.inLifeCicle = True
        # print(f'    pg.mouse.get_pressed() = {pg.mouse.get_pressed()}')
        # print(f'    pg.event.get() = {pg.event.get()}')
        # if pgEvent.type == pg.MOUSEBUTTONDOWN :
        #     print(f'    pgEvent.button = {pgEvent.button}')
        #     if pgEvent.button == 4 :
        #         print(f'    whell up')
        #     elif pgEvent.button == 5 :
        #         print(f'    whell down')
        #################################
        # pg.event.get() - related to exit or enter in application area, ammong possible others
        # pg.mouse.get_pressed()
        # 1- Left click
        # 2- Center click
        # 3- Right click
        # 4- Whell up
        # 5- Whell down
        if pg.mouse.get_pressed() != (0, 0, 0):
            # clear()
            pass

        if pg.mouse.get_pressed() == (1, 0, 0):
            if pgEvent.type == pg.MOUSEBUTTONDOWN:
                if self.lastBusyState == mouseFunction.State.NOT_BUZY:
                    self.nextState(mouseFunction.State.LEFT_CLICK_DOWN)
                    self.inLifeCicle = True

        if pg.mouse.get_pressed() == (0, 0, 0):
            if pgEvent.type == pg.MOUSEBUTTONUP:
                if self.lastBusyState == mouseFunction.State.LEFT_CLICK_DOWN:
                    self.nextState(mouseFunction.State.LEFT_CLICK_UP)
                    self.inLifeCicle = False
            elif self.state != mouseFunction.State.FREE:
                debugText = f'Mouse.updateState():\n'
                debugText += f'Mouse.lastBusyState = {self.lastBusyState}\n'
                debugText += f'Mouse.state = {self.state}\n'
                debugText += f'{mouseFunction.State.INVALID_STATE}\n'
                ErrorEvent.ErrorEvent(None, message=debugText)

        if not self.inLifeCicle:
            if self.lastBusyState != mouseFunction.State.NOT_BUZY and self.state != mouseFunction.State.FREE:
                debugText = f'Mouse.updateState():\n'
                debugText += f'Mouse.lastBusyState = {self.lastBusyState}\n'
                debugText += f'Mouse.state = {self.state}\n'
                debugText += f'{mouseFunction.State.INVALID_STATE}\n'
                ErrorEvent.ErrorEvent(None, message=debugText)
 def applicationScriptFileIsValid(self):
     if self.applicationScriptFile:
         applicationScriptFileIsValid = (
             self.applicationScriptFile ==
             f'{self.object.father.tutor.name}.{self.object.name}.{self.application.extension}'
         )
         if not applicationScriptFileIsValid:
             ErrorEvent.ErrorEvent(self, message='errorMessage')
         return applicationScriptFileIsValid
Esempio n. 3
0
 def addEvent(self, event):
     if event.name not in self.events:
         self.events[event.name] = event
     else:
         ErrorEvent.ErrorEvent(
             None,
             message=f'Handler.addEvent():\n' +
             f'      {event.name} already exists in {self.object.name}.handler.events'
         )
Esempio n. 4
0
 def removeEvent(self, event):
     if event.name in self.events:
         event.updateStatus(eventFunction.Status.REMOVED)
         del self.events[event.name]
     else:
         ErrorEvent.ErrorEvent(
             None,
             message=f'Handler.removeEvent():\n' +
             f'      {event.name} not found in {self.object.name}.handler.events'
         )
Esempio n. 5
0
 def revealObjects(self, objectNames):
     if objectNames:
         for objectName in objectNames:
             if objectName in self.object.handler.objects:
                 self.object.handler.objects[objectName].visible = True
             else:
                 ErrorEvent.ErrorEvent(
                     None,
                     message=
                     f'{objectName} not found in {self.object.name}.handler.objects'
                 )
         self.object.screen.mustUpdateNextFrame()
Esempio n. 6
0
 def removeObject(self, object):
     if object.name in self.objects:
         object.handler.removeAllEvents()
         object.handler.removeStudentTree()
         object.handler.removeObjectTree()
         # object.tutor.handler.removeStudent(object)
         object.screen.remove()
         del self.objects[object.name]
         self.object.screen.mustUpdateNextFrame()
     else:
         ErrorEvent.ErrorEvent(
             None,
             message=f'Handler.removeObject():\n' +
             f'      {object.name} not found in {self.object.name}.handler.objects'
         )
Esempio n. 7
0
 def update(self):
     if self.event.type == eventFunction.Type.CLICK_EVENT and self.object.onLeftClick :
         if self.object.onLeftClick :
             self.object.onLeftClick(self.event)
     elif self.event.type == eventFunction.Type.MENU_NAVIGATION_EVENT :
         if self.object.onMenuResolve :
             self.object.onMenuResolve(self.event)
     elif self.event.type == eventFunction.Type.HOVER_EVENT :
         if self.object.onHovering :
             self.object.onHovering(self.event)
     else :
         ErrorEvent.ErrorEvent(self.event,
             message = f'{self.name}.update(): {self.object.type} funcion handler not implemented'
         )
     self.updateStatus(eventFunction.Status.RESOLVED)
Esempio n. 8
0
 def removeStudent(self, student):
     if student.name in self.students:
         if student.name in self.students[
                 student.name].father.handler.objects:
             student.handler.removeAllEvents()
             student.handler.removeStudentTree()
             student.handler.removeObjectTree()
             del self.students[student.name].father.handler.objects[
                 student.name]
             self.object.screen.mustUpdateNextFrame()
     else:
         ErrorEvent.ErrorEvent(
             None,
             message=f'Handler.removeStudent():\n' +
             f'      {student.name} not found in {self.object.name}.handler.students'
         )
Esempio n. 9
0
    def __init__(self,
                 object,
                 name=None,
                 type=eventFunction.Type.EVENT,
                 inherited=False):

        if object:
            self.object = object
            self.application = self.object.application
            self.inherited = inherited
            self.newEvent = True

            if type:
                self.type = type
            else:
                self.type = eventFunction.Type.EVENT

            if name:
                self.name = name
            else:
                self.name = f'{self.type}.{object.name}'
            self.targetClass = object.__class__.__name__

            self.status = eventFunction.Status.NOT_RESOLVED

            if self.name not in self.object.handler.events:
                # print(f'{self.name} event added to {self.object.name}.handler.events')
                self.object.handler.addEvent(self)
            elif self.object.handler.events[
                    self.name].status == eventFunction.Status.NOT_RESOLVED:
                # print(f'{self.name} event not added to {self.object.name}.handler.events')
                self.object.handler.events[self.name].update()
                self.newEvent = False

            self.execute()

        else:
            import ErrorEvent
            ErrorEvent.ErrorEvent(None, message=getObjectHitDebugText(object))
Esempio n. 10
0
 def update(self, *args, **kargs):
     import ErrorEvent
     ErrorEvent.ErrorEvent(
         self.object,
         message=f'{self.type}.update() method not implemented')
     self.updateStatus(eventFunction.Status.RESOLVED)