예제 #1
0
    def data_change_10(self, p1, p2):
        '''
        Centralize
        first do 'Left Right Converge' and then 'Up Down Converge'
        '''
        p3 = Point()
        p4 = Point()
        self.data_change_6(p1, p2)  #first do 'Left Right Converge'
        #find the new position of p1,p2 after 'Left Right Converge',then do 'Up Down Converge' on new position
        p3.x = p1.x
        if p1.y < self.col / 2:
            p3.y = self.col / 2 - 1
            sign = -1
        else:
            p3.y = self.col / 2
            sign = 1
        while self.data[p3.x][p3.y] != 0:
            p3.y += sign

        p4.x = p2.x
        if p2.y < self.col / 2:
            p4.y = self.col / 2 - 1
            sign = -1
        else:
            p4.y = self.col / 2
            sign = 1
        while self.data[p4.x][p4.y] != 0:
            p4.y += sign

        #modify in case of special situation
        if p1.x == p2.x:
            if p1.y < self.col / 2 and p2.y < self.col / 2:
                p4.y = p3.y - 1
            elif p1.y >= self.col / 2 and p2.y >= self.col / 2:
                p4.y = p3.y + 1

        #p3,p4 are the new position of p1,p2 after 'Left Right Converge',
        #do 'Up Down Converge' on them
        self.data_change_5(p3, p4)
예제 #2
0
    def data_change_9(self, p1, p2):
        '''
        Disperse from Center
        first,left and right seperate,and then up and down seperate
        '''
        p3 = Point()
        p4 = Point()
        self.data_change_4(p1, p2)  #1.left and right seperate
        #find p1,p2 's position after 'left and right seperate',then do 'up and down seperate' on p1,p2 's new position
        p3.x = p1.x
        if p1.y < self.col / 2:
            p3.y = 0
            sign = 1
        else:
            p3.y = self.col - 1
            sign = -1
        while self.data[p3.x][p3.y] != 0:
            p3.y += sign

        p4.x = p2.x
        if p2.y < self.col / 2:
            p4.y = 0
            sign = 1
        else:
            p4.y = self.col - 1
            sign = -1
        while self.data[p4.x][p4.y] != 0:
            p4.y += sign

        #modify in case of special situation
        if p1.x == p2.x:
            if p1.y < self.col / 2 and p2.y < self.col / 2:
                p4.y = p3.y + 1
            elif p1.y >= self.col / 2 and p2.y >= self.col / 2:
                p4.y = p3.y - 1

        #p3,p4 are the new position of p1,p2 after 'left and right seperate',
        #do 'up and down seperate' on them
        self.data_change_3(p3, p4)
예제 #3
0
파일: llkgame.py 프로젝트: jifengmao/pyllk
    def data_change_10(self, p1, p2):
        '''
        Centralize
        first do 'Left Right Converge' and then 'Up Down Converge'
        '''
        p3 = Point()
        p4 = Point()
        self.data_change_6(p1, p2)   #first do 'Left Right Converge'
        #find the new position of p1,p2 after 'Left Right Converge',then do 'Up Down Converge' on new position
        p3.x = p1.x
        if p1.y < self.col/2:
            p3.y = self.col/2 - 1
            sign = -1
        else:
            p3.y = self.col/2
            sign = 1
        while self.data[p3.x][p3.y] != 0:
            p3.y += sign

        p4.x = p2.x
        if p2.y < self.col/2:
            p4.y = self.col/2 -1
            sign = -1
        else:
            p4.y = self.col/2
            sign = 1
        while self.data[p4.x][p4.y] != 0:
            p4.y += sign

        #modify in case of special situation
        if p1.x == p2.x:
            if p1.y < self.col/2 and p2.y < self.col/2:
                p4.y = p3.y - 1
            elif p1.y >= self.col/2 and p2.y >= self.col/2:
                p4.y = p3.y + 1

        #p3,p4 are the new position of p1,p2 after 'Left Right Converge',
        #do 'Up Down Converge' on them
        self.data_change_5(p3, p4)
예제 #4
0
파일: llkgame.py 프로젝트: jifengmao/pyllk
    def data_change_9(self, p1, p2):
        '''
        Disperse from Center
        first,left and right seperate,and then up and down seperate
        '''
        p3 = Point()
        p4 = Point()
        self.data_change_4(p1, p2)   #1.left and right seperate
        #find p1,p2 's position after 'left and right seperate',then do 'up and down seperate' on p1,p2 's new position
        p3.x = p1.x
        if p1.y < self.col/2:
            p3.y = 0
            sign = 1
        else:
            p3.y = self.col - 1
            sign = -1
        while self.data[p3.x][p3.y] != 0:
            p3.y += sign

        p4.x = p2.x
        if p2.y < self.col/2:
            p4.y = 0
            sign = 1
        else:
            p4.y = self.col - 1
            sign = -1
        while self.data[p4.x][p4.y] != 0:
            p4.y += sign

        #modify in case of special situation
        if p1.x == p2.x:
            if p1.y < self.col/2 and p2.y < self.col/2:
                p4.y = p3.y + 1
            elif p1.y >= self.col/2 and p2.y >= self.col/2:
                p4.y = p3.y - 1

        #p3,p4 are the new position of p1,p2 after 'left and right seperate',
        #do 'up and down seperate' on them
        self.data_change_3(p3, p4)
예제 #5
0
    def Display(self, caller=None, funnle=True, funnlefullscreen=False):
        """
        Display the menu
        """

        self.BeforeDisplay()

        if not self.IsShown() and len(self):

            self.spine.CalcSize()

            if caller and isinstance(caller, SimpleMenuSpine):

                self.caller = None
                rect = caller.GetSelectionRect()

                position = Point(rect.x + rect.width,
                                 rect.y - self.spine.framesize.top)
                newrect = RectPS(position, self.ScreenRect.Size)
                screenrect = Monitor.GetFromRect(newrect).Geometry

                if newrect.bottom > screenrect.bottom:
                    position.y = rect.y + rect.height - self.Size.height
                if newrect.right > screenrect.right:
                    position.x = rect.x - self.Size.width

            elif caller:
                self.caller = caller
                caller_rect = caller.ScreenRect
                position = caller_rect.BottomLeft
                newrect = RectPS(position, self.ScreenRect.Size)
                screenrect = Monitor.GetFromWindow(caller).Geometry

                if newrect.bottom > screenrect.bottom:
                    position.y -= caller_rect.Height + self.spine.Size.height
                if newrect.right > screenrect.right:
                    position.x += caller_rect.Width - self.spine.Size.width

            else:
                self.caller = None
                position = wx.GetMousePosition()
                newrect = RectPS(position, self.ScreenRect.Size)
                screenrect = Monitor.GetFromPoint(position).Geometry

                if newrect.bottom > screenrect.bottom:
                    position.y -= self.spine.Size.height
                if newrect.right > screenrect.right and pref(
                        'menus.shift_mode', False):
                    position.x -= self.spine.Size.width

            newrect = wx.RectPS(position, self.Size)
            screenrect = Monitor.GetFromRect(newrect).Geometry
            pos = screenrect.Clamp(newrect).Position if funnle else position
            self.SetRect(RectPS(pos, self.Size))

            self.spine.SetSelection(-1)

            fadein(self, 'xfast')
            self.spine.RefreshAll()

            if not self.spine.HasCapture():
                self.spine.CaptureMouse()

            wx.CallLater(10, self.Refresh)

            if not isinstance(caller, SimpleMenuSpine):
                self.TopConnect()
예제 #6
0
    def Display(self, caller = None, funnle = True,funnlefullscreen=False):
        """
        Display the menu
        """

        self.BeforeDisplay()

        if not self.IsShown() and len(self):

            self.spine.CalcSize()

            if caller and isinstance(caller, SimpleMenuSpine):

                self.caller = None
                rect = caller.GetSelectionRect()

                position = Point(rect.x+rect.width,rect.y - self.spine.framesize.top)
                newrect  = RectPS(position, self.ScreenRect.Size)
                screenrect = Monitor.GetFromRect(newrect).Geometry

                if newrect.bottom > screenrect.bottom:
                    position.y=rect.y+rect.height-self.Size.height
                if newrect.right > screenrect.right:
                    position.x=rect.x-self.Size.width

            elif caller:
                self.caller = caller
                caller_rect = caller.ScreenRect
                position    = caller_rect.BottomLeft
                newrect     = RectPS(position, self.ScreenRect.Size)
                screenrect  = Monitor.GetFromWindow(caller).Geometry

                if newrect.bottom > screenrect.bottom:
                    position.y -= caller_rect.Height + self.spine.Size.height
                if newrect.right > screenrect.right:
                    position.x += caller_rect.Width - self.spine.Size.width

            else:
                self.caller = None
                position    = wx.GetMousePosition()
                newrect     = RectPS(position, self.ScreenRect.Size)
                screenrect  = Monitor.GetFromPoint(position).Geometry

                if newrect.bottom > screenrect.bottom:
                    position.y -= self.spine.Size.height
                if newrect.right > screenrect.right and pref('menus.shift_mode', False):
                    position.x -= self.spine.Size.width

            newrect = wx.RectPS(position,self.Size)
            screenrect = Monitor.GetFromRect(newrect).Geometry
            pos = screenrect.Clamp(newrect).Position if funnle else position
            self.SetRect(RectPS(pos, self.Size))

            self.spine.SetSelection(-1)

            fadein(self, 'xfast')
            self.spine.RefreshAll()

            if not self.spine.HasCapture():
                self.spine.CaptureMouse()

            wx.CallLater(10, self.Refresh)

            if not isinstance(caller, SimpleMenuSpine):
                self.TopConnect()