def logic_update(self, Events): for q in range(len(self.__MenuActual)): self.__MenuActual[q][0].logic_update(Events) if Clasic.GetFocused(Events, self.PositionFlechaContinue, self.FlechaContinue.get_size()): self.FlechaContinue = pygame.transform.scale( Loaded.Images.FlechaSiguienteHover, (60, 50)) if Events.mouse.get_now_pressed()[0]: if pygame.time.get_ticks() > self.LT + 200: self.LT = pygame.time.get_ticks() if self.MenuSeleccionado == "Primer menu": TerrainType = self.GetMenuForName( "Selector of players and terrain" ).GetSelectedRadio() NumberOfPlayers = self.GetMenuForName( "Selector of players and terrain" ).GetSelectedSelect("Player select") self.Data["Terrain type"] = TerrainType self.Data["Number of players"] = int(NumberOfPlayers) self.MenuSeleccionado = "Selector de nombres" self.__MenuActual = [[ PlayerConfiguration.PlayerConfiguration( self.ActualPlayer, self.PositionNames), "Player " + str(self.ActualPlayer) ]] elif self.MenuSeleccionado == "Selector de nombres": NewData = self.GetMenuForName( "Player " + str(self.ActualPlayer)).GetData() if NewData != False: self.Data["Players"].append(NewData) if self.ActualPlayer < self.Data[ "Number of players"]: self.ActualPlayer += 1 self.__MenuActual = [[ PlayerConfiguration.PlayerConfiguration( self.ActualPlayer, self.PositionNames), "Player " + str(self.ActualPlayer) ]] else: self.__MenuActual = [] self.MenuSeleccionado = "" return [{ "Title": "Start game", "Data": self.Data }] else: self.FlechaContinue = pygame.transform.scale( Loaded.Images.FlechaSiguiente, (60, 50))
def GenerateNormal(self): self.x, self.y = self.OriginalPosition Surface = pygame.surface.Surface(self.NormalSize) if not self.Gradient: Surface.fill(self.Background) else: Gradient.FillGradient(Surface, self.Background[0], self.Background[1]) Surface = add_border.add_border(Surface, (0, 0, 0), 2, 2, 2, 2) Text = self.UbuntuBoldSS.render(self.Title, 0, (0, 0, 0)) TextPosition = Clasic.GetCenterPosition(Surface, Text) Surface.blit(Text, TextPosition) self.UpdateSurface(Surface)
def GeneratePressed(self): self.x = self.OriginalPosition[0] - ( (self.FocusSize[0] - self.NormalSize[0]) / 2) self.y = self.OriginalPosition[1] - ( (self.FocusSize[1] - self.NormalSize[1]) / 2) Surface = pygame.surface.Surface(self.FocusSize) if not self.Gradient: Surface.fill(self.Background) else: Gradient.FillGradient(Surface, self.Background[0], self.Background[1]) Surface = add_border.add_border(Surface, (0, 0, 0), 4, 4, 4, 4) Text = self.UbuntuBoldB.render(self.Title, 0, (0, 0, 0)) TextPosition = Clasic.GetCenterPosition(Surface, Text) Surface.blit(Text, TextPosition) self.UpdateSurface(Surface)
def graphic_update(self, Screen): if not self.Finished: GlobalButtonSize = self.Button.NormalSize[ 0] + 10 + self.ReturnButton.NormalSize[0] Name = self.Font.render(dat.GetWord("ingresar nombre"), 1, (0, 0, 0)) if self.Input.surface.get_size()[0] > Name.get_size( )[0] and self.Input.surface.get_size()[0] > GlobalButtonSize: self.GlobalSize = [ self.Input.surface.get_size()[0], Name.get_size()[1] + 10 + self.Input.surface.get_size()[1] + 10 + self.Button.NormalSize[1] ] elif Name.get_size()[0] > self.Input.surface.get_size( )[0] and Name.get_size()[0] > GlobalButtonSize: self.GlobalSize = [ Name.get_size()[0], Name.get_size()[1] + 10 + self.Input.surface.get_size()[1] + 10 + self.Button.NormalSize[1] ] elif GlobalButtonSize > self.Input.surface.get_size( )[0] and GlobalButtonSize > Name.get_size()[0]: self.GlobalSize = [ GlobalButtonSize, Name.get_size()[1] + 10 + self.Input.surface.get_size()[1] + 10 + self.Button.NormalSize[1] ] GlobalTestSurface = pygame.Surface(self.GlobalSize) self.PosName = (Clasic.GetCenterPosition(Screen, Name)[0] + self.Disf, Clasic.GetCenterPosition(Screen, GlobalTestSurface)[1]) Screen.blit(Name, self.PosName) self.PosInput = ( Clasic.GetCenterPosition(Screen, self.Input.surface)[0] + self.Disf, Clasic.GetCenterPosition(Screen, GlobalTestSurface)[1] + Name.get_size()[1] + 10) self.Input.set_position(self.PosInput) self.Input.graphic_update(Screen) TestSurface = pygame.Surface( (GlobalButtonSize, self.Button.surface.get_size()[1])) self.ReturnButton.UpdatePosition( (Clasic.GetCenterPosition(Screen, TestSurface)[0] + self.Button.NormalSize[0] + 10 + self.Disf, Clasic.GetCenterPosition(Screen, GlobalTestSurface)[1] + Name.get_size()[1] + 10 + self.Input.surface.get_size()[1] + 10)) self.Button.UpdatePosition( (Clasic.GetCenterPosition(Screen, TestSurface)[0] + self.Disf, Clasic.GetCenterPosition(Screen, GlobalTestSurface)[1] + Name.get_size()[1] + 10 + self.Input.surface.get_size()[1] + 10)) self.Button.graphic_update(Screen) if self.Moving != None: if self.DirMove == None: if self.Moving < self.Button.OriginalPosition[0]: self.DirMove = "Izquierda" elif self.Moving > self.Button.OriginalPosition[0]: self.DirMove = "Derecha" else: if self.DirMove == "Izquierda": if self.Moving < self.Button.OriginalPosition[0]: self.Disf -= self.SpeedMove else: if self.Moving != self.Button.OriginalPosition[0]: self.SpeedMove = 1 else: self.Moving = None self.DirMove = None elif self.DirMove == "Derecha": if self.Moving > self.Button.OriginalPosition[0]: self.Disf += self.SpeedMove else: if self.Moving != self.Button.OriginalPosition[0]: self.SpeedMove = 1 else: self.Moving = None self.DirMove = None if self.Moving == self.Button.OriginalPosition[0]: self.Moving = None self.ReturnButton.graphic_update(Screen)