Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SelectGameModeDialog.cs
浏览该文件的文档.
1using System.Xml.Linq;
2using Engine;
3
4namespace Game {
6 public SelectGameModeDialog(string title, bool allowAdventure, bool allowCruel, Action<GameMode> selectionHandler) : base(
7 title,
8 GetAllowedGameModes(allowAdventure, allowCruel),
9 140f,
10 delegate(object item) {
11 GameMode gameMode = (GameMode)item;
12 XElement node = ContentManager.Get<XElement>("Widgets/SelectGameModeItem");
13 ContainerWidget obj = (ContainerWidget)LoadWidget(null, node, null);
14 obj.Children.Find<LabelWidget>("SelectGameModeItem.Name").Text = LanguageControl.Get("GameMode", gameMode.ToString());
15 obj.Children.Find<LabelWidget>("SelectGameModeItem.Description").Text =
16 StringsManager.GetString($"GameMode.{gameMode}.Description");
17 return obj;
18 },
19 delegate(object item) { selectionHandler((GameMode)item); }
20 ) => ContentSize = new Vector2(750f, 420f);
21
22 public static IEnumerable<GameMode> GetAllowedGameModes(bool allowAdventure, bool allowCruel) {
23 yield return GameMode.Creative;
24 yield return GameMode.Survival;
25 yield return GameMode.Challenging;
26 yield return GameMode.Harmless;
27 if (allowAdventure) {
28 yield return GameMode.Adventure;
29 }
30 if (allowCruel) {
31 yield return GameMode.Cruel;
32 }
33 }
34 }
35}
static object Get(Type type, string name)
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
ListSelectionDialog(string title, IEnumerable items, float itemSize, Func< object, Widget > itemWidgetFactory, Action< object > selectionHandler)
SelectGameModeDialog(string title, bool allowAdventure, bool allowCruel, Action< GameMode > selectionHandler) static IEnumerable< GameMode > GetAllowedGameModes(bool allowAdventure, bool allowCruel)
static string GetString(string name)
static Widget LoadWidget(object eventsTarget, XElement node, ContainerWidget parentWidget)