def _add_fr_line(self, username): ''' Add a line to the friend scroll list. ''' cadre = Cadre(DIM_FRL_CADRE, (0, 0)) text_username = TextBox(DIM_L_USERNAME, DX_L + DY_L, text=username, font=Font.f(45)) button_requests = Button(DIM_L_BUTTON, POS_L_BUTTON, color=C.LIGHT_BLUE, text='Add', font=Font.f(30)) scroll = self.get_component('s frs') scroll.add_line([cadre, text_username, button_requests]) # set buttons logic line = scroll.get_line(-1) button_requests.set_logic(self._get_request_logic(line))
def _add_friend_line(self, username): ''' Add a line to the friend scroll list. ''' cadre = Cadre(DIM_CADRE_LINE, (0, 0)) text_username = TextBox(Spec.DIM_MEDIUM_TEXT, (20, 10), text=username, font=Font.f(35)) color = self._get_color_connected(username) form_connected = Form(DIM_CONN, POS_CONN, color) button_profil = Button(Spec.DIM_SMALL_BUTTON, POS_PROFIL, color=C.LIGHT_BLUE, text="Profil", font=Font.f(30)) button_play = Button(Spec.DIM_SMALL_BUTTON, POS_PLAY, color=C.LIGHT_GREEN, text="Play", font=Font.f(30)) notif = TextBox(Spec.DIM_NOTIF, POS_NOTIF, color=C.LIGHT_RED, text_color=C.WHITE, text='0', font=Font.f(30)) # add line scroll = self.get_component('s frs') scroll.add_line([ cadre, text_username, form_connected, button_profil, button_play, notif ]) # set buttons logic line = scroll.get_line(-1) button_profil.set_logic(self._get_profil_logic(line)) button_play.set_logic(self._get_play_logic(line)) # set notif state scroll.set_active_state(False, line=line, element=notif)
def _add_game_demand_line(self, username): ''' Add a line to the game demand scroll list. ''' cadre = Cadre(DIM_CADRE_LINE_DFR, (0, 0), color=C.XLIGHT_GREY) icon = Form(DIM_IMG, POS_IMG, color=C.XLIGHT_GREY, surface=img_game, with_font=True) text_username = TextBox(Spec.DIM_MEDIUM_TEXT, POS_DFR_TEXT, color=C.XLIGHT_GREY, text=username, font=Font.f(35), centered=False) button_yes = Button(DIM_DFR_BUTT, POS_YES, color=C.LIGHT_GREEN, surface=vu, with_font=True) button_no = Button(DIM_DFR_BUTT, POS_NO, color=C.LIGHT_RED, surface=cross, with_font=True) # add line scroll = self.get_component('s dfrs') scroll.add_line([cadre, icon, text_username, button_yes, button_no]) line = scroll.get_line(-1) # set buttons logic button_yes.set_logic(self._get_demand_game_logic(line, True)) button_no.set_logic(self._get_demand_game_logic(line, False))
scroll_dfrs = ScrollList(DIM_SCR_DFRS, POS_SCR_DFRS, []) img_vu = pygame.image.load("imgs/correct.png") vu = pygame.Surface(15 * DIM_DFR_BUTT, pygame.SRCALPHA) vu.blit(img_vu, POS_ICON) img_cross = pygame.image.load("imgs/cross.png") cross = pygame.Surface(15 * DIM_DFR_BUTT, pygame.SRCALPHA) cross.blit(img_cross, POS_ICON) img_friend = pygame.image.load("imgs/friend.png") img_game = pygame.image.load("imgs/game.png") ### add fr/game demand ### cadre_add_fr = Cadre(DIM_CADRE, POS_CADRE) input_userame = InputText(Spec.DIM_SMALL_TEXT, POS_USER, has_marge=False, pretext="Enter a username...", font=Font.f(30)) button_send = Button(Spec.DIM_SMALL_BUTTON, POS_SEND, color=C.LIGHT_BLUE, text="Send", font=Font.f(30)) text_info = TextBox(None, POS_ERROR,
POS_CADRE_ACTS2 = np.array([2150, 50]) POS_TITLE_ACTS = np.array([5, 5]) POS_TEXT_ACTS = np.array([5, 60]) DIM_TEXT_ACTS = np.array([390, 390]) titles = ['HP', 'Shield', 'Engine', 'Speed', 'Orientation', 'Script errors'] ### components ### text_time = TextBox(Spec.DIM_MEDIUM_TEXT, POS_TIME, marge=True, color=C.XLIGHT_GREY, font=Font.f(40)) cadre_1 = Cadre(DIM_CADRE, POS_CADRE1) cadre_2 = Cadre(DIM_CADRE, POS_CADRE2) cadre_1.MARGE_WIDTH = 8 cadre_2.MARGE_WIDTH = 8 cadre_acts_1 = Cadre(DIM_CADRE_ACTIONS, POS_CADRE_ACTS1, color=C.XLIGHT_BLUE) cadre_acts_2 = Cadre(DIM_CADRE_ACTIONS, POS_CADRE_ACTS2, color=C.XLIGHT_BLUE) text_username1 = TextBox(DIM_USER, POS_CADRE1 + POS_USER, text_color=Spec.DCOLOR_P1, font=Font.f(60)) text_username2 = TextBox(DIM_USER, POS_CADRE2 + POS_USER, text_color=Spec.DCOLOR_P2,
### Components ### img_question = pygame.image.load("imgs/question_mark.png") chat = Chat(POS_CHAT, general_chat=False) title = TextBox(Spec.DIM_TITLE, Spec.POS_TITLE, font=Font.f(80)) button_back = Button(Spec.DIM_MEDIUM_BUTTON, POS_BACK, color=C.LIGHT_BLUE, text="Back", font=Font.f(35)) cadre = Cadre(DIM_CADRE, POS_CADRE) form_ship = Cadre(DIM_SHIP, POS_SHIP) title_games = TextBox(DIM_CASE, POS_TABLE, text='Games', marge=True, font=Font.f(45)) title_wins = TextBox(DIM_CASE, POS_TABLE + DX, text='Wins', marge=True, font=Font.f(45))
import requests, json, threading, time, os from lib.plougame import SubPage, Form, TextBox, ScrollList, InputText, Button, Cadre, Font, C from data.spec import Spec from lib.perfeval import Counter import numpy as np DIM_CADRE = np.array([600, 200]) POS_TEXT = np.array([100, 20]) DIM_INFO = np.array([560, 80]) POS_INFO = np.array([20, 100]) # components cadre = Cadre(DIM_CADRE, (0, 0)) text_state = TextBox(Spec.DIM_MEDIUM_TEXT, POS_TEXT, text='Looking for update...', font=Font.f(45), text_color=C.GREY) text_info = TextBox(DIM_INFO, POS_INFO, font=Font.f(35)) components = [('cadre', cadre), ('t state', text_state), ('t info', text_info)] states = ['base'] class Updater(SubPage): root_link = "https://raw.githubusercontent.com/Plouc314/CodeShip/master/CodeShip/"