Esempio n. 1
0
    def __init__(self, parent, url):
        wx.Panel.__init__(self, parent, style=wx.TE_PROCESS_ENTER, size=parent.getSize())
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.flash = Flash(self, url)
        sizer.Add(self.flash, proportion=1, flag=wx.EXPAND) #On Maximise, expand TFM
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        ######BINDS FOR EACH HOTKEY SHORTCUT#######
        self.Bind(wx.EVT_MENU, self.genericF1, id=220)
        self.Bind(wx.EVT_MENU, self.onKeyDownTest, id=221)
        self.Bind(wx.EVT_MENU, self.genericF2, id=222)
        self.Bind(wx.EVT_MENU, self.genericF3, id=223)
        self.Bind(wx.EVT_MENU, self.genericF4, id=224)
        self.Bind(wx.EVT_MENU, self.genericF5, id=225)
        self.Bind(wx.EVT_MENU, self.genericF6, id=226)
        self.Bind(wx.EVT_MENU, self.genericF7, id=227)
        self.Bind(wx.EVT_MENU, self.genericF8, id=228)
        self.Bind(wx.EVT_MENU, self.genericF9, id=229)
        self.Bind(wx.EVT_SIZE, self.onResizeResetPans)
        self.Bind(wx.EVT_MENU, self.panUp, id=240)
        self.Bind(wx.EVT_MENU, self.panDown, id=241)
        self.Bind(wx.EVT_MENU, self.panLeft, id=242)
        self.Bind(wx.EVT_MENU, self.panRight, id=243)
        self.Bind(wx.EVT_MENU, self.panReset, id=244)
        accel_tbl = wx.AcceleratorTable([(wx.ACCEL_NORMAL, wx.WXK_F1, 220),
                                         ((wx.ACCEL_NORMAL, ord('`'), 221)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F2, 222)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F3, 223)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F4, 224)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F5, 225)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F6, 226)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F7, 227)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F8, 228)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F9, 229)),
                                         ((wx.ACCEL_SHIFT, wx.WXK_UP, 240)),
                                         ((wx.ACCEL_SHIFT, wx.WXK_DOWN, 241)),
                                         ((wx.ACCEL_SHIFT, wx.WXK_LEFT, 242)),
                                         ((wx.ACCEL_SHIFT, wx.WXK_RIGHT, 243)),
                                         ((wx.ACCEL_CTRL, wx.WXK_SPACE, 244))
        ])
        self.Bind(wx.EVT_CHILD_FOCUS, self.focusTest)
        self.flash.SetAcceleratorTable(accel_tbl)
        #After Binds
        self.epoch = time.time()
        self.hotkeyId = 0
        self.isShaObj = False
        self.baseInitW = 0
        self.baseInitH = 0

        ###################################################
        #################Inherited Setting#################
        ###################################################
        self.getMSDelay = parent.proxyGetPictionaryDelay()
        self.getUsername = parent.proxyGetUsername()
        self.loadOffSetF1 = parent.proxyGetOffSetF1()
        self.loadOffSetF2 = parent.proxyGetOffSetF2()
        self.loadOffSetF3 = parent.proxyGetOffSetF3()
        self.loadOffSetF4 = parent.proxyGetOffSetF4()
Esempio n. 2
0
class MyPanel(wx.Panel):
    def __init__(self, parent, url):
        wx.Panel.__init__(self, parent, style=wx.TE_PROCESS_ENTER, size=parent.getSize())
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.flash = Flash(self, url)
        sizer.Add(self.flash, proportion=1, flag=wx.EXPAND) #On Maximise, expand TFM
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        ######BINDS FOR EACH HOTKEY SHORTCUT#######
        self.Bind(wx.EVT_MENU, self.genericF1, id=220)
        self.Bind(wx.EVT_MENU, self.onKeyDownTest, id=221)
        self.Bind(wx.EVT_MENU, self.genericF2, id=222)
        self.Bind(wx.EVT_MENU, self.genericF3, id=223)
        self.Bind(wx.EVT_MENU, self.genericF4, id=224)
        self.Bind(wx.EVT_MENU, self.genericF5, id=225)
        self.Bind(wx.EVT_MENU, self.genericF6, id=226)
        self.Bind(wx.EVT_MENU, self.genericF7, id=227)
        self.Bind(wx.EVT_MENU, self.genericF8, id=228)
        self.Bind(wx.EVT_MENU, self.genericF9, id=229)
        self.Bind(wx.EVT_SIZE, self.onResizeResetPans)
        self.Bind(wx.EVT_MENU, self.panUp, id=240)
        self.Bind(wx.EVT_MENU, self.panDown, id=241)
        self.Bind(wx.EVT_MENU, self.panLeft, id=242)
        self.Bind(wx.EVT_MENU, self.panRight, id=243)
        self.Bind(wx.EVT_MENU, self.panReset, id=244)
        accel_tbl = wx.AcceleratorTable([(wx.ACCEL_NORMAL, wx.WXK_F1, 220),
                                         ((wx.ACCEL_NORMAL, ord('`'), 221)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F2, 222)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F3, 223)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F4, 224)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F5, 225)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F6, 226)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F7, 227)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F8, 228)),
                                         ((wx.ACCEL_NORMAL, wx.WXK_F9, 229)),
                                         ((wx.ACCEL_SHIFT, wx.WXK_UP, 240)),
                                         ((wx.ACCEL_SHIFT, wx.WXK_DOWN, 241)),
                                         ((wx.ACCEL_SHIFT, wx.WXK_LEFT, 242)),
                                         ((wx.ACCEL_SHIFT, wx.WXK_RIGHT, 243)),
                                         ((wx.ACCEL_CTRL, wx.WXK_SPACE, 244))
        ])
        self.Bind(wx.EVT_CHILD_FOCUS, self.focusTest)
        self.flash.SetAcceleratorTable(accel_tbl)
        #After Binds
        self.epoch = time.time()
        self.hotkeyId = 0
        self.isShaObj = False
        self.baseInitW = 0
        self.baseInitH = 0

        ###################################################
        #################Inherited Setting#################
        ###################################################
        self.getMSDelay = parent.proxyGetPictionaryDelay()
        self.getUsername = parent.proxyGetUsername()
        self.loadOffSetF1 = parent.proxyGetOffSetF1()
        self.loadOffSetF2 = parent.proxyGetOffSetF2()
        self.loadOffSetF3 = parent.proxyGetOffSetF3()
        self.loadOffSetF4 = parent.proxyGetOffSetF4()


    def sizeDeterminerAndSend(self, correctionx, correctiony):
        x_val = self.getCorrectedX() + correctionx
        y_val = self.getCorrectedY() + correctiony
        s = SendKeys("", True, dest=(x_val,y_val))
        s.voidStart()

    #Bloew two methods correct the Coord. retrieval for all screen sizes, and center it to access Game Items.
    def getCorrectedX(self):
        tupleSize = self.GetSize()
        tuplePos = self.GetScreenPosition()
        x_val = int(tuplePos[0] + (tupleSize[0]/2))
        return x_val #Origin at center.

    def getCorrectedY(self):
        tupleSize = self.GetSize()
        tuplePos = self.GetScreenPosition()
        y_val = int(tuplePos[1] + (tupleSize[1]/2))
        return y_val #Likewise as X getter.


    def genericF1(self, event):
        if(self.hotkeyId == 0):
            t1 = time.time() - self.epoch
            if(t1 > self.getMSDelay):
                self.epoch = time.time()
                s = SendKeys("1", True)
                s.voidStart()

        elif(self.hotkeyId == 1):
            s = SendKeys("{enter}{!}off "+ self.loadOffSetF1+"{enter}", False)
            s.voidStart()

        elif(self.hotkeyId == 2):
            s = SendKeys("9ccc", False)
            s.voidStart()

        elif(self.hotkeyId == 3):
            if not self.isShaObj:
                self.sizeDeterminerAndSend(350,125)
                self.isShaObj = True
            else:
                self.isShaObj = False
                self.sizeDeterminerAndSend(300,125)
                #Resets mouse from Item globally using F1

        elif(self.hotkeyId == 4):
            s = SendKeys("{enter}/ch " +self.getUsername +"{enter}", False)
            s.voidStart()

        elif(self.hotkeyId == 5):
            s = SendKeys("{enter}voulez vous danser avec moi ce soir{enter}", False)
            s.voidStart()

    def genericF2(self, event):
        if(self.hotkeyId == 0):
            t1 = time.time() - self.epoch
            if(t1 > self.getMSDelay):
                self.epoch = time.time()
                s = SendKeys("1", True)
                s.voidStart()

        elif(self.hotkeyId == 1):
            s = SendKeys("{enter}{!}off "+ self.loadOffSetF2+"{enter}", False)
            s.voidStart()

        elif(self.hotkeyId == 2):
            s = SendKeys("9vv", False)
            s.voidStart()

        elif(self.hotkeyId == 3):
            if not self.isShaObj:
                self.sizeDeterminerAndSend(350,175)
                self.isShaObj = True
            else:
                self.isShaObj = False
                self.sizeDeterminerAndSend(300,125)

        elif(self.hotkeyId == 4):
            s = SendKeys("{enter}/sy{enter}", False)
            s.voidStart()

        elif(self.hotkeyId == 5):
            s = SendKeys("{enter}vous habitez chez vos parents{enter}", False)
            s.voidStart()

    def genericF3(self, event):
        if(self.hotkeyId == 1):
            s = SendKeys("{enter}{!}off "+self.loadOffSetF3+"{enter}", False)
            s.voidStart()

        elif(self.hotkeyId == 2):
            s = SendKeys("9cxxxxxx ", False)
            s.voidStart()

        elif(self.hotkeyId == 3):
            if not self.isShaObj:
                self.sizeDeterminerAndSend(300,175)
                self.isShaObj = True
            else:
                self.isShaObj = False
                self.sizeDeterminerAndSend(300,125)
                #Resets mouse from Item globally using F1

        elif(self.hotkeyId == 4):
            s = SendKeys("{enter}/np ", False)
            s.voidStart()

        elif(self.hotkeyId == 5):
            s = SendKeys("{enter}tu as de beaux yeux{enter}", False)
            s.voidStart()

    def genericF4(self, event):
        if(self.hotkeyId == 2):
            s = SendKeys("9cccxxxxxx ", False)
            s.voidStart()

        elif(self.hotkeyId == 1):
            s = SendKeys("{enter}{!}off "+self.loadOffSetF4+"{enter}", False)
            s.voidStart()

        elif(self.hotkeyId == 3):
            if not self.isShaObj:
                self.sizeDeterminerAndSend(300,125)
                self.isShaObj = True
            else:
                self.isShaObj = False
                self.sizeDeterminerAndSend(300,125)
                #Resets mouse from Item globally using F1

        elif(self.hotkeyId == 5):
            s = SendKeys("{enter}veux tu m'epouser{enter}", False)
            s.voidStart()

    def genericF5(self, event):
        if(self.hotkeyId == 2):
            s = SendKeys("7cc ", False)
            s.voidStart()

        elif(self.hotkeyId == 3):
            if not self.isShaObj:
                self.sizeDeterminerAndSend(300,225)
                self.isShaObj = True
            else:
                self.isShaObj = False
                self.sizeDeterminerAndSend(300,125)
                #Resets mouse from Item globally using F1

        elif(self.hotkeyId == 5):
            s = SendKeys("{enter}fais moi un bisous{enter}", False)
            s.voidStart()

    def genericF6(self, event):
        if(self.hotkeyId == 2):
            s = SendKeys("7ccc ", False)
            s.voidStart()

    def genericF7(self, event):
        if(self.hotkeyId == 2):
            s = SendKeys("4c4cccxxxxxx ", False)
            s.voidStart()

    def genericF8(self, event):
        if(self.hotkeyId == 2):
            s = SendKeys("5ccxxxxxx", False)
            s.voidStart()

    def genericF9(self, event):
        if(self.hotkeyId == 2):
            s = SendKeys("6ccxxxxxx ", False)
            s.voidStart()

    def onKeyDownTest(self, event):
        if(self.hotkeyId == 0):
            s = SendKeys("{ENTER}! ", False)
            s.voidStart()
        elif(self.hotkeyId != 2 and self.hotkeyId != -1):
            s = SendKeys("{ENTER}!", False)
            s.voidStart()
        elif self.hotkeyId == 2:
            s = SendKeys("{enter}Shaman it appears that I have found myself in a rather bothersome predicament, if you would be so kind as to assist me here I would appreciate that generosity of yours.{enter}", False)
            s.voidStart()
        else:
            pass

    def panUp(self, event):
        if(self.isMovingAlongBothAxes()): self.panReset(event)
        self.baseInitH += SHIFTER
        if self.flash.getHeight() + self.baseInitH < self.flash.getHeight():
            self.flash.SetDimensions(self.baseInitW,self.baseInitH,self.flash.getWidth() + self.baseInitW, self.flash.getHeight() - self.baseInitH)
        else:
            self.flash.SetDimensions(0,0,self.flash.getWidth() + self.baseInitW, self.flash.getHeight() + self.baseInitH)

    def panDown(self, event):
        if(self.isMovingAlongBothAxes()): self.panReset(event)
        self.baseInitH -= SHIFTER
        if not self.flash.getHeight() + self.baseInitH < self.flash.getHeight():
            self.flash.SetDimensions(0,0,self.flash.getWidth() + self.baseInitW, self.flash.getHeight() + self.baseInitH)
        else:
            self.flash.SetDimensions(self.baseInitW,self.baseInitH,self.flash.getWidth(), self.flash.getHeight() - self.baseInitH)

    def panLeft(self, event):
        if(self.isMovingAlongBothAxes()): self.panReset(event)
        self.baseInitW += SHIFTER
        if self.flash.getWidth() + self.baseInitW < self.flash.getWidth():
            self.flash.SetDimensions(self.baseInitW,self.baseInitH,self.flash.getWidth() - self.baseInitW, self.flash.getHeight() - self.baseInitH)
        else:
            self.flash.SetDimensions(0,0,self.flash.getWidth() + self.baseInitW, self.flash.getHeight() + self.baseInitH)


    def panRight(self,event):
        if(self.isMovingAlongBothAxes()): self.panReset(event)
        self.baseInitW -= SHIFTER
        if not self.flash.getWidth() + self.baseInitW < self.flash.getWidth():
            self.flash.SetDimensions(0,0,self.flash.getWidth() + self.baseInitW, self.flash.getHeight() + self.baseInitH)
        else:
            self.flash.SetDimensions(self.baseInitW,self.baseInitH,self.flash.getWidth() - self.baseInitW, self.flash.getHeight() - self.baseInitH)

    def onResizeResetPans(self, event):
        event.Skip()
        self.baseInitH = 0
        self.baseInitW = 0

    def panReset(self, event):
        self.baseInitH = 0
        self.baseInitW = 0
        self.flash.SetDimensions(0,0,self.flash.getWidth(), self.flash.getHeight())


    ##############################################
    #Getters, setters and test methods are below.#
    ##############################################
    #ToDo Remove this method and actually fix the negative axes movement, in 2 Dimensions
    def isMovingAlongBothAxes(self):
        if(self.baseInitH != 0 and self.baseInitW != 0):
            return True

    def getAbsolutePosX(self):
        return self.flash.GetPositionTuple()[0]

    def getAbsolutePosY(self):
        return self.flash.GetPositionTuple()[1]

    def setHotKeyId(self, id):
        self.hotkeyId = id

    def focusTest(self, event):
        pass