Skip to content

Commit d382512

Browse files
authored
Merge pull request #51 from SilverEzredes/master
Home Page Tips + fixes
2 parents 3376783 + 0d5ec4e commit d382512

File tree

7 files changed

+433
-327
lines changed

7 files changed

+433
-327
lines changed

ContentEditor.App/Configuration/AppConfig.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public static class Keys
5353
public const string WindowRect = "window_rect";
5454
public const string PauseAnimPlayerOnSeek = "pause_anim_player_on_seek";
5555
public const string UseFullscreenAnimPlayback = "use_fullscreen_anim_playback";
56+
public const string DateFormat = "date_format";
57+
public const string ClockFormat = "clock_format";
5658

5759
public const string RenderAxis = "render_axis";
5860
public const string RenderMeshes = "render_meshes";
@@ -191,6 +193,8 @@ public void Set(T? value) => SetAndSave(value, (v) => {
191193
public readonly SettingWrapper<DateTime> LastUpdateCheck = new SettingWrapper<DateTime>(Keys.LastUpdateCheck, _lock, DateTime.MinValue);
192194
public readonly SettingWrapper<bool> PauseAnimPlayerOnSeek = new SettingWrapper<bool>(Keys.PauseAnimPlayerOnSeek, _lock, true);
193195
public readonly SettingWrapper<bool> UseFullscreenAnimPlayback = new SettingWrapper<bool>(Keys.UseFullscreenAnimPlayback, _lock, false);
196+
public readonly SettingWrapper<int> DateFormat = new SettingWrapper<int>(Keys.DateFormat, _lock, 0);
197+
public readonly SettingWrapper<bool> ClockFormat = new SettingWrapper<bool>(Keys.ClockFormat, _lock, false);
194198

195199
public readonly SettingWrapper<int> PakDisplayModeValue = new SettingWrapper<int>(Keys.LogToFile, _lock, (int)FileDisplayMode.List);
196200
public FileDisplayMode PakDisplayMode { get => (FileDisplayMode)PakDisplayModeValue.Get(); set => PakDisplayModeValue.Set((int)value); }
@@ -339,6 +343,8 @@ public static void SaveConfigToIni()
339343
(Keys.QuaternionsAsEuler, instance.ShowQuaternionsAsEuler.value.ToString(), null),
340344
(Keys.PauseAnimPlayerOnSeek, instance.PauseAnimPlayerOnSeek.value.ToString(), null),
341345
(Keys.UseFullscreenAnimPlayback, instance.UseFullscreenAnimPlayback.value.ToString(), null),
346+
(Keys.DateFormat, instance.DateFormat.value.ToString(), null),
347+
(Keys.ClockFormat, instance.ClockFormat.value.ToString(), null),
342348

343349
(Keys.RenderAxis, instance.RenderAxis.value.ToString(), null),
344350
(Keys.RenderMeshes, instance.RenderMeshes.value.ToString(), null),
@@ -452,10 +458,13 @@ private void LoadConfigs(IEnumerable<(string key, string value, string? group)>
452458
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsed)) UnpackMaxThreads.value = Math.Clamp(parsed, 1, 64);
453459
break;
454460
case Keys.BackgroundColor:
455-
if (ReeLib.via.Color.TryParse(value, out var _col)) BackgroundColor.value = _col;
461+
if (ReeLib.via.Color.TryParse(value, out var _col)) BackgroundColor.value = _col;
456462
break;
457463
case Keys.LogLevel:
458-
if (int.TryParse(value, out var _intvalue)) LogLevel.value = _intvalue;
464+
if (int.TryParse(value, out var _intvalue)) LogLevel.value = _intvalue;
465+
break;
466+
case Keys.DateFormat:
467+
if (int.TryParse(value, out _intvalue)) DateFormat.value = _intvalue;
459468
break;
460469
case Keys.MaxUndoSteps:
461470
if (int.TryParse(value, out _intvalue)) MaxUndoSteps.value = Math.Max(_intvalue, 0);
@@ -478,6 +487,9 @@ private void LoadConfigs(IEnumerable<(string key, string value, string? group)>
478487
case Keys.UseFullscreenAnimPlayback:
479488
UseFullscreenAnimPlayback.value = ReadBool(value);
480489
break;
490+
case Keys.ClockFormat:
491+
ClockFormat.value = ReadBool(value);
492+
break;
481493
case Keys.RecentFiles:
482494
JsonSettings.RecentFiles.AddRange(value.Split('|', StringSplitOptions.RemoveEmptyEntries));
483495
break;

ContentEditor.App/Core/Time.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ public class Time
1616

1717
internal Time() { mainThread = Thread.CurrentThread; }
1818

19+
private static readonly string[] DateFormats =
20+
[
21+
"dd/MM/yyyy",
22+
"MM/dd/yyyy",
23+
"yyyy/MM/dd"
24+
];
25+
public static string dateFormat => DateFormats[Math.Clamp(AppConfig.Instance.DateFormat.Get(), 0, DateFormats.Length - 1)];
1926
internal void Init()
2027
{
2128

@@ -31,4 +38,4 @@ internal void Update(float deltaTime, bool isMainThread)
3138
_totalTime += deltaTime;
3239
}
3340
}
34-
}
41+
}

ContentEditor.App/Imgui/App/BundleManagementUI.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using ReeLib;
77
using ReeLib.Aimp;
88
using System;
9+
using System.Globalization;
910
using System.Numerics;
1011
using System.Runtime.InteropServices;
1112
using System.Text.Json.Nodes;
@@ -49,6 +50,7 @@ public BundleManagementUI(BundleManager workspace, string? preselectBundle, Acti
4950
protected UIContext context = null!;
5051
private readonly CreateBundleFromLooseFileFolderDelegate? createFromLooseFileFolder;
5152
private readonly CreateBundleFromPakDelegate? createFromPak;
53+
private static string timeFormat => AppConfig.Instance.ClockFormat.Get() ? " hh:mm:ss tt" : " HH:mm:ss";
5254

5355
public void Init(UIContext context)
5456
{
@@ -283,8 +285,8 @@ private void ShowBundlesMenu()
283285
}
284286

285287
ImGui.BeginDisabled();
286-
string createDate = $"Created at: {bundle.CreatedAt}";
287-
string updateDate = $"Updated at: {bundle.UpdatedAt}";
288+
string createDate = "Created at: " + FormatUTCString(bundle.CreatedAt);
289+
string updateDate = "Updated at: " + FormatUTCString(bundle.UpdatedAt);
288290
ImGui.InputText("##CreationDate", ref createDate, 100);
289291
ImGui.InputText("##UpdateDate", ref updateDate, 100);
290292
ImGui.EndDisabled();
@@ -491,7 +493,14 @@ private void OpenFileFromNode(HierarchyTreeWidget node, Bundle bundle)
491493
openFileCallback!(path);
492494
}
493495
}
494-
496+
private string FormatUTCString(string utcString)
497+
{
498+
utcString = utcString.Replace("UTC", "").Trim();
499+
if (DateTime.TryParseExact(utcString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out var utc)) {
500+
return utc.ToLocalTime().ToString(Time.dateFormat + timeFormat, CultureInfo.InvariantCulture);
501+
}
502+
return utcString;
503+
}
495504
public bool RequestClose()
496505
{
497506
return false;

0 commit comments

Comments
 (0)