def AddInput(self): interpolationConstantText = Text(fonts.BebasNeue.c20, "Interpolation constant:", (255, 255, 255)) interpolationConstantText.y = 60 - interpolationConstantText.surface.get_size( )[1] / 2 interpolationConstantText.x = self.width / 4 - interpolationConstantText.surface.get_size( )[0] / 2 self.AddElement(interpolationConstantText, "textIC") interpolationConstantInput = Input() interpolationConstantInput.AllowNumbers() interpolationConstantInput.SetSize(100, 30) interpolationConstantInput.y = 60 - interpolationConstantInput.size[ 1] / 2 interpolationConstantInput.x = self.width / 4 * 3 - interpolationConstantInput.size[ 0] / 2 interpolationConstantInput.text = str(config.interpolation_constant) self.AddElement(interpolationConstantInput, "IConstant") thresholdText = Text(fonts.BebasNeue.c20, "Threshold correction:", (255, 255, 255)) thresholdText.y = 100 - thresholdText.surface.get_size()[1] / 2 thresholdText.x = self.width / 4 - thresholdText.surface.get_size( )[0] / 2 self.AddElement(thresholdText, "textTH") thresholdInput = Input() thresholdInput.AllowNumbers() thresholdInput.SetSize(100, 30) thresholdInput.y = 100 - thresholdInput.size[1] / 2 thresholdInput.x = self.width / 4 * 3 - thresholdInput.size[0] / 2 thresholdInput.text = str(config.threshold) self.AddElement(thresholdInput, "TH")
def SetGoalsFinal(self,cdata): if not cdata.has_key("FN"): return self.sum_y += 0 lineS = pygame.surface.Surface((300,1)) lineS.fill((255,255,255)) surfaceLine = Surface(lineS,(0,0)) surfaceLine.x = self.width/2 - lineS.get_size()[0]/2 surfaceLine.y = self.sum_y - lineS.get_size()[1]/2 self.AddElement(surfaceLine,"line") self.sum_y += 40 data = cdata["FN"] textFinal = Text(fonts.BebasNeue.c40,"final",(255,255,255),0,0) textFinal.y = self.sum_y - textFinal.surface.get_size()[1]/2 textFinal.x = self.width/2 - textFinal.surface.get_size()[0]/2 self.AddElement(textFinal,"textFinal") textA = Text(fonts.BebasNeue.c40,str(data["A"]),(255,255,255)) textA.y = self.sum_y - textA.surface.get_size()[1]/2 textA.x = self.width/4 - textA.surface.get_size()[0]/2 self.AddElement(textA,"final_A") textB = Text(fonts.BebasNeue.c40,str(data["B"]),(255,255,255)) textB.y = self.sum_y - textB.surface.get_size()[1]/2 textB.x = self.width/4*3 - textB.surface.get_size()[0]/2 self.AddElement(textB,"final_B") self.sum_y += 40
def SetData(self, ping, mode, players): #### PING #### self.DeleteElement("PingShown") PingContent = Text(fonts.BebasNeue.c20, ping, (255, 255, 255)) PingContent.y = 180 PingContent.x = self.width * 3 / 4 - PingContent.surface.get_size( )[0] / 2 self.AddElement(PingContent, "PingShown") #### MODE #### self.DeleteElement("ModeShown") ModeContent = Text(fonts.BebasNeue.c20, mode, (255, 255, 255)) ModeContent.y = 100 ModeContent.x = self.width * 3 / 4 - ModeContent.surface.get_size( )[0] / 2 self.AddElement(ModeContent, "ModeShown") #### PLAYERS #### self.DeleteElement("PlayersShown") PlayersContent = Text(fonts.BebasNeue.c20, players, (255, 255, 255)) PlayersContent.y = 140 PlayersContent.x = self.width * 3 / 4 - PlayersContent.surface.get_size( )[0] / 2 self.AddElement(PlayersContent, "PlayersShown")
def __init__(self, parent): self.parent = parent Window.__init__(self, "Add server", (36, 107, 97), (43, 76, 111), 0, 0, 500, 250, (255, 255, 255), 250) y_act = 40 + 5 name = Text(BebasNeue.c30, "Server name", (0, 0, 0)) name.x = self.width / 4 - name.surface.get_size()[0] / 2 name.y = y_act self.AddElement(name, "Name") #y_act += 3+name.surface.get_size()[1] name_input = Input() name_input.AllowAll() name_input.SetSize(200, 30) name_input.x = self.width / 4 * 3 - name_input.size[0] / 2 name_input.y = y_act name_input.SetTextColor(255, 0, 0) name_input.SetBackgroundColor(100, 100, 100) self.AddElement(name_input, "Name input") y_act += name_input.size[1] + name_input.border_size * 2 + 10 ip = Text(BebasNeue.c30, "IP Adress", (0, 0, 0)) ip.x = self.width / 4 - ip.surface.get_size()[0] / 2 ip.y = y_act self.AddElement(ip, "IP") #y_act += ip.surface.get_size()[1]+3 ip_input = Input() ip_input.AllowNumbers() ip_input.SetSize(200, 30) ip_input.x = self.width / 4 * 3 - ip_input.size[0] / 2 ip_input.y = y_act ip_input.SetTextColor(255, 0, 0) ip_input.SetBackgroundColor(100, 100, 100) name_input.SetNextInput(ip_input) self.AddElement(ip_input, "IP input") y_act += ip_input.size[1] + 2 * ip_input.border_size + 15 accept_button = AcceptButton("Create", 150, [self.width / 2 + 20, y_act]) self.AddElement(accept_button, "Create button") cancel_button = RejectButton("Cancel", 150, [self.width / 2 - 150 - 20, y_act]) self.AddElement(cancel_button, "Cancel button") y_act += cancel_button.size[1] + 5 self.height = y_act self.GenerateSurface() self.tab = False self.tab_elements = ["Name input", "IP input"] self.current_tab = -1
def __init__(self): Window.__init__(self, "High ping", (36, 107, 97), (43, 76, 111), 0, 0, 400, 150, (255, 255, 255)) textTitle = Text(fonts.BebasNeue.c30, "Your ping is too high", (255, 255, 255), 0, 0) textTitle.x = self.width / 2 - textTitle.surface.get_size()[0] / 2 textTitle.y = 60 self.AddElement(textTitle, "info") currentPing = Text(fonts.BebasNeue.c40, "", (255, 255, 255)) currentPing.x = self.width / 2 - textTitle.surface.get_size()[0] / 2 currentPing.y = 90 self.AddElement(currentPing, "ping")
def Login(self, data): #si el login es correcto self.loging_in = False if data["pass"] == "DT": session_query.SessionDeclareLogin(self.username, self.password) self.Kill() elif data["pass"] == "error": error_msg = Text(fonts.BebasNeue.c20, data["error"], (255, 0, 0)) error_msg.x = self.width / 2 - error_msg.surface.get_size()[0] / 2 error_msg.y = 26 if not self.references.has_key("Error"): self.AddElement(error_msg, "Error") extra = error_msg.surface.get_size()[1] self.references["User Text"].y += extra self.references["Pass Text"].y += extra self.references["User Input"].y += extra self.references["Pass Input"].y += extra self.references["Accept"].y += extra self.references["Cancel"].y += extra self.references["User Input"].SetBackgroundColor(200, 0, 0) self.references["Pass Input"].SetBackgroundColor(200, 0, 0) self.height += extra self.GenerateSurface() else: self.DeleteElement("Error") self.AddElement(error_msg, "Error")
def AddInputError(self, error): text = Text(fonts.BebasNeue.c20, "Sorry, your name is being used in this server", (200, 0, 0)) text.y = 50 text.x = self.width / 2 - text.surface.get_size()[0] / 2 self.AddElement(text, "inputError")
def AddFullA(self): self.fullA = True self.DeleteElement("ButtonA") signal = Text(fonts.BebasNeue.c30, "FULL", (255, 0, 0)) signal.x = self.width / 6 - signal.surface.get_size()[0] / 2 signal.y = 90 self.AddElement(signal, "ButtonA")
def SetUpTextB(self, text): self.DeleteElement("TextB") text = Text(fonts.BebasNeue.c20, str(text) + "/" + str(self.maxB), (255, 255, 255)) text.x = self.width / 6 * 5 - text.surface.get_size()[0] / 2 text.y = 60 self.AddElement(text, "TextB")
def UDPsignal(self): self.DeleteElement("PingUDP") PingUDPcontent = Text(fonts.BebasNeue.c20,str(Round(time.time()*1000 - self.count)) + "ms",(255,255,255)) PingUDPcontent.y = 200 PingUDPcontent.x = self.width/4*3 - PingUDPcontent.surface.get_size()[0]/2 self.AddElement(PingUDPcontent,"PingUDP") if self.allowConnect: self.AddAcceptReject()
def Start(self, error=None): self.Send({"action": "req_av_players"}) y_act = 40 if error != None: error = Text(fonts.BebasNeue.c20, error, (255, 0, 0)) error.x = self.width / 2 - error.surface.get_size()[0] / 2 error.y = y_act self.AddElement(error, "Error") y_act += error.surface.get_size()[1] + 10 textName = Text(fonts.BebasNeue.c30, "Player Name:", (255, 255, 255)) textName.x = self.width / 4 - textName.surface.get_size()[0] / 2 textName.y = y_act self.AddElement(textName, "TextName") inputName = Input() inputName.x = self.width / 4 * 3 - inputName.size[0] / 2 inputName.y = y_act inputName.AllowAll() inputName.SetSize(200, 30) self.AddElement(inputName, "inputName") y_act += 60 loading = LoadingAnimation(0.4, 5) loading.x = self.width / 2 - loading.width / 2 loading.y = y_act self.AddElement(loading, "LoadingA") y_act += 30 loadingText = Text(fonts.BebasNeue.c20, "Loading players...", (255, 255, 255)) loadingText.x = self.width / 2 - loadingText.surface.get_size()[0] / 2 loadingText.y = y_act self.AddElement(loadingText, "LoadingT") y_act += 70 cancelButton = RejectButton("Cancel") cancelButton.x = self.width / 2 - cancelButton.imageA.get_size()[0] / 2 cancelButton.y = y_act self.AddElement(cancelButton, "CancelButton") y_act += cancelButton.size[1] self.SetHeight(y_act + 10) self.originalPlayer = None
def Fail(self): textFail = Text(fonts.BebasNeue.c17, "Are you crazy?!?! try again", (255, 255, 255)) textFail.y = 25 textFail.x = self.width / 2 - textFail.surface.get_size()[0] / 2 self.AddElement(textFail, "fail") self.references["IConstant"].SetBackgroundColor(200, 0, 0) self.references["TH"].SetBackgroundColor(200, 0, 0)
def SetHead(self,headCode): headCodeText = Text(fonts.BebasNeue.c25,headCode,(255,255,255)) headCodeText.y = self.y-10 headCodeText.x = self.width/2 - headCodeText.surface.get_size()[0]/2 self.headCodeText = headCodeText self.headImage.ChangeImage(Heads.codes[headCode][0]) self.headImage.y = self.height/2-self.headImage.GetSize()[1]/2 self.headImage.x = self.width/2-self.headImage.GetSize()[0]/2
def __init__(self, parent, save): self.save = save Window.__init__(self, "Login", (36, 107, 97), (43, 76, 111), 0, 0, 400, 160, (255, 255, 255)) self.parent = parent font = fonts.AldoTheApache UserText = Text(font.c30, "Username:"******"User Text") PassText = Text(font.c30, "Password:"******"Pass Text") UserInput = Input() UserInput.AllowAll() UserInput.SetParent(self) UserInput.SetSize(150, 30) UserInput.x = self.width / 2 + 5 UserInput.y = self.height / 2 - UserInput.size[1] - 2 - 15 self.AddElement(UserInput, "User Input") PassInput = copy.copy(UserInput) PassInput.y += PassInput.size[1] + 5 PassInput.password = True self.AddElement(PassInput, "Pass Input") UserInput.SetNextInput(PassInput) Accept = AcceptButton("Login", 150, (0, 0), font) Accept.x = self.width / 2 + 10 Accept.y = PassInput.y + PassInput.size[1] + 20 self.AddElement(Accept, "Accept") Reject = RejectButton("Cancel", 150, (0, 0), font) Reject.x = self.width / 2 - 10 - Reject.size[0] Reject.y = Accept.y self.AddElement(Reject, "Cancel") self.was_pressed1 = False self.was_pressed2 = False self.parent.SetLoginDef(self.Login) self.loging_in = False self.username = "" self.password = ""
def SetGoalsSHalf(self,cdata): if not cdata.has_key("SH"): return data = cdata["SH"] textSHalf = Text(fonts.BebasNeue.c30,"2nd",(255,255,255),0,0) textSHalf.y = self.sum_y - textSHalf.surface.get_size()[1]/2 textSHalf.x = self.width/2 - textSHalf.surface.get_size()[0]/2 self.AddElement(textSHalf,"textSHalf") textA = Text(fonts.BebasNeue.c40,str(data["A"]),(255,255,255)) textA.y = self.sum_y - textA.surface.get_size()[1]/2 textA.x = self.width/4 - textA.surface.get_size()[0]/2 self.AddElement(textA,"second_half_A") textB = Text(fonts.BebasNeue.c40,str(data["B"]),(255,255,255)) textB.y = self.sum_y - textB.surface.get_size()[1]/2 textB.x = self.width/4*3 - textB.surface.get_size()[0]/2 self.AddElement(textB,"second_half_B") self.sum_y += 40
def SetNameInput(self, with_error=None): self.RemoveLoading() self.RemoveMSJ() self.RemoveQuit() self.mode = "setting-name" self.RemoveLoading() self.RemoveMSJ() self.RemoveQuit() y_act = 30 if with_error != None: error = Text(fonts.BebasNeue.c20, with_error, (255, 0, 0)) error.x = self.width / 2 - error.surface.get_size()[0] / 2 error.y = y_act self.AddElement(error, "Error") y_act += error.surface.get_size()[1] + 5 textQuestion = Text(fonts.BebasNeue.c30, "Name:", (255, 255, 255)) textQuestion.x = self.width / 4 textQuestion.y = y_act self.AddElement(textQuestion, "Question") input = Input() input.AllowAll() input.SetSize(200, 30) input.x = textQuestion.x + textQuestion.surface.get_size()[0] + 10 input.y = y_act input.SetTextColor(0, 0, 0) input.SetBackgroundColor(100, 100, 100) self.AddElement(input, "Input") y_act += 50 confirmButton = AcceptButton("Confirm") confirmButton.x = self.width / 2 - confirmButton.size[0] / 2 confirmButton.y = y_act self.AddElement(confirmButton, "Confirm") y_act += confirmButton.size[1] self.SetHeight(y_act)
def __init__(self): Window.__init__(self, "Connection lost", (200, 100, 100), (43, 76, 111), 0, 0, 400, 120, (0, 0, 0), 255) textContent = Text(fonts.BebasNeue.c30, "Network game server conection lost", (255, 255, 255)) textContent.y = 50 textContent.x = self.width / 2 - textContent.surface.get_size()[0] / 2 self.AddElement(textContent) ButtonAccept = NeutralButton("OK") ButtonAccept.y = 90 ButtonAccept.x = self.width / 2 - ButtonAccept.imageA.get_size()[0] / 2 self.AddElement(ButtonAccept, "Accept")
def SetLoading(self): self.DeleteElement("TextName") self.DeleteElement("inputName") self.DeleteElement("CancelButton") self.DeleteElement("AcceptButton") self.DeleteElement("Selector") self.DeleteElement("Error") loading = LoadingAnimation(0.4, 5) loading.x = self.width / 2 - loading.width / 2 loading.y = self.height / 2 - 10 - loading.height self.AddElement(loading, "LoadingA") loadingText = Text(fonts.BebasNeue.c20, "Checking name...", (255, 255, 255)) loadingText.x = self.width / 2 - loadingText.surface.get_size()[0] / 2 loadingText.y = self.height / 2 + 10 self.AddElement(loadingText, "LoadingT")
def __init__(self,data): Window.__init__(self,"Match statistics",(36, 107, 97),(36, 107, 97),0,0,500,300,(255,255,255),200) textWin = Text(fonts.CTProLamina.c40,data["textWin"],(255,255,255),0,0) textWin.y = 40 textWin.x = self.width/2 - textWin.surface.get_size()[0]/2 self.AddElement(textWin,"textWin") self.sum_y = 100 self.SetGoalsFHalf(data["goalsData"]) self.SetGoalsSHalf(data["goalsData"]) self.SetGoalsFinal(data["goalsData"]) self.ref = time.time() self.left = 20 self.wait = 20 self.AddTimeSurface()
def __init__(self): ww, hh = pygame.display.get_surface().get_size() ww -= 50 hh -= 50 Window.__init__(self, "MULTITPLAYER GAME", (36, 107, 97), (43, 76, 111), 0, 0, ww, hh, (255, 255, 255)) self.enabled = False self.locked = True title = Text(fonts.BebasNeue.c40, "SERVER BROWSER", (255, 255, 255)) title.x = self.width / 2 - title.surface.get_size()[0] / 2 title.y = 35 self.AddElement(title) #bar = Bar(10,400,0.1,self.width-50,100) #self.AddElement(bar) listSystem = list_system.ListSystem(0, 0, True, self.height - 250) listSystem.AddUpKey("Name", 400) listSystem.AddUpKey("IP", 150) listSystem.AddUpKey("Mode", 150) listSystem.y = 100 listSystem.x = self.width / 2 - listSystem.width / 2 self.AddElement(listSystem, "ListSystem") connectButton = AdvancedButton((350, 80), (0, 0), "Connect", (63, 20, 57), (43, 11, 39)) distance_to_back_list = (listSystem.y + 70 + listSystem.height) connectButton.y = ( self.height - distance_to_back_list ) / 2 + distance_to_back_list - connectButton.image.get_size()[1] / 2 connectButton.x = self.width / 2 - connectButton.image.get_size()[0] / 2 self.AddElement(connectButton, "ConnectButton") add = ClassicButton("+", (0, 255, 0), (0, listSystem.y + listSystem.height + 50)) add.x = listSystem.x + listSystem.width - add.imageA.get_size()[0] self.AddElement(add, "AddButton") remove = ClassicButton("-", (255, 0, 0), (0, add.y)) remove.x = add.x - remove.size[0] self.AddElement(remove, "RemoveButton") self.LoadLocalSevers()
def SetInputName(self): self.DeleteAllElements() nameInputTitle = Text(fonts.BebasNeue.c30, "Name:", (255, 255, 255)) nameInputTitle.y = 100 - nameInputTitle.surface.get_size()[1] / 2 nameInputTitle.x = self.width / 4 - nameInputTitle.surface.get_size( )[0] / 2 self.AddElement(nameInputTitle, "nameInput") inputField = Input() inputField.SetSize(150, 30) inputField.y = 100 - inputField.size[1] / 2 inputField.x = self.width / 4 * 3 - inputField.size[0] / 2 inputField.AllowAll() self.AddElement(inputField, "inputField") okButton = AcceptButton("Accept", 200) okButton.y = 150 - okButton.size[1] / 2 okButton.x = self.width / 2 - okButton.imageA.get_size()[0] / 2 self.AddElement(okButton, "okButton")
def SetOpinion(self,data): self.mode = "opinion" self.RemoveLoading() self.RemoveMSJ() self.RemoveQuit() textQuestion = Text(fonts.BebasNeue.c25,data["content"]["question"],(255,255,255)) textQuestion.x = self.width/2-textQuestion.surface.get_size()[0]/2 textQuestion.y = 30 self.AddElement(textQuestion,"Question") self.optionsButtons = [] for x in range(len(data["content"]["options"])): button_text = data["content"]["options"][x] button = NeutralButton(button_text,400) button.x = self.width/2-button.imageA.get_size()[0]/2 button.y = 70 + 45*x name = "Button "+str(x) self.AddElement(button,name) self.optionsButtons.append(name) if button.y > self.height: self.SetHeight(button.y+50)
def RegisterConfirm(self, data): if data["error"] != "": self.sending_data = False error = Text(fonts.BebasNeue.c20, data["error"], (255, 0, 0)) error.x = self.width / 2 - error.surface.get_size()[0] / 2 error.y = 29 if not self.references.has_key("Error"): self.AddElement(error, "Error") add = error.surface.get_size()[1] + 5 elements = [ "User Text", "User Input", "Pass Text", "Pass Input", "Confirm Password Text", "Confirm Password Input", "Email Text", "Email Input", "Accept", "Cancel" ] for x in elements: self.references[x].y += add self.height += add self.GenerateSurface() else: self.DeleteElement("Error") self.AddElement(error, "Error") else: self.parent.DeleteWindow("SignUp") self.parent.AddWindowCenteredOnFront(self.save, None, "Login")
def __init__(self, parent, dataSession): Window.__init__(self, "Restore game", (253, 245, 230), (30, 144, 255), 0, 0, 400, 330, (0, 0, 0), 255, (0, 0, 0)) self.parent = parent self.data = dataSession textColor = 255, 255, 255 title = Text(fonts.BebasNeue.c15, "Your last connection data:", textColor) title.x = self.width / 2 - title.surface.get_size()[0] / 2 title.y = 30 self.AddElement(title, "Tittle") if dataSession["status"] == "TryConnect" or dataSession[ "status"] == "TryConnectRoom": server = Text(fonts.BebasNeue.c20, "Server Address: ", textColor) server.x = self.width / 4 - server.surface.get_size()[0] / 2 server.y = 80 - server.surface.get_size()[1] / 2 self.AddElement(server, "Server title") server_IP = Text(fonts.BebasNeue.c30, str(dataSession["ip"]), textColor) server_IP.x = self.width / 4 * 3 - server_IP.surface.get_size( )[0] / 2 server_IP.y = 80 - server_IP.surface.get_size()[1] / 2 self.AddElement(server_IP, "ip data") if dataSession["logData"]["type"] == "needGuestName": textInfo = Text(fonts.BebasNeue.c30, "You need to be asigned a name!", textColor) textInfo.x = self.width / 2 - textInfo.surface.get_size()[0] / 2 textInfo.y = 90 - textInfo.surface.get_size()[1] / 2 self.AddElement(textInfo, "textInfo") else: textSession = Text(fonts.BebasNeue.c15, "Your login data:", textColor) textSession.x = self.width / 2 - textSession.surface.get_size( )[0] / 2 textSession.y = 130 - textSession.surface.get_size()[1] / 2 self.AddElement(textSession, "sessionData") textType = Text(fonts.BebasNeue.c20, "Type:", textColor) textType.x = self.width / 4 - textType.surface.get_size()[0] / 2 textType.y = 160 - textSession.surface.get_size()[1] / 2 self.AddElement(textType, "sessionTypeText") if dataSession["logData"]["type"] == "guest": textContentType = Text(fonts.BebasNeue.c30, "Guest", textColor) else: textContentType = Text(fonts.BebasNeue.c20, "Login", textColor) ### ADD PASSWORD FIELD passTitle = Text(fonts.BebasNeue.c20, "password:"******"passTitle") passContent = Text(fonts.BebasNeue.c30, "****", textColor) passContent.y = 225 - passContent.surface.get_size()[1] / 2 passContent.x = self.width / 4 * 3 - passContent.surface.get_size( )[0] / 2 self.AddElement(passContent, "passContent") titleName = Text(fonts.BebasNeue.c20, "User:"******"titleName") nameContent = Text(fonts.BebasNeue.c20, dataSession["logData"]["name"], textColor) nameContent.x = self.width / 4 * 3 - nameContent.surface.get_size( )[0] / 2 nameContent.y = 200 - nameContent.surface.get_size()[1] / 2 self.AddElement(nameContent, "name") ### ADD TEXT CONTENT TYPE, GUEST OR LOGIN textContentType.x = self.width / 4 * 3 - textContentType.surface.get_size( )[0] / 2 textContentType.y = 160 - textContentType.surface.get_size( )[1] / 2 self.AddElement(textContentType, "contentType") if dataSession["status"] == "TryConnectRoom": titleRoom = Text(fonts.BebasNeue.c20, "Room", textColor) titleRoom.x = self.width / 4 - titleRoom.surface.get_size( )[0] / 2 titleRoom.y = 240 - titleRoom.surface.get_size()[1] / 2 self.AddElement(titleRoom, "titleRoom") roomContent = Text(fonts.BebasNeue.c20, dataSession["room"], textColor) roomContent.x = self.width / 4 * 3 - roomContent.surface.get_size( )[0] / 2 roomContent.y = 240 - roomContent.surface.get_size()[1] / 2 self.AddElement(roomContent, "roomName") self.AddButtons() self.parent.SetOptionRoomsDef(self.JoiningActions) self.parent.SetErrorDef(self.Network_Error) self.parent.SetConnectDef(self.Network_connected) self.parent.SetRBasicDef(self.Network_RBasic) self.parent.SetLoginDef(self.LoginSuccess)
def __init__(self, x, y, server_name, server_ip, parent): self.ip = server_ip Window.__init__(self, server_name, (36, 107, 97), (43, 76, 111), x, y, 500, 330, (255, 255, 255), 250) self.parent = parent textIP = Text(fonts.BebasNeue.c30, server_ip, (255, 255, 255)) textIP.y = 30 textIP.x = self.width / 2 - textIP.surface.get_size()[0] / 2 self.AddElement(textIP) textDetails = Text(fonts.BebasNeue.c20, "DETAILS:", (255, 255, 255)) textDetails.y = 70 textDetails.x = self.width / 2 - textDetails.surface.get_size()[0] / 2 self.AddElement(textDetails) Mode = Text(fonts.BebasNeue.c20, "MODE:", (255, 255, 255)) Mode.y = 100 Mode.x = self.width / 4 - Mode.surface.get_size()[0] / 2 self.AddElement(Mode) Players = Text(fonts.BebasNeue.c20, "PLAYERS:", (255, 255, 255)) Players.y = 140 Players.x = self.width / 4 - Players.surface.get_size()[0] / 2 self.AddElement(Players) Ping = Text(fonts.BebasNeue.c20, "TCP PING:", (255, 255, 255)) Ping.y = 180 Ping.x = self.width / 4 - Ping.surface.get_size()[0] / 2 self.AddElement(Ping) PingUDP = Text(fonts.BebasNeue.c20, "UDP PING:", (255, 255, 255)) PingUDP.y = 200 PingUDP.x = self.width / 4 - PingUDP.surface.get_size()[0] / 2 self.AddElement(PingUDP) ModeContent = Text(fonts.BebasNeue.c20, "NN", (255, 255, 255)) ModeContent.y = 100 ModeContent.x = self.width * 3 / 4 - ModeContent.surface.get_size( )[0] / 2 self.AddElement(ModeContent, "ModeShown") PlayersContent = Text(fonts.BebasNeue.c20, "NN", (255, 255, 255)) PlayersContent.y = 140 PlayersContent.x = self.width * 3 / 4 - PlayersContent.surface.get_size( )[0] / 2 self.AddElement(PlayersContent, "PlayersShown") PingContent = Text(fonts.BebasNeue.c20, "NN", (255, 255, 255)) PingContent.y = 180 PingContent.x = self.width * 3 / 4 - PingContent.surface.get_size( )[0] / 2 self.AddElement(PingContent, "PingShown") PingUDPcontent = Text(fonts.BebasNeue.c20, "NN", (255, 255, 255)) PingUDPcontent.y = 200 PingUDPcontent.x = self.width / 4 * 3 - PingUDPcontent.surface.get_size( )[0] / 2 self.AddElement(PingUDPcontent, "PingUDP") self.status = "reject" ##### LOADING #### loadingText = Text(fonts.BebasNeue.c15, "Connecting...", (255, 255, 255)) loadingText.y = 230 loadingText.x = self.width / 2 - loadingText.surface.get_size()[0] / 2 self.AddElement(loadingText, "LoadingText") loadingA = LoadingAnimation(squares=4) loadingA.y = 250 loadingA.x = self.width / 2 - loadingA.width / 2 self.AddElement(loadingA, "LoadingA") ##### BUTTON REJECT ##### rejectButton = RejectButton("Cancel") rejectButton.y = 290 rejectButton.x = self.width / 2 - rejectButton.imageA.get_size()[0] / 2 self.AddElement(rejectButton, "Reject") ##### NETWORK ##### self.parent.SetErrorDef(self.Network_error) self.parent.SetConnectDef(self.Network_connected) self.parent.SetRBasicDef(self.Network_RBasic) self.parent.SetUDPsignalDef(self.UDPsignal) self.allowConnect = False self.Connect()
def AddTimeSurface(self): text = Text(fonts.BebasNeue.c40,str(self.wait)+" seconds left",(255,255,255)) text.x = self.width/2 - text.surface.get_size()[0]/2 text.y = self.sum_y self.AddElement(text,"MSJ")
def SetMessage(self, msj): self.DeleteElement("LoadingText") loadingText = Text(fonts.BebasNeue.c15, str(msj), (255, 255, 255)) loadingText.y = 240 loadingText.x = self.width / 2 - loadingText.surface.get_size()[0] / 2 self.AddElement(loadingText, "LoadingText")
def __init__(self, server_name, room_data, parent): self.room_data = room_data ww, hh = pygame.display.get_surface().get_size() ww -= 50 hh -= 50 Window.__init__(self, server_name, (170, 102, 57), (221, 202, 11), 0, 0, ww, hh, (255, 255, 255)) title = Text(fonts.BebasNeue.c40, "GAMES", (255, 255, 255)) title.y = 35 title.x = self.width / 2 - title.surface.get_size()[0] / 2 self.AddElement(title, "Title") listRooms = ListSystem( 0, 0, False, ) listRooms.AddUpKey("Name", 250) listRooms.AddUpKey("Mode", 150) listRooms.AddUpKey("Stadium", 250) listRooms.AddUpKey("Players", 120) listRooms.SetBackground((200, 150, 150), (50, 50, 50)) listRooms.SetUpBackground((41, 0, 69), (149, 0, 255)) listRooms.SetItemColor((23, 0, 45), (86, 0, 173)) listRooms.SetSendInfoDef(self.NewSelected) rooms = room_data["info"] for x in range(len(rooms)): listRooms.AddRow({ "Name": rooms[x]["name"], "Mode": rooms[x]["mode"], "Stadium": rooms[x]["stadium"], "Players": str(rooms[x]["players"]["clients"]) + "/" + str(rooms[x]["players"]["max-clients"]) }) listRooms.y = 100 listRooms.x = self.width / 2 - listRooms.width / 2 self.AddElement(listRooms, "LIST") disconnect = NeutralButton("Disconnect", 120, (0, 0), fonts.BebasNeue.c20) disconnect.y = 30 disconnect.x = 10 self.AddElement(disconnect, "Disconnect") cPlayer = NeutralButton("Change player", 120, (0, 0), fonts.BebasNeue.c20) cPlayer.y = 30 cPlayer.x = self.width - 10 - cPlayer.imageA.get_size()[0] self.AddElement(cPlayer, "cplayer") connect = AdvancedButton((350, 80), (0, 0), "Play", (50, 50, 200), (50, 50, 50)) distance_to_back_list = (listRooms.y + 70 + listRooms.height) connect.y = ( self.height - distance_to_back_list ) / 2 + distance_to_back_list - connect.image.get_size()[1] / 2 connect.x = self.width / 2 - connect.image.get_size()[0] / 2 self.AddElement(connect, "Connect") parent.SetUpdateRoomsDef(self.RoomChanges)
def AddPingNumber(self): pingText = Text(fonts.Absender.c20," ",(0,0,0)) pingText.x = self.game.pixelWidth - 20 - pingText.surface.get_size()[0] pingText.y = 10 self.Add(pingText,"PingText")
def SetMSJ(self, msj): self.DeleteElement("MSJ_loading") msjLoading = Text(fonts.BebasNeue.c25, msj, (255, 255, 255)) msjLoading.y = 100 msjLoading.x = self.width / 2 - msjLoading.surface.get_size()[0] / 2 self.AddElement(msjLoading, "MSJ_loading")