Ejemplo n.º 1
0
 def new_board(self, name):
     """Make a board for a character name, and switch to it."""
     char = self.engine.character[name]
     board = Board(character=char)
     self.mainscreen.boards[name] = board
     self.character = char
Ejemplo n.º 2
0
    def _add_screens(self, *args):
        if not getattr(self, '_started'):
            Clock.schedule_once(self._add_screens, 0)
            return

        def toggler(screenname):
            def tog(*args):
                if self.manager.current == screenname:
                    self.manager.current = 'main'
                else:
                    self.manager.current = screenname

            return tog

        config = self.config

        self.pawncfg = ELiDE.spritebuilder.PawnConfigScreen(
            toggle=toggler('pawncfg'),
            data=json.loads(config['ELiDE']['thing_graphics']))

        self.spotcfg = ELiDE.spritebuilder.SpotConfigScreen(
            toggle=toggler('spotcfg'),
            data=json.loads(config['ELiDE']['place_graphics']))

        self.rules = ELiDE.rulesview.RulesScreen(engine=self.engine,
                                                 toggle=toggler('rules'))

        self.charrules = ELiDE.rulesview.CharacterRulesScreen(
            engine=self.engine,
            character=self.character,
            toggle=toggler('charrules'))
        self.bind(character=self.charrules.setter('character'))

        self.chars = ELiDE.charsview.CharactersScreen(
            engine=self.engine,
            toggle=toggler('chars'),
            names=list(self.engine.character),
            new_board=self.new_board)
        self.bind(character_name=self.chars.setter('character_name'))

        def chars_push_character_name(*args):
            self.unbind(character_name=self.chars.setter('character_name'))
            self.character_name = self.chars.character_name
            self.bind(character_name=self.chars.setter('character_name'))

        self.chars.push_character_name = chars_push_character_name

        self.strings = ELiDE.stores.StringsEdScreen(
            language=self.engine.string.language,
            language_setter=self._set_language,
            toggle=toggler('strings'))

        self.funcs = ELiDE.stores.FuncsEdScreen(name='funcs',
                                                toggle=toggler('funcs'))

        self.select_character(
            self.engine.character[config['ELiDE']['boardchar']])

        self.statcfg = ELiDE.statcfg.StatScreen(toggle=toggler('statcfg'),
                                                engine=self.engine)
        self.bind(selected_proxy=self.statcfg.setter('proxy'))

        self.mainscreen = ELiDE.screen.MainScreen(
            use_kv=config['ELiDE']['user_kv'] == 'yes',
            play_speed=int(config['ELiDE']['play_speed']),
            boards={
                name: Board(character=char)
                for name, char in self.engine.character.items()
            })
        if self.mainscreen.statlist:
            self.statcfg.statlist = self.mainscreen.statlist
        self.mainscreen.bind(statlist=self.statcfg.setter('statlist'))
        self.bind(selection=self.refresh_selected_proxy,
                  character=self.refresh_selected_proxy)
        self.selected_proxy = self._get_selected_proxy()
        for wid in (self.mainscreen, self.pawncfg, self.spotcfg, self.statcfg,
                    self.rules, self.charrules, self.chars, self.strings,
                    self.funcs):
            self.manager.add_widget(wid)