コード例 #1
0
ファイル: screens.py プロジェクト: Smug28/Mobile-TetriNET
 def on_pre_enter(self, *args):
     # Před vstupem na obrazovku načte seznam oblíbených serverů
     if len(self.layout.children) == 0:
         bookmarks = self.root.Cfg[-1]
         if len(bookmarks) == 0:
             self.layout.add_widget(Label(text=self.STR_NO_BOOKMARKS, font_name='font/Roboto-Regular.ttf', font_size='18dp', size_hint_y = None, text_size=(self.width*3, None)))
         else:
             head = BoxLayout(size_hint=(1,None), height=50)
             head.add_widget(Label(text=self.STR_SERVER, font_name='font/Roboto-Bold.ttf', size_hint=(None,1), font_size="20dp", width = self.width*1.9, text_size=(self.width*1.9, None)))
             head.add_widget(Label(text=self.STR_MOD, font_name='font/Roboto-Bold.ttf', size_hint=(1,1), font_size="15dp", width = self.width, text_size=(self.width, None)))
             head.add_widget(DelButton(opacity=0, size_hint=(None, 1)))
             self.layout.add_widget(head)
             for y, server in enumerate(bookmarks):
                 srvr = Bookmark(size_hint=(1,None), height = 50)
                 for i, cell in enumerate(server):
                     if i == 0:
                         lbl = Label(text="[ref={0}]{1}[/ref]".format(y,cell), markup=True, font_name='font/Roboto-Regular.ttf', size_hint=(None,1), font_size="20dp", text_size=(None, None))
                         lbl.bind(on_ref_press=self.connectBookmark)
                         srvr.add_widget(lbl)
                     elif i == 1:
                         pass
                     elif i == 2:
                         lbl = Label(text="[ref={0}]{1}[/ref]".format(y,cell), markup=True, font_name='font/Roboto-Regular.ttf', size_hint=(1,1), font_size="20dp")
                         lbl.bind(on_ref_press=self.connectBookmark)
                         srvr.add_widget(lbl)
                 btn = DelButton(OBJ=srvr, ID=y, background_normal="crop/delete.png", background_down="crop/delete.png",size_hint=(None, 1))
                 btn.bind(on_press=self.removeBookmark)
                 srvr.add_widget(btn)
                 self.layout.add_widget(srvr)
コード例 #2
0
ファイル: screens.py プロジェクト: Smug28/Mobile-TetriNET
 def __init__(self, **kwargs):  # inicializace
     super(PartylineScreen, self).__init__(**kwargs)
     self.root.insertStrings.append((self, "STR_PARTYLINE"))
     self.input = TextInput(size_hint=(.8, .07),
                            pos_hint={
                                'x': .08,
                                'y': .024
                            })
     self.output = Label(markup=True,
                         font_name='font/Roboto-Regular.ttf',
                         font_size='16dp',
                         size_hint_y=None)
     self.SLayout = GridLayout(size_hint_y=None, cols=1, spacing=0)
     self.SLayout.bind(minimum_height=self.SLayout.setter('height'))
     self.scroll = ScrollView(size_hint=(1, .9),
                              pos_hint={
                                  'center_x': .58,
                                  'y': .125
                              },
                              scroll_timeout=10000)
     self.scroll.do_scroll_x = False
     self.scroll.add_widget(self.SLayout)
     self.SLayout.add_widget(self.output)
     self.layout = RelativeLayout(size_hint=(.75, .83),
                                  pos_hint={
                                      'center_x': .437,
                                      'y': .02
                                  })
     self.send = DelButton(color=(1, 1, 1, 0),
                           text='SEND',
                           size_hint=(None, .1),
                           pos_hint={
                               'x': .88,
                               'y': .022
                           },
                           background_normal='crop/icons/send.png',
                           background_down='crop/icons/send.png')
     self.send.bind(on_press=self.sendMsg)
     self.input.bind(focus=self.on_focus)
     self.layout.content.add_widget(self.scroll)
     self.layout.content.add_widget(self.input)
     self.layout.content.add_widget(self.send)
     self.add_widget(self.layout)
     if self.root.onAndroid():
         self.LayouFocusOn = Animation(size_hint_y=.5,
                                       pos_hint={
                                           'center_x': .437,
                                           'y': .38
                                       },
                                       duration=.2)
         self.LayouFocusOut = Animation(size_hint_y=.83,
                                        pos_hint={
                                            'center_x': .437,
                                            'y': .02
                                        },
                                        duration=.2)
コード例 #3
0
ファイル: screens.py プロジェクト: Smug28/Mobile-TetriNET
class PartylineScreen(SideScreen):
    def __init__(self, **kwargs):   # inicializace
        super(PartylineScreen, self).__init__(**kwargs)
        self.root.insertStrings.append((self, "STR_PARTYLINE"))
        self.input = TextInput(size_hint=(.8, .07), pos_hint={'x':.08, 'y':.024})
        self.output = Label(markup=True, font_name='font/Roboto-Regular.ttf', font_size='16dp', size_hint_y = None)
        self.SLayout = GridLayout(size_hint_y = None, cols=1, spacing=0)
        self.SLayout.bind(minimum_height=self.SLayout.setter('height'))
        self.scroll = ScrollView(size_hint=(1,.9), pos_hint={'center_x': .58, 'y': .125}, scroll_timeout=10000)
        self.scroll.do_scroll_x = False
        self.scroll.add_widget(self.SLayout)
        self.SLayout.add_widget(self.output)
        self.layout = RelativeLayout(size_hint=(.75, .83), pos_hint={'center_x': .437, 'y': .02})
        self.send = DelButton(color=(1,1,1,0), text='SEND', size_hint=(None, .1), pos_hint={'x':.88, 'y':.022}, background_normal='crop/icons/send.png', background_down='crop/icons/send.png')
        self.send.bind(on_press=self.sendMsg)
        self.input.bind(focus=self.on_focus)
        self.layout.content.add_widget(self.scroll)
        self.layout.content.add_widget(self.input)
        self.layout.content.add_widget(self.send)
        self.add_widget(self.layout)
        if self.root.onAndroid():
            self.LayouFocusOn = Animation(size_hint_y=.5, pos_hint={'center_x': .437, 'y': .38}, duration=.2)
            self.LayouFocusOut = Animation(size_hint_y=.83, pos_hint={'center_x': .437, 'y': .02}, duration=.2)
    
    def on_pre_enter(self, *args):
        # Voláno těsně před zobrazením obrazovky
        self.output.text_size = (self.root.root.size[0]*0.75, None)
        
    def sendMsg(self, instance):
        # Odeslat zprávu do chatu
        if len(self.input.text) > 0:
            out = "pline "+str(self.root.id)+" "+self.input.text.replace("\n", " ")
            self.root.send_message(out)
            self.root.print_message("{0}\xff".format(out))
            self.input.text = ""
    def on_focus(self, instance, value):
        # Při označení vstupního pole
        if self.root.onAndroid():
            if value:
                self.LayouFocusOn.start(self.layout)
            else:
                self.LayouFocusOut.start(self.layout)
    
    def prev(self):
        # Metoda pro návrat na předchozí obrazovku
        if self.input.focus:
            self.input.focus = False
        self.root.sm.transition = SlideTransition(direction="left")
        self.root.sm.current = 'GameScreen'
コード例 #4
0
ファイル: screens.py プロジェクト: Smug28/Mobile-TetriNET
 def __init__(self, **kwargs):   # inicializace
     super(PartylineScreen, self).__init__(**kwargs)
     self.root.insertStrings.append((self, "STR_PARTYLINE"))
     self.input = TextInput(size_hint=(.8, .07), pos_hint={'x':.08, 'y':.024})
     self.output = Label(markup=True, font_name='font/Roboto-Regular.ttf', font_size='16dp', size_hint_y = None)
     self.SLayout = GridLayout(size_hint_y = None, cols=1, spacing=0)
     self.SLayout.bind(minimum_height=self.SLayout.setter('height'))
     self.scroll = ScrollView(size_hint=(1,.9), pos_hint={'center_x': .58, 'y': .125}, scroll_timeout=10000)
     self.scroll.do_scroll_x = False
     self.scroll.add_widget(self.SLayout)
     self.SLayout.add_widget(self.output)
     self.layout = RelativeLayout(size_hint=(.75, .83), pos_hint={'center_x': .437, 'y': .02})
     self.send = DelButton(color=(1,1,1,0), text='SEND', size_hint=(None, .1), pos_hint={'x':.88, 'y':.022}, background_normal='crop/icons/send.png', background_down='crop/icons/send.png')
     self.send.bind(on_press=self.sendMsg)
     self.input.bind(focus=self.on_focus)
     self.layout.content.add_widget(self.scroll)
     self.layout.content.add_widget(self.input)
     self.layout.content.add_widget(self.send)
     self.add_widget(self.layout)
     if self.root.onAndroid():
         self.LayouFocusOn = Animation(size_hint_y=.5, pos_hint={'center_x': .437, 'y': .38}, duration=.2)
         self.LayouFocusOut = Animation(size_hint_y=.83, pos_hint={'center_x': .437, 'y': .02}, duration=.2)
コード例 #5
0
ファイル: screens.py プロジェクト: Smug28/Mobile-TetriNET
 def on_pre_enter(self, *args):
     # Před vstupem na obrazovku načte seznam oblíbených serverů
     if len(self.layout.children) == 0:
         bookmarks = self.root.Cfg[-1]
         if len(bookmarks) == 0:
             self.layout.add_widget(
                 Label(text=self.STR_NO_BOOKMARKS,
                       font_name='font/Roboto-Regular.ttf',
                       font_size='18dp',
                       size_hint_y=None,
                       text_size=(self.width * 3, None)))
         else:
             head = BoxLayout(size_hint=(1, None), height=50)
             head.add_widget(
                 Label(text=self.STR_SERVER,
                       font_name='font/Roboto-Bold.ttf',
                       size_hint=(None, 1),
                       font_size="20dp",
                       width=self.width * 1.9,
                       text_size=(self.width * 1.9, None)))
             head.add_widget(
                 Label(text=self.STR_MOD,
                       font_name='font/Roboto-Bold.ttf',
                       size_hint=(1, 1),
                       font_size="15dp",
                       width=self.width,
                       text_size=(self.width, None)))
             head.add_widget(DelButton(opacity=0, size_hint=(None, 1)))
             self.layout.add_widget(head)
             for y, server in enumerate(bookmarks):
                 srvr = Bookmark(size_hint=(1, None), height=50)
                 for i, cell in enumerate(server):
                     if i == 0:
                         lbl = Label(text="[ref={0}]{1}[/ref]".format(
                             y, cell),
                                     markup=True,
                                     font_name='font/Roboto-Regular.ttf',
                                     size_hint=(None, 1),
                                     font_size="20dp",
                                     text_size=(None, None))
                         lbl.bind(on_ref_press=self.connectBookmark)
                         srvr.add_widget(lbl)
                     elif i == 1:
                         pass
                     elif i == 2:
                         lbl = Label(text="[ref={0}]{1}[/ref]".format(
                             y, cell),
                                     markup=True,
                                     font_name='font/Roboto-Regular.ttf',
                                     size_hint=(1, 1),
                                     font_size="20dp")
                         lbl.bind(on_ref_press=self.connectBookmark)
                         srvr.add_widget(lbl)
                 btn = DelButton(OBJ=srvr,
                                 ID=y,
                                 background_normal="crop/delete.png",
                                 background_down="crop/delete.png",
                                 size_hint=(None, 1))
                 btn.bind(on_press=self.removeBookmark)
                 srvr.add_widget(btn)
                 self.layout.add_widget(srvr)
コード例 #6
0
ファイル: screens.py プロジェクト: Smug28/Mobile-TetriNET
class PartylineScreen(SideScreen):
    def __init__(self, **kwargs):  # inicializace
        super(PartylineScreen, self).__init__(**kwargs)
        self.root.insertStrings.append((self, "STR_PARTYLINE"))
        self.input = TextInput(size_hint=(.8, .07),
                               pos_hint={
                                   'x': .08,
                                   'y': .024
                               })
        self.output = Label(markup=True,
                            font_name='font/Roboto-Regular.ttf',
                            font_size='16dp',
                            size_hint_y=None)
        self.SLayout = GridLayout(size_hint_y=None, cols=1, spacing=0)
        self.SLayout.bind(minimum_height=self.SLayout.setter('height'))
        self.scroll = ScrollView(size_hint=(1, .9),
                                 pos_hint={
                                     'center_x': .58,
                                     'y': .125
                                 },
                                 scroll_timeout=10000)
        self.scroll.do_scroll_x = False
        self.scroll.add_widget(self.SLayout)
        self.SLayout.add_widget(self.output)
        self.layout = RelativeLayout(size_hint=(.75, .83),
                                     pos_hint={
                                         'center_x': .437,
                                         'y': .02
                                     })
        self.send = DelButton(color=(1, 1, 1, 0),
                              text='SEND',
                              size_hint=(None, .1),
                              pos_hint={
                                  'x': .88,
                                  'y': .022
                              },
                              background_normal='crop/icons/send.png',
                              background_down='crop/icons/send.png')
        self.send.bind(on_press=self.sendMsg)
        self.input.bind(focus=self.on_focus)
        self.layout.content.add_widget(self.scroll)
        self.layout.content.add_widget(self.input)
        self.layout.content.add_widget(self.send)
        self.add_widget(self.layout)
        if self.root.onAndroid():
            self.LayouFocusOn = Animation(size_hint_y=.5,
                                          pos_hint={
                                              'center_x': .437,
                                              'y': .38
                                          },
                                          duration=.2)
            self.LayouFocusOut = Animation(size_hint_y=.83,
                                           pos_hint={
                                               'center_x': .437,
                                               'y': .02
                                           },
                                           duration=.2)

    def on_pre_enter(self, *args):
        # Voláno těsně před zobrazením obrazovky
        self.output.text_size = (self.root.root.size[0] * 0.75, None)

    def sendMsg(self, instance):
        # Odeslat zprávu do chatu
        if len(self.input.text) > 0:
            out = "pline " + str(self.root.id) + " " + self.input.text.replace(
                "\n", " ")
            self.root.send_message(out)
            self.root.print_message("{0}\xff".format(out))
            self.input.text = ""

    def on_focus(self, instance, value):
        # Při označení vstupního pole
        if self.root.onAndroid():
            if value:
                self.LayouFocusOn.start(self.layout)
            else:
                self.LayouFocusOut.start(self.layout)

    def prev(self):
        # Metoda pro návrat na předchozí obrazovku
        if self.input.focus:
            self.input.focus = False
        self.root.sm.transition = SlideTransition(direction="left")
        self.root.sm.current = 'GameScreen'