Example #1
0
 def _update(self, root):
     #print "_update root type [%s]"%type(root), why root always return NoneType?
     if self.server == None:
         pytorque.setglobal("$loginInfo::message",
                            "Version checking failed!")
         return
     self.getWorldList()
Example #2
0
 def changeServer(self, root):
     if self.server == None:
         pytorque.setglobal("$loginInfo::message", "Login failed!")
         return
     WorldListBox = TorqueObject("WorldList")
     self.server.callRemote("changeServer", int(
         WorldListBox.getSelectedId())).addCallback(self._changeServer)
Example #3
0
 def _getWorldList(self, list):
     print "_getWorldList(self, list): %d" % len(list)
     WorldListBox = TorqueObject("WorldList")
     for key in list:
         print "key[%d] name[%s]" % (key, list[key])
         WorldListBox.addRow(key, list[key])
     loginButton = TorqueObject("LoginButton")
     signupButton = TorqueObject("SignupButton")
     loginButton.setActive(1)
     signupButton.setActive(1)
     pytorque.setglobal("$loginInfo::message", "Version updated!")
     self.updated = True
Example #4
0
 def _getWorldList(self, list):
     print "_getWorldList(self, list): %d"%len(list)
     WorldListBox = TorqueObject("WorldList")
     for key in list:
         print "key[%d] name[%s]"%(key, list[key])
         WorldListBox.addRow(key, list[key])
     loginButton = TorqueObject("LoginButton")
     signupButton = TorqueObject("SignupButton")
     loginButton.setActive(1)
     signupButton.setActive(1)
     pytorque.setglobal("$loginInfo::message","Version updated!")
     self.updated = True
Example #5
0
def OnSignupPressed(ip, port):
    global clientObj
    global userObj
    if not clientObj.updated: return

    username = pytorque.getglobal("$loginInfo::username")
    password1 = pytorque.getglobal("$loginInfo::password1")
    password2 = pytorque.getglobal("$loginInfo::password2")
    if password1 == "" or (password1 != password2):
        pytorque.setglobal("$loginInfo::message","Password Error!")
        return
    roleCtrl = TorqueObject("LoginRole")
    roleId = int(roleCtrl.getSelected())
    #print "name[%s] password[%s] confirm[%s] role[%d]" % (usernameCtrl.getText(), password1Ctrl.getText(), password2Ctrl.getText(), roleCtrl.getSelected())
    print "name[%s] password[%s] confirm[%s] role[%d]" % (username, password1, password2, roleId)
    clientObj.register(username, password1, roleId)
Example #6
0
def OnSignupPressed(ip, port):
    global clientObj
    global userObj
    if not clientObj.updated: return

    username = pytorque.getglobal("$loginInfo::username")
    password1 = pytorque.getglobal("$loginInfo::password1")
    password2 = pytorque.getglobal("$loginInfo::password2")
    if password1 == "" or (password1 != password2):
        pytorque.setglobal("$loginInfo::message", "Password Error!")
        return
    roleCtrl = TorqueObject("LoginRole")
    roleId = int(roleCtrl.getSelected())
    #print "name[%s] password[%s] confirm[%s] role[%d]" % (usernameCtrl.getText(), password1Ctrl.getText(), password2Ctrl.getText(), roleCtrl.getSelected())
    print "name[%s] password[%s] confirm[%s] role[%d]" % (username, password1,
                                                          password2, roleId)
    clientObj.register(username, password1, roleId)
Example #7
0
 def login(self, name, password, ip, port):
     self.name = name
     self.ip = ip
     pytorque.setglobal("$loginInfo::message", "Login in to world")
     return PbAuth.login(self, name, password, ip,
                         port).addCallback(self.changeServer)
Example #8
0
 def _registerFailure(self, failure):
     pytorque.setglobal("$loginInfo::message", failure.getErrorMessage())
Example #9
0
 def login(self, name, password, ip, port):
     pytorque.setglobal("$loginInfo::message", "Checking client version")
     return PbAuth.login(self, name, password, ip,
                         port).addCallback(self._update)
Example #10
0
#buttons are kind of worthless without commands.  Let's make one:
def OnMyButton(value):
    print "Button pushed with value",value
    
#export the function to the console system in much the same way the C++ system does...
#we also support optional namespaces, usage documentation, and min/max args
pytorque.export(OnMyButton,"MyButton","OnButton","Example button command",1,1)

#we can get and set fields (including dynamic fields).  We'll set our button's command:
button.command = "MyButton::OnButton(42);"

#we can call console methods on our TorqueObjects... So, let's simulate a button click.
#the OnMyButton function will be called with the value 42 :)
button.performClick()

#note that getting an object reference to the button and setting the command like this is 
#purely for illustration. You can also: command = "MyButton::OnButton(42);" in the evaluated code.

#moving on, we can get and set global variables
pytorque.setglobal("$MyVariable",42)
print pytorque.getglobal("$MyVariable")
pytorque.evaluate('echo ("*** Here is your variable:" @ $MyVariable);')

#the main loop is broken out and can be combined with other frameworks rather easily
while pytorque.tick():
    pass

#cleanup pytorque.. goodbye!
pytorque.shutdown()
Example #11
0
 def changeServer(self, root):
     if self.server == None:
         pytorque.setglobal("$loginInfo::message","Login failed!")
         return
     WorldListBox = TorqueObject("WorldList")
     self.server.callRemote("changeServer", int(WorldListBox.getSelectedId())).addCallback(self._changeServer)
Example #12
0
 def login(self, name, password, ip, port):
     self.name = name
     self.ip = ip
     pytorque.setglobal("$loginInfo::message","Login in to world")
     return PbAuth.login(self, name, password, ip, port).addCallback(self.changeServer)
Example #13
0
 def _registerFailure(self, failure):
     pytorque.setglobal("$loginInfo::message",failure.getErrorMessage())
Example #14
0
 def _update(self, root):
     #print "_update root type [%s]"%type(root), why root always return NoneType?
     if self.server == None: 
         pytorque.setglobal("$loginInfo::message","Version checking failed!")
         return
     self.getWorldList()
Example #15
0
 def login(self, name, password, ip, port):
     pytorque.setglobal("$loginInfo::message","Checking client version")
     return PbAuth.login(self, name, password, ip, port).addCallback(self._update)