Ejemplo n.º 1
0
        private void FillWorldList()
        {
            Debug.Assert(worldList != null);

            worldList.DeleteAllChildren();

            foreach ((WorldInformation info, string path) in worldProvider.Worlds)
            {
                GroupBox world = new(worldList)
                {
                    Text = info.Name
                };

                DockLayout layout = new(world);

                VerticalLayout infoPanel = new(layout)
                {
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Center
                };

                Label date = new(infoPanel)
                {
                    Text = $"{info.Creation.ToLongDateString()} - {info.Creation.ToLongTimeString()}",
                    Font = Fonts.Small
                };

                Label version = new(infoPanel)
                {
                    Text      = info.Version,
                    Font      = Fonts.Small,
                    TextColor = GameInformation.Instance.Version == info.Version ? Color.Green : Color.Red
                };

                Label file = new(infoPanel)
                {
                    Text      = path,
                    Font      = Fonts.Path,
                    TextColor = Color.Grey
                };

                HorizontalLayout buttons = new(layout)
                {
                    HorizontalAlignment = HorizontalAlignment.Right,
                    VerticalAlignment   = VerticalAlignment.Center
                };

                Button load = new(buttons)
                {
                    ImageName   = Source.GetIconName("load"),
                    ImageSize   = new Size(width: 40, height: 40),
                    ToolTipText = Language.Load
                };

                Button delete = new(buttons)
                {
                    ImageName   = Source.GetIconName("delete"),
                    ImageSize   = new Size(width: 40, height: 40),
                    ToolTipText = Language.Delete
                };

                load.Pressed += (_, _) => worldProvider.LoadWorld(info, path);

                delete.Pressed += (_, _) => Modals.OpenBooleanModal(
                    this,
                    Language.DeleteWorldQuery,
                    () =>
                {
                    worldProvider.DeleteWorld(path);
                    Refresh();
                },
                    () => {});
            }
        }