mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-19 21:37:57 +08:00
UI for series length
This commit is contained in:
parent
2c66a5f245
commit
c2f34bac3a
@ -406,6 +406,10 @@ class ServerController:
|
||||
else:
|
||||
raise RuntimeError(f'Unknown session type {sessiontype}')
|
||||
|
||||
appcfg['Teams Series Length'] = self._config.teams_series_length
|
||||
appcfg['FFA Series Length'] = self._config.ffa_series_length
|
||||
|
||||
# deprecated, left here in order to not break mods
|
||||
classic.teams_series_length = self._config.teams_series_length
|
||||
classic.ffa_series_length = self._config.ffa_series_length
|
||||
|
||||
|
||||
@ -101,8 +101,8 @@ class ClassicSubsystem(babase.AppSubsystem):
|
||||
self.maps: dict[str, type[bascenev1.Map]] = {}
|
||||
|
||||
# Gameplay.
|
||||
self.teams_series_length = 7
|
||||
self.ffa_series_length = 24
|
||||
self.teams_series_length = 7 # deprecated, left for old mods
|
||||
self.ffa_series_length = 24 # deprecated, left for old mods
|
||||
self.coop_session_args: dict = {}
|
||||
|
||||
# UI.
|
||||
|
||||
@ -65,8 +65,8 @@ class MultiTeamSession(Session):
|
||||
max_players=self.get_max_players(),
|
||||
)
|
||||
|
||||
self._series_length: int = classic.teams_series_length
|
||||
self._ffa_series_length: int = classic.ffa_series_length
|
||||
self._series_length: int = int(cfg.get('Teams Series Length', 7))
|
||||
self._ffa_series_length: int = int(cfg.get('FFA Series Length', 24))
|
||||
|
||||
show_tutorial = cfg.get('Show Tutorial', True)
|
||||
|
||||
|
||||
@ -94,6 +94,8 @@ class ConfigNumberEdit:
|
||||
changesound: bool = True,
|
||||
textscale: float = 1.0,
|
||||
as_percent: bool = False,
|
||||
fallback_value: float = 0.0,
|
||||
f: int = 1,
|
||||
):
|
||||
if displayname is None:
|
||||
displayname = configkey
|
||||
@ -103,8 +105,12 @@ class ConfigNumberEdit:
|
||||
self._maxval = maxval
|
||||
self._increment = increment
|
||||
self._callback = callback
|
||||
self._value = bui.app.config.resolve(configkey)
|
||||
try:
|
||||
self._value = bui.app.config.resolve(configkey)
|
||||
except ValueError:
|
||||
self._value = bui.app.config.get(configkey, fallback_value)
|
||||
self._as_percent = as_percent
|
||||
self._f = f
|
||||
|
||||
self.nametext = bui.textwidget(
|
||||
parent=parent,
|
||||
@ -171,5 +177,5 @@ class ConfigNumberEdit:
|
||||
if self._as_percent:
|
||||
val = f'{round(self._value*100.0)}%'
|
||||
else:
|
||||
val = f'{self._value:.1f}'
|
||||
val = f'{self._value:.{self._f}f}'
|
||||
bui.textwidget(edit=self.valuetext, text=val)
|
||||
|
||||
@ -32,6 +32,7 @@ class PlayOptionsWindow(PopupWindow):
|
||||
# pylint: disable=too-many-locals
|
||||
from bascenev1 import filter_playlist, get_map_class
|
||||
from bauiv1lib.playlist import PlaylistTypeVars
|
||||
from bauiv1lib.config import ConfigNumberEdit
|
||||
|
||||
self._r = 'gameListWindow'
|
||||
self._delegate = delegate
|
||||
@ -51,7 +52,7 @@ class PlayOptionsWindow(PopupWindow):
|
||||
self._playlist = playlist
|
||||
|
||||
self._width = 500.0
|
||||
self._height = 330.0 - 50.0
|
||||
self._height = 370.0 - 50.0
|
||||
|
||||
# In teams games, show the custom names/colors button.
|
||||
if self._sessiontype is bs.DualTeamSession:
|
||||
@ -274,13 +275,37 @@ class PlayOptionsWindow(PopupWindow):
|
||||
texture=bui.gettexture('lock'),
|
||||
)
|
||||
|
||||
y_offs = 50 if show_shuffle_check_box else 0
|
||||
|
||||
# Series Length
|
||||
y_offs2 = 40 if self._sessiontype is bs.DualTeamSession else 0
|
||||
self._series_length_numedit = ConfigNumberEdit(
|
||||
parent=self.root_widget,
|
||||
position=(100, 200 + y_offs + y_offs2),
|
||||
configkey=(
|
||||
'FFA' if self._sessiontype is bs.FreeForAllSession else 'Teams'
|
||||
) + ' Series Length',
|
||||
displayname=bui.Lstr(
|
||||
resource=self._r + (
|
||||
'.pointsToWinText'
|
||||
if self._sessiontype is bs.FreeForAllSession
|
||||
else '.seriesLengthText'
|
||||
)
|
||||
),
|
||||
minval=1.0,
|
||||
increment=1.0 if self._sessiontype is bs.FreeForAllSession else 2.0,
|
||||
fallback_value=(
|
||||
24 if self._sessiontype is bs.FreeForAllSession else 7
|
||||
),
|
||||
f=0,
|
||||
)
|
||||
|
||||
# Team names/colors.
|
||||
self._custom_colors_names_button: bui.Widget | None
|
||||
if self._sessiontype is bs.DualTeamSession:
|
||||
y_offs = 50 if show_shuffle_check_box else 0
|
||||
self._custom_colors_names_button = bui.buttonwidget(
|
||||
parent=self.root_widget,
|
||||
position=(100, 200 + y_offs),
|
||||
position=(100, 195 + y_offs),
|
||||
size=(290, 35),
|
||||
on_activate_call=bui.WeakCall(self._custom_colors_names_press),
|
||||
autoselect=True,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user