2024-04-28 13:55:19 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
2024-06-12 19:04:12 +00:00
|
|
|
|
|
2024-04-28 13:55:19 +00:00
|
|
|
|
using ColdMint.scripts.camp;
|
2024-06-14 16:14:17 +00:00
|
|
|
|
using ColdMint.scripts.contribute;
|
2024-06-04 14:23:06 +00:00
|
|
|
|
using ColdMint.scripts.deathInfo;
|
2024-04-28 13:55:19 +00:00
|
|
|
|
using ColdMint.scripts.debug;
|
2024-06-10 13:05:18 +00:00
|
|
|
|
using ColdMint.scripts.inventory;
|
2024-06-12 19:04:12 +00:00
|
|
|
|
using ColdMint.scripts.item;
|
2024-06-16 08:56:45 +00:00
|
|
|
|
using ColdMint.scripts.loot;
|
2024-05-30 14:49:54 +00:00
|
|
|
|
using ColdMint.scripts.map;
|
|
|
|
|
using ColdMint.scripts.map.roomInjectionProcessor;
|
2024-06-14 16:14:17 +00:00
|
|
|
|
using ColdMint.scripts.utils;
|
2024-06-12 19:04:12 +00:00
|
|
|
|
|
2024-04-28 13:55:19 +00:00
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
namespace ColdMint.scripts.loader.uiLoader;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>UI loader for the main menu</para>
|
|
|
|
|
/// <para>主菜单的UI加载器</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class MainMenuLoader : UiLoaderTemplate
|
|
|
|
|
{
|
2024-05-08 10:22:04 +00:00
|
|
|
|
private Button? _startGameButton;
|
|
|
|
|
private Label? _copyrightLabel;
|
|
|
|
|
private StringBuilder? _copyrightBuilder;
|
|
|
|
|
private PackedScene? _gameScene;
|
2024-06-14 16:14:17 +00:00
|
|
|
|
private PackedScene? _contributor;
|
|
|
|
|
private PackedScene? _levelGraphEditor;
|
2024-05-08 10:22:04 +00:00
|
|
|
|
private Label? _sloganLabel;
|
|
|
|
|
private Label? _versionLabel;
|
2024-05-12 10:00:47 +00:00
|
|
|
|
private Button? _levelGraphEditorButton;
|
2024-06-14 16:14:17 +00:00
|
|
|
|
private LinkButton? _contributorButton;
|
2024-04-28 13:55:19 +00:00
|
|
|
|
|
2024-05-08 10:22:04 +00:00
|
|
|
|
public override void InitializeData()
|
|
|
|
|
{
|
2024-05-24 14:58:52 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
2024-05-30 14:49:54 +00:00
|
|
|
|
|
2024-06-12 19:04:12 +00:00
|
|
|
|
|
2024-06-14 16:14:17 +00:00
|
|
|
|
ContributorDataManager.RegisterAllContributorData();
|
2024-06-04 14:23:06 +00:00
|
|
|
|
DeathInfoGenerator.RegisterDeathInfoHandler(new SelfDeathInfoHandler());
|
2024-05-30 14:49:54 +00:00
|
|
|
|
MapGenerator.RegisterRoomInjectionProcessor(new ChanceRoomInjectionProcessor());
|
|
|
|
|
MapGenerator.RegisterRoomInjectionProcessor(new TimeIntervalRoomInjectorProcessor());
|
2024-05-08 10:22:04 +00:00
|
|
|
|
//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);
|
|
|
|
|
}
|
2024-05-24 14:58:52 +00:00
|
|
|
|
|
2024-06-16 08:56:45 +00:00
|
|
|
|
|
2024-05-08 10:22:04 +00:00
|
|
|
|
//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);
|
2024-06-14 16:14:17 +00:00
|
|
|
|
_gameScene = GD.Load<PackedScene>("res://scenes/game.tscn");
|
|
|
|
|
_contributor = GD.Load<PackedScene>("res://scenes/contributor.tscn");
|
|
|
|
|
_levelGraphEditor = GD.Load<PackedScene>("res://scenes/levelGraphEditor.tscn");
|
2024-06-16 08:56:45 +00:00
|
|
|
|
|
2024-06-13 15:49:59 +00:00
|
|
|
|
//Register ItemTypes from file
|
|
|
|
|
//从文件注册物品类型
|
2024-06-14 14:38:29 +00:00
|
|
|
|
ItemTypeRegister.RegisterFromFile();
|
2024-06-13 15:49:59 +00:00
|
|
|
|
//Hardcoded ItemTypes Register
|
|
|
|
|
//硬编码注册物品类型
|
2024-06-16 08:56:45 +00:00
|
|
|
|
ItemTypeRegister.StaticRegister();
|
|
|
|
|
|
|
|
|
|
//静态注册掉落表
|
|
|
|
|
LootRegister.StaticRegister();
|
2024-05-08 10:22:04 +00:00
|
|
|
|
}
|
2024-04-28 13:55:19 +00:00
|
|
|
|
|
2024-05-08 10:22:04 +00:00
|
|
|
|
public override void InitializeUi()
|
|
|
|
|
{
|
2024-06-14 16:14:17 +00:00
|
|
|
|
_contributorButton = GetNode<LinkButton>("VBoxContainer2/ContributorButton");
|
2024-05-08 10:22:04 +00:00
|
|
|
|
_startGameButton = GetNode<Button>("StartGameButton");
|
2024-05-12 10:00:47 +00:00
|
|
|
|
_levelGraphEditorButton = GetNode<Button>("levelGraphEditorButton");
|
|
|
|
|
//The level map editor is only available in debug mode.
|
|
|
|
|
//关卡图编辑器仅在调试模式可用。
|
|
|
|
|
_levelGraphEditorButton.Visible = Config.IsDebug();
|
2024-05-08 10:22:04 +00:00
|
|
|
|
_startGameButton.GrabFocus();
|
|
|
|
|
_versionLabel = GetNode<Label>("VBoxContainer2/VersionLabel");
|
|
|
|
|
//Generative copyright
|
|
|
|
|
//生成版权
|
|
|
|
|
_copyrightLabel = GetNode<Label>("VBoxContainer/CopyrightLabel");
|
|
|
|
|
_sloganLabel = GetNode<Label>("CenterContainer2/SloganLabel");
|
|
|
|
|
_copyrightBuilder = new StringBuilder();
|
|
|
|
|
_copyrightBuilder.Append('\u00a9');
|
|
|
|
|
var currentYear = DateTime.Now.Year;
|
|
|
|
|
_copyrightBuilder.Append(Config.CreationYear);
|
|
|
|
|
if (currentYear != Config.CreationYear)
|
|
|
|
|
{
|
|
|
|
|
_copyrightBuilder.Append('-');
|
|
|
|
|
_copyrightBuilder.Append(currentYear);
|
|
|
|
|
}
|
2024-04-28 13:55:19 +00:00
|
|
|
|
|
2024-05-08 10:22:04 +00:00
|
|
|
|
_copyrightBuilder.Append(' ');
|
|
|
|
|
_copyrightBuilder.Append(Config.CompanyName);
|
|
|
|
|
_copyrightBuilder.Append(" all rights reserved.");
|
|
|
|
|
_copyrightLabel.Text = _copyrightBuilder.ToString();
|
|
|
|
|
_versionLabel.Text = "ver." + Config.GetVersion();
|
|
|
|
|
_sloganLabel.Text = SloganProvider.GetSlogan();
|
2024-06-14 16:14:17 +00:00
|
|
|
|
_contributorButton.Text =
|
|
|
|
|
TranslationServerUtils.TranslateWithFormat("ui_contributor_tips",
|
|
|
|
|
ContributorDataManager.GetContributorTotals());
|
2024-05-08 10:22:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void LoadUiActions()
|
|
|
|
|
{
|
|
|
|
|
if (_startGameButton != null)
|
|
|
|
|
{
|
|
|
|
|
_startGameButton.Pressed += () =>
|
|
|
|
|
{
|
|
|
|
|
LogCat.Log("start_game");
|
2024-06-14 16:14:17 +00:00
|
|
|
|
if (_gameScene == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-05-08 10:22:04 +00:00
|
|
|
|
GetTree().ChangeSceneToPacked(_gameScene);
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-05-12 10:00:47 +00:00
|
|
|
|
|
2024-06-14 16:14:17 +00:00
|
|
|
|
if (_contributorButton!=null)
|
|
|
|
|
{
|
|
|
|
|
_contributorButton.Pressed += () =>
|
|
|
|
|
{
|
|
|
|
|
if (_contributor == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
GetTree().ChangeSceneToPacked(_contributor);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-12 15:06:07 +00:00
|
|
|
|
if (_levelGraphEditorButton != null)
|
2024-05-12 10:00:47 +00:00
|
|
|
|
{
|
|
|
|
|
_levelGraphEditorButton.Pressed += () =>
|
|
|
|
|
{
|
|
|
|
|
LogCat.Log("level_graph_editor");
|
2024-06-14 16:14:17 +00:00
|
|
|
|
if (_levelGraphEditor == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
GetTree().ChangeSceneToPacked(_levelGraphEditor);
|
2024-05-12 10:00:47 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
2024-05-08 10:22:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|