Add a contributor page.
添加贡献者页面。
This commit is contained in:
parent
30a0a6539f
commit
4077d77b32
|
@ -26,7 +26,6 @@ log_death_info,生物{0}被{1}击败。,"Creature {0} was defeated by {1}.",生
|
|||
log_loot_list_has_no_entries,ID为{0}的战利品表,没有指定条目。,"Loot list with ID {0}, no entry specified.",ID{0}の戦利品テーブルは、エントリ指定されていません。
|
||||
log_not_within_the_loot_spawn_range,给定的数值{0}没有在战利品{1}的生成范围{2}内。,The given value {0} is not within the spawn range {2} of loot {1}.,与えられた数値{0}は戦利品{1}の生成範囲{2}内にありません。
|
||||
log_loot_data_quantity,有{0}个战利品数据被返回。,{0} loot data was returned.,{0}個の戦利品データが返されます。
|
||||
|
||||
log_start_item_register_from_file,开始从文件注册物品信息,Start registering item information from files,アイテム情報をファイルから登録開始
|
||||
log_item_register_from_file,从文件{0}中注册物品信息,Registering item information from file {0},ファイル{0}からアイテム情報を登録する
|
||||
log_item_register_find_item_in_file,注册发现的物品{0},Register discovered item {0},見つかったアイテム{0}を登録
|
||||
|
|
|
|
@ -25,3 +25,11 @@ ui_room_injection_processor,房间注入处理器,Room injection processor,部
|
|||
ui_game_over_title,游戏结束!,Game Over!,ゲームオーバー!
|
||||
ui_death_info_describe,死因,death,死因
|
||||
ui_restart,重新开始,Restart,ぶり返す
|
||||
ui_contributor_tips,由{0}位贡献者共同打造,Built by {0} contributors,{0}のコントリビューターが共同で作り上げました
|
||||
ui_contributor,贡献者,contributor,貢献者です
|
||||
ui_coder,编程,coder,程序设计
|
||||
ui_artist,美术,artist,びじゅつ
|
||||
ui_musician,音乐,musician,音楽
|
||||
ui_character_voice,角色配音,character_voice,キャラクターボイスです
|
||||
ui_translator,翻译,translator,翻訳
|
||||
ui_unordered_list_tip,排名不分先后,Ranking is not in order,順位は関係ありません
|
||||
|
|
|
|
@ -45,18 +45,42 @@ script = ExtResource("2_6p8mv")
|
|||
|
||||
[node name="StaffOfTheUndead" parent="." instance=ExtResource("3_ud0w8")]
|
||||
position = Vector2(231, 116)
|
||||
_minContactInjury = null
|
||||
_maxContactInjury = null
|
||||
_firingIntervalAsMillisecond = null
|
||||
_recoil = null
|
||||
|
||||
[node name="StaffOfTheUndead2" parent="." instance=ExtResource("3_ud0w8")]
|
||||
position = Vector2(113, 149)
|
||||
_minContactInjury = null
|
||||
_maxContactInjury = null
|
||||
_firingIntervalAsMillisecond = null
|
||||
_recoil = null
|
||||
|
||||
[node name="StaffOfTheUndead5" parent="." instance=ExtResource("3_ud0w8")]
|
||||
position = Vector2(213, 177)
|
||||
_minContactInjury = null
|
||||
_maxContactInjury = null
|
||||
_firingIntervalAsMillisecond = null
|
||||
_recoil = null
|
||||
|
||||
[node name="StaffOfTheUndead6" parent="." instance=ExtResource("3_ud0w8")]
|
||||
position = Vector2(290, 167)
|
||||
_minContactInjury = null
|
||||
_maxContactInjury = null
|
||||
_firingIntervalAsMillisecond = null
|
||||
_recoil = null
|
||||
|
||||
[node name="StaffOfTheUndead3" parent="." instance=ExtResource("3_ud0w8")]
|
||||
position = Vector2(70, 88)
|
||||
_minContactInjury = null
|
||||
_maxContactInjury = null
|
||||
_firingIntervalAsMillisecond = null
|
||||
_recoil = null
|
||||
|
||||
[node name="StaffOfTheUndead4" parent="." instance=ExtResource("3_ud0w8")]
|
||||
position = Vector2(367, 85)
|
||||
_minContactInjury = null
|
||||
_maxContactInjury = null
|
||||
_firingIntervalAsMillisecond = null
|
||||
_recoil = null
|
||||
|
|
32
prefab/ui/contributorGroup.tscn
Normal file
32
prefab/ui/contributorGroup.tscn
Normal file
|
@ -0,0 +1,32 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://6i7rgx3sdu1k"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/loader/uiLoader/ContributorGroupLoader.cs" id="1_xwjh1"]
|
||||
|
||||
[node name="ContributorGroup" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("1_xwjh1")
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 39.0
|
||||
grow_horizontal = 2
|
||||
theme_override_font_sizes/font_size = 25
|
||||
text = "组名"
|
||||
|
||||
[node name="HFlowContainer" type="HFlowContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = 51.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
|
@ -16,6 +16,10 @@ collision_mask = 34
|
|||
script = ExtResource("1_w8hhv")
|
||||
ProjectileScenes = [ExtResource("2_34250")]
|
||||
Id = "staff_of_the_undead"
|
||||
_minContactInjury = null
|
||||
_maxContactInjury = null
|
||||
_firingIntervalAsMillisecond = null
|
||||
_recoil = null
|
||||
metadata/Projectiles = PackedStringArray("res://prefab/projectile/curseOfTheUndead.tscn")
|
||||
|
||||
[node name="DamageArea2D" type="Area2D" parent="."]
|
||||
|
|
68
scenes/contributor.tscn
Normal file
68
scenes/contributor.tscn
Normal file
|
@ -0,0 +1,68 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://ljvmhhrk1d6j"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/loader/uiLoader/ContributorLoader.cs" id="1_ia4x6"]
|
||||
|
||||
[node name="Contributor" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_ia4x6")
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 45.0
|
||||
grow_horizontal = 2
|
||||
|
||||
[node name="Label" type="Label" parent="CenterContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 30
|
||||
text = "ui_contributor"
|
||||
|
||||
[node name="ExitButton" type="Button" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -86.0
|
||||
offset_top = 6.0
|
||||
offset_right = -19.0
|
||||
offset_bottom = 39.0
|
||||
grow_horizontal = 0
|
||||
text = "ui_close"
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 20.0
|
||||
offset_top = 59.0
|
||||
offset_right = -18.0
|
||||
offset_bottom = -20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 16.0
|
||||
offset_top = -36.0
|
||||
offset_right = 168.0
|
||||
offset_bottom = -11.0
|
||||
grow_vertical = 0
|
||||
text = "ui_unordered_list_tip"
|
|
@ -119,6 +119,12 @@ grow_vertical = 0
|
|||
layout_mode = 2
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="ContributorButton" type="LinkButton" parent="VBoxContainer2"]
|
||||
layout_direction = 3
|
||||
layout_mode = 2
|
||||
text = "ui_contributor_tips"
|
||||
underline = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
|
||||
|
|
26
scripts/contribute/ContributorData.cs
Normal file
26
scripts/contribute/ContributorData.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
namespace ColdMint.scripts.contribute;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Contributor information</para>
|
||||
/// <para>贡献者数据</para>
|
||||
/// </summary>
|
||||
public class ContributorData
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Contributor's name</para>
|
||||
/// <para>贡献者的名字</para>
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Links to contributors' home pages</para>
|
||||
/// <para>贡献者的主页链接</para>
|
||||
/// </summary>
|
||||
public string? Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Type of contribution</para>
|
||||
/// <para>贡献的类型</para>
|
||||
/// </summary>
|
||||
public ContributorType[]? ContributorTypes { get; set; }
|
||||
}
|
151
scripts/contribute/ContributorDataManager.cs
Normal file
151
scripts/contribute/ContributorDataManager.cs
Normal file
|
@ -0,0 +1,151 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ColdMint.scripts.utils;
|
||||
|
||||
namespace ColdMint.scripts.contribute;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Contributor data Manager</para>
|
||||
/// <para>贡献者数据管理器</para>
|
||||
/// </summary>
|
||||
public static class ContributorDataManager
|
||||
{
|
||||
private static Dictionary<ContributorType, List<ContributorData>>? _contributorTypeDictionary;
|
||||
|
||||
private static readonly ContributorData[] ContributorArray =
|
||||
[
|
||||
new ContributorData
|
||||
{
|
||||
Name = "Cold-Mint",
|
||||
Url = "https://github.com/Cold-Mint",
|
||||
ContributorTypes = [ContributorType.Coder]
|
||||
},
|
||||
new ContributorData
|
||||
{
|
||||
Name = "Web13234",
|
||||
Url = "https://github.com/Web13234",
|
||||
ContributorTypes = [ContributorType.Coder]
|
||||
},
|
||||
new ContributorData
|
||||
{
|
||||
Name = "HYPERLINK BLOCKED",
|
||||
Url = "https://www.pixiv.net/users/74412798",
|
||||
ContributorTypes = [ContributorType.Artist]
|
||||
}
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// <para>Get contributor totals</para>
|
||||
/// <para>获取贡献者总数</para>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int GetContributorTotals()
|
||||
{
|
||||
return ContributorArray.Length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Gets a dictionary of contribution types to the contributor array</para>
|
||||
/// <para>获取贡献类型到贡献者数组的字典</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>Cache the results after calling this method, as it is very expensive to generate results.</para>
|
||||
///<para>调用此方法后请将结果缓存起来,因为生成结果是非常昂贵的。</para>
|
||||
/// </remarks>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
public static Dictionary<ContributorType, ContributorData[]>? GetContributorTypeToContributorDataArray()
|
||||
{
|
||||
if (_contributorTypeDictionary == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = new Dictionary<ContributorType, ContributorData[]>();
|
||||
foreach (var contributorType in _contributorTypeDictionary.Keys)
|
||||
{
|
||||
result[contributorType] = _contributorTypeDictionary[contributorType].ToArray();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Register all contributor data</para>
|
||||
/// <para>注册所有的贡献者数据</para>
|
||||
/// </summary>
|
||||
public static void RegisterAllContributorData()
|
||||
{
|
||||
if (_contributorTypeDictionary!= null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var contributorData in ContributorArray)
|
||||
{
|
||||
RegisterContributorData(contributorData);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Gets a string description of a contribution type</para>
|
||||
/// <para>获取某个贡献类型的字符串描述</para>
|
||||
/// </summary>
|
||||
/// <param name="contributorType"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
||||
public static string? ContributorTypeToString(ContributorType contributorType)
|
||||
{
|
||||
return contributorType switch
|
||||
{
|
||||
ContributorType.Coder => TranslationServerUtils.Translate("ui_coder"),
|
||||
ContributorType.Artist => TranslationServerUtils.Translate("ui_artist"),
|
||||
ContributorType.Musician => TranslationServerUtils.Translate("ui_musician"),
|
||||
ContributorType.CharacterVoice => TranslationServerUtils.Translate("ui_character_voice"),
|
||||
ContributorType.Translator => TranslationServerUtils.Translate("ui_translator"),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(contributorType), contributorType, null)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Register contributor data to the type dictionary</para>
|
||||
/// <para>注册贡献者数据到类型字典</para>
|
||||
/// </summary>
|
||||
/// <param name="contributorType"></param>
|
||||
/// <param name="contributorData"></param>
|
||||
private static void AddContributorDataToTypeDictionary(ContributorType contributorType,
|
||||
ContributorData contributorData)
|
||||
{
|
||||
if (_contributorTypeDictionary == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_contributorTypeDictionary.ContainsKey(contributorType))
|
||||
{
|
||||
_contributorTypeDictionary[contributorType].Add(contributorData);
|
||||
}
|
||||
else
|
||||
{
|
||||
_contributorTypeDictionary[contributorType] = [contributorData];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Register Contributor data</para>
|
||||
/// <para>注册贡献者数据</para>
|
||||
/// </summary>
|
||||
/// <param name="contributorData"></param>
|
||||
private static void RegisterContributorData(ContributorData contributorData)
|
||||
{
|
||||
if (contributorData.Name == null || contributorData.ContributorTypes == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_contributorTypeDictionary ??= new Dictionary<ContributorType, List<ContributorData>>();
|
||||
foreach (var contributorDataContributorType in contributorData.ContributorTypes)
|
||||
{
|
||||
AddContributorDataToTypeDictionary(contributorDataContributorType, contributorData);
|
||||
}
|
||||
}
|
||||
}
|
54
scripts/contribute/ContributorType.cs
Normal file
54
scripts/contribute/ContributorType.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
namespace ColdMint.scripts.contribute;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Contribution type</para>
|
||||
/// <para>贡献类型</para>
|
||||
/// </summary>
|
||||
public enum ContributorType
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Coder</para>
|
||||
/// <para>程序员</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>Contributed code to the project</para>
|
||||
///<para>为项目贡献了代码</para>
|
||||
/// </remarks>
|
||||
Coder,
|
||||
/// <summary>
|
||||
/// <para>Artist</para>
|
||||
/// <para>美术</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>Contributed art assets to the project</para>
|
||||
///<para>为项目贡献了美术资产</para>
|
||||
/// </remarks>
|
||||
Artist,
|
||||
/// <summary>
|
||||
/// <para>Musician</para>
|
||||
/// <para>音乐家</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>Contributed music, sound assets to the project</para>
|
||||
///<para>为项目贡献了音乐,音效资产</para>
|
||||
/// </remarks>
|
||||
Musician,
|
||||
/// <summary>
|
||||
/// <para>CharacterVoice</para>
|
||||
/// <para>角色配音</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>Contributed voice to the game character</para>
|
||||
///<para>为游戏角色贡献了语音</para>
|
||||
/// </remarks>
|
||||
CharacterVoice,
|
||||
/// <summary>
|
||||
/// <para>Translator</para>
|
||||
/// <para>翻译者</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>Contribute to localization of the project(specified language)</para>
|
||||
///<para>为项目的本地化做出贡献(指定的语言)</para>
|
||||
/// </remarks>
|
||||
Translator
|
||||
}
|
|
@ -210,7 +210,6 @@ public interface IItemContainer : IEnumerable<ItemSlotNode>
|
|||
/// <para>IEnumerable for the item slot matched to, will be empty if there's no slot satisfies the predicate</para>
|
||||
/// <para>包含匹配到的槽位的IEnumerable,当没有满足条件的槽位时为空</para>
|
||||
/// </returns>
|
||||
/// <seealso cref="Match(Func{IItemStack?,bool})"/>
|
||||
IEnumerable<ItemSlotNode> MatchAll(Func<ItemSlotNode, bool> predicate);
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ColdMint.scripts.inventory;
|
||||
using ColdMint.scripts.item.itemStacks;
|
||||
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.item;
|
||||
|
@ -37,7 +36,7 @@ public partial class Packsack : RigidBody2D, IItem
|
|||
|
||||
public bool CanStackWith(IItem item) => false;
|
||||
|
||||
public IItemStack? SpecialStack()
|
||||
public IItemStack SpecialStack()
|
||||
{
|
||||
return new PacksackStack(this);
|
||||
}
|
||||
|
@ -49,8 +48,5 @@ public partial class Packsack : RigidBody2D, IItem
|
|||
{
|
||||
base._Ready();
|
||||
ItemContainer = new UniversalItemContainer();
|
||||
|
||||
//Test: Add one ItemSlot for pack
|
||||
ItemContainer.AddItemSlot(this);
|
||||
}
|
||||
}
|
102
scripts/loader/uiLoader/ContributorGroupLoader.cs
Normal file
102
scripts/loader/uiLoader/ContributorGroupLoader.cs
Normal file
|
@ -0,0 +1,102 @@
|
|||
using ColdMint.scripts.contribute;
|
||||
using ColdMint.scripts.utils;
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.loader.uiLoader;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Contributor group loader</para>
|
||||
/// <para>贡献者组加载器</para>
|
||||
/// </summary>
|
||||
public partial class ContributorGroupLoader : UiLoaderTemplate
|
||||
{
|
||||
private string? _title;
|
||||
private ContributorData[]? _contributorDataArray;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Contributor array</para>
|
||||
/// <para>贡献者数组</para>
|
||||
/// </summary>
|
||||
public ContributorData[]? ContributorDataArray
|
||||
{
|
||||
get => _contributorDataArray;
|
||||
set
|
||||
{
|
||||
_contributorDataArray = value;
|
||||
SetContributorData(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>The title of the contribution group</para>
|
||||
/// <para>贡献组的标题</para>
|
||||
/// </summary>
|
||||
public string? Title
|
||||
{
|
||||
get => _title;
|
||||
set
|
||||
{
|
||||
_title = value;
|
||||
SetTitle(value);
|
||||
}
|
||||
}
|
||||
|
||||
private Label? _titleLabel;
|
||||
private HFlowContainer? _flowContainer;
|
||||
|
||||
public override void InitializeUi()
|
||||
{
|
||||
_titleLabel = GetNode<Label>("TitleLabel");
|
||||
_flowContainer = GetNode<HFlowContainer>("HFlowContainer");
|
||||
//If there is initial data, it is loaded at startup.
|
||||
//如果有初始数据,那么在启动时加载。
|
||||
SetTitle(_title);
|
||||
SetContributorData(_contributorDataArray);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Set contributor array</para>
|
||||
/// <para>设置贡献者数组</para>
|
||||
/// </summary>
|
||||
/// <param name="contributorDataArray"></param>
|
||||
private void SetContributorData(ContributorData[]? contributorDataArray)
|
||||
{
|
||||
if (_flowContainer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
NodeUtils.DeleteAllChild(_flowContainer);
|
||||
if (contributorDataArray == null || contributorDataArray.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var contributorData in contributorDataArray)
|
||||
{
|
||||
var linkButton = new LinkButton();
|
||||
linkButton.Text = contributorData.Name;
|
||||
linkButton.Uri = contributorData.Url;
|
||||
_flowContainer.AddChild(linkButton);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Set Title</para>
|
||||
/// <para>设置标题</para>
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
private void SetTitle(string? title)
|
||||
{
|
||||
if (_titleLabel != null)
|
||||
{
|
||||
if (title == null)
|
||||
{
|
||||
_titleLabel.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
_titleLabel.Show();
|
||||
_titleLabel.Text = title;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
73
scripts/loader/uiLoader/ContributorLoader.cs
Normal file
73
scripts/loader/uiLoader/ContributorLoader.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
using System.Collections.Generic;
|
||||
using ColdMint.scripts.contribute;
|
||||
using ColdMint.scripts.utils;
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.loader.uiLoader;
|
||||
|
||||
/// <summary>
|
||||
/// <para>ContributorLoader</para>
|
||||
/// <para>贡献者页面加载器</para>
|
||||
/// </summary>
|
||||
public partial class ContributorLoader : UiLoaderTemplate
|
||||
{
|
||||
private Button? _exitButton;
|
||||
private VBoxContainer? _boxContainer;
|
||||
private PackedScene? _packedScene;
|
||||
private PackedScene? _mainMenu;
|
||||
private PackedScene? _contributorGroup;
|
||||
|
||||
public override void InitializeData()
|
||||
{
|
||||
_mainMenu = GD.Load<PackedScene>("res://scenes/mainMenu.tscn");
|
||||
_packedScene = GD.Load<PackedScene>("res://prefab/ui/contributorGroup.tscn");
|
||||
_contributorGroup = GD.Load<PackedScene>("res://prefab/ui/contributorGroup.tscn");
|
||||
}
|
||||
|
||||
public override void InitializeUi()
|
||||
{
|
||||
_exitButton = GetNode<Button>("ExitButton");
|
||||
_boxContainer = GetNode<VBoxContainer>("VBoxContainer");
|
||||
var dictionary =
|
||||
ContributorDataManager.GetContributorTypeToContributorDataArray();
|
||||
if (dictionary != null)
|
||||
{
|
||||
foreach (var contributorType in dictionary.Keys)
|
||||
{
|
||||
AddGroup(ContributorDataManager.ContributorTypeToString(contributorType), dictionary[contributorType]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddGroup(string? title, ContributorData[] contributorDataArray)
|
||||
{
|
||||
if (_boxContainer == null || _contributorGroup == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var contributorGroupLoader = NodeUtils.InstantiatePackedScene<ContributorGroupLoader>(_contributorGroup);
|
||||
if (contributorGroupLoader != null)
|
||||
{
|
||||
contributorGroupLoader.Title = title;
|
||||
contributorGroupLoader.ContributorDataArray = contributorDataArray;
|
||||
_boxContainer.AddChild(contributorGroupLoader);
|
||||
}
|
||||
}
|
||||
|
||||
public override void LoadUiActions()
|
||||
{
|
||||
if (_exitButton != null)
|
||||
{
|
||||
_exitButton.Pressed += () =>
|
||||
{
|
||||
if (_mainMenu == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GetTree().ChangeSceneToPacked(_mainMenu);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,6 +36,7 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
private PackedScene? _roomNodeScene;
|
||||
|
||||
private readonly List<Node> _selectedNodes = new();
|
||||
private PackedScene? _mainMenu;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Displays the time to enter the suggestion</para>
|
||||
|
@ -59,7 +60,8 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
public override void InitializeData()
|
||||
{
|
||||
base.InitializeData();
|
||||
_roomNodeScene = (PackedScene)GD.Load("res://prefab/ui/RoomNode.tscn");
|
||||
_mainMenu = GD.Load<PackedScene>("res://scenes/mainMenu.tscn");
|
||||
_roomNodeScene = GD.Load<PackedScene>("res://prefab/ui/RoomNode.tscn");
|
||||
_defaultRoomName = TranslationServerUtils.Translate("ui_default_room_name");
|
||||
var folder = Config.GetLevelGraphExportDirectory();
|
||||
if (!Directory.Exists(folder))
|
||||
|
@ -310,7 +312,11 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
{
|
||||
_nodeBinding.ReturnButton.Pressed += () =>
|
||||
{
|
||||
GetTree().ChangeSceneToPacked((PackedScene)GD.Load("res://scenes/mainMenu.tscn"));
|
||||
if (_mainMenu == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GetTree().ChangeSceneToPacked(_mainMenu);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,14 @@ using System.IO;
|
|||
using System.Text;
|
||||
|
||||
using ColdMint.scripts.camp;
|
||||
using ColdMint.scripts.contribute;
|
||||
using ColdMint.scripts.deathInfo;
|
||||
using ColdMint.scripts.debug;
|
||||
using ColdMint.scripts.inventory;
|
||||
using ColdMint.scripts.item;
|
||||
using ColdMint.scripts.map;
|
||||
using ColdMint.scripts.map.roomInjectionProcessor;
|
||||
|
||||
using ColdMint.scripts.utils;
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.loader.uiLoader;
|
||||
|
@ -24,9 +25,12 @@ public partial class MainMenuLoader : UiLoaderTemplate
|
|||
private Label? _copyrightLabel;
|
||||
private StringBuilder? _copyrightBuilder;
|
||||
private PackedScene? _gameScene;
|
||||
private PackedScene? _contributor;
|
||||
private PackedScene? _levelGraphEditor;
|
||||
private Label? _sloganLabel;
|
||||
private Label? _versionLabel;
|
||||
private Button? _levelGraphEditorButton;
|
||||
private LinkButton? _contributorButton;
|
||||
|
||||
public override void InitializeData()
|
||||
{
|
||||
|
@ -69,6 +73,7 @@ public partial class MainMenuLoader : UiLoaderTemplate
|
|||
LootListManager.RegisterLootList(testLootList);
|
||||
}
|
||||
|
||||
ContributorDataManager.RegisterAllContributorData();
|
||||
DeathInfoGenerator.RegisterDeathInfoHandler(new SelfDeathInfoHandler());
|
||||
MapGenerator.RegisterRoomInjectionProcessor(new ChanceRoomInjectionProcessor());
|
||||
MapGenerator.RegisterRoomInjectionProcessor(new TimeIntervalRoomInjectorProcessor());
|
||||
|
@ -93,7 +98,9 @@ public partial class MainMenuLoader : UiLoaderTemplate
|
|||
CampManager.AddCamp(mazoku);
|
||||
var aborigines = new Camp(Config.CampId.Aborigines);
|
||||
CampManager.AddCamp(aborigines);
|
||||
_gameScene = (PackedScene)GD.Load("res://scenes/game.tscn");
|
||||
_gameScene = GD.Load<PackedScene>("res://scenes/game.tscn");
|
||||
_contributor = GD.Load<PackedScene>("res://scenes/contributor.tscn");
|
||||
_levelGraphEditor = GD.Load<PackedScene>("res://scenes/levelGraphEditor.tscn");
|
||||
|
||||
//Register ItemTypes from file
|
||||
//从文件注册物品类型
|
||||
|
@ -105,6 +112,7 @@ public partial class MainMenuLoader : UiLoaderTemplate
|
|||
|
||||
public override void InitializeUi()
|
||||
{
|
||||
_contributorButton = GetNode<LinkButton>("VBoxContainer2/ContributorButton");
|
||||
_startGameButton = GetNode<Button>("StartGameButton");
|
||||
_levelGraphEditorButton = GetNode<Button>("levelGraphEditorButton");
|
||||
//The level map editor is only available in debug mode.
|
||||
|
@ -132,6 +140,9 @@ public partial class MainMenuLoader : UiLoaderTemplate
|
|||
_copyrightLabel.Text = _copyrightBuilder.ToString();
|
||||
_versionLabel.Text = "ver." + Config.GetVersion();
|
||||
_sloganLabel.Text = SloganProvider.GetSlogan();
|
||||
_contributorButton.Text =
|
||||
TranslationServerUtils.TranslateWithFormat("ui_contributor_tips",
|
||||
ContributorDataManager.GetContributorTotals());
|
||||
}
|
||||
|
||||
public override void LoadUiActions()
|
||||
|
@ -141,16 +152,36 @@ public partial class MainMenuLoader : UiLoaderTemplate
|
|||
_startGameButton.Pressed += () =>
|
||||
{
|
||||
LogCat.Log("start_game");
|
||||
if (_gameScene == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GetTree().ChangeSceneToPacked(_gameScene);
|
||||
};
|
||||
}
|
||||
|
||||
if (_contributorButton!=null)
|
||||
{
|
||||
_contributorButton.Pressed += () =>
|
||||
{
|
||||
if (_contributor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GetTree().ChangeSceneToPacked(_contributor);
|
||||
};
|
||||
}
|
||||
|
||||
if (_levelGraphEditorButton != null)
|
||||
{
|
||||
_levelGraphEditorButton.Pressed += () =>
|
||||
{
|
||||
LogCat.Log("level_graph_editor");
|
||||
GetTree().ChangeSceneToPacked((PackedScene)GD.Load("res://scenes/levelGraphEditor.tscn"));
|
||||
if (_levelGraphEditor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GetTree().ChangeSceneToPacked(_levelGraphEditor);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 372 B After Width: | Height: | Size: 1011 B |
Loading…
Reference in New Issue
Block a user