private static void RedoMenuItem_Click(object sender, Game.GUI.Controls.EventArgs e) { var jobHistory = lastJobs.Single(jhi => jhi.MenuItem == sender); var jobConfig = jobHistory.Configuration; Game.GnomanEmpire.Instance.Region.TileSelectionManager.SetMouseAction( jobConfig.Type, jobConfig.Data, jobConfig.MultiSelect, jobConfig.Rotatable, jobConfig.GroundSelect, jobConfig.SnapToGround ); var aw = Game.GnomanEmpire.Instance.GuiManager.HUD.ActiveWindow; if (aw is Game.GUI.BuildConstructionUI) { // may add sth similar to "ConstructionPanel"s CanConstruct() ? See also BuildConstructionUI's click handler Game.GnomanEmpire.Instance.Region.TileSelectionManager.ComponentsSelected(jobConfig.ConstructionID, jobConfig.Materials.ToList()); aw.Close(); } else { throw new Exception("Interesting, this can happen? Pls contact the mod author and tell him what you have done :)"); } /* * new Game.GUI.Controls.EventHandler((sender, args) => * { * * }); * throw new NotImplementedException(); */ }
static void btn_Click(object sender, Game.GUI.Controls.EventArgs e) { all_items.RemoveAll(el => !el.Item1.IsAlive); var seri = new System.Web.Script.Serialization.JavaScriptSerializer(); var query = all_items.Select(el => el.Item2).GroupBy(el => el).Select(el => new { stack = el.Key, count = el.Count() }).OrderByDescending(el => el.count); var txt = seri.Serialize(query); System.IO.File.WriteAllText("D:\\Temp\\Stacks.txt", txt); var query2 = all_items.GroupBy(el => el.Item1.Target.ItemID).OrderByDescending(group => group.Count()).Select(group => { var dict = new Dictionary <string, int>(); var regrouped = group.GroupBy(el2 => el2.Item1.Target.MaterialID); if (regrouped.Count() > 1) { dict.Add("total", group.Count()); } foreach (var el in regrouped) { dict.Add(((Material)el.Key).ToString(), el.Count()); } return(Tuple.Create(group.Key.ToString(), new SerializableDataBag <int>(dict))); }).ToBag(); using (var file = System.IO.File.OpenWrite("D:\\Temp\\Types.txt")) { JSON.ToJSON(query2, file, typeof(SerializableDataBag <int>)); } //var txt2 = seri.Serialize(query2); //System.IO.File.WriteAllText("D:\\Temp\\Types.txt", txt2); }
static void OnStockpileArea(object sender, Game.GUI.Controls.EventArgs e) { var tsm = Game.GnomanEmpire.Instance.Region.TileSelectionManager; //tsm.SetMouseAction(Game.JobType.Mine, true, false, true); tsm.SetMouseAction(Game.JobType.StockItem, true, false, true); //throw new NotImplementedException(); }