mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add config in settings for forcing 24H time, determines default off CurrentCulture
This commit is contained in:
@ -102,6 +102,8 @@ namespace osu.Game.Configuration
|
||||
|
||||
SetDefault(OsuSetting.MenuParallax, true);
|
||||
|
||||
SetDefault(OsuSetting.Prefer24HourTime, false);
|
||||
|
||||
// Gameplay
|
||||
SetDefault(OsuSetting.PositionalHitsounds, true); // replaced by level setting below, can be removed 20220703.
|
||||
SetDefault(OsuSetting.PositionalHitsoundsLevel, 0.2f, 0, 1);
|
||||
@ -287,6 +289,7 @@ namespace osu.Game.Configuration
|
||||
MenuVoice,
|
||||
CursorRotation,
|
||||
MenuParallax,
|
||||
Prefer24HourTime,
|
||||
BeatmapDetailTab,
|
||||
BeatmapDetailModsFilter,
|
||||
Username,
|
||||
|
@ -24,6 +24,11 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString CursorRotation => new TranslatableString(getKey(@"cursor_rotation"), @"Rotate cursor when dragging");
|
||||
|
||||
/// <summary>
|
||||
/// "Prefer 24-hour time"
|
||||
/// </summary>
|
||||
public static LocalisableString Prefer24HourTime => new TranslatableString(getKey(@"prefer_24_hour_time"), @"Prefer 24-hour time");
|
||||
|
||||
/// <summary>
|
||||
/// "Menu cursor size"
|
||||
/// </summary>
|
||||
|
@ -41,6 +41,11 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
|
||||
Current = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay),
|
||||
KeyboardStep = 50
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = UserInterfaceStrings.Prefer24HourTime,
|
||||
Current = config.GetBindable<bool>(OsuSetting.Prefer24HourTime)
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,21 @@ namespace osu.Game.Overlays.Toolbar
|
||||
}
|
||||
}
|
||||
|
||||
private bool format12H = true;
|
||||
private bool format12H = false;
|
||||
|
||||
public bool Format12H
|
||||
{
|
||||
get => format12H;
|
||||
set
|
||||
{
|
||||
if (format12H == value)
|
||||
return;
|
||||
|
||||
format12H = value;
|
||||
updateMetrics();
|
||||
UpdateDisplay(DateTimeOffset.Now); //Update realTime.Text immediately instead of waiting until next second
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
@ -52,14 +66,14 @@ namespace osu.Game.Overlays.Toolbar
|
||||
|
||||
protected override void UpdateDisplay(DateTimeOffset now)
|
||||
{
|
||||
realTime.Text = format12H ? $"{now:hh:mm:ss tt}" : $"{now:HH:mm:ss}";
|
||||
realTime.Text = format12H ? $"{now:h:mm:ss tt}" : $"{now:HH:mm:ss}";
|
||||
gameTime.Text = $"running {new TimeSpan(TimeSpan.TicksPerSecond * (int)(Clock.CurrentTime / 1000)):c}";
|
||||
}
|
||||
|
||||
private void updateMetrics()
|
||||
{
|
||||
if (format12H)
|
||||
Width = 74;
|
||||
Width = 70;
|
||||
else
|
||||
Width = showRuntime ? 66 : 45; // Allows for space for game time up to 99 days (in the padding area since this is quite rare).
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Globalization;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
@ -20,6 +21,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
public class ToolbarClock : OsuClickableContainer
|
||||
{
|
||||
private Bindable<ToolbarClockDisplayMode> clockDisplayMode;
|
||||
private Bindable<bool> digitalPrefer24Hour;
|
||||
|
||||
private Box hoverBackground;
|
||||
private Box flashBackground;
|
||||
@ -38,6 +40,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
clockDisplayMode = config.GetBindable<ToolbarClockDisplayMode>(OsuSetting.ToolbarClockDisplayMode);
|
||||
digitalPrefer24Hour = config.GetBindable<bool>(OsuSetting.Prefer24HourTime);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -94,6 +97,9 @@ namespace osu.Game.Overlays.Toolbar
|
||||
|
||||
analog.FadeTo(showAnalog ? 1 : 0);
|
||||
}, true);
|
||||
|
||||
digitalPrefer24Hour.BindValueChanged(prefer24H =>
|
||||
digital.Format12H = prefer24H.NewValue ? false : CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains("tt"), true);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
|
Reference in New Issue
Block a user