Inheritance: System.Windows.Window
Exemplo n.º 1
0
        public static void SendCreateItem(CreateItemDialog dialog)
        {
            var args = new Dictionary<string, object>()
            {
                { "envID", dialog.Environment.ObjectID },
                { "area", dialog.Area },
                { "itemID", dialog.ItemID },
                { "materialID", dialog.MaterialID },
            };

            var script =
            @"env = world.GetObject(envID)
            for p in area.Range():
            builder = Dwarrowdelf.Server.ItemObjectBuilder(itemID, materialID)
            item = builder.Create(world)
            item.MoveTo(env, p)";

            var msg = new Dwarrowdelf.Messages.IPScriptMessage(script, args);

            GameData.Data.User.Send(msg);
        }
Exemplo n.º 2
0
		void MapControl_GotSelection(MapSelection selection)
		{
			var env = this.Map;

			switch (this.ClientTools.ToolMode)
			{
				case ClientToolMode.DesignationRemove:
					env.Designations.RemoveArea(selection.SelectionBox);
					break;

				case ClientToolMode.DesignationMine:
					env.Designations.AddArea(selection.SelectionBox, DesignationType.Mine);
					break;

				case ClientToolMode.DesignationStairs:
					env.Designations.AddArea(selection.SelectionBox, DesignationType.CreateStairs);
					break;

				case ClientToolMode.DesignationChannel:
					env.Designations.AddArea(selection.SelectionBox, DesignationType.Channel);
					break;

				case ClientToolMode.DesignationFellTree:
					env.Designations.AddArea(selection.SelectionBox, DesignationType.FellTree);
					break;

				case ClientToolMode.CreateStockpile:
					{
						var stockpile = Stockpile.CreateStockpile(env, selection.SelectionIntRectZ);

						var dlg = new ObjectEditDialog();
						dlg.DataContext = stockpile;
						dlg.Owner = this;
						dlg.Show();
					}
					break;

				case ClientToolMode.InstallItem:
					{
						var p = selection.SelectionPoint;

						var dlg = new InstallItemDialog();
						dlg.SetContext(env, p);

						var res = dlg.ShowDialog();

						if (res == true)
						{
							var item = dlg.SelectedItem;

							if (item != null)
								env.InstallItemManager.AddInstallJob(item, p);
						}
					}
					break;

				case ClientToolMode.BuildItem:
					{
						var p = selection.SelectionPoint;

						var workbench = env.GetContents(p).OfType<ItemObject>()
							.SingleOrDefault(i => i.IsInstalled && i.ItemCategory == ItemCategory.Workbench);

						if (workbench == null)
							break;

						var ctrl = new BuildingEditControl();
						ctrl.DataContext = BuildItemManager.FindOrCreateBuildItemManager(workbench);

						var dlg = new Window();
						dlg.Content = ctrl;

						var res = dlg.ShowDialog();

						if (res == true)
						{
						}
					}
					break;

				case ClientToolMode.SetTerrain:
					{
						var dialog = new SetTerrainDialog();
						dialog.Owner = this;
						if (m_setTerrainData != null)
							dialog.Data = m_setTerrainData;
						var res = dialog.ShowDialog();

						if (res == true)
						{
							var data = dialog.Data;
							m_setTerrainData = data;

							DebugScriptMessages.SendSetTerrains(dialog, map.Environment, selection.SelectionBox);
						}
					}
					break;

				case ClientToolMode.CreateItem:
					{
						var dialog = new CreateItemDialog();
						dialog.Owner = this;
						dialog.SetContext(env, selection.SelectionBox);
						var res = dialog.ShowDialog();

						if (res == true)
							DebugScriptMessages.SendCreateItem(dialog);
					}
					break;

				case ClientToolMode.CreateLiving:
					{
						var dialog = new CreateLivingDialog();
						dialog.Owner = this;
						dialog.SetContext(env, selection.SelectionIntRectZ);
						var res = dialog.ShowDialog();

						if (res == true)
							DebugScriptMessages.SendCreateLiving(dialog);
					}
					break;

				case ClientToolMode.ConstructRemove:
					env.ConstructManager.RemoveArea(selection.SelectionIntRectZ);
					break;

				case ClientToolMode.ConstructWall:
				case ClientToolMode.ConstructFloor:
				case ClientToolMode.ConstructPavement:
					{
						ConstructMode mode;

						switch (this.ClientTools.ToolMode)
						{
							case ClientToolMode.ConstructWall:
								mode = ConstructMode.Wall;
								break;

							case ClientToolMode.ConstructFloor:
								mode = ConstructMode.Floor;
								break;

							case ClientToolMode.ConstructPavement:
								mode = ConstructMode.Pavement;
								break;

							default:
								throw new Exception();
						}

						var dialog = new ConstructDialog();
						dialog.Owner = this;
						dialog.ConstructMode = mode;
						var res = dialog.ShowDialog();

						if (res == true)
						{
							var area = selection.SelectionIntRectZ;
							var filter = dialog.GetItemFilter();

							env.ConstructManager.AddConstructJob(mode, area, filter);
						}
					}
					break;

				default:
					throw new Exception();
			}

			this.MapControl.Selection = new MapSelection();
		}
Exemplo n.º 3
0
        void MapControl_GotSelection(MapSelection selection)
        {
            var env = this.Map;

            switch (this.ToolMode)
            {
            case ClientToolMode.View:
                ShowObjectsPopup(selection.SelectionPoint);
                break;

            case ClientToolMode.DesignationRemove:
                env.Designations.RemoveArea(selection.SelectionBox);
                break;

            case ClientToolMode.DesignationMine:
                env.Designations.AddArea(selection.SelectionBox, DesignationType.Mine);
                break;

            case ClientToolMode.DesignationStairs:
                env.Designations.AddArea(selection.SelectionBox, DesignationType.CreateStairs);
                break;

            case ClientToolMode.DesignationFellTree:
                env.Designations.AddArea(selection.SelectionBox, DesignationType.FellTree);
                break;

            case ClientToolMode.CreateStockpile:
            {
                var stockpile = Stockpile.CreateStockpile(env, selection.SelectionIntRectZ);

                var dlg = new ObjectEditDialog();
                dlg.DataContext = stockpile;
                dlg.Owner       = this;
                dlg.Show();
            }
            break;

            case ClientToolMode.InstallItem:
            {
                var p = selection.SelectionPoint;

                var dlg = new InstallItemDialog();
                dlg.SetContext(env, p);

                var res = dlg.ShowDialog();

                if (res == true)
                {
                    var item = dlg.SelectedItem;

                    if (item != null)
                    {
                        env.InstallItemManager.AddInstallJob(item, p);
                    }
                }
            }
            break;

            case ClientToolMode.BuildItem:
            {
                var p = selection.SelectionPoint;

                var workbench = env.GetContents(p).OfType <ItemObject>()
                                .SingleOrDefault(i => i.IsInstalled && i.ItemCategory == ItemCategory.Workbench);

                if (workbench == null)
                {
                    break;
                }

                var ctrl = new BuildingEditControl();
                ctrl.DataContext = BuildItemManager.FindOrCreateBuildItemManager(workbench);

                var dlg = new Window();
                dlg.Content = ctrl;

                var res = dlg.ShowDialog();

                if (res == true)
                {
                }
            }
            break;

            case ClientToolMode.SetTerrain:
            {
                var dialog = new SetTerrainDialog();
                dialog.Owner = this;
                if (m_setTerrainData != null)
                {
                    dialog.Data = m_setTerrainData;
                }
                var res = dialog.ShowDialog();

                if (res == true)
                {
                    var data = dialog.Data;
                    m_setTerrainData = data;

                    DebugScriptMessages.SendSetTerrains(dialog, map.Environment, selection.SelectionBox);
                }
            }
            break;

            case ClientToolMode.CreateItem:
            {
                var dialog = new CreateItemDialog();
                dialog.Owner = this;
                dialog.SetContext(env, selection.SelectionBox);
                var res = dialog.ShowDialog();

                if (res == true)
                {
                    DebugScriptMessages.SendCreateItem(dialog);
                }
            }
            break;

            case ClientToolMode.CreateLiving:
            {
                var dialog = new CreateLivingDialog();
                dialog.Owner = this;
                dialog.SetContext(env, selection.SelectionIntRectZ);
                var res = dialog.ShowDialog();

                if (res == true)
                {
                    DebugScriptMessages.SendCreateLiving(dialog);
                }
            }
            break;

            case ClientToolMode.ConstructRemove:
                env.ConstructManager.RemoveArea(selection.SelectionIntRectZ);
                break;

            case ClientToolMode.ConstructWall:
            case ClientToolMode.ConstructFloor:
            case ClientToolMode.ConstructPavement:
            {
                ConstructMode mode;

                switch (this.ToolMode)
                {
                case ClientToolMode.ConstructWall:
                    mode = ConstructMode.Wall;
                    break;

                case ClientToolMode.ConstructFloor:
                    mode = ConstructMode.Floor;
                    break;

                case ClientToolMode.ConstructPavement:
                    mode = ConstructMode.Pavement;
                    break;

                default:
                    throw new Exception();
                }

                var dialog = new ConstructDialog();
                dialog.Owner         = this;
                dialog.ConstructMode = mode;
                var res = dialog.ShowDialog();

                if (res == true)
                {
                    var area   = selection.SelectionIntRectZ;
                    var filter = dialog.GetItemFilter();

                    env.ConstructManager.AddConstructJob(mode, area, filter);
                }
            }
            break;

            default:
                throw new Exception();
            }

            this.MapControl.Selection = new MapSelection();
        }