Skip to content

Commit 020a887

Browse files
committed
rename TimeBase -> DaylightCycleDescriptor
1 parent 64255f8 commit 020a887

File tree

15 files changed

+40
-50
lines changed

15 files changed

+40
-50
lines changed

Framework/Intersect.Framework.Core/Descriptors/GameObjectType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public enum GameObjectType
6161
[GameObjectInfo(typeof(TilesetDescriptor), "tilesets")]
6262
Tileset,
6363

64-
[GameObjectInfo(typeof(TimeBase), "")]
64+
[GameObjectInfo(typeof(DaylightCycleDescriptor), "")]
6565
Time,
6666

6767
[GameObjectInfo(typeof(GuildVariableDescriptor), "guild_variables")]

Framework/Intersect.Framework.Core/GameObjects/TimeBase.cs renamed to Framework/Intersect.Framework.Core/GameObjects/DaylightCycle/DaylightCycleDescriptor.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
namespace Intersect.GameObjects;
55

6-
public partial class TimeBase
6+
public partial class DaylightCycleDescriptor
77
{
8-
private static TimeBase sTimeBase = new();
9-
8+
public static DaylightCycleDescriptor Instance { get; set; } = new();
9+
1010
[NotMapped]
1111
public Color[]? DaylightHues { get; set; }
1212

13-
public TimeBase()
13+
public DaylightCycleDescriptor()
1414
{
1515
ResetColors();
1616
}
@@ -44,7 +44,7 @@ public string GetInstanceJson()
4444

4545
public static string GetTimeJson()
4646
{
47-
return JsonConvert.SerializeObject(sTimeBase);
47+
return JsonConvert.SerializeObject(Instance);
4848
}
4949

5050
public void ResetColors()
@@ -121,14 +121,4 @@ public static int GetTimeInterval(int index)
121121

122122
return 5;
123123
}
124-
125-
public static void SetStaticTime(TimeBase time)
126-
{
127-
sTimeBase = time;
128-
}
129-
130-
public static TimeBase GetTimeBase()
131-
{
132-
return sTimeBase;
133-
}
134124
}

Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_ConditionalBranch.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,10 @@ private void UpdateFormElements(ConditionType type)
499499
cmbTime1.Items.Clear();
500500
cmbTime2.Items.Clear();
501501
var time = new DateTime(2000, 1, 1, 0, 0, 0);
502-
for (var i = 0; i < 1440; i += TimeBase.GetTimeBase().RangeInterval)
502+
for (var i = 0; i < 1440; i += DaylightCycleDescriptor.Instance.RangeInterval)
503503
{
504504
var addRange = time.ToString("h:mm:ss tt") + " " + Strings.EventConditional.to + " ";
505-
time = time.AddMinutes(TimeBase.GetTimeBase().RangeInterval);
505+
time = time.AddMinutes(DaylightCycleDescriptor.Instance.RangeInterval);
506506
addRange += time.ToString("h:mm:ss tt");
507507
cmbTime1.Items.Add(addRange);
508508
cmbTime2.Items.Add(addRange);

Intersect.Editor/Forms/Editors/frmTime.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ namespace Intersect.Editor.Forms.Editors;
1111
public partial class FrmTime : Form
1212
{
1313

14-
private TimeBase mBackupTime;
14+
private DaylightCycleDescriptor mBackupTime;
1515

1616
private Bitmap mTileBackbuffer;
1717

18-
private TimeBase mYTime;
18+
private DaylightCycleDescriptor mYTime;
1919

2020
public FrmTime()
2121
{
@@ -45,32 +45,32 @@ private void InitLocalization()
4545
btnCancel.Text = Strings.TimeEditor.cancel;
4646
}
4747

48-
public void InitEditor(TimeBase time)
48+
public void InitEditor(DaylightCycleDescriptor time)
4949
{
5050
//Create a backup in case we want to revert
5151
mYTime = time;
52-
mBackupTime = new TimeBase();
52+
mBackupTime = new DaylightCycleDescriptor();
5353
mBackupTime.LoadFromJson(time.GetInstanceJson());
5454

5555
mTileBackbuffer = new Bitmap(pnlColor.Width, pnlColor.Height);
56-
UpdateList(TimeBase.GetTimeInterval(cmbIntervals.SelectedIndex));
56+
UpdateList(DaylightCycleDescriptor.GetTimeInterval(cmbIntervals.SelectedIndex));
5757
typeof(Panel).InvokeMember(
5858
"DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null,
5959
pnlColor, new object[] {true}
6060
);
6161

6262
chkSync.Checked = mYTime.SyncTime;
6363
txtTimeRate.Text = mYTime.Rate.ToString();
64-
cmbIntervals.SelectedIndex = TimeBase.GetIntervalIndex(mYTime.RangeInterval);
64+
cmbIntervals.SelectedIndex = DaylightCycleDescriptor.GetIntervalIndex(mYTime.RangeInterval);
6565
UpdateList(mYTime.RangeInterval);
6666
txtTimeRate.Enabled = !mYTime.SyncTime;
6767
}
6868

6969
private void cmbIntervals_SelectedIndexChanged(object sender, EventArgs e)
7070
{
71-
if (mYTime.RangeInterval != TimeBase.GetTimeInterval(cmbIntervals.SelectedIndex))
71+
if (mYTime.RangeInterval != DaylightCycleDescriptor.GetTimeInterval(cmbIntervals.SelectedIndex))
7272
{
73-
mYTime.RangeInterval = TimeBase.GetTimeInterval(cmbIntervals.SelectedIndex);
73+
mYTime.RangeInterval = DaylightCycleDescriptor.GetTimeInterval(cmbIntervals.SelectedIndex);
7474
UpdateList(mYTime.RangeInterval);
7575
mYTime.ResetColors();
7676
grpRangeOptions.Hide();

Intersect.Editor/Forms/frmMain.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,10 +1522,10 @@ private void UpdateTimeSimulationList()
15221522

15231523
btn.Click += TimeDropdownButton_Click;
15241524
toolStripTimeButton.DropDownItems.Add(btn);
1525-
for (var i = 0; i < 1440; i += TimeBase.GetTimeBase().RangeInterval)
1525+
for (var i = 0; i < 1440; i += DaylightCycleDescriptor.Instance.RangeInterval)
15261526
{
15271527
var addRange = time.ToString("h:mm:ss tt") + " to ";
1528-
time = time.AddMinutes(TimeBase.GetTimeBase().RangeInterval);
1528+
time = time.AddMinutes(DaylightCycleDescriptor.Instance.RangeInterval);
15291529
addRange += time.ToString("h:mm:ss tt");
15301530

15311531
//Create image of overlay color
@@ -1539,7 +1539,7 @@ private void UpdateTimeSimulationList()
15391539
g.DrawImage(transtile, new System.Drawing.Point(0, 0));
15401540
}
15411541

1542-
var clr = TimeBase.GetTimeBase().DaylightHues[x];
1542+
var clr = DaylightCycleDescriptor.Instance.DaylightHues[x];
15431543
Brush brush = new SolidBrush(System.Drawing.Color.FromArgb(clr.A, clr.R, clr.G, clr.B));
15441544
g.FillRectangle(brush, new System.Drawing.Rectangle(0, 0, 32, 32));
15451545

@@ -1711,7 +1711,7 @@ private void TryOpenEditorMethod(GameObjectType type)
17111711
if (mTimeEditor == null || mTimeEditor.Visible == false)
17121712
{
17131713
mTimeEditor = new FrmTime();
1714-
mTimeEditor.InitEditor(TimeBase.GetTimeBase());
1714+
mTimeEditor.InitEditor(DaylightCycleDescriptor.Instance);
17151715
mTimeEditor.Show();
17161716
}
17171717

Intersect.Editor/Localization/Strings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ public static string GetEventConditionalDesc(TimeBetweenCondition condition)
212212
{
213213
var timeRanges = new List<string>();
214214
var time = new DateTime(2000, 1, 1, 0, 0, 0);
215-
for (var i = 0; i < 1440; i += TimeBase.GetTimeBase().RangeInterval)
215+
for (var i = 0; i < 1440; i += DaylightCycleDescriptor.Instance.RangeInterval)
216216
{
217217
var addRange = time.ToString("h:mm:ss tt") + " to ";
218-
time = time.AddMinutes(TimeBase.GetTimeBase().RangeInterval);
218+
time = time.AddMinutes(DaylightCycleDescriptor.Instance.RangeInterval);
219219
addRange += time.ToString("h:mm:ss tt");
220220
timeRanges.Add(addRange);
221221
}

Intersect.Editor/Networking/PacketHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,6 @@ public void HandlePacket(IPacketSender packetSender, OpenEditorPacket packet)
750750
//TimeDataPacket
751751
public void HandlePacket(IPacketSender packetSender, TimeDataPacket packet)
752752
{
753-
TimeBase.GetTimeBase().LoadFromJson(packet.TimeJson);
753+
DaylightCycleDescriptor.Instance.LoadFromJson(packet.TimeJson);
754754
}
755755
}

Intersect.Server.Core/Database/DbInterface.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,13 +1837,13 @@ private static void LoadTime()
18371837
var time = context.Time.OrderBy(t => t.Id).FirstOrDefault();
18381838
if (time == null)
18391839
{
1840-
context.Time.Add(TimeBase.GetTimeBase());
1840+
context.Time.Add(DaylightCycleDescriptor.Instance);
18411841
context.ChangeTracker.DetectChanges();
18421842
context.SaveChanges();
18431843
}
18441844
else
18451845
{
1846-
TimeBase.SetStaticTime(time);
1846+
DaylightCycleDescriptor.Instance = time;
18471847
}
18481848
}
18491849
Time.Init();
@@ -1861,7 +1861,7 @@ public static void SaveTime()
18611861
{
18621862
using (var context = CreateGameContext(readOnly: false))
18631863
{
1864-
context.Time.Update(TimeBase.GetTimeBase());
1864+
context.Time.Update(DaylightCycleDescriptor.Instance);
18651865
context.ChangeTracker.DetectChanges();
18661866
context.SaveChanges();
18671867
}

Intersect.Server.Core/Database/GameData/GameContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected GameContext(DatabaseContextOptions databaseContextOptions) : base(data
7878
public DbSet<TilesetDescriptor> Tilesets { get; set; }
7979

8080
//Time
81-
public DbSet<TimeBase> Time { get; set; }
81+
public DbSet<DaylightCycleDescriptor> Time { get; set; }
8282

8383
protected override void OnModelCreating(ModelBuilder modelBuilder)
8484
{

Intersect.Server.Core/Database/GameData/IGameContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ public interface IGameContext : IDbContext
4848

4949
DbSet<TilesetDescriptor> Tilesets { get; set; }
5050

51-
DbSet<TimeBase> Time { get; set; }
51+
DbSet<DaylightCycleDescriptor> Time { get; set; }
5252
}

0 commit comments

Comments
 (0)