public override void Load() { this.Width = 300; this.Height = 720; this.Scrollable = true; this.ScrollLimits = new Vector2(75, 1000); this.Name = "OPtions"; this.Background = AssetLoader.LoadTexture("Textures/ui/ui.png"); // get how many files are in the textures. var files = System.IO.Directory.GetFiles(this.path); int row = 0; // row to put tiles in int column = 0; for (int i = 0; i < files.Length; i++) { // create a button in the right row var button = new Button(files[i].Split('.')[0].Replace(this.path, "").Replace("\\", "")) { LocalPosition = new Vector2((column * 60) + 25, (row * 60) + 25) }; // load the texture button.LoadTextures(files[i], files[i]); button.OnClick += () => { EditorManager.TileMode = false; if (button.Name == "player") { EditorManager.currentMarker = new MapMarker(button.Name, Vector2.Zero, button.normalTexture, MarkerType.PlayerSpawnPoint); } else if (button.Name.Contains("npc")) { EditorManager.currentMarker = new MapMarker(button.Name, Vector2.Zero, button.normalTexture, MarkerType.NPCSpawnPoint); } else if (button.Name.Contains("light")) { EditorManager.currentMarker = new MapMarker(button.Name, Vector2.Zero, button.normalTexture, MarkerType.LightSource); } else { EditorManager.currentMarker = new MapMarker(button.Name, Vector2.Zero, button.normalTexture, MarkerType.SpawnPoint); } }; this.AddObject(button); column++; // prevetn overlap, every 3 squares go to the next row if (column > 3) { column = 0; row++; } } base.Load(); }
public override void Load() { this.Name = "fileui"; this.Scrollable = false; this.Background = AssetLoader.LoadTexture("Textures/ui/fileui.png"); this.Width = 1280; this.Height = 20; loadButton.LoadTextures("Textures/ui/load_button.png", "Textures/ui/load_button_hover.png"); loadButton.LocalPosition = new Vector2(0, 0); loadButton.OnClick += () => { System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog(); ofd.Filter = "Rey Map File|*.guat"; ofd.Title = "Save the map"; System.Windows.Forms.DialogResult dialogResult = ofd.ShowDialog(); if (ofd.FileName != "" && dialogResult == System.Windows.Forms.DialogResult.OK) { Load(ofd.FileName); } }; saveButton.LoadTextures("Textures/ui/save_button.png", "Textures/ui/save_button_hover.png"); saveButton.LocalPosition = new Vector2(100, 0); saveButton.OnClick += () => { // save the file System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog(); sfd.Filter = "Rey Map File|*.guat"; sfd.Title = "Save the map"; System.Windows.Forms.DialogResult dialogResult = sfd.ShowDialog(); if (sfd.FileName != "" && dialogResult == System.Windows.Forms.DialogResult.OK) { Save(sfd.FileName); } }; this.AddObject(loadButton); this.AddObject(saveButton); optionButton.LoadTextures("Textures/ui/options_button.png", "Textures/ui/options_button_hover.png"); optionButton.LocalPosition = new Vector2(200, 0); optionButton.OnClick += () => { OptionForm optionForm = new OptionForm(); optionForm.ShowDialog(); }; this.AddObject(optionButton); base.Load(); }
public override void Load() { this.Width = 300; this.Height = 720; this.Scrollable = true; this.ScrollLimits = new Vector2(75, 1000); this.Background = AssetLoader.LoadTexture("Textures/ui/ui.png"); // get how many files are in the textures. var files = System.IO.Directory.GetFiles(this.path); int row = 0; // row to put tiles in int column = 0; for (int i = 0; i < files.Length; i++) { // create a button in the right row var button = new Button(files[i].Split('.')[0].Replace(this.path, "").Replace("\\", "")) { LocalPosition = new Vector2((column * 60) + 25, (row * 60) + 25) }; // load the texture button.LoadTextures(files[i], files[i]); button.OnClick += () => { EditorManager.TileMode = true; EditorManager.currentTile = new Tile(button.Name, Vector2.Zero, button.normalTexture, this.tileType); EditorManager.currentTileName = button.Name; }; this.AddObject(button); column++; // prevetn overlap, every 3 squares go to the next row if (column > 3) { column = 0; row++; } } // remove the default tile this.objects.RemoveAll(x => x.Name == "default_tile"); // fix the delete button var deleteButton = this.objects.Find(x => x.Name == "delete"); if (deleteButton != null) { deleteButton.OnClick += () => { EditorManager.currentTile = new Tile("", Vector2.Zero, EditorManager.defaultTile, TileType.Empty); }; } base.Load(); }