private void DoExport(string name) { try { try { Scribe.InitWriting(FilePath(name), "ManagerJobs"); } catch (Exception ex) { GenUI.ErrorDialog("ProblemSavingFile".Translate(ex.ToString())); throw; } ScribeMetaHeaderUtility.WriteMetaHeader(); _jobStackIO = Manager.For(manager).JobStack; Scribe_Deep.LookDeep(ref _jobStackIO, "JobStack"); } catch (Exception ex2) { Log.Error("Exception while saving jobstack: " + ex2); } finally { Scribe.FinalizeWriting(); Messages.Message("FM.JobsExported".Translate(_jobStackIO.FullStack().Count), MessageSound.Standard); Refresh(); } }
/// <summary> /// Draw a square group of ordering buttons for a job in rect. /// This is an LOCAL method that within the specified job type. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rect"></param> /// <param name="job"></param> /// <returns></returns> public static bool DrawOrderButtons <T>(Rect rect, Manager manager, T job) where T : ManagerJob { var ret = false; JobStack jobStack = manager.JobStack; float width = rect.width / 2, height = rect.height / 2; Rect upRect = new Rect(rect.xMin, rect.yMin, width, height).ContractedBy(1f), downRect = new Rect(rect.xMin, rect.yMin + height, width, height).ContractedBy(1f), topRect = new Rect(rect.xMin + width, rect.yMin, width, height).ContractedBy(1f), bottomRect = new Rect(rect.xMin + width, rect.yMin + height, width, height).ContractedBy(1f); List <T> jobsOfType = jobStack.FullStack <T>(); bool top = jobsOfType.IndexOf(job) == 0, bottom = jobsOfType.IndexOf(job) == jobsOfType.Count - 1; if (!top) { DrawOrderTooltips(upRect, topRect); if (Widgets.ButtonImage(topRect, Resources.ArrowTop)) { jobStack.TopPriority(job); ret = true; } if (Widgets.ButtonImage(upRect, Resources.ArrowUp)) { jobStack.IncreasePriority(job); ret = true; } } if (!bottom) { DrawOrderTooltips(downRect, bottomRect, false); if (Widgets.ButtonImage(downRect, Resources.ArrowDown)) { jobStack.DecreasePriority(job); ret = true; } if (Widgets.ButtonImage(bottomRect, Resources.ArrowBottom)) { jobStack.BottomPriority(job); ret = true; } } return(ret); }
internal void NewJobStack(JobStack jobstack) { // clean up old jobs foreach (var job in _stack.FullStack()) { job.CleanUp(); } // replace stack _stack = jobstack; // touch new jobs in inappropriate places (reset timing so they are properly performed) foreach (var job in _stack.FullStack()) { job.manager = this; job.Touch(); } }
public override void ExposeData() { base.ExposeData(); Scribe_Values.Look(ref id, "id", -1, true); Scribe_Values.Look(ref HelpShown, "HelpShown"); Scribe_Deep.Look(ref _stack, "JobStack", this); foreach (var tab in Tabs) { var exposableTab = tab as IExposable; if (exposableTab != null) { Scribe_Deep.Look(ref exposableTab, tab.Label, this); } } if (_stack == null) { _stack = new JobStack(this); } }
public Manager(Map map) : base(map) { _stack = new JobStack(this); ManagerTabs = new List <ManagerTab> { new ManagerTab_Overview(this), new ManagerTab_Production(this), new ManagerTab_ImportExport(this), new ManagerTab_Hunting(this), new ManagerTab_Forestry(this), new ManagerTab_Livestock(this), new ManagerTab_Foraging(this) // Power is added by Manager.UnlockPowerTab() after the appropriate research is done. }; // if not created in SavingLoading, give yourself the ID of the map you were constructed on. if (Scribe.mode == Verse.LoadSaveMode.Inactive) { id = map.uniqueID; } }
public Manager(Map map) : base(map) { _stack = new JobStack(this); Tabs = new List <ManagerTab> { new ManagerTab_Overview(this), //new ManagerTab_Production( this ), //new ManagerTab_ImportExport( this ), new ManagerTab_Hunting(this), new ManagerTab_Forestry(this), new ManagerTab_Livestock(this), new ManagerTab_Foraging(this), new ManagerTab_Mining(this), new ManagerTab_Power(this) }; // if not created in SavingLoading, give yourself the ID of the map you were constructed on. if (Scribe.mode == Verse.LoadSaveMode.Inactive) { id = map.uniqueID; } }
public override void ExposeData() { base.ExposeData(); // TODO: migrate HelpShown to HugsLib invisible setting. Scribe_Values.LookValue(ref id, "id", -1, true); Scribe_Values.LookValue(ref HelpShown, "HelpShown", false); Scribe_Deep.LookDeep(ref _stack, "JobStack", this); foreach (ManagerTab tab in ManagerTabs) { var exposableTab = tab as IExposable; if (exposableTab != null) { Scribe_Deep.LookDeep(ref exposableTab, tab.Label, this); } } if (_stack == null) { _stack = new JobStack(this); } }
public ManagerTab_ImportExport(Manager manager) : base(manager) { _jobStackIO = new JobStack(manager); }