Add localization support and refactor menus
- 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.
This commit is contained in:
55
scripts/GameSeed.cs
Normal file
55
scripts/GameSeed.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
|
||||
namespace TheGame
|
||||
{
|
||||
public class GameSeed
|
||||
{
|
||||
public string SeedValue { get; set; }
|
||||
public DateTime CreatedDate { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public GameSeed()
|
||||
{
|
||||
SeedValue = GenerateNewSeed();
|
||||
CreatedDate = DateTime.Now;
|
||||
DisplayName = $"Game {CreatedDate:yyyy-MM-dd HH:mm}";
|
||||
}
|
||||
|
||||
public GameSeed(string customSeed, string displayName = "")
|
||||
{
|
||||
SeedValue = customSeed;
|
||||
CreatedDate = DateTime.Now;
|
||||
DisplayName = string.IsNullOrEmpty(displayName) ? $"Game {CreatedDate:yyyy-MM-dd HH:mm}" : displayName;
|
||||
}
|
||||
|
||||
private static string GenerateNewSeed()
|
||||
{
|
||||
// Generera en 8-tecken seed baserad på timestamp och random
|
||||
var random = new Random();
|
||||
var timestamp = DateTime.Now.Ticks;
|
||||
var combined = timestamp + random.Next(1000, 9999);
|
||||
|
||||
// Konvertera till hexadecimal och ta första 8 tecknen
|
||||
return Math.Abs(combined).ToString("X")[..8];
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{DisplayName} (Seed: {SeedValue})";
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is GameSeed other)
|
||||
{
|
||||
return SeedValue.Equals(other.SeedValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return SeedValue.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user