bastd.ui.settings.allsettings

UI for top level settings categories.

  1# Released under the MIT License. See LICENSE for details.
  2#
  3"""UI for top level settings categories."""
  4
  5from __future__ import annotations
  6
  7from typing import TYPE_CHECKING
  8
  9import _ba
 10import ba
 11
 12if TYPE_CHECKING:
 13    pass
 14
 15
 16class AllSettingsWindow(ba.Window):
 17    """Window for selecting a settings category."""
 18
 19    def __init__(self,
 20                 transition: str = 'in_right',
 21                 origin_widget: ba.Widget | None = None):
 22        # pylint: disable=too-many-statements
 23        # pylint: disable=too-many-locals
 24        import threading
 25
 26        # Preload some modules we use in a background thread so we won't
 27        # have a visual hitch when the user taps them.
 28        threading.Thread(target=self._preload_modules).start()
 29
 30        ba.set_analytics_screen('Settings Window')
 31        scale_origin: tuple[float, float] | None
 32        if origin_widget is not None:
 33            self._transition_out = 'out_scale'
 34            scale_origin = origin_widget.get_screen_space_center()
 35            transition = 'in_scale'
 36        else:
 37            self._transition_out = 'out_right'
 38            scale_origin = None
 39        uiscale = ba.app.ui.uiscale
 40        width = 900 if uiscale is ba.UIScale.SMALL else 580
 41        x_inset = 75 if uiscale is ba.UIScale.SMALL else 0
 42        height = 435
 43        self._r = 'settingsWindow'
 44        top_extra = 20 if uiscale is ba.UIScale.SMALL else 0
 45
 46        uiscale = ba.app.ui.uiscale
 47        super().__init__(root_widget=ba.containerwidget(
 48            size=(width, height + top_extra),
 49            transition=transition,
 50            toolbar_visibility='menu_minimal',
 51            scale_origin_stack_offset=scale_origin,
 52            scale=(1.75 if uiscale is ba.UIScale.SMALL else
 53                   1.35 if uiscale is ba.UIScale.MEDIUM else 1.0),
 54            stack_offset=(0, -8) if uiscale is ba.UIScale.SMALL else (0, 0)))
 55
 56        if ba.app.ui.use_toolbars and uiscale is ba.UIScale.SMALL:
 57            self._back_button = None
 58            ba.containerwidget(edit=self._root_widget,
 59                               on_cancel_call=self._do_back)
 60        else:
 61            self._back_button = btn = ba.buttonwidget(
 62                parent=self._root_widget,
 63                autoselect=True,
 64                position=(40 + x_inset, height - 55),
 65                size=(130, 60),
 66                scale=0.8,
 67                text_scale=1.2,
 68                label=ba.Lstr(resource='backText'),
 69                button_type='back',
 70                on_activate_call=self._do_back)
 71            ba.containerwidget(edit=self._root_widget, cancel_button=btn)
 72
 73        ba.textwidget(parent=self._root_widget,
 74                      position=(0, height - 44),
 75                      size=(width, 25),
 76                      text=ba.Lstr(resource=self._r + '.titleText'),
 77                      color=ba.app.ui.title_color,
 78                      h_align='center',
 79                      v_align='center',
 80                      maxwidth=130)
 81
 82        if self._back_button is not None:
 83            ba.buttonwidget(edit=self._back_button,
 84                            button_type='backSmall',
 85                            size=(60, 60),
 86                            label=ba.charstr(ba.SpecialChar.BACK))
 87
 88        v = height - 80
 89        v -= 145
 90
 91        basew = 280 if uiscale is ba.UIScale.SMALL else 230
 92        baseh = 170
 93        x_offs = x_inset + (105 if uiscale is ba.UIScale.SMALL else
 94                            72) - basew  # now unused
 95        x_offs2 = x_offs + basew - 7
 96        x_offs3 = x_offs + 2 * (basew - 7)
 97        x_offs4 = x_offs2
 98        x_offs5 = x_offs3
 99
100        def _b_title(x: float, y: float, button: ba.Widget,
101                     text: str | ba.Lstr) -> None:
102            ba.textwidget(parent=self._root_widget,
103                          text=text,
104                          position=(x + basew * 0.47, y + baseh * 0.22),
105                          maxwidth=basew * 0.7,
106                          size=(0, 0),
107                          h_align='center',
108                          v_align='center',
109                          draw_controller=button,
110                          color=(0.7, 0.9, 0.7, 1.0))
111
112        ctb = self._controllers_button = ba.buttonwidget(
113            parent=self._root_widget,
114            autoselect=True,
115            position=(x_offs2, v),
116            size=(basew, baseh),
117            button_type='square',
118            label='',
119            on_activate_call=self._do_controllers)
120        if ba.app.ui.use_toolbars and self._back_button is None:
121            bbtn = _ba.get_special_widget('back_button')
122            ba.widget(edit=ctb, left_widget=bbtn)
123        _b_title(x_offs2, v, ctb,
124                 ba.Lstr(resource=self._r + '.controllersText'))
125        imgw = imgh = 130
126        ba.imagewidget(parent=self._root_widget,
127                       position=(x_offs2 + basew * 0.49 - imgw * 0.5, v + 35),
128                       size=(imgw, imgh),
129                       texture=ba.gettexture('controllerIcon'),
130                       draw_controller=ctb)
131
132        gfxb = self._graphics_button = ba.buttonwidget(
133            parent=self._root_widget,
134            autoselect=True,
135            position=(x_offs3, v),
136            size=(basew, baseh),
137            button_type='square',
138            label='',
139            on_activate_call=self._do_graphics)
140        if ba.app.ui.use_toolbars:
141            pbtn = _ba.get_special_widget('party_button')
142            ba.widget(edit=gfxb, up_widget=pbtn, right_widget=pbtn)
143        _b_title(x_offs3, v, gfxb, ba.Lstr(resource=self._r + '.graphicsText'))
144        imgw = imgh = 110
145        ba.imagewidget(parent=self._root_widget,
146                       position=(x_offs3 + basew * 0.49 - imgw * 0.5, v + 42),
147                       size=(imgw, imgh),
148                       texture=ba.gettexture('graphicsIcon'),
149                       draw_controller=gfxb)
150
151        v -= (baseh - 5)
152
153        abtn = self._audio_button = ba.buttonwidget(
154            parent=self._root_widget,
155            autoselect=True,
156            position=(x_offs4, v),
157            size=(basew, baseh),
158            button_type='square',
159            label='',
160            on_activate_call=self._do_audio)
161        _b_title(x_offs4, v, abtn, ba.Lstr(resource=self._r + '.audioText'))
162        imgw = imgh = 120
163        ba.imagewidget(parent=self._root_widget,
164                       position=(x_offs4 + basew * 0.49 - imgw * 0.5 + 5,
165                                 v + 35),
166                       size=(imgw, imgh),
167                       color=(1, 1, 0),
168                       texture=ba.gettexture('audioIcon'),
169                       draw_controller=abtn)
170
171        avb = self._advanced_button = ba.buttonwidget(
172            parent=self._root_widget,
173            autoselect=True,
174            position=(x_offs5, v),
175            size=(basew, baseh),
176            button_type='square',
177            label='',
178            on_activate_call=self._do_advanced)
179        _b_title(x_offs5, v, avb, ba.Lstr(resource=self._r + '.advancedText'))
180        imgw = imgh = 120
181        ba.imagewidget(parent=self._root_widget,
182                       position=(x_offs5 + basew * 0.49 - imgw * 0.5 + 5,
183                                 v + 35),
184                       size=(imgw, imgh),
185                       color=(0.8, 0.95, 1),
186                       texture=ba.gettexture('advancedIcon'),
187                       draw_controller=avb)
188        self._restore_state()
189
190    # noinspection PyUnresolvedReferences
191    @staticmethod
192    def _preload_modules() -> None:
193        """Preload modules we use (called in bg thread)."""
194        import bastd.ui.mainmenu as _unused1
195        import bastd.ui.settings.controls as _unused2
196        import bastd.ui.settings.graphics as _unused3
197        import bastd.ui.settings.audio as _unused4
198        import bastd.ui.settings.advanced as _unused5
199
200    def _do_back(self) -> None:
201        # pylint: disable=cyclic-import
202        from bastd.ui.mainmenu import MainMenuWindow
203        self._save_state()
204        ba.containerwidget(edit=self._root_widget,
205                           transition=self._transition_out)
206        ba.app.ui.set_main_menu_window(
207            MainMenuWindow(transition='in_left').get_root_widget())
208
209    def _do_controllers(self) -> None:
210        # pylint: disable=cyclic-import
211        from bastd.ui.settings.controls import ControlsSettingsWindow
212        self._save_state()
213        ba.containerwidget(edit=self._root_widget, transition='out_left')
214        ba.app.ui.set_main_menu_window(
215            ControlsSettingsWindow(
216                origin_widget=self._controllers_button).get_root_widget())
217
218    def _do_graphics(self) -> None:
219        # pylint: disable=cyclic-import
220        from bastd.ui.settings.graphics import GraphicsSettingsWindow
221        self._save_state()
222        ba.containerwidget(edit=self._root_widget, transition='out_left')
223        ba.app.ui.set_main_menu_window(
224            GraphicsSettingsWindow(
225                origin_widget=self._graphics_button).get_root_widget())
226
227    def _do_audio(self) -> None:
228        # pylint: disable=cyclic-import
229        from bastd.ui.settings.audio import AudioSettingsWindow
230        self._save_state()
231        ba.containerwidget(edit=self._root_widget, transition='out_left')
232        ba.app.ui.set_main_menu_window(
233            AudioSettingsWindow(
234                origin_widget=self._audio_button).get_root_widget())
235
236    def _do_advanced(self) -> None:
237        # pylint: disable=cyclic-import
238        from bastd.ui.settings.advanced import AdvancedSettingsWindow
239        self._save_state()
240        ba.containerwidget(edit=self._root_widget, transition='out_left')
241        ba.app.ui.set_main_menu_window(
242            AdvancedSettingsWindow(
243                origin_widget=self._advanced_button).get_root_widget())
244
245    def _save_state(self) -> None:
246        try:
247            sel = self._root_widget.get_selected_child()
248            if sel == self._controllers_button:
249                sel_name = 'Controllers'
250            elif sel == self._graphics_button:
251                sel_name = 'Graphics'
252            elif sel == self._audio_button:
253                sel_name = 'Audio'
254            elif sel == self._advanced_button:
255                sel_name = 'Advanced'
256            elif sel == self._back_button:
257                sel_name = 'Back'
258            else:
259                raise ValueError(f'unrecognized selection \'{sel}\'')
260            ba.app.ui.window_states[type(self)] = {'sel_name': sel_name}
261        except Exception:
262            ba.print_exception(f'Error saving state for {self}.')
263
264    def _restore_state(self) -> None:
265        try:
266            sel_name = ba.app.ui.window_states.get(type(self),
267                                                   {}).get('sel_name')
268            sel: ba.Widget | None
269            if sel_name == 'Controllers':
270                sel = self._controllers_button
271            elif sel_name == 'Graphics':
272                sel = self._graphics_button
273            elif sel_name == 'Audio':
274                sel = self._audio_button
275            elif sel_name == 'Advanced':
276                sel = self._advanced_button
277            elif sel_name == 'Back':
278                sel = self._back_button
279            else:
280                sel = self._controllers_button
281            if sel is not None:
282                ba.containerwidget(edit=self._root_widget, selected_child=sel)
283        except Exception:
284            ba.print_exception(f'Error restoring state for {self}.')
class AllSettingsWindow(ba.ui.Window):
 17class AllSettingsWindow(ba.Window):
 18    """Window for selecting a settings category."""
 19
 20    def __init__(self,
 21                 transition: str = 'in_right',
 22                 origin_widget: ba.Widget | None = None):
 23        # pylint: disable=too-many-statements
 24        # pylint: disable=too-many-locals
 25        import threading
 26
 27        # Preload some modules we use in a background thread so we won't
 28        # have a visual hitch when the user taps them.
 29        threading.Thread(target=self._preload_modules).start()
 30
 31        ba.set_analytics_screen('Settings Window')
 32        scale_origin: tuple[float, float] | None
 33        if origin_widget is not None:
 34            self._transition_out = 'out_scale'
 35            scale_origin = origin_widget.get_screen_space_center()
 36            transition = 'in_scale'
 37        else:
 38            self._transition_out = 'out_right'
 39            scale_origin = None
 40        uiscale = ba.app.ui.uiscale
 41        width = 900 if uiscale is ba.UIScale.SMALL else 580
 42        x_inset = 75 if uiscale is ba.UIScale.SMALL else 0
 43        height = 435
 44        self._r = 'settingsWindow'
 45        top_extra = 20 if uiscale is ba.UIScale.SMALL else 0
 46
 47        uiscale = ba.app.ui.uiscale
 48        super().__init__(root_widget=ba.containerwidget(
 49            size=(width, height + top_extra),
 50            transition=transition,
 51            toolbar_visibility='menu_minimal',
 52            scale_origin_stack_offset=scale_origin,
 53            scale=(1.75 if uiscale is ba.UIScale.SMALL else
 54                   1.35 if uiscale is ba.UIScale.MEDIUM else 1.0),
 55            stack_offset=(0, -8) if uiscale is ba.UIScale.SMALL else (0, 0)))
 56
 57        if ba.app.ui.use_toolbars and uiscale is ba.UIScale.SMALL:
 58            self._back_button = None
 59            ba.containerwidget(edit=self._root_widget,
 60                               on_cancel_call=self._do_back)
 61        else:
 62            self._back_button = btn = ba.buttonwidget(
 63                parent=self._root_widget,
 64                autoselect=True,
 65                position=(40 + x_inset, height - 55),
 66                size=(130, 60),
 67                scale=0.8,
 68                text_scale=1.2,
 69                label=ba.Lstr(resource='backText'),
 70                button_type='back',
 71                on_activate_call=self._do_back)
 72            ba.containerwidget(edit=self._root_widget, cancel_button=btn)
 73
 74        ba.textwidget(parent=self._root_widget,
 75                      position=(0, height - 44),
 76                      size=(width, 25),
 77                      text=ba.Lstr(resource=self._r + '.titleText'),
 78                      color=ba.app.ui.title_color,
 79                      h_align='center',
 80                      v_align='center',
 81                      maxwidth=130)
 82
 83        if self._back_button is not None:
 84            ba.buttonwidget(edit=self._back_button,
 85                            button_type='backSmall',
 86                            size=(60, 60),
 87                            label=ba.charstr(ba.SpecialChar.BACK))
 88
 89        v = height - 80
 90        v -= 145
 91
 92        basew = 280 if uiscale is ba.UIScale.SMALL else 230
 93        baseh = 170
 94        x_offs = x_inset + (105 if uiscale is ba.UIScale.SMALL else
 95                            72) - basew  # now unused
 96        x_offs2 = x_offs + basew - 7
 97        x_offs3 = x_offs + 2 * (basew - 7)
 98        x_offs4 = x_offs2
 99        x_offs5 = x_offs3
100
101        def _b_title(x: float, y: float, button: ba.Widget,
102                     text: str | ba.Lstr) -> None:
103            ba.textwidget(parent=self._root_widget,
104                          text=text,
105                          position=(x + basew * 0.47, y + baseh * 0.22),
106                          maxwidth=basew * 0.7,
107                          size=(0, 0),
108                          h_align='center',
109                          v_align='center',
110                          draw_controller=button,
111                          color=(0.7, 0.9, 0.7, 1.0))
112
113        ctb = self._controllers_button = ba.buttonwidget(
114            parent=self._root_widget,
115            autoselect=True,
116            position=(x_offs2, v),
117            size=(basew, baseh),
118            button_type='square',
119            label='',
120            on_activate_call=self._do_controllers)
121        if ba.app.ui.use_toolbars and self._back_button is None:
122            bbtn = _ba.get_special_widget('back_button')
123            ba.widget(edit=ctb, left_widget=bbtn)
124        _b_title(x_offs2, v, ctb,
125                 ba.Lstr(resource=self._r + '.controllersText'))
126        imgw = imgh = 130
127        ba.imagewidget(parent=self._root_widget,
128                       position=(x_offs2 + basew * 0.49 - imgw * 0.5, v + 35),
129                       size=(imgw, imgh),
130                       texture=ba.gettexture('controllerIcon'),
131                       draw_controller=ctb)
132
133        gfxb = self._graphics_button = ba.buttonwidget(
134            parent=self._root_widget,
135            autoselect=True,
136            position=(x_offs3, v),
137            size=(basew, baseh),
138            button_type='square',
139            label='',
140            on_activate_call=self._do_graphics)
141        if ba.app.ui.use_toolbars:
142            pbtn = _ba.get_special_widget('party_button')
143            ba.widget(edit=gfxb, up_widget=pbtn, right_widget=pbtn)
144        _b_title(x_offs3, v, gfxb, ba.Lstr(resource=self._r + '.graphicsText'))
145        imgw = imgh = 110
146        ba.imagewidget(parent=self._root_widget,
147                       position=(x_offs3 + basew * 0.49 - imgw * 0.5, v + 42),
148                       size=(imgw, imgh),
149                       texture=ba.gettexture('graphicsIcon'),
150                       draw_controller=gfxb)
151
152        v -= (baseh - 5)
153
154        abtn = self._audio_button = ba.buttonwidget(
155            parent=self._root_widget,
156            autoselect=True,
157            position=(x_offs4, v),
158            size=(basew, baseh),
159            button_type='square',
160            label='',
161            on_activate_call=self._do_audio)
162        _b_title(x_offs4, v, abtn, ba.Lstr(resource=self._r + '.audioText'))
163        imgw = imgh = 120
164        ba.imagewidget(parent=self._root_widget,
165                       position=(x_offs4 + basew * 0.49 - imgw * 0.5 + 5,
166                                 v + 35),
167                       size=(imgw, imgh),
168                       color=(1, 1, 0),
169                       texture=ba.gettexture('audioIcon'),
170                       draw_controller=abtn)
171
172        avb = self._advanced_button = ba.buttonwidget(
173            parent=self._root_widget,
174            autoselect=True,
175            position=(x_offs5, v),
176            size=(basew, baseh),
177            button_type='square',
178            label='',
179            on_activate_call=self._do_advanced)
180        _b_title(x_offs5, v, avb, ba.Lstr(resource=self._r + '.advancedText'))
181        imgw = imgh = 120
182        ba.imagewidget(parent=self._root_widget,
183                       position=(x_offs5 + basew * 0.49 - imgw * 0.5 + 5,
184                                 v + 35),
185                       size=(imgw, imgh),
186                       color=(0.8, 0.95, 1),
187                       texture=ba.gettexture('advancedIcon'),
188                       draw_controller=avb)
189        self._restore_state()
190
191    # noinspection PyUnresolvedReferences
192    @staticmethod
193    def _preload_modules() -> None:
194        """Preload modules we use (called in bg thread)."""
195        import bastd.ui.mainmenu as _unused1
196        import bastd.ui.settings.controls as _unused2
197        import bastd.ui.settings.graphics as _unused3
198        import bastd.ui.settings.audio as _unused4
199        import bastd.ui.settings.advanced as _unused5
200
201    def _do_back(self) -> None:
202        # pylint: disable=cyclic-import
203        from bastd.ui.mainmenu import MainMenuWindow
204        self._save_state()
205        ba.containerwidget(edit=self._root_widget,
206                           transition=self._transition_out)
207        ba.app.ui.set_main_menu_window(
208            MainMenuWindow(transition='in_left').get_root_widget())
209
210    def _do_controllers(self) -> None:
211        # pylint: disable=cyclic-import
212        from bastd.ui.settings.controls import ControlsSettingsWindow
213        self._save_state()
214        ba.containerwidget(edit=self._root_widget, transition='out_left')
215        ba.app.ui.set_main_menu_window(
216            ControlsSettingsWindow(
217                origin_widget=self._controllers_button).get_root_widget())
218
219    def _do_graphics(self) -> None:
220        # pylint: disable=cyclic-import
221        from bastd.ui.settings.graphics import GraphicsSettingsWindow
222        self._save_state()
223        ba.containerwidget(edit=self._root_widget, transition='out_left')
224        ba.app.ui.set_main_menu_window(
225            GraphicsSettingsWindow(
226                origin_widget=self._graphics_button).get_root_widget())
227
228    def _do_audio(self) -> None:
229        # pylint: disable=cyclic-import
230        from bastd.ui.settings.audio import AudioSettingsWindow
231        self._save_state()
232        ba.containerwidget(edit=self._root_widget, transition='out_left')
233        ba.app.ui.set_main_menu_window(
234            AudioSettingsWindow(
235                origin_widget=self._audio_button).get_root_widget())
236
237    def _do_advanced(self) -> None:
238        # pylint: disable=cyclic-import
239        from bastd.ui.settings.advanced import AdvancedSettingsWindow
240        self._save_state()
241        ba.containerwidget(edit=self._root_widget, transition='out_left')
242        ba.app.ui.set_main_menu_window(
243            AdvancedSettingsWindow(
244                origin_widget=self._advanced_button).get_root_widget())
245
246    def _save_state(self) -> None:
247        try:
248            sel = self._root_widget.get_selected_child()
249            if sel == self._controllers_button:
250                sel_name = 'Controllers'
251            elif sel == self._graphics_button:
252                sel_name = 'Graphics'
253            elif sel == self._audio_button:
254                sel_name = 'Audio'
255            elif sel == self._advanced_button:
256                sel_name = 'Advanced'
257            elif sel == self._back_button:
258                sel_name = 'Back'
259            else:
260                raise ValueError(f'unrecognized selection \'{sel}\'')
261            ba.app.ui.window_states[type(self)] = {'sel_name': sel_name}
262        except Exception:
263            ba.print_exception(f'Error saving state for {self}.')
264
265    def _restore_state(self) -> None:
266        try:
267            sel_name = ba.app.ui.window_states.get(type(self),
268                                                   {}).get('sel_name')
269            sel: ba.Widget | None
270            if sel_name == 'Controllers':
271                sel = self._controllers_button
272            elif sel_name == 'Graphics':
273                sel = self._graphics_button
274            elif sel_name == 'Audio':
275                sel = self._audio_button
276            elif sel_name == 'Advanced':
277                sel = self._advanced_button
278            elif sel_name == 'Back':
279                sel = self._back_button
280            else:
281                sel = self._controllers_button
282            if sel is not None:
283                ba.containerwidget(edit=self._root_widget, selected_child=sel)
284        except Exception:
285            ba.print_exception(f'Error restoring state for {self}.')

Window for selecting a settings category.

AllSettingsWindow( transition: str = 'in_right', origin_widget: _ba.Widget | None = None)
 20    def __init__(self,
 21                 transition: str = 'in_right',
 22                 origin_widget: ba.Widget | None = None):
 23        # pylint: disable=too-many-statements
 24        # pylint: disable=too-many-locals
 25        import threading
 26
 27        # Preload some modules we use in a background thread so we won't
 28        # have a visual hitch when the user taps them.
 29        threading.Thread(target=self._preload_modules).start()
 30
 31        ba.set_analytics_screen('Settings Window')
 32        scale_origin: tuple[float, float] | None
 33        if origin_widget is not None:
 34            self._transition_out = 'out_scale'
 35            scale_origin = origin_widget.get_screen_space_center()
 36            transition = 'in_scale'
 37        else:
 38            self._transition_out = 'out_right'
 39            scale_origin = None
 40        uiscale = ba.app.ui.uiscale
 41        width = 900 if uiscale is ba.UIScale.SMALL else 580
 42        x_inset = 75 if uiscale is ba.UIScale.SMALL else 0
 43        height = 435
 44        self._r = 'settingsWindow'
 45        top_extra = 20 if uiscale is ba.UIScale.SMALL else 0
 46
 47        uiscale = ba.app.ui.uiscale
 48        super().__init__(root_widget=ba.containerwidget(
 49            size=(width, height + top_extra),
 50            transition=transition,
 51            toolbar_visibility='menu_minimal',
 52            scale_origin_stack_offset=scale_origin,
 53            scale=(1.75 if uiscale is ba.UIScale.SMALL else
 54                   1.35 if uiscale is ba.UIScale.MEDIUM else 1.0),
 55            stack_offset=(0, -8) if uiscale is ba.UIScale.SMALL else (0, 0)))
 56
 57        if ba.app.ui.use_toolbars and uiscale is ba.UIScale.SMALL:
 58            self._back_button = None
 59            ba.containerwidget(edit=self._root_widget,
 60                               on_cancel_call=self._do_back)
 61        else:
 62            self._back_button = btn = ba.buttonwidget(
 63                parent=self._root_widget,
 64                autoselect=True,
 65                position=(40 + x_inset, height - 55),
 66                size=(130, 60),
 67                scale=0.8,
 68                text_scale=1.2,
 69                label=ba.Lstr(resource='backText'),
 70                button_type='back',
 71                on_activate_call=self._do_back)
 72            ba.containerwidget(edit=self._root_widget, cancel_button=btn)
 73
 74        ba.textwidget(parent=self._root_widget,
 75                      position=(0, height - 44),
 76                      size=(width, 25),
 77                      text=ba.Lstr(resource=self._r + '.titleText'),
 78                      color=ba.app.ui.title_color,
 79                      h_align='center',
 80                      v_align='center',
 81                      maxwidth=130)
 82
 83        if self._back_button is not None:
 84            ba.buttonwidget(edit=self._back_button,
 85                            button_type='backSmall',
 86                            size=(60, 60),
 87                            label=ba.charstr(ba.SpecialChar.BACK))
 88
 89        v = height - 80
 90        v -= 145
 91
 92        basew = 280 if uiscale is ba.UIScale.SMALL else 230
 93        baseh = 170
 94        x_offs = x_inset + (105 if uiscale is ba.UIScale.SMALL else
 95                            72) - basew  # now unused
 96        x_offs2 = x_offs + basew - 7
 97        x_offs3 = x_offs + 2 * (basew - 7)
 98        x_offs4 = x_offs2
 99        x_offs5 = x_offs3
100
101        def _b_title(x: float, y: float, button: ba.Widget,
102                     text: str | ba.Lstr) -> None:
103            ba.textwidget(parent=self._root_widget,
104                          text=text,
105                          position=(x + basew * 0.47, y + baseh * 0.22),
106                          maxwidth=basew * 0.7,
107                          size=(0, 0),
108                          h_align='center',
109                          v_align='center',
110                          draw_controller=button,
111                          color=(0.7, 0.9, 0.7, 1.0))
112
113        ctb = self._controllers_button = ba.buttonwidget(
114            parent=self._root_widget,
115            autoselect=True,
116            position=(x_offs2, v),
117            size=(basew, baseh),
118            button_type='square',
119            label='',
120            on_activate_call=self._do_controllers)
121        if ba.app.ui.use_toolbars and self._back_button is None:
122            bbtn = _ba.get_special_widget('back_button')
123            ba.widget(edit=ctb, left_widget=bbtn)
124        _b_title(x_offs2, v, ctb,
125                 ba.Lstr(resource=self._r + '.controllersText'))
126        imgw = imgh = 130
127        ba.imagewidget(parent=self._root_widget,
128                       position=(x_offs2 + basew * 0.49 - imgw * 0.5, v + 35),
129                       size=(imgw, imgh),
130                       texture=ba.gettexture('controllerIcon'),
131                       draw_controller=ctb)
132
133        gfxb = self._graphics_button = ba.buttonwidget(
134            parent=self._root_widget,
135            autoselect=True,
136            position=(x_offs3, v),
137            size=(basew, baseh),
138            button_type='square',
139            label='',
140            on_activate_call=self._do_graphics)
141        if ba.app.ui.use_toolbars:
142            pbtn = _ba.get_special_widget('party_button')
143            ba.widget(edit=gfxb, up_widget=pbtn, right_widget=pbtn)
144        _b_title(x_offs3, v, gfxb, ba.Lstr(resource=self._r + '.graphicsText'))
145        imgw = imgh = 110
146        ba.imagewidget(parent=self._root_widget,
147                       position=(x_offs3 + basew * 0.49 - imgw * 0.5, v + 42),
148                       size=(imgw, imgh),
149                       texture=ba.gettexture('graphicsIcon'),
150                       draw_controller=gfxb)
151
152        v -= (baseh - 5)
153
154        abtn = self._audio_button = ba.buttonwidget(
155            parent=self._root_widget,
156            autoselect=True,
157            position=(x_offs4, v),
158            size=(basew, baseh),
159            button_type='square',
160            label='',
161            on_activate_call=self._do_audio)
162        _b_title(x_offs4, v, abtn, ba.Lstr(resource=self._r + '.audioText'))
163        imgw = imgh = 120
164        ba.imagewidget(parent=self._root_widget,
165                       position=(x_offs4 + basew * 0.49 - imgw * 0.5 + 5,
166                                 v + 35),
167                       size=(imgw, imgh),
168                       color=(1, 1, 0),
169                       texture=ba.gettexture('audioIcon'),
170                       draw_controller=abtn)
171
172        avb = self._advanced_button = ba.buttonwidget(
173            parent=self._root_widget,
174            autoselect=True,
175            position=(x_offs5, v),
176            size=(basew, baseh),
177            button_type='square',
178            label='',
179            on_activate_call=self._do_advanced)
180        _b_title(x_offs5, v, avb, ba.Lstr(resource=self._r + '.advancedText'))
181        imgw = imgh = 120
182        ba.imagewidget(parent=self._root_widget,
183                       position=(x_offs5 + basew * 0.49 - imgw * 0.5 + 5,
184                                 v + 35),
185                       size=(imgw, imgh),
186                       color=(0.8, 0.95, 1),
187                       texture=ba.gettexture('advancedIcon'),
188                       draw_controller=avb)
189        self._restore_state()
Inherited Members
ba.ui.Window
get_root_widget