Exemple #1
0
        public override void Construct()
        {
            AutoSizeColumns = true;
            IsRootTray      = true;

            ItemSource = new Gui.Widget[]
            {
                new HorizontalMenuTray.MenuItem
                {
                    Text = "CHEAT MODE",
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "DEBUG",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSize   = new Point(200, 20),
                        ItemSource = Debugger.EnumerateSwitches().Select(s =>
                                                                         new HorizontalMenuTray.CheckboxMenuItem
                        {
                            Text         = Debugger.GetNicelyFormattedName(s.Name),
                            InitialState = s.State,
                            SetCallback  = s.Set
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "DEBUG SAVE",
                    OnClick = (sender, args) =>
                    {
                        // Turn off binary compressed saves and save a nice straight json save for debugging purposes.

                        // Todo: Why isn't World managing this paused state itself?
                        bool paused          = Master.World.Paused;
                        var  previousSetting = DwarfGame.COMPRESSED_BINARY_SAVES;
                        DwarfGame.COMPRESSED_BINARY_SAVES = false;
                        Master.World.Save(
                            String.Format("{0}_{1}_DEBUG", Overworld.Name, Master.World.GameID),
                            (success, exception) =>
                        {
                            Master.World.MakeAnnouncement(success ? "Debug save created.": "Debug save failed - " + exception.Message);
                            DwarfGame.COMPRESSED_BINARY_SAVES = previousSetting;
                            Master.World.Paused = paused;
                        });
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "BUILD",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = RoomLibrary.GetRoomTypes().Select(r =>
                                                                       new HorizontalMenuTray.MenuItem
                        {
                            Text    = r,
                            OnClick = (sender, args) => ActivateGodTool("Build/" + r)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "SPAWN",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 5,
                        ItemSource = EntityFactory.EnumerateEntityTypes().Where(s => !s.Contains("Resource") ||
                                                                                !ResourceLibrary.GetResourceByName(s.Substring(0, s.Length - " Resource".Length)).Generated).OrderBy(s => s).Select(s =>
                                                                                                                                                                                                    new HorizontalMenuTray.MenuItem
                        {
                            Text    = s,
                            OnClick = (sender, args) => ActivateGodTool("Spawn/" + s)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "PLACE BLOCK",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 3,
                        ItemSource = VoxelLibrary.PrimitiveMap.Keys
                                     .Where(t => t.Name != "empty" && t.Name != "water")
                                     .OrderBy(s => s.Name)
                                     .Select(s =>
                                             new HorizontalMenuTray.MenuItem
                        {
                            Text    = s.Name,
                            OnClick = (sender, args) => ActivateGodTool("Place/" + s.Name)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "DELETE BLOCK",
                    OnClick = (sender, args) => ActivateGodTool("Delete Block")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "KILL BLOCK",
                    OnClick = (sender, args) => ActivateGodTool("Kill Block")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "PLACE GRASS",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 3,
                        ItemSource = GrassLibrary.TypeList
                                     .OrderBy(s => s.Name)
                                     .Select(s =>
                                             new HorizontalMenuTray.MenuItem
                        {
                            Text    = s.Name,
                            OnClick = (sender, args) => ActivateGodTool("Grass/" + s.Name)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "PLACE DECAL",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 3,
                        ItemSource = DecalLibrary.TypeList
                                     .OrderBy(s => s.Name)
                                     .Select(s =>
                                             new HorizontalMenuTray.MenuItem
                        {
                            Text    = s.Name,
                            OnClick = (sender, args) => ActivateGodTool("Decal/" + s.Name)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "PLACE RAIL",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 1,
                        ItemSource = new HorizontalMenuTray.MenuItem[]
                        {
                            new HorizontalMenuTray.MenuItem
                            {
                                Text           = "RAW PIECES",
                                ExpansionChild = new HorizontalMenuTray.Tray
                                {
                                    Columns    = 2,
                                    ItemSize   = new Point(200, 20),
                                    ItemSource = Rail.RailLibrary.EnumeratePieces().Select(p =>
                                                                                           new HorizontalMenuTray.MenuItem
                                    {
                                        Text    = p.Name,
                                        OnClick = (sender, args) => ActivateGodTool("Rail/" + p.Name)
                                    })
                                }
                            },

                            new HorizontalMenuTray.MenuItem
                            {
                                Text           = "USING PATTERNS",
                                ExpansionChild = new HorizontalMenuTray.Tray
                                {
                                    Columns    = 1,
                                    ItemSource = Rail.RailLibrary.EnumeratePatterns().Select(p =>
                                                                                             new HorizontalMenuTray.MenuItem
                                    {
                                        Text    = p.Name,
                                        OnClick = (sender, args) =>
                                        {
                                            var railTool     = Master.Tools[GameMaster.ToolMode.BuildRail] as Rail.BuildRailTool;
                                            railTool.Pattern = p;
                                            Master.ChangeTool(GameMaster.ToolMode.BuildRail);
                                            railTool.GodModeSwitch = true;
                                        }
                                    })
                                }
                            },

                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "PAINT",
                                OnClick = (sender, args) =>
                                {
                                    var railTool = Master.Tools[GameMaster.ToolMode.PaintRail] as Rail.PaintRailTool;
                                    railTool.SelectedResources = new List <ResourceAmount>(new ResourceAmount[] { new ResourceAmount("Rail", 1) });
                                    Master.ChangeTool(GameMaster.ToolMode.PaintRail);
                                    railTool.GodModeSwitch = true;
                                }
                            }
                        }
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "KILL THINGS",
                    OnClick = (sender, args) => ActivateGodTool("Kill Things")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "TRAILER",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = new List <HorizontalMenuTray.MenuItem>()
                        {
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "SPIN +",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Zero, 2.0f, 0.0f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "SPIN -",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Zero, -2.0f, 0.0f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "ZOOM -",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Zero, 0.0f, 2.5f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "ZOOM +",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Zero, 0.0f, -2.5f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "FWD",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Forward * 5, 0.0f, 0.0f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "BACK",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Backward * 5, 0.0f, 0.0f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "LEFT",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Left * 5, 0.0f, 0.0f),
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "RIGHT",
                                OnClick = (sender, args) => this.Master.World.Camera.Trailer(Vector3.Right * 5, 0.0f, 0.0f),
                            },
                        }
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "FILL WATER",
                    OnClick = (sender, args) => ActivateGodTool("Fill Water")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "FILL LAVA",
                    OnClick = (sender, args) => ActivateGodTool("Fill Lava")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "TRADE ENVOY",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = Master.World.Factions.Factions.Values.Where(f => f.Race.IsIntelligent && f != Master.Faction).Select(s =>
                        {
                            return(new HorizontalMenuTray.MenuItem
                            {
                                Text = s.Name,
                                OnClick = (sender, args) => Master.World.Diplomacy.SendTradeEnvoy(s, Master.World)
                            });
                        }),
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text           = "EVENT",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = Master.World.GoalManager.EventScheduler.Events.Events.Select(e =>
                        {
                            return(new HorizontalMenuTray.MenuItem
                            {
                                Text = e.Name,
                                OnClick = (sender, args) => Master.World.GoalManager.EventScheduler.ActivateEvent(Master.World, e)
                            });
                        }),
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text           = "WAR PARTY",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = Master.World.Factions.Factions.Values.Where(f => f.Race.IsIntelligent && f != Master.Faction).Select(s =>
                        {
                            return(new HorizontalMenuTray.MenuItem
                            {
                                Text = s.Name,
                                OnClick = (sender, args) => Master.World.Diplomacy.SendWarParty(s)
                            });
                        }),
                    }
                },


                new HorizontalMenuTray.MenuItem
                {
                    Text    = "DWARF BUX",
                    OnClick = (sender, args) => Master.Faction.AddMoney(100m)
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "MINIONS",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = new HorizontalMenuTray.MenuItem[]
                        {
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "PAY",
                                OnClick = (sender, args) => Master.PayEmployees()
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "STARVE",
                                OnClick = (sender, args) =>
                                {
                                    foreach (var minion in Master.Faction.Minions)
                                    {
                                        minion.Status.Hunger.CurrentValue = 0;
                                    }
                                }
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "XP",
                                OnClick = (sender, args) =>
                                {
                                    foreach (var minion in Master.Faction.Minions)
                                    {
                                        minion.AddXP(100);
                                    }
                                }
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "DISEASE",
                                OnClick = (sender, args) => ActivateGodTool("Disease")
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "HAPPY",
                                OnClick = (sender, args) =>
                                {
                                    foreach (var minion in Master.Faction.Minions)
                                    {
                                        var thoughts = minion.GetRoot().GetComponent <DwarfThoughts>();
                                        if (thoughts != null)
                                        {
                                            thoughts.AddThought(Thought.ThoughtType.CheatedHappy);
                                        }
                                    }
                                }
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "PISSED",
                                OnClick = (sender, args) =>
                                {
                                    foreach (var minion in Master.Faction.Minions)
                                    {
                                        var thoughts = minion.GetRoot().GetComponent <DwarfThoughts>();
                                        if (thoughts != null)
                                        {
                                            thoughts.AddThought(Thought.ThoughtType.CheatedPissed);
                                        }
                                    }
                                }
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "GAMBLE",
                                OnClick = (sender, args) =>
                                {
                                    foreach (var employee in Master.Faction.Minions)
                                    {
                                        employee.AssignTask(new Scripting.GambleTask()
                                        {
                                            Priority = Task.PriorityType.High
                                        });
                                    }
                                }
                            },
                            new HorizontalMenuTray.MenuItem
                            {
                                Text    = "PASS OUT",
                                OnClick = (sender, args) =>
                                {
                                    var employee = Datastructures.SelectRandom(Master.Faction.Minions);
                                    if (employee != null)
                                    {
                                        employee.Creature.Heal(-employee.Status.Health.CurrentValue * employee.Creature.MaxHealth + 1);
                                    }
                                }
                            }
                        }
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "SPAWN TEST",
                    OnClick = (sender, args) =>
                    {
                        // Copy is required because spawning some types results in the creation of new types. EG, snakes create snake meat.
                        var     keys       = EntityFactory.EnumerateEntityTypes().ToList();
                        int     num        = keys.Count();
                        float   gridSize   = (float)Math.Ceiling(Math.Sqrt((double)num));
                        Vector3 gridCenter = Master.World.CursorLightPos;
                        int     i          = 0;
                        for (float dx = -gridSize / 2; dx <= gridSize / 2; dx++)
                        {
                            for (float dz = -gridSize / 2; dz <= gridSize / 2; dz++)
                            {
                                if (i >= num)
                                {
                                    continue;
                                }

                                Vector3     pos    = MathFunctions.Clamp(gridCenter + new Vector3(dx, VoxelConstants.ChunkSizeY, dz), Master.World.ChunkManager.Bounds);
                                VoxelHandle handle = VoxelHelpers.FindFirstVisibleVoxelOnRay(Master.World.ChunkManager.ChunkData, pos, pos + Vector3.Down * 100);
                                if (handle.IsValid)
                                {
                                    EntityFactory.CreateEntity <GameComponent>(keys[i], handle.WorldPosition + Vector3.Up);
                                }
                                i++;
                            }
                        }
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "SPAWN CRAFTS",
                    OnClick = (sender, args) =>
                    {
                        // Copy is required because spawning some types results in the creation of new types. EG, snakes create snake meat.
                        var     itemTypes  = CraftLibrary.EnumerateCraftables().Where(craft => craft.Type == CraftItem.CraftType.Object).ToList();
                        int     num        = itemTypes.Count();
                        float   gridSize   = (float)Math.Ceiling(Math.Sqrt((double)num));
                        Vector3 gridCenter = Master.World.CursorLightPos;

                        int i = 0;
                        for (float dx = -gridSize / 2; dx <= gridSize / 2; dx++)
                        {
                            for (float dz = -gridSize / 2; dz <= gridSize / 2; dz++)
                            {
                                if (i < num)
                                {
                                    var item = itemTypes[i];
                                    if (item.Name != "Explosive")
                                    {
                                        Vector3     pos    = MathFunctions.Clamp(gridCenter + new Vector3(dx, VoxelConstants.ChunkSizeY, dz), Master.World.ChunkManager.Bounds);
                                        VoxelHandle handle = VoxelHelpers.FindFirstVisibleVoxelOnRay(Master.World.ChunkManager.ChunkData, pos, pos + Vector3.Down * 100);

                                        if (handle.IsValid)
                                        {
                                            var blackboard = new Blackboard();
                                            List <ResourceAmount> resources = item.RequiredResources.Select(r => new ResourceAmount(ResourceLibrary.GetResourcesByTag(r.ResourceType).First(), r.NumResources)).ToList();
                                            blackboard.SetData <List <ResourceAmount> >("Resources", resources);
                                            blackboard.SetData <string>("CraftType", item.Name);

                                            var entity = EntityFactory.CreateEntity <GameComponent>(item.EntityName, handle.WorldPosition + Vector3.Up + item.SpawnOffset, blackboard);
                                            if (entity != null)
                                            {
                                                if (item.AddToOwnedPool)
                                                {
                                                    Master.Faction.OwnedObjects.Add(entity as Body);
                                                }
                                                if (item.Moveable)
                                                {
                                                    entity.Tags.Add("Moveable");
                                                }
                                                if (item.Deconstructable)
                                                {
                                                    entity.Tags.Add("Deconstructable");
                                                }
                                            }
                                        }
                                    }
                                }
                                i++;
                            }
                        }
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "+1 HOUR",
                    OnClick = (sender, args) =>
                    {
                        Master.World.Time.CurrentDate += new TimeSpan(1, 0, 0);
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "FORCE REBUILD",
                    OnClick = (sender, args) =>
                    {
                        foreach (var chunk in Master.World.ChunkManager.ChunkData.ChunkMap)
                        {
                            for (int Y = 0; Y < VoxelConstants.ChunkSizeY; ++Y)
                            {
                                chunk.InvalidateSlice(Y);
                            }
                        }
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "REPULSE",
                    OnClick = (sender, args) => ActivateGodTool("Repulse")
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "SLOWMO",
                    OnClick = (sender, args) => GameSettings.Default.EnableSlowMotion = !GameSettings.Default.EnableSlowMotion
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "LET IT SNOW",
                    OnClick = (sender, args) =>
                    {
                        var storm = Weather.CreateStorm(Vector3.One, 100.0f, Master.World);
                        storm.TypeofStorm = StormType.SnowStorm;
                        storm.Start();
                    }
                }
            };

            base.Construct();
        }
Exemple #2
0
        public override void Construct()
        {
            IsRootTray = true;

            ItemSource = new Gui.Widget[]
            {
                new HorizontalMenuTray.MenuItem
                {
                    Text = "CHEAT MODE",
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text           = "BUILD",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = RoomLibrary.GetRoomTypes().Select(r =>
                                                                       new HorizontalMenuTray.MenuItem
                        {
                            Text    = r,
                            OnClick = (sender, args) => ActivateGodTool("Build/" + r)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "SPAWN",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 5,
                        ItemSource = EntityFactory.EntityFuncs.Keys.OrderBy(s => s).Select(s =>
                                                                                           new HorizontalMenuTray.MenuItem
                        {
                            Text    = s,
                            OnClick = (sender, args) => ActivateGodTool("Spawn/" + s)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "PLACE",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 3,
                        ItemSource = VoxelLibrary.PrimitiveMap.Keys
                                     .Where(t => t.Name != "empty" && t.Name != "water")
                                     .OrderBy(s => s.Name)
                                     .Select(s =>
                                             new HorizontalMenuTray.MenuItem
                        {
                            Text    = s.Name,
                            OnClick = (sender, args) => ActivateGodTool("Place/" + s.Name)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "DELETE BLOCK",
                    OnClick = (sender, args) => ActivateGodTool("Delete Block")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "KILL BLOCK",
                    OnClick = (sender, args) => ActivateGodTool("Kill Block")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "PLACE GRASS",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 3,
                        ItemSource = GrassLibrary.TypeList
                                     .OrderBy(s => s.Name)
                                     .Select(s =>
                                             new HorizontalMenuTray.MenuItem
                        {
                            Text    = s.Name,
                            OnClick = (sender, args) => ActivateGodTool("Grass/" + s.Name)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "PLACE DECAL",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        Columns    = 3,
                        ItemSource = DecalLibrary.TypeList
                                     .OrderBy(s => s.Name)
                                     .Select(s =>
                                             new HorizontalMenuTray.MenuItem
                        {
                            Text    = s.Name,
                            OnClick = (sender, args) => ActivateGodTool("Decal/" + s.Name)
                        })
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "KILL THINGS",
                    OnClick = (sender, args) => ActivateGodTool("Kill Things")
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "DISEASE",
                    OnClick = (sender, args) => ActivateGodTool("Disease")
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "FILL WATER",
                    OnClick = (sender, args) => ActivateGodTool("Fill Water")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "FILL LAVA",
                    OnClick = (sender, args) => ActivateGodTool("Fill Lava")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "FIRE",
                    OnClick = (sender, args) => ActivateGodTool("Fire")
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text           = "TRADE ENVOY",
                    ExpansionChild = new HorizontalMenuTray.Tray
                    {
                        ItemSource = Master.World.Factions.Factions.Values.Where(f => f.Race.IsIntelligent && f != Master.Faction).Select(s =>
                        {
                            return(new HorizontalMenuTray.MenuItem
                            {
                                Text = s.Name,
                                OnClick = (sender, args) => Master.World.Diplomacy.SendTradeEnvoy(s, Master.World)
                            });
                        }),
                    }
                },

                new HorizontalMenuTray.MenuItem
                {
                    Text    = "DWARF BUX",
                    OnClick = (sender, args) => Master.Faction.AddMoney(100m)
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "PAY",
                    OnClick = (sender, args) => Master.PayEmployees()
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "STARVE",
                    OnClick = (sender, args) =>
                    {
                        foreach (var minion in Master.Faction.Minions)
                        {
                            minion.Status.Hunger.CurrentValue = 0;
                        }
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "XP",
                    OnClick = (sender, args) =>
                    {
                        foreach (var minion in Master.Faction.Minions)
                        {
                            minion.AddXP(100);
                        }
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "SPAWN TEST",
                    OnClick = (sender, args) =>
                    {
                        var keys = EntityFactory.EntityFuncs.Keys.ToList();
                        foreach (var key in keys)
                        {
                            EntityFactory.CreateEntity <GameComponent>(key, Master.World.CursorLightPos);
                        }
                    }
                },

                // Shouldn't this go into some kind of 'debug' menu?
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "DRAW PATHS",
                    OnClick = (sender, args) =>
                    {
                        GameSettings.Default.DrawPaths = !GameSettings.Default.DrawPaths;
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "+1 HOUR",
                    OnClick = (sender, args) =>
                    {
                        Master.World.Time.CurrentDate += new TimeSpan(1, 0, 0);
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "FORCE REBUILD",
                    OnClick = (sender, args) =>
                    {
                        foreach (var chunk in Master.World.ChunkManager.ChunkData.ChunkMap)
                        {
                            for (int Y = 0; Y < VoxelConstants.ChunkSizeY; ++Y)
                            {
                                chunk.InvalidateSlice(Y);
                            }
                        }
                    }
                },
                new HorizontalMenuTray.MenuItem
                {
                    Text    = "LET IT SNOW",
                    OnClick = (sender, args) =>
                    {
                        var storm = Weather.CreateStorm(Vector3.One, 100.0f, Master.World);
                        storm.TypeofStorm = StormType.SnowStorm;
                        storm.Start();
                    }
                },
            };

            base.Construct();
        }
Exemple #3
0
        public override void OnEnter()
        {
            // Clear the input queue... cause other states aren't using it and it's been filling up.
            DwarfGame.GumInputMapper.GetInputQueue();

            GuiRoot = new Gui.Root(DwarfGame.GuiSkin);
            GuiRoot.MousePointer = new Gui.MousePointer("mouse", 4, 0);
            MakeMenu();

            Progress = GuiRoot.RootItem.AddChild(new Gui.Widgets.ProgressBar
            {
                Rect = new Rectangle(0, 0, GuiRoot.RenderData.VirtualScreen.Width, 32)
            }) as Gui.Widgets.ProgressBar;

            Dictionary <GameMaster.ToolMode, Gui.Widget> ToolbarItems = new Dictionary <GameMaster.ToolMode, Gui.Widget>();

            //ToolbarItems[GameMaster.ToolMode.SelectUnits] = CreateIcon(5, GameMaster.ToolMode.SelectUnits);
            //    ToolbarItems[GameMaster.ToolMode.Dig] = CreateIcon(0, GameMaster.ToolMode.Dig);
            //    ToolbarItems[GameMaster.ToolMode.Build] = CreateIcon(2, GameMaster.ToolMode.Build);
            //    ToolbarItems[GameMaster.ToolMode.Cook] = CreateIcon(3, GameMaster.ToolMode.Cook);
            //    ToolbarItems[GameMaster.ToolMode.Farm] = CreateIcon(5, GameMaster.ToolMode.Farm);
            //    ToolbarItems[GameMaster.ToolMode.Magic] = CreateIcon(6, GameMaster.ToolMode.Magic);
            //    ToolbarItems[GameMaster.ToolMode.Gather] = CreateIcon(6, GameMaster.ToolMode.Gather);
            //    ToolbarItems[GameMaster.ToolMode.Chop] = CreateIcon(1, GameMaster.ToolMode.Chop);
            //    ToolbarItems[GameMaster.ToolMode.Guard] = CreateIcon(4, GameMaster.ToolMode.Guard);
            //    ToolbarItems[GameMaster.ToolMode.Attack] = CreateIcon(3, GameMaster.ToolMode.Attack);

            var Tilesheet = AssetManager.GetContentTexture(ContentPaths.Terrain.terrain_tiles);

            VoxelLibrary.InitializeDefaultLibrary(Game.GraphicsDevice);

            var bottomRightTray = GuiRoot.RootItem.AddChild(new Gui.Widgets.ToolTray.Tray
            {
                IsRootTray = true,
                Corners    = Gui.Scale9Corners.Left | Gui.Scale9Corners.Top,
                AutoLayout = Gui.AutoLayout.FloatBottom,
                ItemSource = new Gui.Widget[]
                {
                    new Gui.Widgets.ToolTray.Icon
                    {
                        Icon             = new TileReference("tool-icons", 5),
                        KeepChildVisible = true,
                        ExpansionChild   = new Gui.Widgets.ToolTray.Tray
                        {
                            ItemSource = RoomLibrary.GetRoomTypes().Select(name => RoomLibrary.GetData(name))
                                         .Select(data => new Gui.Widgets.ToolTray.Icon
                            {
                                Icon           = data.NewIcon,
                                ExpansionChild = new Gui.Widgets.BuildRoomInfo
                                {
                                    Data = data,
                                    Rect = new Rectangle(0, 0, 256, 128)
                                },
                                OnClick = (sender, args) =>
                                {
                                    (sender as Gui.Widgets.FramedIcon).Enabled = false;
                                }
                            })
                        }
                    },
                    new Gui.Widgets.ToolTray.Icon
                    {
                        Icon             = new TileReference("tool-icons", 6),
                        KeepChildVisible = true,
                        ExpansionChild   = new Gui.Widgets.ToolTray.Tray
                        {
                            ItemSource = VoxelLibrary.GetTypes().Where(voxel => voxel.IsBuildable)
                                         .Select(data => new Gui.Widgets.ToolTray.Icon
                            {
                                Icon           = new TileReference("rooms", 0),
                                ExpansionChild = new Gui.Widgets.BuildWallInfo
                                {
                                    Data = data,
                                    Rect = new Rectangle(0, 0, 256, 128)
                                }
                            })
                        }
                    }
                }
            });

            bottomRightTray.Hidden = false;
            GuiRoot.RootItem.Layout();

            IsInitialized = true;

            base.OnEnter();
        }
Exemple #4
0
        public override void Construct()
        {
            Rect   = Root.VirtualScreen;
            Border = "border-fancy";

            AddChild(new Widget
            {
                Text = "CLOSE",
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                Border     = "border-button",
                OnClick    = (sender, args) => this.Close(),
                AutoLayout = AutoLayout.FloatBottomRight
            });

            var tabPanel = AddChild(new Gum.Widgets.TabPanel
            {
                AutoLayout       = AutoLayout.DockFill,
                Font             = "outline-font",
                TextColor        = new Vector4(1, 1, 1, 1),
                SelectedTabColor = new Vector4(1, 0, 0, 1),
                OnLayout         = (sender) => sender.Rect.Height -= 36 // Keep it from overlapping bottom buttons.
            }) as Gum.Widgets.TabPanel;

            #region Room Tab
            if (BuildType.HasFlag(BuildTypes.Room))
            {
                var iconSheet = Root.GetTileSheet("rooms") as Gum.TileSheet;

                BuildTab(tabPanel, "Rooms", RoomLibrary.GetRoomTypes().Select(name => RoomLibrary.GetData(name)).Select(data =>
                                                                                                                        new BuildableItem
                {
                    Icon = data.NewIcon,
                    Name = data.Name,
                    Data = data
                }),
                         (item, description, buildButton) =>
                {
                    var data    = item.Data as RoomData;
                    var builder = new StringBuilder();
                    builder.AppendLine(data.Description);
                    if (!data.CanBuildAboveGround)
                    {
                        builder.AppendLine("* Must be built below ground.");
                    }
                    if (!data.CanBuildBelowGround)
                    {
                        builder.AppendLine("* Must be built above ground.");
                    }
                    if (data.MustBeBuiltOnSoil)
                    {
                        builder.AppendLine("* Must be built on soil.");
                    }
                    builder.AppendLine("Required per 4 tiles:");
                    foreach (var requirement in data.RequiredResources)
                    {
                        builder.AppendLine(String.Format("{0}: {1}",
                                                         requirement.Key, requirement.Value.NumResources));
                    }
                    if (data.RequiredResources.Count == 0)
                    {
                        builder.AppendLine("Nothing!");
                    }

                    description.AddChild(new Gum.Widget
                    {
                        Background  = item.Icon,
                        MinimumSize = new Point(32, 32),
                        AutoLayout  = Gum.AutoLayout.DockTop,
                        MaximumSize = new Point(32, 32)
                    });

                    description.AddChild(new Gum.Widget
                    {
                        Font       = "outline-font",
                        Text       = builder.ToString(),
                        AutoLayout = Gum.AutoLayout.DockFill
                    });

                    buildButton.OnClick = (sender, args) =>
                    {
                        Master.Faction.RoomBuilder.CurrentRoomData  = item.Data as RoomData;
                        Master.VoxSelector.SelectionType            = VoxelSelectionType.SelectFilled;
                        Master.Faction.WallBuilder.CurrentVoxelType = null;
                        Master.Faction.CraftBuilder.IsEnabled       = false;
                        Master.CurrentToolMode = GameMaster.ToolMode.Build;
                        World.ShowToolPopup("Click and drag to build " + item.Name);
                        this.Close();
                    };
                });
            }
            #endregion

            #region Wall tab
            if (BuildType.HasFlag(BuildTypes.Wall))
            {
                var wallTypes = VoxelLibrary.GetTypes().Where(voxel => voxel.IsBuildable);

                BuildTab(tabPanel, "Walls", wallTypes.Select(wall =>
                                                             new BuildableItem
                {
                    Icon = null,
                    Name = wall.Name,
                    Data = wall
                }),
                         (item, description, buildButton) =>
                {
                    var data    = item.Data as VoxelType;
                    var builder = new StringBuilder();
                    builder.AppendLine(String.Format("{0} Wall", data.Name));
                    builder.AppendLine(String.Format("Strength: {0}", data.StartingHealth));
                    builder.AppendLine(String.Format("Requires: {0}", ResourceLibrary.Resources[data.ResourceToRelease].ResourceName));

                    description.AddChild(new Gum.Widget
                    {
                        Font       = "outline-font",
                        Text       = builder.ToString(),
                        AutoLayout = AutoLayout.DockFill
                    });

                    buildButton.OnClick = (sender, args) =>
                    {
                        Master.Faction.RoomBuilder.CurrentRoomData  = null;
                        Master.VoxSelector.SelectionType            = VoxelSelectionType.SelectEmpty;
                        Master.Faction.WallBuilder.CurrentVoxelType = item.Data as VoxelType;
                        Master.Faction.CraftBuilder.IsEnabled       = false;
                        Master.CurrentToolMode = GameMaster.ToolMode.Build;
                        World.ShowToolPopup("Click and drag to build " + item.Name + " wall.");
                        this.Close();
                    };
                });
            }
            #endregion

            #region Item Tab
            if (BuildType.HasFlag(BuildTypes.Item))
            {
                var iconSheet = Root.GetTileSheet("crafts") as Gum.TileSheet;
                BuildTab(tabPanel, "Objects",
                         CraftLibrary.CraftItems.Values.Where(item => item.Type == CraftItem.CraftType.Object).Select(craft => new BuildableItem
                {
                    Icon = craft.Icon,
                    Name = craft.Name,
                    Data = craft
                }),
                         (item, description, buildButton) =>
                {
                    var data    = item.Data as CraftItem;
                    var builder = new StringBuilder();
                    builder.AppendLine(data.Name);
                    builder.AppendLine(data.Description);
                    builder.AppendLine("Required:");

                    description.AddChild(new Gum.Widget
                    {
                        Background  = item.Icon,
                        MinimumSize = new Point(32, 32),
                        AutoLayout  = AutoLayout.DockTop,
                        MaximumSize = new Point(32, 32)
                    });

                    description.AddChild(new Gum.Widget
                    {
                        Font       = "outline-font",
                        Text       = builder.ToString(),
                        AutoLayout = Gum.AutoLayout.DockTop
                    });

                    var nearestBuildLocation = World.PlayerFaction.FindNearestItemWithTags(data.CraftLocation, Vector3.Zero, false);

                    if (nearestBuildLocation == null)
                    {
                        description.AddChild(new Gum.Widget
                        {
                            Font       = "outline-font",
                            Text       = String.Format("Needs {0} to build!", data.CraftLocation),
                            TextColor  = new Vector4(1, 0, 0, 1),
                            AutoLayout = Gum.AutoLayout.DockTop
                        });
                    }
                    else
                    {
                        foreach (var resourceAmount in data.RequiredResources)
                        {
                            var resourceSelector = description.AddChild(new Gum.Widgets.ComboBox
                            {
                                Font       = "outline-font",
                                Items      = Master.Faction.ListResourcesWithTag(resourceAmount.ResourceType).Select(r => r.ResourceType.ToString()).ToList(),
                                AutoLayout = AutoLayout.DockTop
                            }) as Gum.Widgets.ComboBox;

                            if (resourceSelector.Items.Count == 0)
                            {
                                resourceSelector.Items.Add("<Not enough!>");
                            }
                        }
                    }
                });
            }


            #endregion

            Layout();
        }