using System;
using System.IO;
using System.Text;
using ColdMint.scripts.camp;
using ColdMint.scripts.debug;
using Godot;
namespace ColdMint.scripts.loader.uiLoader;
///
/// UI loader for the main menu
/// 主菜单的UI加载器
///
public partial class MainMenuLoader : UiLoaderTemplate
{
private Button? _startGameButton;
private Label? _copyrightLabel;
private StringBuilder? _copyrightBuilder;
private PackedScene? _gameScene;
private Label? _sloganLabel;
private Label? _versionLabel;
private Button? _levelGraphEditorButton;
public override void InitializeData()
{
if (Config.IsDebug())
{
//Set the minimum log level to Info in debug mode.(Print all logs)
//在调试模式下将最小日志等级设置为Info。(打印全部日志)
LogCat.MinLogLevel = LogCat.InfoLogLevel;
}
else
{
//Disable all logs in the release version.
//在发行版禁用所有日志。
LogCat.MinLogLevel = LogCat.DisableAllLogLevel;
}
//Load the slogan
//加载标语
SloganProvider.LoadSloganCsv();
//Register the corresponding encoding provider to solve the problem of garbled Chinese path of the compressed package
//注册对应的编码提供程序,解决压缩包中文路径乱码问题
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
//创建游戏数据文件夹
var dataPath = Config.GetGameDataDirectory();
if (!Directory.Exists(dataPath))
{
Directory.CreateDirectory(dataPath);
}
//Registered camp
//注册阵营
var defaultCamp = new Camp(Config.CampId.Default)
{
FriendInjury = true
};
CampManager.SetDefaultCamp(defaultCamp);
var mazoku = new Camp(Config.CampId.Mazoku);
CampManager.AddCamp(mazoku);
var aborigines = new Camp(Config.CampId.Aborigines);
CampManager.AddCamp(aborigines);
_gameScene = (PackedScene)GD.Load("res://scenes/game.tscn");
}
public override void InitializeUi()
{
_startGameButton = GetNode