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 __init__(self, pos, general_chat=True, client=None, target=None): self.MAX_MSG = Spec.CHAT_MAX_MSG self.is_general_chat = general_chat self.target = target self.client = client # create components scroll = ScrollList(DIM_SCROLL, (0, 0), []) input_msg = InputText(DIM_INPUT, (0, DIM_SCROLL[1]), pretext="Write message...", font=Font.f(30)) button_send = Button(DIM_SEND, (DIM_INPUT[0], DIM_SCROLL[1]), color=C.LIGHT_BLUE, text='Send', font=Font.f(30)) components = (('scroll', scroll), ('i msg', input_msg), ('b send', button_send)) super().__init__(['base'], components, pos, active_states='all') self.add_button_logic('b send', self.on_send)
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))
POS_NO = np.array([480, 20]) DIM_CADRE_LINE_DFR = np.array([560, 80]) ### Components ### ### base ### title = TextBox(Spec.DIM_TITLE, Spec.POS_TITLE, text="Friends", font=Font.f(80)) button_back = Button(Spec.DIM_MEDIUM_BUTTON, POS_BACK, color=C.LIGHT_BLUE, text="Back", font=Font.f(35)) button_add_fr = Button(Spec.DIM_MEDIUM_BUTTON, POS_ADD_FR, color=C.LIGHT_BLUE, text="Add friend", font=Font.f(35)) scroll_frs = ScrollList(DIM_SCR_FRS, POS_SCR_FRS, []) chat = Chat(POS_CHAT, general_chat=False) ### dfr /game demand ###
POS_DONE = np.array([2200, 1200]) POS_BACK = np.array([100, 100]) POS_ERROR = np.array([2120, 1140]) ### Components ### title = TextBox(Spec.DIM_TITLE, Spec.POS_TITLE, text="Connection", font=Font.f(80)) button_back = Button(Spec.DIM_MEDIUM_BUTTON, POS_BACK, color=C.LIGHT_BLUE, text="Back", font=Font.f(35)) ### base ### button_login = Button(Spec.DIM_BIG_BUTTON, POS_LOG, color=C.LIGHT_BLUE, text="Login", font=Font.f(45)) button_sign_up = Button((Spec.DIM_BIG_BUTTON), POS_SIGN, color=C.LIGHT_BLUE, text="Sign up",
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, font=Font.f(60)) button_quit = Button(Spec.DIM_MEDIUM_BUTTON, POS_EXIT, color=C.LIGHT_BLUE, text="Quit", font=Font.f(30)) form_red_hp1 = Form(DIM_HP, POS_CADRE1 + POS_HP, color=C.RED) form_green_hp1 = Form(DIM_HP, POS_CADRE1 + POS_HP, color=C.GREEN) form_red_hp2 = Form(DIM_HP, POS_CADRE2 + POS_HP, color=C.RED) form_green_hp2 = Form(DIM_HP, POS_CADRE2 + POS_HP, color=C.GREEN) form_red_shield_hp1 = Form(DIM_HP, POS_CADRE1 + POS_SHIELD_HP, color=C.RED) form_blue_shield_hp1 = Form(DIM_HP, POS_CADRE1 + POS_SHIELD_HP, color=C.NEO_BLUE) form_red_shield_hp2 = Form(DIM_HP, POS_CADRE2 + POS_SHIELD_HP, color=C.RED)
POS_L_BUTTON = np.array([340, 20]) DX_L = np.array([20, 0]) DY_L = np.array([0, 10]) ### 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,
import numpy as np ### Components ### Y_TB = 100 X_TB1 = 100 POS_SHIP_EDITOR = np.array([300, 400]) POS_SCRIPT = np.array([1920, 400]) ### base ### title = TextBox(Spec.DIM_TITLE, Spec.POS_TITLE, text="Editor", font=Font.f(80)) button_back = Button(Spec.DIM_MEDIUM_BUTTON, (X_TB1, Y_TB), color=C.LIGHT_BLUE, text="Back", font=Font.f(35)) script_analyser = ScriptAnalyser(POS_SCRIPT) ship_editor = ShipEditor(POS_SHIP_EDITOR) states = ['base'] components = [('title', title), ('b back', button_back), ('script analyser', script_analyser), ('ship editor', ship_editor)] class Editor(Page): def __init__(self, client):