- Implemented LocalizationManager for handling multiple languages. - Updated LoadGameMenu, MainMenu, PauseMenu, and SettingsMenu to support localization. - Added InstanceSelectionMenu for selecting game instances. - Refactored SaveManager to handle new SaveInstance structure. - Created SaveDialog for saving games with user-defined names. - Enhanced SaveData to manage multiple save instances. - Added error handling and logging for save/load operations. - Updated UI elements to reflect localized text.
57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using System;
|
|
|
|
namespace TheGame
|
|
{
|
|
public class SaveInstance
|
|
{
|
|
public string InstanceId { get; set; }
|
|
public float GameTime { get; set; }
|
|
public DateTime SaveDate { get; set; }
|
|
public string DisplayName { get; set; }
|
|
public bool IsAutoSave { get; set; } = false;
|
|
|
|
public SaveInstance()
|
|
{
|
|
InstanceId = Guid.NewGuid().ToString("N")[..8]; // 8-tecken ID
|
|
SaveDate = DateTime.Now;
|
|
DisplayName = $"Save {SaveDate:HH:mm:ss}";
|
|
}
|
|
|
|
public SaveInstance(float gameTime, string displayName = "", bool isAutoSave = false)
|
|
{
|
|
InstanceId = Guid.NewGuid().ToString("N")[..8];
|
|
GameTime = gameTime;
|
|
SaveDate = DateTime.Now;
|
|
IsAutoSave = isAutoSave;
|
|
|
|
if (string.IsNullOrEmpty(displayName))
|
|
{
|
|
if (isAutoSave)
|
|
{
|
|
DisplayName = $"Auto-save {SaveDate:HH:mm:ss}";
|
|
}
|
|
else
|
|
{
|
|
DisplayName = $"Save {SaveDate:HH:mm:ss}";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DisplayName = displayName;
|
|
}
|
|
}
|
|
|
|
public string GetFormattedGameTime()
|
|
{
|
|
int hours = (int)(GameTime / 3600);
|
|
int minutes = (int)((GameTime % 3600) / 60);
|
|
int seconds = (int)(GameTime % 60);
|
|
return $"{hours:D2}:{minutes:D2}:{seconds:D2}";
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{DisplayName} - {GetFormattedGameTime()} ({SaveDate:yyyy-MM-dd HH:mm:ss})";
|
|
}
|
|
}
|
|
} |