Пример #1
0
class Unit(EventDispatcher):
    n = kp.NumericProperty(0)
    n_str = kp.StringProperty("0")
    icon = kp.StringProperty()

    def __init__(self, **kwargs):
        super().__init__()
        self.name = kwargs.get("name").upper()
        self.settings = UNITS.get(self.name)
        self.name = self.name.lower()
        self.icon = self.settings.get("ICON")
        self._type = self.settings.get("TYPE", "general")
        self.requirements = self.settings.get("REQUIREMENTS")
        self.population = self.requirements.get("POPULATION")
        self.unlock = self.requirements.get("UNLOCK")
        self.atk = self.settings.get("ATK")
        self.defence = self.settings.get("DEFENCE")
        self.speed = self.settings.get("SPEED")
        self.capacity = self.settings.get("CAPACITY")
        self.special_abilities = self.settings.get("SPECIAL_ABILITIES")

    def __repr__(self):
        return "Unit(name=%s)" % self.name

    def on_n(self, *args):
        self.n_str = str(self.n)

    def recruit(self, n):
        n = int(n)
        app = App.get_running_app()
        # check if can recruit:
        if app.wood.current >= self.requirements.get("WOOD") * n:
            app.wood.current -= self.requirements.get("WOOD") * n
            self.n += n
Пример #2
0
class TempWidget(Image, EventDispatcher):
    text = Properties.StringProperty('')
    unit = Properties.StringProperty()
    c_id = Properties.StringProperty()
    chosenColor = Properties.ListProperty()

    def on_text(self, *_):
        # Just get large texture:
        l = Label(text=self.text)
        l.font_size = '1000dp'  # something that'll give texture bigger than phone's screen size
        l.color = self.color
        l.texture_update()
        # Set it to image, it'll be scaled to image size automatically:
        self.texture = l.texture

    def __init__(self, **kwargs):
        super(TempWidget, self).__init__(**kwargs)

        currentTemp = getTemp()
        self.chosenColor = currentTemp.color
        self.unit = currentTemp.formato
        self.c_id = currentTemp.c_id
        self.color = self.chosenColor
        self.bind(chosenColor=self.update_temp)
        #Temperature
        self.text = str(
            int(getWeatherReducedByCityId(self.c_id, self.unit)['temp'])) + "º"
        Clock.schedule_interval(self.update_temp, 200)

    def update_temp(self, *args):
        self.text = str(
            int(getWeatherReducedByCityId(self.c_id, self.unit)['temp'])) + "º"
        self.color = self.chosenColor
Пример #3
0
class InfoDayConfig(Screen):
    colorHora = Properties.ListProperty([1, 1, 1, 1])
    formatoHora = Properties.ListProperty(["24h", False])

    colorFecha = Properties.ListProperty([1, 1, 1, 1])
    formatoFecha = Properties.StringProperty("dd/mm")

    colorTemp = Properties.ListProperty([1, 1, 1, 1])
    formatoTemp = Properties.StringProperty("metric")

    formatoClima = Properties.NumericProperty(2)

    c_id = Properties.StringProperty('6361046')
    activeInter = Properties.BooleanProperty(True)

    colorInter = Properties.ListProperty([1, 1, 1, 1])

    def __init__(self, **kwargs):
        super(InfoDayConfig, self).__init__(**kwargs)
        self.pos_hint = {'center_y': 0.5, 'center_x': 0.5}
        self.getAllInter()

    def saveConfig(self):
        #guardar las configs
        if self.ids.textinput.text == "":
            self.c_id = self.ids.textinput.hint_text
        else:
            self.c_id = self.ids.textinput.text
        dbWrapper.saveHora("hora", self.formatoHora, self.colorHora)
        dbWrapper.saveFecha("fecha", self.formatoFecha, self.colorFecha)
        dbWrapper.saveTemp("temp", self.formatoTemp, self.colorTemp, self.c_id)
        dbWrapper.saveClima("weather", self.formatoClima, self.c_id)
        dbWrapper.saveInfoState(self.activeInter)
        dbWrapper.saveInternationalConfig("inter", self.colorInter)

    def getAllInter(self):
        datos = dbWrapper.getAllInterByMonth(str(strftime('%m')))

        for j in datos:
            layout = BoxLayout(orientation='horizontal',
                               size_hint_y=None,
                               height=20,
                               padding=[-40, 0, 0, 0])
            layout.add_widget(Texto(text=str(j.dia)))
            layout.add_widget(
                Texto(text=str(j.info if len(j.info) < 25 else '...' +
                               j.info[10:35] + '...')))
            self.ids.todos.add_widget(layout)

    def pressedBack(self, widget):
        anim = Animation(pos_hint={"center_x": .5, "y": -.03}, duration=.1)
        anim += Animation(pos_hint={"center_x": .5, "y": 0}, duration=.1)
        anim.bind(on_complete=partial(self.goToMenuScreen))
        anim.start(widget)

    def goToMenuScreen(self, widget, selected):
        self.saveConfig()
        App.get_running_app().root.transition = FadeTransition(duration=.3)
        App.get_running_app().root.current = "menu"
Пример #4
0
class StatusBar(GridLayout):
    connection = properties.StringProperty("")
    mission = properties.StringProperty("None")
    speed = properties.NumericProperty(0)
    direction = properties.NumericProperty(0)

    def get_dir(self):
        return self.direction
Пример #5
0
class IconToggleLabel(ToggleButtonBehavior, IconLabel):
    
    icon_down = prop.StringProperty()
    icon_normal = prop.StringProperty()
    
    def on_state(self, *args):
        if self.state=='down':
            self.icon = self.icon_down
        else:
            self.icon = self.icon_normal
Пример #6
0
class ContextMenuText(ContextMenuItem):
    label = kp.ObjectProperty(None)
    submenu_postfix = kp.StringProperty(' ...')
    text = kp.StringProperty('')
    font_size = kp.NumericProperty(14)
    color = kp.ListProperty([1, 1, 1, 1])

    def __init__(self, *args, **kwargs):
        super(ContextMenuText, self).__init__(*args, **kwargs)

    @property
    def content_width(self):
        # keep little space for eventual arrow for submenus
        return self.label.texture_size[0] + 10
Пример #7
0
class SearchNode(ButtonBehavior, HoverBehavior, MDBoxLayout):
    """Custom widget to populate recycleview"""

    cls_nome = prop.StringProperty() ## Node name
    codigo_ref = prop.StringProperty() ## Node reference rode
    legacyId = prop.NumericProperty() ## Node id to be searched
    search_frame = prop.ObjectProperty() ## Root widget reference

    def on_enter(self, *args):
        """Mouse over node, bg color becomes gray"""
        self.md_bg_color = [.8, .8, .8, .8]

    def on_leave(self, *args):
        """Mouse leaves node, bg color back to default"""
        self.md_bg_color = [1, 1, 1, 1]
Пример #8
0
class NewBinding(InputWindow):
    """
    Acts as a user-friendly gui for creating new Keybind objects.
    """
    name = kp.StringProperty('')
    binding_props = dict(
        binding='',
        tab_back=False,
    )

    def update_binding_props(self, **props) -> None:
        """
        A universal method for updating the contents of binding_props
        using kwargs.

        :param props: Any number of kwargs.
        :return: None
        """
        for k, v in props.items():
            self.binding_props[k] = v

    def execute(self) -> None:
        """
        Sends binding_props off to parent (AppFrame expected) to create
        a new Keybind.

        :return: None
        """
        self.parent.update_keybind(**self.binding_props)
Пример #9
0
class ShmupApp(App):
    screen_manager = kp.ObjectProperty(None)
    highscore = kp.NumericProperty(0)
    game_over_msg = kp.StringProperty("")
    score = kp.NumericProperty(0)
    
    def build(self):
        # self.game = Game()
        # Clock.schedule_interval(self.game.update, 1.0/FPS)
        # return self.game
        self.screen_manager = MetaGame()
        return self.screen_manager

    def new_game(self):
        if self.screen_manager.game_screen.game.over:
            self.screen_manager.game_screen.game.new()
        self.screen_manager.current = "game_screen"
        Clock.schedule_interval(self.screen_manager.game_screen.game.update, 1.0/FPS)

    def update_score(self):
        self.score = self.screen_manager.game_screen.game.score
        self.highscore = max(self.highscore, self.score)

    def quit_game(self):
        self.update_score()
        self.screen_manager.game_screen.game.quit_game()
        self.screen_manager.current = "game_over_screen"
Пример #10
0
class RecycleViewRow_Cocktails(BoxLayout):
    text = kivy_property.StringProperty()
    image_source = kivy_property.StringProperty()
    rating = kivy_property.StringProperty()

    def show_rezept(self, cocktail_name):
        text_rezept = ""

        rezept_geladen = DB_Helper().GET_Rezept_JSON(cocktail_name,
                                                     'cocktails')
        text_rezept = JSON_Manager().JSON_to_Rezept_String(rezept_geladen)

        popup_rezept = Rezept()
        popup_rezept.title = cocktail_name
        popup_rezept.rezept = text_rezept
        popup_rezept.open()
Пример #11
0
class ScatterColoredLabel(Scatter):
    background_color = Properties.ListProperty((0, 0, 0, 1))
    visible = Properties.BooleanProperty()
    saveOnDBEvent = Properties.ObjectProperty()
    noteId = Properties.NumericProperty()
    text = Properties.StringProperty()

    def on_pos(self, instance, value):
        try:
            self.saveOnDBEvent.cancel()
        except:
            logging.info('Notes: No previous event')
        self.saveOnDBEvent = Clock.schedule_once(self.saveOnDB, 5)

    def saveOnDB(self, dt):
        noteToSave = Notes(
            _id=self.noteId,
            pinned=self.visible,
            text=self.text,
            posX=self.pos[0],
            posY=self.pos[1],
            scale=self.scale,
            rotation=self.rotation,
            rgb=[
                self.background_color[0]*255,
                self.background_color[1]*255,
                self.background_color[2]*255,
                self.background_color[3],
            ],

        )
        noteToSave.save()

        logging.info('DB: Updated note with id: ' + str(self.noteId))
Пример #12
0
class ScatterImage(Scatter):
    source = Properties.StringProperty()
    anim_delay = Properties.NumericProperty()
    saveOnDBEvent = Properties.ObjectProperty()
    imagenId = Properties.NumericProperty()

    def on_pos(self, instance, value):
        try:
            self.saveOnDBEvent.cancel()
        except:
            logging.info('Gifs: No previous event')

        self.saveOnDBEvent = Clock.schedule_once(self.saveOnDB, 5)

    def bringToFront(self):
        parent = self.parent
        children = parent.children
        childOnTop = children[0]

        if (self != childOnTop):
            parent.remove_widget(self)
            parent.add_widget(self)

    def saveOnDB(self, dt):
        gifToSave = Gifs(
            _id=self.imagenId,
            source=self.source,
            posX=self.pos[0],
            posY=self.pos[1],
            scale=self.scale,
            rotation=self.rotation,
            delay=self.anim_delay)
        gifToSave.save()

        logging.info('DB: Updated gif with id: ' + str(self.imagenId))
Пример #13
0
class AppMenuTextItem(ToggleButton, AbstractMenuItem):
    label = kp.ObjectProperty(None)
    text = kp.StringProperty('')
    font_size = kp.NumericProperty(14)
    color = kp.ListProperty([1, 1, 1, 1])

    def on_release(self):
        submenu = self.get_submenu()

        if self.state == 'down':
            root = self._root_parent
            submenu.bounding_box_widget = root.bounding_box if root.bounding_box else root.parent

            submenu.bind(visible=self.on_visible)
            submenu.show(self.x, self.y - 1)

            for sibling in self.siblings:
                if sibling.get_submenu() is not None:
                    sibling.state = 'normal'
                    sibling.get_submenu().hide()

            self.parent._setup_hover_timer()
        else:
            self.parent._cancel_hover_timer()
            submenu.hide()

    def on_visible(self, *args):
        submenu = self.get_submenu()
        if self.width > submenu.get_max_width():
            submenu.width = self.width

    def _check_submenu(self):
        super(AppMenuTextItem, self)._check_submenu()
        self.disabled = (self.get_submenu() is None)
class TurnOrderRecord(widget.Widget):

    text = prop.StringProperty()

    def __init__(self, text, **kwargs):
        super().__init__(**kwargs)
        self.text = text
Пример #15
0
class RecycleViewRow_Alkoholfrei(BoxLayout):
    text = kivy_property.StringProperty()
    image_source = kivy_property.StringProperty()
    rating = kivy_property.StringProperty()

    def show_rezept(self, alkoholfrei_name):
        text_rezept = ""

        rezept_geladen = DB_Helper().GET_Rezept_JSON(alkoholfrei_name,
                                                     'alkoholfrei')
        text_rezept = JSON_Manager().JSON_to_Rezept_String(rezept_geladen)

        popup_rezept = Rezept()
        popup_rezept.title = alkoholfrei_name
        popup_rezept.rezept = text_rezept
        popup_rezept.open()
Пример #16
0
class IconLabel(HoverInfoBehavior, Label):
    icon = prop.StringProperty('')
    icon_size = prop.NumericProperty(16)

    def __init__(self, **k):
        super(IconLabel, self).__init__(**k)
        self.markup=True
Пример #17
0
class TwitterConfig(Screen):

    colorInter = Properties.ListProperty([1, 1, 1, 1])
    activeInter = Properties.BooleanProperty(False)
    halign = Properties.StringProperty('left')

    def __init__(self, **kwargs):
        super(TwitterConfig, self).__init__(**kwargs)
        self.pos_hint = {'center_y': 0.5, 'center_x': 0.5}

    def changeHalign(self, halign):
        self.halign = halign

    def saveConfig(self):
        #guardar las configs
        print(self.activeInter)
        dbWrapper.saveTwitter(self.activeInter, self.colorInter, self.halign)

    def pressedBack(self, widget):
        anim = Animation(pos_hint={"center_x": .5, "y": -.03}, duration=.1)
        anim += Animation(pos_hint={"center_x": .5, "y": 0}, duration=.1)
        anim.bind(on_complete=partial(self.goToMenuScreen))
        anim.start(widget)

    def goToMenuScreen(self, widget, selected):
        self.saveConfig()
        App.get_running_app().root.transition = FadeTransition(duration=.3)
        App.get_running_app().root.current = "menu"
Пример #18
0
class GameScreen(Screen):
    # pai_1 = kyprops.StringProperty(None)
    # pai_2 = kyprops.StringProperty(None)
    # pai_3 = kyprops.StringProperty(None)
    # pai_4 = kyprops.StringProperty(None)
    # pai_5 = kyprops.StringProperty(None)
    # pai_6 = kyprops.StringProperty(None)
    # pai_7 = kyprops.StringProperty(None)
    # pai_8 = kyprops.StringProperty(None)
    # pai_9 = kyprops.StringProperty(None)
    # pai_10 = kyprops.StringProperty(None)
    # pai_11 = kyprops.StringProperty(None)
    # pai_12 = kyprops.StringProperty(None)
    # pai_13 = kyprops.StringProperty(None)
    pais = [kyprops.StringProperty(None)] * 14

    # pai_14 = kyprops.StringProperty(None)

    def setup(self):
        data = s.recv(2048)
        data = data.decode("utf-8")
        data = json.loads(data)
        list_of_pai = data["hand"]
        pai_str = "../img/imgUp/p_"
        for i, pai in enumerate(list_of_pai):
            self.pais[i] = pai_str + str(pai[0]) + ".png"
Пример #19
0
class GameOverScreen(Screen):

    app = prop.ObjectProperty()
    winner_name = prop.StringProperty()

    def __init__(self, app, winner_name=None, **kwargs):
        super().__init__(**kwargs)
        self.app = app
        self.winner_name = winner_name or ""
Пример #20
0
class MenuButton(MenuItem, but.Button, HoverBehavior):

    icon = prop.StringProperty(None, allownone=True)
    menubar = prop.ObjectProperty(None)

    def on_release(self):
        print("Button", self.text, "triggered")
        if isinstance(self.parent.parent, MenuDropDown):
            self.menubar.selected = False
            self.parent.parent.dismiss()
Пример #21
0
class Fondo(ToggleButtonBehavior, Image):
    imagen = Properties.StringProperty("")

    def __init__(self, imagen, **kwargs):
        super(Fondo, self).__init__(**kwargs)
        self.imagen = imagen
        self.source = "images/saveScreen/" + imagen

    def on_state(self, widget, value):
        if value == 'down' and self.imagen != "":
            dbWrapper.saveSaveScreen(self.imagen)
Пример #22
0
class CommandTerminal(KivyCmd):

    text = prop.StringProperty()
    ''' property where the logs are stored '''

    top_pannel_items = prop.ListProperty()

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        clearbtn = Factory.TopPanelButton(icon='fa-trash-o')
        self.top_pannel_items.append(clearbtn)
Пример #23
0
class ClockWidget(Image):
    text = Properties.StringProperty('')
    chosenColor = Properties.ListProperty()
    segundos = Properties.BooleanProperty()
    horas = Properties.StringProperty()

    def on_text(self, *_):
        # Just get large texture:z
        l = Label(text=self.text)
        l.font_size = '1000dp'  # something that'll give texture bigger than phone's screen size
        l.color = self.color
        l.texture_update()
        # Set it to image, it'll be scaled to image size automatically:
        self.texture = l.texture

    def __init__(self, **kwargs):
        super(ClockWidget, self).__init__(**kwargs)
        currentHora = getHora()
        self.chosenColor = currentHora.color
        self.segundos = currentHora.formato[1]
        self.horas = currentHora.formato[0]
        self.color = self.chosenColor
        self.text = datetime.now().strftime(
            self.update_secondsAndFormat(self.segundos, self.horas))
        Clock.schedule_interval(self.update_time, 1)

    def update_time(self, *args):
        self.text = datetime.now().strftime(
            self.update_secondsAndFormat(self.segundos, self.horas))
        self.color = self.chosenColor

    def update_secondsAndFormat(self, seconds, formato):
        if (seconds == True and formato == "24h"):
            return '%H:%M:%S'
        elif (seconds == True and formato == "12h"):
            return '%I:%M:%S %p'
        elif (seconds == False and formato == "24h"):
            return '%H:%M'
        else:
            return '%I:%M %p'
Пример #24
0
class LinhaHomePage(BoxLayout):
    nome_group = kvProps.StringProperty('')
    idGrupo = kvProps.NumericProperty()

    def go_chat(self):
        db = BancoDadosGrupos()
        GrupoList = db.listarGruposPorId(self.idGrupo)
        App.get_running_app().registro_atual = GrupoList
        App.get_running_app().route.transition.direction = 'left'
        App.get_running_app().route.current = 'chat'

        global idGrupoChat
        idGrupoChat = self.idGrupo
Пример #25
0
class Platform(Sprite):
    img1 = kp.StringProperty("imgs/ground_grass.png")
    img1_width = kp.NumericProperty(380)
    img1_height = kp.NumericProperty(94)
    img2 = kp.StringProperty("imgs/ground_grass_small.png")
    img2_width = kp.NumericProperty(201)
    img2_height = kp.NumericProperty(100)

    def __init__(self, x, y, w, h, game, **kwargs):
        self.groups = (game.all_sprites, game.platforms)
        super().__init__(**kwargs)
        width = w * Window.width
        width = min(width, self.img1_width)
        width = max(width, self.img2_width * 0.5)
        if width > self.img2_width:
            self.source = self.img1
            self.ratio = self.img1_height / self.img1_width
        else:
            self.source = self.img2
            self.ratio = self.img2_height / self.img2_width
        self.game = game
        self.add_to_groups(index=PLATFORM_LAYER)
        self.pos = (x * Window.width, y * Window.height)
        # self.size = (w * Window.width, h * Window.height)
        self.width = width
        self.height = width * self.ratio
        with self.canvas.before:
            Color(0, 1., 0, 0.8 * DEBUG)
            self.rect = Rectangle(size=self.size, pos=self.pos)

        if randrange(100) < POW_SPAWN_PCT:
            PowerUp(self)

        self.bind(pos=self.update_rect)

    def update_rect(self, *args):
        self.rect.pos = self.pos
Пример #26
0
class Resource(Widget):
    current = kp.NumericProperty(0)
    per_s = kp.NumericProperty(0)
    _type = kp.StringProperty()

    def __init__(self, _type, **kwargs):
        super().__init__(**kwargs)
        self._type = _type.lower()
        self.current = RESOURCES.get("INIT").get(_type)
        self.per_s = RESOURCES.get("PRODUCTION").get(_type)
        self.icon = RESOURCES.get("ICON").get(_type)
        self.ratio = RESOURCES.get("RATIO")

    def calc_next_level(self):
        return self.per_s * self.ratio
Пример #27
0
class SaveScreen(Screen):
    fondo = Properties.StringProperty()

    def __init__(self, **kwargs):
        super(SaveScreen, self).__init__(**kwargs)
        imageName = dbWrapper.getSaveScreen().image
        self.fondo = "images/saveScreen/" + imageName

    def refreshImage(self):
        imageName = dbWrapper.getSaveScreen().image
        self.fondo = "images/saveScreen/" + imageName

    def goToHomeScreen(self, widget):
        App.get_running_app().root.transition = FadeTransition(duration=.3)
        App.get_running_app().root.current = "home"
Пример #28
0
class DateWidget(Image):
    text = Properties.StringProperty('')
    chosenColor = Properties.ListProperty()
    formato = Properties.StringProperty()

    def on_text(self, *_):
        # Just get large texture:
        l = Label(text=self.text)
        l.font_size = '1000dp'  # something that'll give texture bigger than phone's screen size
        l.color = self.color
        l.texture_update()
        # Set it to image, it'll be scaled to image size automatically:
        self.texture = l.texture

    def __init__(self, **kwargs):
        super(DateWidget, self).__init__(**kwargs)
        currentFecha = getFecha()
        self.chosenColor = currentFecha.color
        self.formato = currentFecha.formato
        self.color = self.chosenColor
        self.text = datetime.now().strftime(self.update_Format())
        Clock.schedule_interval(self.update_time, 60)

    def update_time(self, *args):
        self.text = datetime.now().strftime(self.update_Format())
        self.color = self.chosenColor

    def update_Format(self):
        if (self.formato == "dd/mm"):
            return '%d/%m'
        elif (self.formato == "dd/mm/yyyy"):
            return '%d/%m/%y'
        elif (self.formato == "mm/dd"):
            return '%m/%d'
        else:
            return '%m/%d/%y'
Пример #29
0
class LinhaSearch(BoxLayout):
    nome_group = kvProps.StringProperty('')
    idGrupo = kvProps.NumericProperty()

    def clique(self):
        db = BancoDadosGrupos()
        GrupoList = db.listarGruposPorId(self.idGrupo)
        App.get_running_app().registro_atual = GrupoList
        App.get_running_app().route.transition.direction = 'left'
        App.get_running_app().route.current = 'entrar'

        global idGrupoChat
        idGrupoChat = self.idGrupo

        global nome_sala
        nome_sala = self.nome_group
Пример #30
0
class LoginPage(Screen):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    # Logo do app
    imagem_app = kvProps.StringProperty('gjoinLogo.jpeg')

    def login(self):
        #Verificando se o login e senha estão correntos
        user = self.ids.log_email.text
        password = self.ids.log_pass.text
        conn = sqlite3.connect('BANCO.db')
        db = conn.cursor()
        db.execute('SELECT * FROM dados WHERE email = ? AND senha = ?',
                   (user, password))

        if db.fetchall():
            #Chamando as variáveis globais para a função
            global idLogado

            # Mudança da tela de login para a home page
            self.manager.transition.direction = 'left'
            self.manager.current = 'home'

            # Armazenando o ID logado na variável global idLogado
            conn = sqlite3.connect('BANCO.db')
            db = conn.cursor()
            db.execute(
                '''SELECT id FROM dados WHERE email = ? and senha = ?''',
                (user, password))
            idLogado = db.fetchone()[0]
            conn.close()

        else:
            global avisopop
            avisopop = 'O usuario e senha nao sao validos.'

            pops = WarningPopup()
            pops.ids.aviso.text = avisopop
            pops.open()

        conn.close()

    def go_register(self):
        self.manager.transition.direction = 'up'
        self.manager.current = 'register'