Example #1
0
        public LoadScene(TileData[] Tiles, Location Size) : base(Size)
        {
            Button BackButton = new Button(WBGame.ButtonSprite, "Back", 15, () =>
            {
                JuixelGame.Shared.ChangeScene(new SelectionScene(Size));
            });

            BackButton.Position = new Location(10 + BackButton.Size.X / 2, 10 + BackButton.Size.Y / 2);
            UI.AddChild(BackButton);

            this.Tiles   = Tiles;
            ImporterName = new TextField("Importer", Font.Default, new Location(200, 40), 20)
            {
                Position              = new Location(Size.X * 0.3, Size.Y * 0.4),
                AnchorPoint           = 0.5,
                UsePlaceholderAsTitle = true,
                Interactive           = false
            };
            ImporterName.CustomizeBackground(() => new SpriteNode(TextureLibrary.Square)
            {
                Size = new Location(0, 4), AnchorPoint = new Location(0, 1)
            }, (Node, BackSize) => Node.Size = new Location(BackSize.X, Node.Size.Y));
            AddChild(ImporterName);

            SelectImportButton          = new Button(WBGame.ButtonSprite, "Select Importer", 20, LoadImporter);
            SelectImportButton.Position = new Location(Size.X * 0.3, Size.Y * 0.4 + ImporterName.Size.Y + 20);
            AddChild(SelectImportButton);

            ImportButton          = new Button(WBGame.ButtonSprite, "Import", 20, ImportPressed);
            ImportButton.Position = new Location(Size.X * 0.3, SelectImportButton.Position.Y + SelectImportButton.Size.Y + 20);
            ImportButton.Hidden   = true;
            AddChild(ImportButton);

            LoadButton          = new Button(WBGame.ButtonSprite, "Load Map", 20, LoadPressed);
            LoadButton.Position = new Location(Size.X * 0.7, SelectImportButton.Position.Y);
            AddChild(LoadButton);

            SpriteNode Divider = new SpriteNode(TextureLibrary.Square);

            Divider.Size        = new Location(6, 300);
            Divider.AnchorPoint = 0.5;
            Divider.Position    = Size / 2;
            AddChild(Divider);

            string DefImporter = GameSettings.GetString("default_importer", "");

            if (DefImporter != "" && File.Exists(DefImporter))
            {
                LoadImporterFromFile(DefImporter);
            }

            LoadingBack             = new SpriteNode(TextureLibrary.Square);
            LoadingBack.Size        = new Location(300, 30);
            LoadingBack.AnchorPoint = 0.5;
            LoadingBack.Color       = new Color(24, 24, 24);
            LoadingBack.Position    = new Location(Size.X / 2, Size.Y * 0.8);
            LoadingBack.Hidden      = true;
            AddChild(LoadingBack);

            LoadingBar             = new SpriteNode(TextureLibrary.Square);
            LoadingBar.AnchorPoint = LoadingBack.AnchorPoint;
            LoadingBar.Color       = new Color(54, 54, 54);
            LoadingBar.Scale.X     = 0;
            LoadingBack.AddChild(LoadingBar);

            LoadingInfo             = new LabelNode(Font.Default, "", 16);
            LoadingInfo.AnchorPoint = new Location(0.5, 1);
            LoadingInfo.Position    = new Location(LoadingBack.Position.X, LoadingBack.Position.Y - 20);
            AddChild(LoadingInfo);
        }
Example #2
0
        public CreationScene(TileData[] Tiles, Location Size) : base(Size)
        {
            Button BackButton = new Button(WBGame.ButtonSprite, "Back", 15, () =>
            {
                JuixelGame.Shared.ChangeScene(new SelectionScene(Size));
            });

            BackButton.Position = new Location(10 + BackButton.Size.X / 2, 10 + BackButton.Size.Y / 2);
            UI.AddChild(BackButton);

            char[] NumeralCharFilter = "0123456789".ToCharArray();

            WidthField = new TextField("Map Width", Font.Default, new Location(200, 40), 20)
            {
                Position              = new Location(Size.X / 2, Size.Y * 0.2),
                AnchorPoint           = 0.5,
                UsePlaceholderAsTitle = true,
                MaxCharacters         = 5,
                CharFilter            = NumeralCharFilter
            };
            WidthField.OnTextChanged += CheckReady;
            WidthField.Text           = GameSettings.GetString("map_width", "");
            WidthField.CustomizeBackground(() => new SpriteNode(TextureLibrary.Square)
            {
                Size = new Location(0, 4), AnchorPoint = new Location(0, 1)
            }, (Node, BackSize) => Node.Size = new Location(BackSize.X, Node.Size.Y));
            AddChild(WidthField);

            HeightField = new TextField("Map Height", Font.Default, new Location(200, 40), 20)
            {
                Position              = new Location(Size.X / 2, Size.Y * 0.3),
                AnchorPoint           = 0.5,
                UsePlaceholderAsTitle = true,
                MaxCharacters         = 5,
                CharFilter            = NumeralCharFilter
            };
            HeightField.OnTextChanged += CheckReady;
            HeightField.Text           = GameSettings.GetString("map_height", "");
            HeightField.CustomizeBackground(() => new SpriteNode(TextureLibrary.Square)
            {
                Size = new Location(0, 4), AnchorPoint = new Location(0, 1)
            }, (Node, BackSize) => Node.Size = new Location(BackSize.X, Node.Size.Y));
            AddChild(HeightField);

            CreateMapButton = new Button(WBGame.ButtonSprite, "Create Map", 30, () =>
            {
                CheckReady();
                if (_Ready)
                {
                    int Width  = int.Parse(WidthField.Text);
                    int Height = int.Parse(HeightField.Text);
                    GameSettings.SetString("map_width", WidthField.Text);
                    GameSettings.SetString("map_height", HeightField.Text);
                    LoadingBack.Hidden = false;
                    CreateMap(Width, Height, Tiles, UpdateLoading);
                }
            })
            {
                Position = new Location(Size.X / 2, Size.Y * 0.6),
                Alpha    = 0
            };
            AddChild(CreateMapButton);

            CreateMapPosition = CreateMapButton.Position;

            LoadingBack             = new SpriteNode(TextureLibrary.Square);
            LoadingBack.Size        = new Location(300, 30);
            LoadingBack.AnchorPoint = 0.5;
            LoadingBack.Color       = new Color(24, 24, 24);
            LoadingBack.Position    = new Location(Size.X / 2, Size.Y * 0.75);
            LoadingBack.Hidden      = true;
            AddChild(LoadingBack);

            LoadingBar             = new SpriteNode(TextureLibrary.Square);
            LoadingBar.AnchorPoint = LoadingBack.AnchorPoint;
            LoadingBar.Color       = new Color(54, 54, 54);
            LoadingBar.Scale.X     = 0;
            LoadingBack.AddChild(LoadingBar);

            LoadingInfo             = new LabelNode(Font.Default, "", 16);
            LoadingInfo.AnchorPoint = new Location(0.5, 1);
            LoadingInfo.Position    = new Location(LoadingBack.Position.X, LoadingBack.Position.Y - 20);
            AddChild(LoadingInfo);

            _CanReady = true;
            CheckReady();
        }