// ------------------------------------------------------------------- // SetIconsTreeNodes // ------------------------------------------------------------------- public static void SetIconsTreeNodes(IEnumerable <TreeNode> treeNodeCollection) { foreach (TreeNode node in treeNodeCollection) { TreeTag tag = (TreeTag)node.Tag; if (tag.IsMap) { MapInfos mapInfos = LoadBinaryDatas <MapInfos>(Path.Combine(MapsDirectoryPath, tag.RealMapName, "infos.map")); node.Tag = TreeTag.CreateMap(mapInfos.MapName, tag.RealMapName); node.Text = mapInfos.MapName; node.ImageIndex = 1; node.SelectedImageIndex = 1; } TreeNode[] nodes = new TreeNode[node.Nodes.Count]; node.Nodes.CopyTo(nodes, 0); SetIconsTreeNodes(nodes); } }
// ------------------------------------------------------------------- // PasteMap // ------------------------------------------------------------------- public string PasteMap(string mapName) { string newMapName = WANOK.GenerateMapName(); Directory.CreateDirectory(Path.Combine(WANOK.MapsDirectoryPath, newMapName)); string[] filePaths = Directory.GetFiles(Path.Combine(WANOK.MapsDirectoryPath, mapName, "temp")); if (filePaths.Length == 0) { filePaths = Directory.GetFiles(Path.Combine(WANOK.MapsDirectoryPath, mapName)); } foreach (string filePath in filePaths) { File.Copy(filePath, Path.Combine(WANOK.MapsDirectoryPath, newMapName, Path.GetFileName(filePath))); } Directory.CreateDirectory(Path.Combine(WANOK.MapsDirectoryPath, newMapName, "temp")); string infosPath = Path.Combine(WANOK.MapsDirectoryPath, newMapName, "infos.map"); MapInfos mapInfos = WANOK.LoadBinaryDatas <MapInfos>(infosPath); mapInfos.RealMapName = newMapName; WANOK.SaveBinaryDatas(mapInfos, infosPath); return(newMapName); }
// ------------------------------------------------------------------- // Constructor // ------------------------------------------------------------------- public DialogNewMap(MapInfos mapInfos = null) { InitializeComponent(); // Control Control = (mapInfos == null) ? new DialogNewMapControl() : new DialogNewMapControl(mapInfos); ViewModelBindingSource.DataSource = Control; InitializeDataBindings(); // Paint groupBox groupBox1.Paint += MainForm.PaintBorderGroupBox; groupBox2.Paint += MainForm.PaintBorderGroupBox; groupBox3.Paint += MainForm.PaintBorderGroupBox; // ComboBox for (int i = 0; i < WANOK.Game.Tilesets.TilesetsList.Count; i++) { ComboBoxTileset.Items.Add(WANOK.GetStringComboBox(WANOK.Game.Tilesets.TilesetsList[i].Id, WANOK.Game.Tilesets.TilesetsList[i].Name)); } ComboBoxTileset.SelectedIndex = WANOK.Game.Tilesets.GetTilesetIndexById(Control.Model.Tileset); for (int i = 0; i < WANOK.Game.System.Colors.Count; i++) { ComboBoxColor.Items.Add(WANOK.GetStringComboBox(WANOK.Game.System.Colors[i].Id, WANOK.Game.System.Colors[i].Name)); } ComboBoxColor.SelectedIndex = WANOK.Game.System.GetColorIndexById(Control.Model.SkyColor); if (ComboBoxSkyBox.Items.Count > 0) { ComboBoxSkyBox.SelectedIndex = 0; } // Is setting if (mapInfos != null) { Text = "Set map"; } }
// ------------------------------------------------------------------- // Update // ------------------------------------------------------------------- public bool Update(GameTime gameTime, Camera camera, MapInfos map) { double angle = camera.HorizontalAngle; int x = GetX(), z = GetZ(), x_plus, z_plus; bool moving = false; if (WANOK.KeyboardManager.IsButtonDown(WANOK.Settings.KeyboardAssign.EditorMoveUp) || WANOK.KeyboardManager.IsButtonDown(WANOK.Settings.KeyboardAssign.EditorMoveDown) || WANOK.KeyboardManager.IsButtonDown(WANOK.Settings.KeyboardAssign.EditorMoveLeft) || WANOK.KeyboardManager.IsButtonDown(WANOK.Settings.KeyboardAssign.EditorMoveRight)) { CursorWait = CursorWaitDuration; } if (WANOK.KeyboardManager.IsButtonDownFirstAndRepeat(WANOK.Settings.KeyboardAssign.EditorMoveUp, CursorWait)) // Up { x_plus = (int)(WANOK.SQUARE_SIZE * (Math.Round(Math.Cos(angle * Math.PI / 180.0)))); z_plus = (int)(WANOK.SQUARE_SIZE * (Math.Round(Math.Sin(angle * Math.PI / 180.0)))); if ((z > 0 && z_plus < 0) || (z < map.Height - 1 && z_plus > 0)) { Position.Z += z_plus; } if (z_plus == 0 && ((x > 0 && x_plus < 0) || (x < map.Width - 1 && x_plus > 0))) { Position.X += x_plus; } moving = true; } if (WANOK.KeyboardManager.IsButtonDownFirstAndRepeat(WANOK.Settings.KeyboardAssign.EditorMoveDown, CursorWait)) // Down { x_plus = (int)(WANOK.SQUARE_SIZE * (Math.Round(Math.Cos(angle * Math.PI / 180.0)))); z_plus = (int)(WANOK.SQUARE_SIZE * (Math.Round(Math.Sin(angle * Math.PI / 180.0)))); if ((z < map.Height - 1 && z_plus < 0) || (z > 0 && z_plus > 0)) { Position.Z -= z_plus; } if (z_plus == 0 && ((x < map.Width - 1 && x_plus < 0) || (x > 0 && x_plus > 0))) { Position.X -= x_plus; } moving = true; } if (WANOK.KeyboardManager.IsButtonDownFirstAndRepeat(WANOK.Settings.KeyboardAssign.EditorMoveLeft, CursorWait)) // Left { x_plus = (int)(WANOK.SQUARE_SIZE * (Math.Round(Math.Cos((angle - 90.0) * Math.PI / 180.0)))); z_plus = (int)(WANOK.SQUARE_SIZE * (Math.Round(Math.Sin((angle - 90.0) * Math.PI / 180.0)))); if ((x > 0 && x_plus < 0) || (x < map.Width - 1 && x_plus > 0)) { Position.X += x_plus; } if (x_plus == 0 && ((z > 0 && z_plus < 0) || (z < map.Height - 1 && z_plus > 0))) { Position.Z += z_plus; } moving = true; } if (WANOK.KeyboardManager.IsButtonDownFirstAndRepeat(WANOK.Settings.KeyboardAssign.EditorMoveRight, CursorWait)) // Right { x_plus = (int)(WANOK.SQUARE_SIZE * (Math.Round(Math.Cos((angle - 90.0) * Math.PI / 180.0)))); z_plus = (int)(WANOK.SQUARE_SIZE * (Math.Round(Math.Sin((angle - 90.0) * Math.PI / 180.0)))); if ((x < map.Width - 1 && x_plus < 0) || (x > 0 && x_plus > 0)) { Position.X -= x_plus; } if (x_plus == 0 && ((z < map.Height - 1 && z_plus < 0) || (z > 0 && z_plus > 0))) { Position.Z -= z_plus; } moving = true; } // Frames update FrameTick += gameTime.ElapsedGameTime.Milliseconds; if (FrameTick >= FrameDuration) { Frame += 1; if (Frame > 3) { Frame = 0; } FrameTick = 0; } if (CursorWait > 0) { CursorWait--; } return(moving); }
public static void SaveMapInfos(MapInfos mapInfos, string mapName) { SaveBinaryDatas(mapInfos, Path.Combine(MapsDirectoryPath, mapName, "temp", "infos.map")); }