private bool SelectPalette(object o) { ResetPalette(); string s = o.ToString(); if ("portal".Equals(s)) { using (RoomSelectorBox pb = new RoomSelectorBox()) { if (pb.ShowDialog() == DialogResult.OK && !string.IsNullOrWhiteSpace(pb.text.Text)) { s = pb.text.Text; } else { ResetPalette(); return(false); } } } selection = s[0]; return(true); }
public WorldPropertiesEditor() { InitializeComponent(); btnAddPortal.Click += (o, e) => { using (RoomSelectorBox sel = new RoomSelectorBox()) { if (sel.ShowDialog() == DialogResult.OK && !string.IsNullOrWhiteSpace(sel.text.Text)) { AddValueToDict(sel.text.Text[0], ""); } } }; }
public WorldEditor() { InitializeComponent(); // Ensure the world gets loaded here WorldFile temp = World; addRowBtn.Click += (o, e) => AddRow(); addColBtn.Click += (o, e) => AddColumn(); remRowBtn.Click += (o, e) => RemoveRow(); remColBtn.Click += (o, e) => RemoveColumn(); setSizeBtn.Click += (o, e) => { using (WorldSizeSetter dialog = new WorldSizeSetter()) { dialog.width.Value = roomWidth; dialog.height.Value = roomHeight; if (dialog.ShowDialog(this) == DialogResult.OK) { SetSize((int)dialog.width.Value, (int)dialog.height.Value); } } }; btnNudgeUp.Click += (o, e) => Nudge(ArrowDirection.Up); btnNudgeDown.Click += (o, e) => Nudge(ArrowDirection.Down); btnNudgeLeft.Click += (o, e) => Nudge(ArrowDirection.Left); btnNudgeRight.Click += (o, e) => Nudge(ArrowDirection.Right); btnNew.Click += (o, e) => { using (RoomSelectorBox sel = new RoomSelectorBox()) { if (sel.ShowDialog() == DialogResult.OK && !string.IsNullOrWhiteSpace(sel.text.Text)) { CreateRoom(sel.text.Text[0]); } } }; btnRename.Click += (o, e) => { using (RoomSelectorBox sel = new RoomSelectorBox()) { sel.text.Text = currentRoomId.ToString(); if (sel.ShowDialog() == DialogResult.OK && !string.IsNullOrWhiteSpace(sel.text.Text) && !rooms.ContainsKey(sel.text.Text[0])) { currentRoomId = sel.text.Text[0]; } } }; btnDelete.Click += (o, e) => DeleteRoom(); btnSave.Click += (o, e) => Save(); btnProperties.Click += (o, e) => { using (RoomDataEditor rd = new RoomDataEditor()) { if (!roomsData.ContainsKey(currentRoomId)) { roomsData[currentRoomId] = new Room(); } rd.RoomId = currentRoomId; rd.floor.Text = roomsData[currentRoomId].floor; rd.floor2.Text = roomsData[currentRoomId].floor2; rd.wall.Text = roomsData[currentRoomId].wall; rd.wall2.Text = roomsData[currentRoomId].wall2; rd.floorHeight.Value = (decimal)roomsData[currentRoomId].floorHeight; rd.floor2Height.Value = (decimal)roomsData[currentRoomId].floor2Height; rd.wallHeight.Value = (decimal)roomsData[currentRoomId].wallHeight; rd.wall2Height.Value = (decimal)roomsData[currentRoomId].wall2Height; if (rd.ShowDialog() == DialogResult.OK) { if (!roomsData.ContainsKey(currentRoomId)) { roomsData[currentRoomId] = new Room(); } if (!string.IsNullOrWhiteSpace(rd.floor.Text)) { roomsData[currentRoomId].floor = rd.floor.Text; } if (!string.IsNullOrWhiteSpace(rd.wall.Text)) { roomsData[currentRoomId].wall = rd.wall.Text; } if (!string.IsNullOrWhiteSpace(rd.floor2.Text)) { roomsData[currentRoomId].floor2 = rd.floor2.Text; } if (!string.IsNullOrWhiteSpace(rd.wall2.Text)) { roomsData[currentRoomId].wall2 = rd.wall2.Text; } roomsData[currentRoomId].floorHeight = (float)rd.floorHeight.Value; roomsData[currentRoomId].floor2Height = (float)rd.floor2Height.Value; roomsData[currentRoomId].wallHeight = (float)rd.wallHeight.Value; roomsData[currentRoomId].wall2Height = (float)rd.wall2Height.Value; SoftUpdateWorld(); } } }; btnWorldProperties.Click += (o, e) => { using (WorldPropertiesEditor wpe = new WorldPropertiesEditor()) { wpe.CustomPortals = customPortals; wpe.startingRoom.Text = startingRoom.ToString(); if (wpe.ShowDialog() == DialogResult.OK) { if (!string.IsNullOrWhiteSpace(wpe.startingRoom.Text)) { startingRoom = wpe.startingRoom.Text[0]; } customPortals = wpe.CustomPortals; } } }; btnLoadImage.Click += (o, e) => { if (openImageDialog.ShowDialog() == DialogResult.OK) { LoadImage(openImageDialog.FileName); } }; rooms = new Dictionary <char, List <List <char> > >(); currentRoom = new List <List <char> >(); foreach (KeyValuePair <char, string> pair in World.keys) { PaletteItem pi = new PaletteItem { Parent = palette, Image = World.GetTexture(pair.Value), Text = pair.Key.ToString() }; if (World.labels.ContainsKey(pair.Key)) { pi.Text += " " + World.labels[pair.Key]; } pi.selectCallbackParam = pair.Key; pi.selectCallback = SelectPalette; } PaletteItem portal = new PaletteItem { Parent = palette, Image = World.GetTexture(World.portal), Text = "(Portal)", selectCallbackParam = "portal", selectCallback = SelectPalette }; UpdateWorld(); }