public Widget makeTextBox(Action <TextBoxWidget> ac, string text = "") { CanvasWidget canvasWidget = new CanvasWidget() { HorizontalAlignment = WidgetAlignment.Center }; RectangleWidget rectangleWidget = new RectangleWidget() { FillColor = Color.Black, OutlineColor = Color.White, Size = new Vector2(120, 30) }; StackPanelWidget stack = new StackPanelWidget() { Direction = LayoutDirection.Vertical }; TextBoxWidget textBox = new TextBoxWidget() { VerticalAlignment = WidgetAlignment.Center, Color = new Color(255, 255, 255), Margin = new Vector2(4f, 0f), Size = new Vector2(120, 30), MaximumLength = 256 }; textBox.FontScale = 0.7f; textBox.Text = text; textBox.TextChanged += ac; stack.Children.Add(textBox); canvasWidget.Children.Add(rectangleWidget); canvasWidget.Children.Add(stack); return(canvasWidget); }
public Widget makeButton() { StackPanelWidget stack = new StackPanelWidget() { Direction = LayoutDirection.Horizontal }; BevelledButtonWidget bevelledButtonWidget1 = new BevelledButtonWidget() { Size = new Vector2(160, 60), Margin = new Vector2(4f, 0), Text = "登陆" }; BevelledButtonWidget bevelledButtonWidget2 = new BevelledButtonWidget() { Size = new Vector2(160, 60), Margin = new Vector2(4f, 0), Text = "注册" }; BevelledButtonWidget bevelledButtonWidget3 = new BevelledButtonWidget() { Size = new Vector2(160, 60), Margin = new Vector2(4f, 0), Text = "取消" }; stack.Children.Add(bevelledButtonWidget1); stack.Children.Add(bevelledButtonWidget2); stack.Children.Add(bevelledButtonWidget3); btna = bevelledButtonWidget1; btnb = bevelledButtonWidget2; btnc = bevelledButtonWidget3; return(stack); }
public StackPanelWidget matchColor(string str) { StackPanelWidget stackPanel = new StackPanelWidget() { Direction = LayoutDirection.Horizontal }; string[] ll = str.Split(new string[] { "[color=", "]", "[/color]" }, System.StringSplitOptions.None); if (ll[0] == str) { LabelWidget labelWidget = new LabelWidget() { Text = str, FontScale = 0.6f, WordWrap = true }; labelWidget.Margin = new Vector2(2, 0); labelWidget.Size = new Vector2(XjJeiLibrary.caculateWidth(labelWidget, labelWidget.FontScale, str, canvasmain.Size.X), XjJeiLibrary.caculateHeight(labelWidget, 1, labelWidget.FontScale)); stackPanel.Children.Add(labelWidget); } else { bool isColor = false; Color cc = Color.White; foreach (string ain in ll) { if (!isColor) { cc = colorTable(ain); if (cc != Color.Transparent) { isColor = true; } else { LabelWidget labelWidget = new LabelWidget() { Text = ain, FontScale = 0.6f, WordWrap = true }; float wid = XjJeiLibrary.caculateWidth(labelWidget, labelWidget.FontScale, ain, canvasmain.Size.X); labelWidget.Size = new Vector2(XjJeiLibrary.caculateWidth(labelWidget, labelWidget.FontScale, ain, canvasmain.Size.X), XjJeiLibrary.caculateHeight(labelWidget, 1, labelWidget.FontScale)); labelWidget.Margin = new Vector2(2, 0); stackPanel.Children.Add(labelWidget); } } else { LabelWidget labelWidget = new LabelWidget() { Text = ain, FontScale = 0.6f, Color = cc, WordWrap = true }; labelWidget.Size = new Vector2(XjJeiLibrary.caculateWidth(labelWidget, labelWidget.FontScale, ain, canvasmain.Size.X), XjJeiLibrary.caculateHeight(labelWidget, 1, labelWidget.FontScale)); labelWidget.Margin = new Vector2(2, 0); stackPanel.Children.Add(labelWidget); isColor = false; } } } return(stackPanel); }
public PlayersScreen() { XElement node = ContentManager.Get <XElement>("Screens/PlayersScreen"); LoadContents(this, node); m_playersPanel = Children.Find <StackPanelWidget>("PlayersPanel"); m_addPlayerButton = Children.Find <ButtonWidget>("AddPlayerButton"); m_screenLayoutButton = Children.Find <ButtonWidget>("ScreenLayoutButton"); }
public ClothingWidget(ComponentPlayer componentPlayer) { m_componentPlayer = componentPlayer; XElement node = ContentManager.Get <XElement>("Widgets/ClothingWidget"); LoadContents(this, node); m_clothingStack = Children.Find <StackPanelWidget>("ClothingStack"); m_inventoryGrid = Children.Find <GridPanelWidget>("InventoryGrid"); m_vitalStatsButton = Children.Find <ButtonWidget>("VitalStatsButton"); m_sleepButton = Children.Find <ButtonWidget>("SleepButton"); m_innerClothingModelWidget = Children.Find <PlayerModelWidget>("InnerClothingModel"); m_outerClothingModelWidget = Children.Find <PlayerModelWidget>("OuterClothingModel"); for (int i = 0; i < 4; i++) { InventorySlotWidget inventorySlotWidget = new InventorySlotWidget(); float y = float.PositiveInfinity; if (i == 0) { y = 68f; } if (i == 3) { y = 54f; } inventorySlotWidget.Size = new Vector2(float.PositiveInfinity, y); inventorySlotWidget.BevelColor = Color.Transparent; inventorySlotWidget.CenterColor = Color.Transparent; inventorySlotWidget.AssignInventorySlot(m_componentPlayer.ComponentClothing, i); inventorySlotWidget.HideEditOverlay = true; inventorySlotWidget.HideInteractiveOverlay = true; inventorySlotWidget.HideFoodOverlay = true; inventorySlotWidget.HideHighlightRectangle = true; inventorySlotWidget.HideBlockIcon = true; inventorySlotWidget.HideHealthBar = (m_componentPlayer.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true).WorldSettings.GameMode == GameMode.Creative); m_clothingStack.Children.Add(inventorySlotWidget); } int num = 10; for (int j = 0; j < m_inventoryGrid.RowsCount; j++) { for (int k = 0; k < m_inventoryGrid.ColumnsCount; k++) { InventorySlotWidget inventorySlotWidget2 = new InventorySlotWidget(); inventorySlotWidget2.AssignInventorySlot(componentPlayer.ComponentMiner.Inventory, num++); m_inventoryGrid.Children.Add(inventorySlotWidget2); m_inventoryGrid.SetWidgetCell(inventorySlotWidget2, new Point2(k, j)); } } m_innerClothingModelWidget.PlayerClass = componentPlayer.PlayerData.PlayerClass; m_innerClothingModelWidget.CharacterSkinTexture = m_componentPlayer.ComponentClothing.InnerClothedTexture; m_outerClothingModelWidget.PlayerClass = componentPlayer.PlayerData.PlayerClass; m_outerClothingModelWidget.OuterClothingTexture = m_componentPlayer.ComponentClothing.OuterClothedTexture; }
public Widget initData() { StackPanelWidget stack = new StackPanelWidget() { Direction = LayoutDirection.Vertical, VerticalAlignment = WidgetAlignment.Center, HorizontalAlignment = WidgetAlignment.Far, Margin = new Vector2(10, 0) }; for (int i = 0; i < 17; i++) { StackPanelWidget line = new StackPanelWidget() { Direction = LayoutDirection.Horizontal }; for (int j = 0; j < 17; j++) { int addr = (i - 1) * 16 + (j - 1); if (j > 0 && i > 0) { ClickTextWidget clickTextWidget = new ClickTextWidget(new Vector2(22), string.Format("{0}", MemoryBankData.m_hexChars[Read(addr)]), delegate() { AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); clickpos = addr; isclick = true; }); list.Add(clickTextWidget); line.Children.Add(clickTextWidget); } else { int p = 0; if (i == 0 && j > 0) { p = j - 1; } else if (j == 0 && i > 0) { p = i - 1; } else { ClickTextWidget click = new ClickTextWidget(new Vector2(22), "", null); line.Children.Add(click); continue; }; ClickTextWidget clickTextWidget = new ClickTextWidget(new Vector2(22), MemoryBankData.m_hexChars[p].ToString(), delegate() { }); clickTextWidget.labelWidget.Color = Color.DarkGray; line.Children.Add(clickTextWidget); } } stack.Children.Add(line); } return(stack); }
public void setCreatureinfo(ComponentCreature componentCreature) { if (componentCreature == null) { return; } clearWidgets(); StackPanelWidget stackLine_healthinfo = new StackPanelWidget() { Direction = LayoutDirection.Vertical, Margin = new Vector2(2, 0) }; creatureInfo.Text = $"{componentCreature.DisplayName}"; if (componentCreature.ComponentHealth.Health < 0.2f) { creatureHealth.Color = Color.Red; } else if (componentCreature.ComponentHealth.Health < 0.5f) { creatureHealth.Color = Color.Yellow; } else { creatureHealth.Color = Color.Green; } creatureInfo.Size = new Vector2(XjJeiLibrary.caculateWidth(creatureInfo, creatureInfo.FontScale, creatureInfo.Text, this.Size.X), creatureInfo.Size.Y); creatureHealth.Text = $"{componentCreature.ComponentHealth.AttackResilience*componentCreature.ComponentHealth.Health:0.00}"; stackLine_healthinfo.Children.Add(creatureInfo); stackLine_healthinfo.Children.Add(creatureHealth); if (!upMode) { Margin = Vector2.Zero; stackmain.Children.Add(stackLine_healthinfo); stackmain.Children.Add(HealthBarWidget); } else //右下角模式 { stackmain.Children.Add(stackLine_healthinfo); stackmain.Children.Add(HealthBarWidget); Margin = new Vector2(0, widget.DesiredSize.Y + SubsystemXjJeiBehavior.margin.Y); } HealthBarWidget.Value = componentCreature.ComponentHealth.Health; this.Size = new Vector2(HealthBarWidget.ActualSize.X + creatureInfo.ActualSize.X + 4, creatureHealth.Size.Y + creatureInfo.Size.Y + 4); }
public LineData ParseLine(MotdManager.Line line) { LineData lineData = new LineData(); lineData.Time = line.Time; if (line.Node != null) { lineData.Widget = Widget.LoadWidget(null, line.Node, null); } else { if (string.IsNullOrEmpty(line.Text)) { throw new InvalidOperationException("Invalid MOTD line."); } StackPanelWidget stackPanelWidget = new StackPanelWidget { Direction = LayoutDirection.Vertical, HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center }; string[] array = line.Text.Replace("\r", "").Split(new string[] { "\n" }, StringSplitOptions.None); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (!string.IsNullOrEmpty(text)) { LabelWidget widget = new LabelWidget { Text = text, Font = ContentManager.Get <BitmapFont>("Fonts/Pericles"), HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center, DropShadow = true }; stackPanelWidget.Children.Add(widget); } } lineData.Widget = stackPanelWidget; } return(lineData); }
public Widget makeTextBox(string title) { CanvasWidget canvasWidget = new CanvasWidget() { Margin = new Vector2(10, 0) }; RectangleWidget rectangleWidget = new RectangleWidget() { FillColor = Color.Black, OutlineColor = Color.White, Size = new Vector2(float.PositiveInfinity, 80) }; StackPanelWidget stack = new StackPanelWidget() { Direction = LayoutDirection.Horizontal }; LabelWidget label = new LabelWidget() { HorizontalAlignment = WidgetAlignment.Near, VerticalAlignment = WidgetAlignment.Near, Text = title, Margin = new Vector2(1f, 1f) }; TextBoxWidget textBox = new TextBoxWidget() { VerticalAlignment = WidgetAlignment.Center, HorizontalAlignment = WidgetAlignment.Stretch, Color = new Color(255, 255, 255), Margin = new Vector2(4f, 0f), Size = new Vector2(float.PositiveInfinity, 80) }; if (title == "用户名:") { txa = textBox; } if (title == "密 码:") { txb = textBox; } stack.Children.Add(label); stack.Children.Add(textBox); canvasWidget.Children.Add(rectangleWidget); canvasWidget.Children.Add(stack); return(canvasWidget); }
public EditMemeryDialogB(MemoryBankData memoryBankData, Action onCancel) { memory = memoryBankData; Data.Clear(); Data.AddRange(memory.Data); CanvasWidget canvasWidget = new CanvasWidget() { Size = new Vector2(600f, float.PositiveInfinity), HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center }; RectangleWidget rectangleWidget = new RectangleWidget() { FillColor = new Color(0, 0, 0, 255), OutlineColor = new Color(128, 128, 128, 128), OutlineThickness = 2 }; StackPanelWidget stackPanel = new StackPanelWidget() { Direction = LayoutDirection.Vertical }; LabelWidget labelWidget = new LabelWidget() { Text = "M 板编辑器", HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0, 10) }; StackPanelWidget stackPanelWidget = new StackPanelWidget() { Direction = LayoutDirection.Horizontal, HorizontalAlignment = WidgetAlignment.Near, VerticalAlignment = WidgetAlignment.Near, Margin = new Vector2(10f, 10f) }; Children.Add(canvasWidget); canvasWidget.Children.Add(rectangleWidget); canvasWidget.Children.Add(stackPanel); stackPanel.Children.Add(labelWidget); stackPanel.Children.Add(stackPanelWidget); stackPanelWidget.Children.Add(initData()); stackPanelWidget.Children.Add(initButton()); MainView = stackPanel; this.onCancel = onCancel; lastvalue = memory.Read(0); }
public LoginDialog() { CanvasWidget canvasWidget = new CanvasWidget() { Size = new Vector2(600f, 240f), HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center }; RectangleWidget rectangleWidget = new RectangleWidget() { FillColor = new Color(0, 0, 0, 255), OutlineColor = new Color(128, 128, 128, 128), OutlineThickness = 2 }; StackPanelWidget stackPanelWidget = new StackPanelWidget() { Direction = LayoutDirection.Vertical, HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Near, Margin = new Vector2(10f, 10f) }; Children.Add(canvasWidget); canvasWidget.Children.Add(rectangleWidget); canvasWidget.Children.Add(stackPanelWidget); MainView = stackPanelWidget; MainView.Children.Add(tip); MainView.Children.Add(makeTextBox("用户名:")); MainView.Children.Add(makeTextBox("密 码:")); MainView.Children.Add(makeButton()); }
public GameMenuDialog(ComponentPlayer componentPlayer) { XElement node = ContentManager.Get <XElement>("Dialogs/GameMenuDialog"); LoadContents(this, node); m_statsPanel = Children.Find <StackPanelWidget>("StatsPanel"); m_componentPlayer = componentPlayer; m_adventureRestartExists = WorldsManager.SnapshotExists(GameManager.WorldInfo.DirectoryName, "AdventureRestart"); if (!m_increaseDetailDialogShown && PerformanceManager.LongTermAverageFrameTime.HasValue && PerformanceManager.LongTermAverageFrameTime.Value * 1000f < 25f && (SettingsManager.VisibilityRange <= 64 || SettingsManager.ResolutionMode == ResolutionMode.Low)) { m_increaseDetailDialogShown = true; DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog(LanguageControl.Get(fName, 1), LanguageControl.Get(fName, 2), LanguageControl.Get("Usual", "ok"), null, null)); AnalyticsManager.LogEvent("[GameMenuScreen] IncreaseDetailDialog Shown"); } if (!m_decreaseDetailDialogShown && PerformanceManager.LongTermAverageFrameTime.HasValue && PerformanceManager.LongTermAverageFrameTime.Value * 1000f > 50f && (SettingsManager.VisibilityRange >= 64 || SettingsManager.ResolutionMode == ResolutionMode.High)) { m_decreaseDetailDialogShown = true; DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog(LanguageControl.Get(fName, 3), LanguageControl.Get(fName, 4), LanguageControl.Get("Usual", "ok"), null, null)); AnalyticsManager.LogEvent("[GameMenuScreen] DecreaseDetailDialog Shown"); } m_statsPanel.Children.Clear(); Project project = componentPlayer.Project; PlayerData playerData = componentPlayer.PlayerData; PlayerStats playerStats = componentPlayer.PlayerStats; SubsystemGameInfo subsystemGameInfo = project.FindSubsystem <SubsystemGameInfo>(throwOnError: true); SubsystemFurnitureBlockBehavior subsystemFurnitureBlockBehavior = project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true); BitmapFont font = ContentManager.Get <BitmapFont>("Fonts/Pericles"); BitmapFont font2 = ContentManager.Get <BitmapFont>("Fonts/Pericles"); Color white = Color.White; StackPanelWidget stackPanelWidget = new StackPanelWidget { Direction = LayoutDirection.Vertical, HorizontalAlignment = WidgetAlignment.Center }; m_statsPanel.Children.Add(stackPanelWidget); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 5), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 6), LanguageControl.Get("GameMode", subsystemGameInfo.WorldSettings.GameMode.ToString()) + ", " + LanguageControl.Get("EnvironmentBehaviorMode", subsystemGameInfo.WorldSettings.EnvironmentBehaviorMode.ToString())); AddStat(stackPanelWidget, LanguageControl.Get(fName, 7), StringsManager.GetString("TerrainGenerationMode." + subsystemGameInfo.WorldSettings.TerrainGenerationMode.ToString() + ".Name")); string seed = subsystemGameInfo.WorldSettings.Seed; AddStat(stackPanelWidget, LanguageControl.Get(fName, 8), (!string.IsNullOrEmpty(seed)) ? seed : LanguageControl.Get(fName, 9)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 10), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.SeaLevelOffset)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 11), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.TemperatureOffset)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 12), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.HumidityOffset)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 13), subsystemGameInfo.WorldSettings.BiomeSize.ToString() + "x"); int num = 0; for (int i = 0; i < ComponentFurnitureInventory.maxDesign; i++) { if (subsystemFurnitureBlockBehavior.GetDesign(i) != null) { num++; } } AddStat(stackPanelWidget, LanguageControl.Get(fName, 14), $"{num}/{ComponentFurnitureInventory.maxDesign}"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 15), string.IsNullOrEmpty(subsystemGameInfo.WorldSettings.OriginalSerializationVersion) ? LanguageControl.Get(fName, 16) : subsystemGameInfo.WorldSettings.OriginalSerializationVersion); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 17), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 18), playerData.Name); AddStat(stackPanelWidget, LanguageControl.Get(fName, 19), playerData.PlayerClass.ToString()); string value = (playerData.FirstSpawnTime >= 0.0) ? (((subsystemGameInfo.TotalElapsedGameTime - playerData.FirstSpawnTime) / 1200.0).ToString("N1") + LanguageControl.Get(fName, 20)) : LanguageControl.Get(fName, 21); AddStat(stackPanelWidget, LanguageControl.Get(fName, 22), value); string value2 = (playerData.LastSpawnTime >= 0.0) ? (((subsystemGameInfo.TotalElapsedGameTime - playerData.LastSpawnTime) / 1200.0).ToString("N1") + LanguageControl.Get(fName, 23)) : LanguageControl.Get(fName, 24); AddStat(stackPanelWidget, LanguageControl.Get(fName, 25), value2); AddStat(stackPanelWidget, LanguageControl.Get(fName, 26), MathUtils.Max(playerData.SpawnsCount - 1, 0).ToString("N0") + LanguageControl.Get(fName, 27)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 28), string.Format(LanguageControl.Get(fName, 29), ((int)MathUtils.Floor(playerStats.HighestLevel)).ToString("N0"))); if (componentPlayer != null) { Vector3 position = componentPlayer.ComponentBody.Position; if (subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative) { AddStat(stackPanelWidget, LanguageControl.Get(fName, 30), string.Format(LanguageControl.Get(fName, 31), $"{position.X:0}", $"{position.Z:0}", $"{position.Y:0}")); } else { AddStat(stackPanelWidget, LanguageControl.Get(fName, 30), string.Format(LanguageControl.Get(fName, 32), LanguageControl.Get("GameMode", subsystemGameInfo.WorldSettings.GameMode.ToString()))); } } if (string.CompareOrdinal(subsystemGameInfo.WorldSettings.OriginalSerializationVersion, "1.29") > 0) { stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 33), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 34), playerStats.PlayerKills.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 35), playerStats.LandCreatureKills.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 36), playerStats.WaterCreatureKills.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 37), playerStats.AirCreatureKills.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 38), playerStats.MeleeAttacks.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 39), playerStats.MeleeHits.ToString("N0"), $"({((playerStats.MeleeHits == 0L) ? 0.0 : ((double)playerStats.MeleeHits / (double)playerStats.MeleeAttacks * 100.0)):0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 40), playerStats.RangedAttacks.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 41), playerStats.RangedHits.ToString("N0"), $"({((playerStats.RangedHits == 0L) ? 0.0 : ((double)playerStats.RangedHits / (double)playerStats.RangedAttacks * 100.0)):0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 42), playerStats.HitsReceived.ToString("N0")); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 43), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 44), playerStats.BlocksDug.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 45), playerStats.BlocksPlaced.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 46), playerStats.BlocksInteracted.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 47), playerStats.ItemsCrafted.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 48), playerStats.FurnitureItemsMade.ToString("N0")); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 49), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 50), FormatDistance(playerStats.DistanceTravelled)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 51), FormatDistance(playerStats.DistanceWalked), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceWalked / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 52), FormatDistance(playerStats.DistanceFallen), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceFallen / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 53), FormatDistance(playerStats.DistanceClimbed), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceClimbed / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 54), FormatDistance(playerStats.DistanceFlown), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceFlown / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 55), FormatDistance(playerStats.DistanceSwam), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceSwam / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 56), FormatDistance(playerStats.DistanceRidden), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceRidden / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 57), FormatDistance(playerStats.LowestAltitude)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 58), FormatDistance(playerStats.HighestAltitude)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 59), playerStats.DeepestDive.ToString("N1") + "m"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 60), playerStats.Jumps.ToString("N0")); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 61), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 62), (playerStats.TotalHealthLost * 100.0).ToString("N0") + "%"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 63), playerStats.FoodItemsEaten.ToString("N0") + LanguageControl.Get(fName, 64)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 65), playerStats.TimesWentToSleep.ToString("N0") + LanguageControl.Get(fName, 66)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 67), (playerStats.TimeSlept / 1200.0).ToString("N1") + LanguageControl.Get(fName, 68)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 69), playerStats.TimesWasSick.ToString("N0") + LanguageControl.Get(fName, 66)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 70), playerStats.TimesPuked.ToString("N0") + LanguageControl.Get(fName, 66)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 71), playerStats.TimesHadFlu.ToString("N0") + LanguageControl.Get(fName, 66)); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 72), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 73), playerStats.StruckByLightning.ToString("N0") + LanguageControl.Get(fName, 66)); GameMode easiestModeUsed = playerStats.EasiestModeUsed; AddStat(stackPanelWidget, LanguageControl.Get(fName, 74), LanguageControl.Get("GameMode", easiestModeUsed.ToString())); if (playerStats.DeathRecords.Count > 0) { stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 75), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); foreach (PlayerStats.DeathRecord deathRecord in playerStats.DeathRecords) { float num2 = (float)MathUtils.Remainder(deathRecord.Day, 1.0); string arg = (!(num2 < 0.2f) && !(num2 >= 0.8f)) ? ((!(num2 >= 0.7f)) ? ((!(num2 >= 0.5f)) ? LanguageControl.Get(fName, 76) : LanguageControl.Get(fName, 77)) : LanguageControl.Get(fName, 78)) : LanguageControl.Get(fName, 79); AddStat(stackPanelWidget, string.Format(LanguageControl.Get(fName, 80), MathUtils.Floor(deathRecord.Day) + 1.0, arg), "", deathRecord.Cause); } } } else { stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 81), WordWrap = true, Font = font2, HorizontalAlignment = WidgetAlignment.Center, TextAnchor = TextAnchor.HorizontalCenter, Margin = new Vector2(20f, 10f), Color = white }); } }
public InventorySlotWidget() { base.Size = new Vector2(72f, 72f); WidgetsList children = Children; Widget[] array = new Widget[7]; BevelledRectangleWidget obj = new BevelledRectangleWidget { BevelSize = -2f, DirectionalLight = 0.15f, CenterColor = Color.Transparent }; BevelledRectangleWidget bevelledRectangleWidget = obj; m_rectangleWidget = obj; array[0] = bevelledRectangleWidget; RectangleWidget obj2 = new RectangleWidget { FillColor = Color.Transparent, OutlineColor = Color.Transparent }; RectangleWidget rectangleWidget = obj2; m_highlightWidget = obj2; array[1] = rectangleWidget; BlockIconWidget obj3 = new BlockIconWidget { HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center, Margin = new Vector2(2f, 2f) }; BlockIconWidget blockIconWidget = obj3; m_blockIconWidget = obj3; array[2] = blockIconWidget; LabelWidget obj4 = new LabelWidget { Font = ContentManager.Get <BitmapFont>("Fonts/Pericles"), FontScale = 1f, HorizontalAlignment = WidgetAlignment.Far, VerticalAlignment = WidgetAlignment.Far, Margin = new Vector2(6f, 2f) }; LabelWidget labelWidget = obj4; m_countWidget = obj4; array[3] = labelWidget; ValueBarWidget obj5 = new ValueBarWidget { LayoutDirection = LayoutDirection.Vertical, HorizontalAlignment = WidgetAlignment.Near, VerticalAlignment = WidgetAlignment.Far, BarsCount = 3, FlipDirection = true, LitBarColor = new Color(32, 128, 0), UnlitBarColor = new Color(24, 24, 24, 64), BarSize = new Vector2(12f, 12f), BarSubtexture = ContentManager.Get <Subtexture>("Textures/Atlas/ProgressBar"), Margin = new Vector2(4f, 4f) }; ValueBarWidget valueBarWidget = obj5; m_healthBarWidget = obj5; array[4] = valueBarWidget; StackPanelWidget obj6 = new StackPanelWidget { Direction = LayoutDirection.Horizontal, HorizontalAlignment = WidgetAlignment.Far, Margin = new Vector2(3f, 3f) }; WidgetsList children2 = obj6.Children; RectangleWidget obj7 = new RectangleWidget { Subtexture = ContentManager.Get <Subtexture>("Textures/Atlas/InteractiveItemOverlay"), Size = new Vector2(13f, 14f), FillColor = new Color(160, 160, 160), OutlineColor = Color.Transparent }; rectangleWidget = obj7; m_interactiveOverlayWidget = obj7; children2.Add(rectangleWidget); WidgetsList children3 = obj6.Children; RectangleWidget obj8 = new RectangleWidget { Subtexture = ContentManager.Get <Subtexture>("Textures/Atlas/EditItemOverlay"), Size = new Vector2(12f, 14f), FillColor = new Color(160, 160, 160), OutlineColor = Color.Transparent }; rectangleWidget = obj8; m_editOverlayWidget = obj8; children3.Add(rectangleWidget); WidgetsList children4 = obj6.Children; RectangleWidget obj9 = new RectangleWidget { Subtexture = ContentManager.Get <Subtexture>("Textures/Atlas/FoodItemOverlay"), Size = new Vector2(11f, 14f), FillColor = new Color(160, 160, 160), OutlineColor = Color.Transparent }; rectangleWidget = obj9; m_foodOverlayWidget = obj9; children4.Add(rectangleWidget); array[5] = obj6; LabelWidget obj10 = new LabelWidget { Text = "Split", Font = ContentManager.Get <BitmapFont>("Fonts/Pericles"), Color = new Color(255, 64, 0), HorizontalAlignment = WidgetAlignment.Near, VerticalAlignment = WidgetAlignment.Near, Margin = new Vector2(2f, 0f) }; labelWidget = obj10; m_splitLabelWidget = obj10; array[6] = labelWidget; children.Add(array); }
public EditPaletteDialog(WorldPalette palette) { XElement node = ContentManager.Get <XElement>("Dialogs/EditPaletteDialog"); LoadContents(this, node); m_listPanel = Children.Find <ContainerWidget>("EditPaletteDialog.ListPanel"); m_okButton = Children.Find <ButtonWidget>("EditPaletteDialog.OK"); m_cancelButton = Children.Find <ButtonWidget>("EditPaletteDialog.Cancel"); for (int i = 0; i < 16; i++) { StackPanelWidget obj = new StackPanelWidget { Direction = LayoutDirection.Horizontal, Children = { (Widget) new CanvasWidget { Size = new Vector2(32f, 60f), Children = { (Widget) new LabelWidget { Text = (i + 1).ToString() + ".", Color = Color.Gray, HorizontalAlignment = WidgetAlignment.Far, VerticalAlignment = WidgetAlignment.Center, Font = ContentManager.Get <BitmapFont>("Fonts/Pericles") } } }, (Widget) new CanvasWidget { Size = new Vector2(10f, 0f) } } }; obj.Children.Add(m_labels[i] = new LinkWidget { Size = new Vector2(300f, -1f), VerticalAlignment = WidgetAlignment.Center, Font = ContentManager.Get <BitmapFont>("Fonts/Pericles") }); obj.Children.Add(new CanvasWidget { Size = new Vector2(10f, 0f) }); obj.Children.Add(m_rectangles[i] = new BevelledButtonWidget { Size = new Vector2(1f / 0f, 60f), BevelSize = 1f, AmbientLight = 1f, DirectionalLight = 0.4f, VerticalAlignment = WidgetAlignment.Center }); obj.Children.Add(new CanvasWidget { Size = new Vector2(10f, 0f) }); obj.Children.Add(m_resetButtons[i] = new BevelledButtonWidget { Size = new Vector2(160f, 60f), VerticalAlignment = WidgetAlignment.Center, Text = "Reset" }); obj.Children.Add(new CanvasWidget { Size = new Vector2(10f, 0f) }); StackPanelWidget widget = obj; m_listPanel.Children.Add(widget); } m_palette = palette; m_tmpPalette = new WorldPalette(); m_palette.CopyTo(m_tmpPalette); }
public EditColorDialog(Color color, Action <Color?> handler) { WidgetsList children = Children; CanvasWidget obj = new CanvasWidget { Size = new Vector2(660f, 420f), HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center, Children = { (Widget) new RectangleWidget { FillColor = new Color(0, 0, 0, 255), OutlineColor = new Color(128, 128, 128, 128), OutlineThickness = 2f } } }; WidgetsList children2 = obj.Children; StackPanelWidget obj2 = new StackPanelWidget { Direction = LayoutDirection.Vertical, Margin = new Vector2(15f), HorizontalAlignment = WidgetAlignment.Center, Children = { (Widget) new LabelWidget { Text = "Edit Color", HorizontalAlignment = WidgetAlignment.Center }, (Widget) new CanvasWidget { Size = new Vector2(0f, float.PositiveInfinity) } } }; WidgetsList children3 = obj2.Children; StackPanelWidget obj3 = new StackPanelWidget { Direction = LayoutDirection.Horizontal }; WidgetsList children4 = obj3.Children; StackPanelWidget obj4 = new StackPanelWidget { Direction = LayoutDirection.Vertical, VerticalAlignment = WidgetAlignment.Center }; WidgetsList children5 = obj4.Children; StackPanelWidget obj5 = new StackPanelWidget { Direction = LayoutDirection.Horizontal, HorizontalAlignment = WidgetAlignment.Far, Margin = new Vector2(0f, 10f), Children = { (Widget) new LabelWidget { Text = "Red:", Color = Color.Gray, VerticalAlignment = WidgetAlignment.Center, Font = ContentManager.Get <BitmapFont>("Fonts/Pericles") }, (Widget) new CanvasWidget { Size = new Vector2(10f, 0f) } } }; WidgetsList children6 = obj5.Children; SliderWidget obj6 = new SliderWidget { Size = new Vector2(300f, 50f), IsLabelVisible = false, MinValue = 0f, MaxValue = 255f, Granularity = 1f, SoundName = "" }; SliderWidget widget = obj6; m_sliderR = obj6; children6.Add(widget); children5.Add(obj5); WidgetsList children7 = obj4.Children; StackPanelWidget obj7 = new StackPanelWidget { Direction = LayoutDirection.Horizontal, HorizontalAlignment = WidgetAlignment.Far, Margin = new Vector2(0f, 10f), Children = { (Widget) new LabelWidget { Text = "Green:", Color = Color.Gray, VerticalAlignment = WidgetAlignment.Center, Font = ContentManager.Get <BitmapFont>("Fonts/Pericles") }, (Widget) new CanvasWidget { Size = new Vector2(10f, 0f) } } }; WidgetsList children8 = obj7.Children; SliderWidget obj8 = new SliderWidget { Size = new Vector2(300f, 50f), IsLabelVisible = false, MinValue = 0f, MaxValue = 255f, Granularity = 1f, SoundName = "" }; widget = obj8; m_sliderG = obj8; children8.Add(widget); children7.Add(obj7); WidgetsList children9 = obj4.Children; StackPanelWidget obj9 = new StackPanelWidget { Direction = LayoutDirection.Horizontal, HorizontalAlignment = WidgetAlignment.Far, Margin = new Vector2(0f, 10f), Children = { (Widget) new LabelWidget { Text = "Blue:", Color = Color.Gray, VerticalAlignment = WidgetAlignment.Center, Font = ContentManager.Get <BitmapFont>("Fonts/Pericles") }, (Widget) new CanvasWidget { Size = new Vector2(10f, 0f) } } }; WidgetsList children10 = obj9.Children; SliderWidget obj10 = new SliderWidget { Size = new Vector2(300f, 50f), IsLabelVisible = false, MinValue = 0f, MaxValue = 255f, Granularity = 1f, SoundName = "" }; widget = obj10; m_sliderB = obj10; children10.Add(widget); children9.Add(obj9); children4.Add(obj4); obj3.Children.Add(new CanvasWidget { Size = new Vector2(20f, 0f) }); WidgetsList children11 = obj3.Children; CanvasWidget canvasWidget = new CanvasWidget(); WidgetsList children12 = canvasWidget.Children; BevelledButtonWidget obj11 = new BevelledButtonWidget { Size = new Vector2(200f, 240f), AmbientLight = 1f, HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center }; BevelledButtonWidget widget2 = obj11; m_rectangle = obj11; children12.Add(widget2); WidgetsList children13 = canvasWidget.Children; LabelWidget obj12 = new LabelWidget { HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center, Font = ContentManager.Get <BitmapFont>("Fonts/Pericles") }; LabelWidget widget3 = obj12; m_label = obj12; children13.Add(widget3); children11.Add(canvasWidget); children3.Add(obj3); obj2.Children.Add(new CanvasWidget { Size = new Vector2(0f, float.PositiveInfinity) }); WidgetsList children14 = obj2.Children; StackPanelWidget obj13 = new StackPanelWidget { Direction = LayoutDirection.Horizontal, HorizontalAlignment = WidgetAlignment.Center }; WidgetsList children15 = obj13.Children; BevelledButtonWidget obj14 = new BevelledButtonWidget { Size = new Vector2(160f, 60f), Text = LanguageControl.Get("Usual", "ok") }; ButtonWidget widget4 = obj14; m_okButton = obj14; children15.Add(widget4); obj13.Children.Add(new CanvasWidget { Size = new Vector2(50f, 0f) }); WidgetsList children16 = obj13.Children; BevelledButtonWidget obj15 = new BevelledButtonWidget { Size = new Vector2(160f, 60f), Text = "Cancel" }; widget4 = obj15; m_cancelButton = obj15; children16.Add(widget4); children14.Add(obj13); children2.Add(obj2); children.Add(obj); m_handler = handler; m_color = color; UpdateControls(); }
public Widget initButton() { StackPanelWidget stack = new StackPanelWidget() { Direction = LayoutDirection.Vertical }; for (int i = 0; i < 6; i++) { StackPanelWidget stackPanelWidget = new StackPanelWidget() { Direction = LayoutDirection.Horizontal }; for (int j = 0; j < 3; j++) { int cc = i * 3 + j; if (cc < 15) { int pp = cc + 1; stackPanelWidget.Children.Add(makeFuncButton(string.Format("{0}", MemoryBankData.m_hexChars[pp]), delegate() { AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); if (!isSetPos) { Write(clickpos, (byte)pp); //写入数据 lastvalue = pp; clickpos += 1; //自动加1 if (clickpos >= 255) { clickpos = 0; } isclick = true; } else { //处于设定位置模式 if (setPosN == 0) { clickpos = 16 * pp; } else if (setPosN == 1) { clickpos += pp; } setPosN += 1; if (setPosN == 2) { if (clickpos > 0xff) { clickpos = 0; } setPosN = 0; isclick = true; isSetPos = false; } } })); } else if (cc == 15) { stackPanelWidget.Children.Add(makeFuncButton(string.Format("{0}", MemoryBankData.m_hexChars[0]), delegate() { AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); if (!isSetPos) { Write(clickpos, (byte)0); //写入数据 lastvalue = 0; clickpos += 1; //自动加1 if (clickpos >= 255) { clickpos = 0; } isclick = true; } else { //处于设定位置模式 if (setPosN == 0) { clickpos = 0; } else if (setPosN == 1) { clickpos += 0; } setPosN += 1; if (setPosN == 2) { if (clickpos > 0xff) { clickpos = 0; } setPosN = 0; isclick = true; isSetPos = false; } } })); continue; } else if (cc == 16) { stackPanelWidget.Children.Add(makeFuncButton("清零", delegate() { AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); for (int ai = 0; ai < Data.Count; ai++) { Write(ai, 0); } isclick = true; })); continue; } else if (cc == 17) { stackPanelWidget.Children.Add(makeFuncButton("转置", delegate() { AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); DynamicArray <byte> tmp = new DynamicArray <byte>(); tmp.AddRange(Data); tmp.Count = 256; for (int c = 0; c < 16; c++) { for (int d = 0; d < 16; d++) { Write(c + d * 16, tmp[c * 16 + d]); } } clickpos = 0; isclick = true; })); continue; } } stack.Children.Add(stackPanelWidget); } LabelWidget labelWidget = new LabelWidget() { FontScale = 0.8f, Text = "输入全部数据:", HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = Color.DarkGray }; stack.Children.Add(labelWidget); stack.Children.Add(makeTextBox(delegate(TextBoxWidget textBoxWidget) { LoadString(textBoxWidget.Text); isclick = true; }, memory.SaveString(false))); stack.Children.Add(makeButton("保存数据", delegate() { for (int i = 0; i < Data.Count; i++) { memory.Write(i, Data[i]); } onCancel?.Invoke(); AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); DialogsManager.HideDialog(this); })); stack.Children.Add(makeButton("取消", delegate() { AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); DialogsManager.HideDialog(this); isclick = true; })); return(stack); }