public void IncreasePriority <T>(T job) where T : ManagerJob { ManagerJob jobB = _stack.OfType <T>().OrderByDescending(mj => mj.priority).First(mj => mj.priority < job.priority); SwitchPriorities(job, jobB); }
public void SwitchPriorities(ManagerJob a, ManagerJob b) { int tmp = a.priority; a.priority = b.priority; b.priority = tmp; }
public void DecreasePriority <T>(T job) where T : ManagerJob { ManagerJob jobB = _stack.OfType <T>() .OrderBy(mj => mj.Priority) .First(mj => mj.Priority > job.Priority); SwitchPriorities(job, jobB); }
/// <summary> /// Cleanup job, delete from stack and update priorities. /// </summary> /// <param name="job"></param> public void Delete(ManagerJob job, bool cleanup = true) { if (cleanup) { job.CleanUp(); } _stack.Remove(job); CleanPriorities(); }
public static void GoTo( ManagerTab tab, ManagerJob job = null ) { // call pre/post open/close methods ManagerTab old = CurrentTab; old.PreClose(); tab.PreOpen(); CurrentTab = tab; old.PostClose(); tab.PostOpen(); // if desired, set selected. if ( job != null ) { tab.Selected = job; } }
private void DrawAvailableJobList(Rect outRect, Rect viewRect) { // set sizes viewRect.height = _availablePawnKinds.Count * LargeListEntryHeight; if (viewRect.height > outRect.height) { viewRect.width -= ScrollbarWidth; } Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect); GUI.BeginGroup(viewRect); for (var i = 0; i < _availablePawnKinds.Count; i++) { // set up rect var row = new Rect(0f, LargeListEntryHeight * i, viewRect.width, LargeListEntryHeight); // highlights Widgets.DrawHighlightIfMouseover(row); if (i % 2 == 0) { Widgets.DrawAltRect(row); } if (_availablePawnKinds[i] == _selectedAvailable) { Widgets.DrawHighlightSelected(row); } // draw label string label = _availablePawnKinds[i].LabelCap + "\n<i>" + "FML.TameWildCount".Translate( _availablePawnKinds[i].GetTame(manager).Count, _availablePawnKinds[i].GetWild(manager).Count) + "</i>"; Label(row, label, TextAnchor.MiddleLeft, margin: Margin * 2); // button if (Widgets.ButtonInvisible(row)) { _selectedAvailable = _availablePawnKinds[i]; // for highlighting to work Selected = new ManagerJob_Livestock(_availablePawnKinds[i], manager); // for details } } GUI.EndGroup(); Widgets.EndScrollView(); }
public static void GoTo(ManagerTab tab, ManagerJob job = null) { // call pre/post open/close methods ManagerTab old = CurrentTab; old.PreClose(); tab.PreOpen(); CurrentTab = tab; old.PostClose(); tab.PostOpen(); // if desired, set selected. if (job != null) { tab.Selected = job; } }
public void Draw(Rect canvas, ManagerJob job) { Text.Anchor = TextAnchor.MiddleCenter; // how many hours have passed since the last update? var lastUpdate = Find.TickManager.TicksGame - job.lastAction; var progress = (float)lastUpdate / GenDate.TicksPerHour; var nextUpdate = (float)job.UpdateInterval.ticks / GenDate.TicksPerHour; // how far over time are we? Draw redder if further over time. var progressColour = progress < nextUpdate ? Color.white : Color.Lerp(Color.white, Color.red, (progress - nextUpdate) / nextUpdate * 2f); if (nextUpdate < 12 && progress < 12) { var nextUpdateHandle = new ClockHandle(nextUpdate, GenUI.MouseoverColor); var progressHandle = new ClockHandle(progress, progressColour); Clock.Draw(canvas.ContractedBy(4f), nextUpdateHandle, progressHandle); } else { var nextUpdateMarker = new CalendarMarker(nextUpdate / GenDate.HoursPerDay, GenUI.MouseoverColor, false); var progressMarker = new CalendarMarker(progress / GenDate.HoursPerDay, progressColour, true); Calendar.Draw(canvas.ContractedBy(2f), progressMarker, nextUpdateMarker); } TooltipHandler.TipRegion(canvas, "FM.LastUpdateTooltip".Translate( lastUpdate.TimeString(), job.UpdateInterval.ticks.TimeString())); Widgets.DrawHighlightIfMouseover(canvas); if (Widgets.ButtonInvisible(canvas)) { var options = new List <FloatMenuOption>(); foreach (var interval in Utilities.UpdateIntervalOptions) { options.Add(new FloatMenuOption(interval.label, () => job.UpdateInterval = interval)); } Find.WindowStack.Add(new FloatMenu(options)); } }
/// <summary> /// Call the worker for the next available job /// </summary> public bool TryDoNextJob() { ManagerJob job = NextJob; if (job == null) { return(false); } // update lastAction job.Touch(); // perform next job if no action was taken if (!job.TryDoJob()) { return(TryDoNextJob()); } return(true); }
private void DrawCurrentJobList(Rect outRect, Rect viewRect) { // set sizes viewRect.height = _currentJobs.Count * LargeListEntryHeight; if (viewRect.height > outRect.height) { viewRect.width -= ScrollbarWidth; } Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect); GUI.BeginGroup(viewRect); for (var i = 0; i < _currentJobs.Count; i++) { // set up rect var row = new Rect(0f, LargeListEntryHeight * i, viewRect.width, LargeListEntryHeight); // highlights Widgets.DrawHighlightIfMouseover(row); if (i % 2 == 0) { Widgets.DrawAltRect(row); } if (_currentJobs[i] == _selectedCurrent) { Widgets.DrawHighlightSelected(row); } // draw label _currentJobs[i].DrawListEntry(row, false, true); // button if (Widgets.ButtonInvisible(row)) { Selected = _currentJobs[i]; } } GUI.EndGroup(); Widgets.EndScrollView(); }
public void DoLeftRow(Rect rect) { Widgets.DrawMenuSection(rect); // content float height = _leftRowHeight; var scrollView = new Rect(0f, 0f, rect.width, height); if (height > rect.height) { scrollView.width -= 16f; } Widgets.BeginScrollView(rect, ref _scrollPosition, scrollView); Rect scrollContent = scrollView; GUI.BeginGroup(scrollContent); Vector2 cur = Vector2.zero; var i = 0; foreach (ManagerJob_Forestry job in _jobs) { var row = new Rect(0f, cur.y, scrollContent.width, Utilities.LargeListEntryHeight); Widgets.DrawHighlightIfMouseover(row); if (_selected == job) { Widgets.DrawHighlightSelected(row); } if (i++ % 2 == 1) { Widgets.DrawAltRect(row); } Rect jobRect = row; if (ManagerTab_Overview.DrawOrderButtons(new Rect(row.xMax - 50f, row.yMin, 50f, 50f), manager, job)) { Refresh(); } jobRect.width -= 50f; job.DrawListEntry(jobRect, false); if (Widgets.ButtonInvisible(jobRect)) { _selected = job; } cur.y += Utilities.LargeListEntryHeight; } // row for new job. var newRect = new Rect(0f, cur.y, scrollContent.width, Utilities.LargeListEntryHeight); Widgets.DrawHighlightIfMouseover(newRect); if (i % 2 == 1) { Widgets.DrawAltRect(newRect); } Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(newRect, "<" + "FMF.NewForestryJob".Translate() + ">"); Text.Anchor = TextAnchor.UpperLeft; if (Widgets.ButtonInvisible(newRect)) { Selected = new ManagerJob_Forestry(manager); } TooltipHandler.TipRegion(newRect, "FMF.NewForestryJobTooltip".Translate()); cur.y += Utilities.LargeListEntryHeight; _leftRowHeight = cur.y; GUI.EndGroup(); Widgets.EndScrollView(); }
private void DrawCurrentJobList( Rect outRect, Rect viewRect ) { // set sizes viewRect.height = _currentJobs.Count * _listEntryHeight; if ( viewRect.height > outRect.height ) { viewRect.width -= 16f; } Widgets.BeginScrollView( outRect, ref _scrollPosition, viewRect ); GUI.BeginGroup( viewRect ); for ( var i = 0; i < _currentJobs.Count; i++ ) { // set up rect var row = new Rect( 0f, _listEntryHeight * i, viewRect.width, _listEntryHeight ); // highlights Widgets.DrawHighlightIfMouseover( row ); if ( i % 2 == 0 ) { Widgets.DrawAltRect( row ); } if ( _currentJobs[i] == _selectedCurrent ) { Widgets.DrawHighlightSelected( row ); } // draw label _currentJobs[i].DrawListEntry( row, false, true ); // button if ( Widgets.ButtonInvisible( row ) ) { Selected = _currentJobs[i]; } } GUI.EndGroup(); Widgets.EndScrollView(); }
public void DoLeftRow( Rect rect ) { Widgets.DrawMenuSection( rect ); // content float height = _leftRowHeight; var scrollView = new Rect( 0f, 0f, rect.width, height ); if ( height > rect.height ) { scrollView.width -= 16f; } Widgets.BeginScrollView( rect, ref _scrollPosition, scrollView ); Rect scrollContent = scrollView; GUI.BeginGroup( scrollContent ); Vector2 cur = Vector2.zero; var i = 0; foreach ( ManagerJob_Foraging job in _jobs ) { var row = new Rect( 0f, cur.y, scrollContent.width, Utilities.LargeListEntryHeight ); Widgets.DrawHighlightIfMouseover( row ); if ( _selected == job ) { Widgets.DrawHighlightSelected( row ); } if ( i++ % 2 == 1 ) { Widgets.DrawAltRect( row ); } Rect jobRect = row; if ( ManagerTab_Overview.DrawOrderButtons( new Rect( row.xMax - 50f, row.yMin, 50f, 50f ), manager, job ) ) { Refresh(); } jobRect.width -= 50f; job.DrawListEntry( jobRect, false ); if ( Widgets.ButtonInvisible( jobRect ) ) { _selected = job; } cur.y += Utilities.LargeListEntryHeight; } // row for new job. var newRect = new Rect( 0f, cur.y, scrollContent.width, Utilities.LargeListEntryHeight ); Widgets.DrawHighlightIfMouseover( newRect ); if ( i % 2 == 1 ) { Widgets.DrawAltRect( newRect ); } Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label( newRect, "<" + "FMG.NewForagingJob".Translate() + ">" ); Text.Anchor = TextAnchor.UpperLeft; if ( Widgets.ButtonInvisible( newRect ) ) { Selected = new ManagerJob_Foraging( manager ); } TooltipHandler.TipRegion( newRect, "FMG.NewForagingJobTooltip".Translate() ); cur.y += Utilities.LargeListEntryHeight; _leftRowHeight = cur.y; GUI.EndGroup(); Widgets.EndScrollView(); }
public void DecreasePriority(ManagerJob job) { ManagerJob jobB = _stack.OrderBy(mj => mj.priority).First(mj => mj.priority > job.priority); SwitchPriorities(job, jobB); }
public void BottomPriority(ManagerJob job) { job.priority = _stack.Count + 10; CleanPriorities(); }
/// <summary> /// Add job to the stack with bottom priority. /// </summary> /// <param name="job"></param> public void Add(ManagerJob job) { job.priority = _stack.Count + 1; _stack.Add(job); }
public void TopPriority(ManagerJob job) { job.priority = -1; CleanPriorities(); }
private void DrawAvailableJobList( Rect outRect, Rect viewRect ) { // set sizes viewRect.height = _availablePawnKinds.Count * _listEntryHeight; if ( viewRect.height > outRect.height ) { viewRect.width -= 16f; } Widgets.BeginScrollView( outRect, ref _scrollPosition, viewRect ); GUI.BeginGroup( viewRect ); for ( var i = 0; i < _availablePawnKinds.Count; i++ ) { // set up rect var row = new Rect( 0f, _listEntryHeight * i, viewRect.width, _listEntryHeight ); // highlights Widgets.DrawHighlightIfMouseover( row ); if ( i % 2 == 0 ) { Widgets.DrawAltRect( row ); } if ( _availablePawnKinds[i] == _selectedAvailable ) { Widgets.DrawHighlightSelected( row ); } // draw label string label = _availablePawnKinds[i].LabelCap + "\n<i>" + "FML.TameWildCount".Translate( _availablePawnKinds[i].GetTame( manager ).Count, _availablePawnKinds[i].GetWild( manager ).Count ) + "</i>"; Utilities.Label( row, label, null, TextAnchor.MiddleLeft, Utilities.Margin * 2 ); // button if ( Widgets.ButtonInvisible( row ) ) { _selectedAvailable = _availablePawnKinds[i]; // for highlighting to work Selected = new ManagerJob_Livestock( _availablePawnKinds[i], manager ); // for details } } GUI.EndGroup(); Widgets.EndScrollView(); }
public void IncreasePriority(ManagerJob job) { ManagerJob jobB = _stack.OrderByDescending(mj => mj.priority).First(mj => mj.priority < job.priority); SwitchPriorities(job, jobB); }