コード例 #1
0
ファイル: frmEditor.cs プロジェクト: GodLesZ/svn-dump
		private void ProjectTreeNodeContextRename_Click(object sender, EventArgs e) {
			if (ProjectTree.SelectedNode == null || ProjectTree.SelectedNode == ProjectTree.Nodes[0]) {
				return;
			}

			var frm = new frmNewLayer {
				txtName = {
					Text = ProjectTree.SelectedNode.Text
				},
				chkBackground = {
					Checked = mTileMap.Layers[ProjectTree.SelectedNode.Index - 1].IsBackground
				},
				chkForeground = {
					Checked = !mTileMap.Layers[ProjectTree.SelectedNode.Index - 1].IsBackground
				}
			};
			frm.chkBackground.Enabled = false;
			frm.chkForeground.Enabled = false;
			frm.ShowDialog();
			if (frm.OKPressed == false) {
				return;
			}

			if (frm.txtName.Text == ProjectTree.SelectedNode.Text) {
				return;
			}

			mTileMap.Layers[mCurrentLayer].Name = frm.txtName.Text;
			ProjectTree.Nodes[0].Nodes[ProjectTree.SelectedNode.Index].Tag = frm.txtName.Text;
			ProjectTree.Nodes[0].Nodes[ProjectTree.SelectedNode.Index].Text = frm.txtName.Text;
			ProjectTree.Invalidate();
		}
コード例 #2
0
ファイル: frmEditor.cs プロジェクト: GodLesZ/svn-dump
		private void AddLayerToTree(string layername, bool canRename, int imageIndex, bool addContextMenu, bool canChoiceBgFg = true, bool isBackgroundSelected = true) {
			TreeNode node;

			var frm = new frmNewLayer {
				txtName = {
					Text = layername
				}
			};
			if (canRename || canChoiceBgFg) {
				if (canRename == false) {
					frm.txtName.ReadOnly = true;
				}
				if (canChoiceBgFg == false) {
					frm.chkBackground.Enabled = false;
					frm.chkForeground.Enabled = false;
				}
				frm.chkBackground.Checked = isBackgroundSelected;
				frm.chkForeground.Checked = !isBackgroundSelected;

				do {
					frm.ShowDialog();
				} while (frm.OKPressed == false);
			}

			var layer = new TileLayer(mTileMap.Width, mTileMap.Height);
			layer.Name = frm.txtName.Text;
			layer.IsBackground = frm.chkBackground.Checked;

			var lastBgIndex = GetLastBGIndex();
			// vor FG [wenn BG Layer] oder ans Ende [wenn FG Layer]
			// wnen keine Layer vorhanden, reicht Add()
			if (layer.IsBackground && lastBgIndex > -1 && lastBgIndex < mTileMap.Layers.Count) {
				node = ProjectTree.Nodes[0].Nodes.Insert(lastBgIndex + 2, layer.Name); // Tree enthält noch Collision 
				mTileMap.Layers.Insert(lastBgIndex + 1, layer);
			} else {
				node = ProjectTree.Nodes[0].Nodes.Add(layer.Name);
				mTileMap.Layers.Add(layer);
			}

			if (addContextMenu) {
				node.ContextMenuStrip = ProjectTreeNodeContext;
			}

			node.ImageIndex = (imageIndex != -1 ? imageIndex : (layer.IsBackground ? 1 : 3));
			node.SelectedImageIndex = imageIndex;
			node.Tag = layer.Name;

			ProjectTree.Nodes[0].Text = BuildMapName();

			if (layer.IsBackground && lastBgIndex > 0) {
				mLastTilesetIndex.Insert(lastBgIndex, 0);
				mLastAutotileIndex.Insert(lastBgIndex, 0);
				mLastAnimationIndex.Insert(lastBgIndex, 0);
				mLastObjectIndex.Insert(lastBgIndex, 0);
			} else {
				mLastTilesetIndex.Add(0);
				mLastAutotileIndex.Add(0);
				mLastAnimationIndex.Add(0);
				mLastObjectIndex.Add(0);
			}
		}