public int CompareTo(object obj) { HelpDef d = obj as HelpDef; if (d != null) { return(d.label.CompareTo(label)); } return(1); }
public void JumpTo(HelpDef helpDef) { Find.MainTabsRoot.SetCurrentTab(this.def); ResetFilter(); _jump = true; SelectedHelpDef = helpDef; HelpCategoryDef cat = DefDatabase <HelpCategoryDef> .AllDefsListForReading.First(hc => hc.HelpDefs.Contains(helpDef)); cat.Expanded = true; ModCategory mod = CachedHelpCategories.First(mc => mc.HelpCategories.Contains(cat)); mod.Expanded = true; }
public void DrawHelpEntry(ref Vector2 cur, int nestLevel, Rect view, HelpDef helpDef) { bool selected = SelectedHelpDef == helpDef; if (selected && _jump) { SelectionScrollPos.y = cur.y; _jump = false; } if (DrawEntry(ref cur, nestLevel, view, helpDef.LabelCap, State.Leaf, selected)) { SelectedHelpDef = helpDef; } }
void DrawHelpRow(Rect hRect, HelpDef hCat) { if (hCat == SelectedHelpDef) { Widgets.DrawHighlightSelected(hRect); } else if (hRect.Contains(Event.current.mousePosition)) { Widgets.DrawHighlight(hRect); } Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(hRect, hCat.LabelCap); Text.Anchor = TextAnchor.UpperLeft; if (Widgets.InvisibleButton(hRect)) { SelectedHelpDef = hCat; } }
public IHelpDefView SecondaryView(HelpDef def) { return(null); }
public void JumpToDef( HelpDef helpDef ) { ResetFilter(); _jump = true; HelpCategoryDef cat = DefDatabase<HelpCategoryDef>.AllDefsListForReading.First(hc => hc.HelpDefs.Contains(helpDef)); cat.Expanded = true; ModCategory mod = CachedHelpCategories.First(mc => mc.HelpCategories.Contains(cat)); mod.Expanded = true; }
static HelpDef HelpForRecipe( ThingDef thingDef, RecipeDef recipeDef, HelpCategoryDef category ) { var helpDef = new HelpDef(); helpDef.keyDef = recipeDef; helpDef.defName = helpDef.keyDef + "_RecipeDef_Help"; helpDef.label = recipeDef.label; helpDef.category = category; helpDef.description = recipeDef.description; #region Base Stats helpDef.HelpDetailSections.Add( new HelpDetailSection( null, new[] { "WorkAmount".Translate() + " : " + recipeDef.WorkAmountTotal( (ThingDef)null ).ToStringWorkAmount() } ) ); #endregion #region Skill Requirements if( !recipeDef.skillRequirements.NullOrEmpty() ) { helpDef.HelpDetailSections.Add( new HelpDetailSection( "MinimumSkills".Translate(), recipeDef.skillRequirements.Select( sr => sr.skill ).ToList().ConvertAll( sd => (Def)sd ), null, recipeDef.skillRequirements.Select( sr => sr.minLevel.ToString( "####0" ) ).ToArray() ) ); } #endregion #region Ingredients // List of ingredients if( !recipeDef.ingredients.NullOrEmpty() ) { // TODO: find the actual thingDefs of ingredients so we can use defs instead of strings. HelpDetailSection ingredients = new HelpDetailSection( "Ingredients".Translate(), recipeDef.ingredients.Select(ic => recipeDef.IngredientValueGetter.BillRequirementsDescription( ic )).ToArray()); helpDef.HelpDetailSections.Add( ingredients ); } #endregion #region Products // List of products if( !recipeDef.products.NullOrEmpty() ) { HelpDetailSection products = new HelpDetailSection( "AutoHelpListRecipeProducts".Translate(), recipeDef.products.Select(tc => tc.thingDef).ToList().ConvertAll(def => (Def)def), recipeDef.products.Select(tc => tc.count.ToString()).ToArray()); helpDef.HelpDetailSections.Add( products ); } #endregion #region Things & Research // Add things it's on var thingDefs = recipeDef.GetThingsCurrent(); if( !thingDefs.NullOrEmpty() ) { HelpDetailSection billgivers = new HelpDetailSection( "AutoHelpListRecipesOnThings".Translate(), thingDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( billgivers ); } // Add research required var researchDefs = recipeDef.GetResearchRequirements(); if( !researchDefs.NullOrEmpty() ) { HelpDetailSection requiredResearch = new HelpDetailSection( "AutoHelpListResearchRequired".Translate(), researchDefs); helpDef.HelpDetailSections.Add( requiredResearch ); } // What things is it on after research thingDefs = recipeDef.GetThingsUnlocked( ref researchDefs ); if( !thingDefs.NullOrEmpty() ) { HelpDetailSection recipesOnThingsUnlocked = new HelpDetailSection( "AutoHelpListRecipesOnThingsUnlocked".Translate(), thingDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( recipesOnThingsUnlocked ); if( !researchDefs.NullOrEmpty() ) { HelpDetailSection researchBy = new HelpDetailSection( "AutoHelpListResearchBy".Translate(), researchDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( researchBy ); } } // Get research which locks recipe thingDefs = recipeDef.GetThingsLocked( ref researchDefs ); if( !thingDefs.NullOrEmpty() ) { HelpDetailSection recipesOnThingsLocked = new HelpDetailSection( "AutoHelpListRecipesOnThingsLocked".Translate(), thingDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( recipesOnThingsLocked ); if( !researchDefs.NullOrEmpty() ) { HelpDetailSection researchBy = new HelpDetailSection( "AutoHelpListResearchBy".Translate(), researchDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( researchBy ); } } #endregion return helpDef; }
public bool Accept(HelpDef def) { return(true); }
private void DrawHelpRow(Rect hRect, HelpDef hCat) { if (hCat == SelectedHelpDef) Widgets.DrawHighlightSelected(hRect); else if (hRect.Contains(Event.current.mousePosition)) Widgets.DrawHighlight(hRect); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(hRect, hCat.LabelCap); Text.Anchor = TextAnchor.UpperLeft; if (Widgets.InvisibleButton(hRect)) { OTab_ModHelp.SelectedHelpDef = hCat; } }
static HelpDef HelpForResearch( ResearchProjectDef researchProjectDef, HelpCategoryDef category ) { var helpDef = new HelpDef(); helpDef.defName = researchProjectDef.defName + "_ResearchProjectDef_Help"; helpDef.keyDef = researchProjectDef; helpDef.label = researchProjectDef.label; helpDef.category = category; helpDef.description = researchProjectDef.description; #region Base Stats HelpDetailSection totalCost = new HelpDetailSection(null, new [] { "AutoHelpTotalCost".Translate(researchProjectDef.totalCost.ToString()) }); helpDef.HelpDetailSections.Add( totalCost ); #endregion #region Research, Buildings, Recipes and SowTags // Add research required var researchDefs = researchProjectDef.GetResearchRequirements(); if( !researchDefs.NullOrEmpty() ) { HelpDetailSection researchRequirements = new HelpDetailSection( "AutoHelpListResearchRequired".Translate(), researchDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( researchRequirements ); } // Add research unlocked //CCL_Log.Message(researchProjectDef.label, "getting unlocked research"); researchDefs = researchProjectDef.GetResearchUnlocked(); if( !researchDefs.NullOrEmpty() ) { HelpDetailSection reseachUnlocked = new HelpDetailSection( "AutoHelpListResearchLeadsTo".Translate(), researchDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( reseachUnlocked ); } // Add buildings it unlocks var thingDefs = researchProjectDef.GetThingsUnlocked(); if( !thingDefs.NullOrEmpty() ) { HelpDetailSection thingsUnlocked = new HelpDetailSection( "AutoHelpListThingsUnlocked".Translate(), thingDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( thingsUnlocked ); } // Add recipes it unlocks var recipeDefs = researchProjectDef.GetRecipesUnlocked( ref thingDefs ); if( (!recipeDefs.NullOrEmpty()) && (!thingDefs.NullOrEmpty()) ) { HelpDetailSection recipesUnlocked = new HelpDetailSection( "AutoHelpListRecipesUnlocked".Translate(), recipeDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( recipesUnlocked ); HelpDetailSection recipesOnThingsUnlocked = new HelpDetailSection( "AutoHelpListRecipesOnThingsUnlocked".Translate(), thingDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( recipesOnThingsUnlocked ); } // Look in advanced research to add plants and sow tags it unlocks var sowTags = researchProjectDef.GetSowTagsUnlocked( ref thingDefs ); if( (!sowTags.NullOrEmpty()) && (!thingDefs.NullOrEmpty()) ) { HelpDetailSection plantsUnlocked = new HelpDetailSection( "AutoHelpListPlantsUnlocked".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def )); helpDef.HelpDetailSections.Add( plantsUnlocked ); HelpDetailSection plantsIn = new HelpDetailSection( "AutoHelpListPlantsIn".Translate(), sowTags.ToArray()); helpDef.HelpDetailSections.Add( plantsIn ); } #endregion #region Lockouts // Get advanced research which locks researchDefs = researchProjectDef.GetResearchedLockedBy(); if( !researchDefs.NullOrEmpty() ) { HelpDetailSection researchLockout = new HelpDetailSection( "AutoHelpListResearchLockout".Translate(), researchDefs.ConvertAll<Def>( def =>(Def)def ) ); helpDef.HelpDetailSections.Add( researchLockout ); } #endregion return helpDef; }
public void JumpTo( HelpDef helpDef ) { Find.MainTabsRoot.SetCurrentTab( this.def ); ResetFilter(); _jump = true; SelectedHelpDef = helpDef; HelpCategoryDef cat = DefDatabase<HelpCategoryDef>.AllDefsListForReading.First(hc => hc.HelpDefs.Contains(helpDef)); cat.Expanded = true; ModCategory mod = CachedHelpCategories.First(mc => mc.HelpCategories.Contains(cat)); mod.Expanded = true; }
public override void PreOpen() { base.PreOpen(); if( Find.ResearchManager.currentProj != null ) SelectedProject = Find.ResearchManager.currentProj.GetHelpDef(); _filter = ""; _oldFilter = ""; RefreshSource(); MainTabWindow_ModHelp.Recache(); }
static HelpDef HelpForBuildable( BuildableDef buildableDef, HelpCategoryDef category ) { var helpDef = new HelpDef(); helpDef.defName = buildableDef.defName + "_BuildableDef_Help"; helpDef.keyDef = buildableDef.defName; helpDef.label = buildableDef.label; helpDef.category = category; var s = new StringBuilder(); s.AppendLine( buildableDef.description ); s.AppendLine(); #region Base Stats // Look at base stats foreach( var stat in buildableDef.statBases ) { s.Append( stat.stat.LabelCap ); s.Append( " : " ); s.AppendLine( stat.stat.ValueToString( stat.value, stat.stat.toStringNumberSense ) ); } s.AppendLine(); #endregion #region ThingDef Specific var thingDef = buildableDef as ThingDef; if( thingDef != null ) { #region Ingestible Stats // Look at base stats if( thingDef.IsNutritionSource ) { if( thingDef.ingestible.nutrition > 0.0001f ) { s.Append( "Nutrition".Translate() ); s.Append( " : " ); s.AppendLine( thingDef.ingestible.nutrition.ToString( "0.###" ) ); } if( thingDef.ingestible.joy > 0.0001f ) { s.Append( "Joy".Translate() ); s.Append( " : " ); s.AppendLine( thingDef.ingestible.joy.ToString( "0.###" ) ); } s.AppendLine(); } #endregion #region Body Part Stats if( ( !thingDef.thingCategories.NullOrEmpty() )&& ( thingDef.thingCategories.Contains( ThingCategoryDefOf.BodyPartsAndImplants ) )&& ( thingDef.IsImplant() ) ) { var hediffDef = thingDef.GetImplantHediffDef(); #region Efficiency if( hediffDef.addedPartProps != null ) { s.Append( "BodyPartEfficiency".Translate() ); s.Append( " : " ); s.AppendLine( hediffDef.addedPartProps.partEfficiency.ToString( "P0" ) ); s.AppendLine(); } #endregion #region Capacities if( ( !hediffDef.stages.NullOrEmpty() )&& ( hediffDef.stages.Exists( stage => ( ( !stage.capMods.NullOrEmpty() ) ) ) ) ) { foreach( var hediffStage in hediffDef.stages ) { if( !hediffStage.capMods.NullOrEmpty() ) { foreach( var c in hediffStage.capMods ) { s.Append( c.capacity.LabelCap ); if( c.offset > 0 ) { s.Append( " : +" ); } else { s.Append( " : " ); } s.AppendLine( c.offset.ToString( "P0" ) ); } } } s.AppendLine(); } #endregion #region Components (Melee attack) if( ( !hediffDef.comps.NullOrEmpty() )&& ( hediffDef.comps.Exists( p => ( ( p.compClass == typeof( HediffComp_VerbGiver ) ) ) ) ) ) { foreach( var comp in hediffDef.comps ) { if( comp.compClass == typeof( HediffComp_VerbGiver ) ) { if( !comp.verbs.NullOrEmpty() ) { foreach( var verb in comp.verbs ) { if( verb.verbClass == typeof( Verb_MeleeAttack ) ) { s.AppendLine( "MeleeAttack".Translate( verb.meleeDamageDef.label ) ); s.Append( "\t" ); s.Append( "MeleeWarmupTime".Translate() ); s.Append( " : " ); s.AppendLine( verb.defaultCooldownTicks.ToString() ); s.Append( "\t" ); s.Append( "StatsReport_MeleeDamage".Translate() ); s.Append( " : " ); s.AppendLine( verb.meleeDamageBaseAmount.ToString() ); s.AppendLine(); } } } } } } #endregion #region Body part fixed or replaced var recipeDef = thingDef.GetImplantRecipeDef(); if( !recipeDef.appliedOnFixedBodyParts.NullOrEmpty() ) { s.Append( "AutoHelpSurgeryFixOrReplace".Translate() ); s.AppendLine( ":" ); foreach( var b in recipeDef.appliedOnFixedBodyParts ) { s.Append( "\t" ); s.AppendLine( b.LabelCap ); } s.AppendLine(); } #endregion } #endregion #region Stuff Cost // What stuff can it be made from? if( thingDef.costStuffCount > 0 ) { s.AppendLine( "AutoHelpStuffCost".Translate( thingDef.costStuffCount.ToString() ) ); BuildDefDescription( s, "AutoHelpListStuffCategories".Translate(), thingDef.stuffCategories.ConvertAll<Def>( def => (Def)def ) ); } #endregion #region Cost List // What other things are required? if( ( thingDef.costList != null )&& ( thingDef.costList.Count > 0 ) ) { s.Append( "AutoHelpThingCost".Translate() ); s.AppendLine( ":" ); foreach( var tc in thingDef.costList ) { s.Append( "\t" ); s.Append( tc.thingDef.LabelCap ); s.Append( " : " ); s.AppendLine( tc.count.ToString() ); } s.AppendLine(); } #endregion #region Recipes & Research // Get list of recipes var recipeDefs = thingDef.AllRecipes; BuildDefDescription( s, "AutoHelpListRecipes".Translate(), recipeDefs.ConvertAll<Def>( def => (Def)def ) ); // Add list of required research var researchDefs = buildableDef.GetResearchRequirements(); BuildDefDescription( s, "AutoHelpListResearchRequired".Translate(), researchDefs.ConvertAll<Def>( def => (Def)def ) ); // Build help for unlocked recipes associated with building recipeDefs = thingDef.GetRecipesUnlocked( ref researchDefs ); BuildDefWithDefDescription( s, "AutoHelpListRecipesUnlocked".Translate(), "AutoHelpListResearchBy".Translate(), recipeDefs.ConvertAll<Def>( def => (Def)def ), researchDefs.ConvertAll<Def>( def => (Def)def ) ); // Build help for locked recipes associated with building recipeDefs = thingDef.GetRecipesLocked( ref researchDefs ); BuildDefWithDefDescription( s, "AutoHelpListRecipesLocked".Translate(), "AutoHelpListResearchBy".Translate(), recipeDefs.ConvertAll<Def>( def => (Def)def ), researchDefs.ConvertAll<Def>( def => (Def)def ) ); #endregion #region Facilities // Get list of facilities that effect it var affectedBy = thingDef.GetCompProperties( typeof( CompAffectedByFacilities ) ); if( ( affectedBy != null )&& ( affectedBy.linkableFacilities != null )&& ( affectedBy.linkableFacilities.Count > 0 ) ) { BuildDefDescription( s, "AutoHelpListFacilitiesAffecting".Translate(), affectedBy.linkableFacilities.ConvertAll<Def>( def => (Def)def ) ); } // Get list of buildings effected by it if( thingDef.HasComp( typeof( CompFacility ) ) ) { var effectsBuildings = DefDatabase< ThingDef >.AllDefsListForReading .Where( f => ( ( f.HasComp( typeof( CompAffectedByFacilities ) ) )&& ( f.GetCompProperties( typeof( CompAffectedByFacilities ) ) != null )&& ( f.GetCompProperties( typeof( CompAffectedByFacilities ) ).linkableFacilities != null )&& ( f.GetCompProperties( typeof( CompAffectedByFacilities ) ).linkableFacilities.Contains( thingDef ) ) ) ).ToList(); if( ( effectsBuildings != null )&& ( effectsBuildings.Count > 0 ) ) { var facilityProperties = thingDef.GetCompProperties( typeof( CompFacility ) ); s.AppendLine( "AutoHelpMaximumAffected".Translate( facilityProperties.maxSimultaneous.ToString() ) ); // Look at stats modifiers foreach( var stat in facilityProperties.statOffsets ) { s.Append( stat.stat.LabelCap ); s.Append( " : " ); s.AppendLine( stat.stat.ValueToString( stat.value, stat.stat.toStringNumberSense ) ); } s.AppendLine(); BuildDefDescription( s, "AutoHelpListFacilitiesAffected".Translate(), effectsBuildings.ConvertAll<Def>( def => (Def)def ) ); } } #endregion #region Joy // Get valid joy givers var joyGiverDefs = DefDatabase< JoyGiverDef >.AllDefsListForReading .Where( j => ( ( j.thingDef == thingDef )&& ( j.jobDef != null ) ) ).ToList(); if( !joyGiverDefs.NullOrEmpty() ) { s.AppendLine( "AutoHelpListJoyActivities".Translate() ); foreach( var joyGiverDef in joyGiverDefs ) { // Get job driver stats s.Append( "\t" ); s.AppendLine( joyGiverDef.jobDef.reportString ); s.Append( "\t" ); s.AppendLine( "AutoHelpMaximumParticipants".Translate( joyGiverDef.jobDef.joyMaxParticipants.ToString() ) ); s.Append( "\t" ); s.AppendLine( "AutoHelpJoyKind".Translate( joyGiverDef.jobDef.joyKind.LabelCap ) ); if( joyGiverDef.jobDef.joySkill != null ) { s.Append( "\t" ); s.AppendLine( "AutoHelpJoySkill".Translate( joyGiverDef.jobDef.joySkill.LabelCap ) ); } } s.AppendLine(); } #endregion } #endregion helpDef.description = s.ToString(); return helpDef; }
public bool Accept( HelpDef def ) { return true; }
static HelpDef HelpForAdvancedResearch( AdvancedResearchDef advancedResearchDef, HelpCategoryDef category ) { var helpDef = new HelpDef(); helpDef.defName = advancedResearchDef.defName + "_AdvancedResearchDef_Help"; helpDef.keyDef = advancedResearchDef.defName; helpDef.label = advancedResearchDef.label; if( advancedResearchDef.helpCategoryDef == null ) { advancedResearchDef.helpCategoryDef = category; } if( advancedResearchDef.IsHelpEnabled ) { helpDef.category = advancedResearchDef.helpCategoryDef; } var s = new StringBuilder(); s.AppendLine( advancedResearchDef.description ); s.AppendLine(); #region Base Stats s.AppendLine( "AutoHelpTotalCost".Translate( advancedResearchDef.TotalCost.ToString() ) ); s.AppendLine(); #endregion #region Research, Buildings, Recipes and SowTags // Add research required var researchDefs = advancedResearchDef.GetResearchRequirements(); BuildDefDescription( s, "AutoHelpListResearchRequired".Translate(), researchDefs.ConvertAll<Def>( def =>(Def)def ) ); // Add buildings it unlocks var thingDefs = advancedResearchDef.GetThingsUnlocked(); BuildDefDescription( s, "AutoHelpListThingsUnlocked".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ) ); // Add recipes it unlocks var recipeDefs = advancedResearchDef.GetRecipesUnlocked( ref thingDefs ); BuildDefWithDefDescription( s, "AutoHelpListRecipesUnlocked".Translate(), "AutoHelpListRecipesOnThings".Translate(), recipeDefs.ConvertAll<Def>( def =>(Def)def ), thingDefs.ConvertAll<Def>( def =>(Def)def ) ); // Add plants and sow tags it unlocks var sowTags = advancedResearchDef.GetSowTagsUnlocked( ref thingDefs ); BuildDefWithStringDescription( s, "AutoHelpListPlantsUnlocked".Translate(), "AutoHelpListPlantsIn".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ), sowTags ); #endregion #region Lockouts // Add buildings it locks thingDefs = advancedResearchDef.GetThingsLocked(); BuildDefDescription( s, "AutoHelpListThingsLocked".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ) ); // Add recipes it locks recipeDefs = advancedResearchDef.GetRecipesLocked( ref thingDefs ); BuildDefWithDefDescription( s, "Prevents recipes:", "AutoHelpListRecipesOnThings".Translate(), recipeDefs.ConvertAll<Def>( def =>(Def)def ), thingDefs.ConvertAll<Def>( def =>(Def)def ) ); // Add plants and sow tags it locks sowTags = advancedResearchDef.GetSowTagsLocked( ref thingDefs ); BuildDefWithStringDescription( s, "AutoHelpListPlantsLocked".Translate(), "AutoHelpListPlantsIn".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ), sowTags ); #endregion helpDef.description = s.ToString(); advancedResearchDef.HelpDef = helpDef; return helpDef; }
private void DrawResearchRow( HelpDef helpDef, Rect sidebarRow ) { if( SelectedProject == helpDef ) { GUI.DrawTexture( sidebarRow, TexUI.HighlightTex ); } string text = helpDef.LabelCap; Def def = helpDef.keyDef; if( def is ResearchProjectDef ) { text += " (" + ( (ResearchProjectDef)def ).totalCost.ToString( "F0" ) + ")"; } else if( def is AdvancedResearchDef ) { text += " (" + ( (AdvancedResearchDef)def ).TotalCost.ToString( "F0" ) + ")"; } #if DEBUG else { text += " (" + def.GetType() + ")"; } #endif Rect sidebarRowInner = new Rect(sidebarRow); sidebarRowInner.x += 6f; sidebarRowInner.width -= 6f; float num2 = Text.CalcHeight(text, sidebarRowInner.width); if( sidebarRowInner.height < num2 ) { sidebarRowInner.height = num2 + 3f; } // give the label a colour if we're in the all tab. Color textColor = new Color( .8f, .85f, 1f ); ; if( def is ResearchProjectDef ) { if( ( (ResearchProjectDef)def ).IsFinished ) { textColor = new Color( 1f, 1f, 1f ); } else if( !( (ResearchProjectDef)def ).PrereqsFulfilled ) { textColor = new Color( .6f, .6f, .6f ); } } else if( def is AdvancedResearchDef ) { if( ( (AdvancedResearchDef)def ).IsFinished ) { textColor = new Color( 1f, 1f, 1f ); } else if( ( (AdvancedResearchDef)def ).IsLockedOut() ) { textColor = new Color( .6f, .6f, .6f ); } } if( Widgets.TextButton( sidebarRowInner, text, false, true, textColor ) ) { SoundDefOf.Click.PlayOneShotOnCamera(); SelectedProject = helpDef; } }
private void DrawResearchContent( Rect rect ) { if( SelectedProject == null ) { return; } // Set up rects Rect descRect = rect.ContractedBy(_margin.x); descRect.height -= _buttonSize.y * 2 + _margin.y * 2; Rect controlRect = rect.ContractedBy(_margin.x); controlRect.yMin = descRect.yMax + _margin.y; #region description float paragraphMargin = 8f; float inset = 30f; var titleRect = new Rect(rect.xMin, rect.yMin, rect.width, 60f); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label( titleRect, SelectedProject.LabelCap ); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Rect outRect = rect.ContractedBy(2 * _margin.x); // double margin, this is a large UI block. outRect.yMin += 60f; Rect viewRect = outRect; viewRect.width -= 16f; viewRect.height = _contentHeight; GUI.BeginGroup( outRect ); Widgets.BeginScrollView( outRect.AtZero(), ref _contentScrollPos, viewRect.AtZero() ); Vector2 cur = Vector2.zero; HelpDetailSectionHelper.DrawText( ref cur, viewRect, SelectedProject.description ); cur.y += paragraphMargin; foreach( HelpDetailSection section in SelectedProject.HelpDetailSections ) { cur.x = 0f; if( !string.IsNullOrEmpty( section.Label ) ) { HelpDetailSectionHelper.DrawText( ref cur, viewRect, section.Label ); cur.x = inset; } if( section.StringDescs != null ) { foreach( string s in section.StringDescs ) { HelpDetailSectionHelper.DrawText( ref cur, viewRect, s ); } } if( section.KeyDefs != null ) { foreach( DefStringTriplet defStringTriplet in section.KeyDefs ) { // deflink may return true if the defstringtriplet contains a valid linkable def and is clicked if( HelpDetailSectionHelper.DrawDefLink( ref cur, viewRect, defStringTriplet ) ) { // Helper can only return true if helpDef exists, lets find it! HelpDef linkedHelpDef = defStringTriplet.Def.GetHelpDef(); if( defStringTriplet.Def is ResearchProjectDef ) { _showResearchedProjects = ShowResearch.All; RefreshSource(); SelectedProject = linkedHelpDef; } else { // If it's not research, we're linking to the help tab. MainTabDef helpTab = DefDatabase<MainTabDef>.GetNamed("CCL_ModHelp", false); if( helpTab != null ) { MainTabWindow_ModHelp helpWindow = (MainTabWindow_ModHelp) helpTab.Window; helpWindow.SelectedHelpDef = linkedHelpDef; Find.MainTabsRoot.SetCurrentTab( helpTab, false ); helpWindow.JumpToDef( linkedHelpDef ); } } } } } cur.y += paragraphMargin; } _contentHeight = cur.y; Widgets.EndScrollView(); GUI.EndGroup(); #endregion #region controls GUI.BeginGroup( controlRect ); Rect buttonRect = new Rect(controlRect.width / 2f - _buttonSize.x / 2, 0f, _buttonSize.x, _buttonSize.y); Def selectedProjectDef = SelectedProject.keyDef; // regular research if (selectedProjectDef is ResearchProjectDef) { ResearchProjectDef selectedResearchProjectDef = (ResearchProjectDef)selectedProjectDef; if( selectedResearchProjectDef.IsFinished ) { Widgets.DrawMenuSection( buttonRect ); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label( buttonRect, "Finished".Translate() ); Text.Anchor = TextAnchor.UpperLeft; } else if( selectedResearchProjectDef == Find.ResearchManager.currentProj ) { Widgets.DrawMenuSection( buttonRect ); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label( buttonRect, "InProgress".Translate() ); Text.Anchor = TextAnchor.UpperLeft; } else if( !selectedResearchProjectDef.PrereqsFulfilled ) { Widgets.DrawMenuSection( buttonRect ); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label( buttonRect, "RI.PreReqLocked".Translate() ); Text.Anchor = TextAnchor.UpperLeft; } else { if( Widgets.TextButton( buttonRect, "Research".Translate() ) ) { SoundDef.Named( "ResearchStart" ).PlayOneShotOnCamera(); Find.ResearchManager.currentProj = selectedResearchProjectDef; } if( Prefs.DevMode ) { Rect devButtonRect = buttonRect; devButtonRect.x += devButtonRect.width + _margin.x; if( Widgets.TextButton( devButtonRect, "Debug Insta-finish" ) ) { Find.ResearchManager.currentProj = selectedResearchProjectDef; Find.ResearchManager.InstantFinish( selectedResearchProjectDef ); } } } Rect progressRect = new Rect(_margin.x, _buttonSize.y + _margin.y, controlRect.width - 2 * _margin.x, _buttonSize.y); Widgets.FillableBar( progressRect, selectedResearchProjectDef.PercentComplete, BarFillTex, BarBgTex, true ); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label( progressRect, selectedResearchProjectDef.ProgressNumbersString ); } // advanced research if( selectedProjectDef is AdvancedResearchDef ) { AdvancedResearchDef selectedAdvancedResearchDef = (AdvancedResearchDef)selectedProjectDef; List<ResearchProjectDef> prereqs = selectedAdvancedResearchDef.researchDefs; if( selectedAdvancedResearchDef.IsFinished ) { Widgets.DrawMenuSection( buttonRect ); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label( buttonRect, "Finished".Translate() ); Text.Anchor = TextAnchor.UpperLeft; } else if( prereqs.Any(rd => rd.IsFinished) ) { Widgets.DrawMenuSection( buttonRect ); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label( buttonRect, "InProgress".Translate() ); Text.Anchor = TextAnchor.UpperLeft; } else if( selectedAdvancedResearchDef.IsLockedOut() ) { Widgets.DrawMenuSection( buttonRect ); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label( buttonRect, "RI.PreReqLocked".Translate() ); Text.Anchor = TextAnchor.UpperLeft; } // progress, slightly different for advanced research def Rect progressRect = new Rect(_margin.x, _buttonSize.y + _margin.y, controlRect.width - 2 * _margin.x, _buttonSize.y); float percentComplete = prereqs.Count(rd => rd.IsFinished) / prereqs.Count; Widgets.FillableBar( progressRect, percentComplete, BarFillTex, BarBgTex, true ); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label( progressRect, prereqs.Count(rd => rd.IsFinished) + " / " + prereqs.Count ); } Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); #endregion }
void DrawDisplayArea( Rect rect ) { float paragraphMargin = 8f; float inset = 30f; Widgets.DrawMenuSection( rect ); if( SelectedHelpDef == null ) { return; } var titleRect = new Rect(rect.xMin, rect.yMin, rect.width, 60f); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label( titleRect, SelectedHelpDef.LabelCap ); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Rect outRect = rect.ContractedBy(Margin); outRect.yMin += 60f; Rect viewRect = outRect; viewRect.width -= 16f; viewRect.height = ContentHeight; GUI.BeginGroup( outRect ); Widgets.BeginScrollView( outRect.AtZero(), ref DisplayScrollPos, viewRect.AtZero() ); Vector2 cur = Vector2.zero; HelpDetailSectionHelper.DrawText( ref cur, viewRect, SelectedHelpDef.description ); cur.y += paragraphMargin; foreach( HelpDetailSection section in SelectedHelpDef.HelpDetailSections ) { cur.x = 0f; if( !string.IsNullOrEmpty( section.Label ) ) { HelpDetailSectionHelper.DrawText( ref cur, viewRect, section.Label ); cur.x = inset; } if( section.StringDescs != null ) { foreach( string s in section.StringDescs ) { HelpDetailSectionHelper.DrawText( ref cur, viewRect, s ); } } if( section.KeyDefs != null ) { foreach( DefStringTriplet defStringTriplet in section.KeyDefs ) { if( HelpDetailSectionHelper.DrawDefLink( ref cur, viewRect, defStringTriplet ) ) { // bit ugly, but since the helper can't return true if the helpdef doesn't exist, we can fetch it again here -Fluffy. // TODO: better way of passing along helpdef. Perhaps make a resolve references step to add helpdef so we don't have to find it in realtime? HelpDef helpDef = DefDatabase<HelpDef>.AllDefsListForReading.First(hd => hd.keyDef == defStringTriplet.Def); SelectedHelpDef = helpDef; JumpToDef( helpDef ); } } } cur.y += paragraphMargin; } ContentHeight = cur.y; Widgets.EndScrollView(); GUI.EndGroup(); }
static HelpDef HelpForBuildable( BuildableDef buildableDef, HelpCategoryDef category ) { var helpDef = new HelpDef(); helpDef.defName = buildableDef.defName + "_BuildableDef_Help"; helpDef.keyDef = buildableDef; helpDef.label = buildableDef.label; helpDef.category = category; helpDef.description = buildableDef.description; #region Base Stats // Look at base stats HelpDetailSection baseStats = new HelpDetailSection( null, buildableDef.statBases.Select(sb => sb.stat).ToList().ConvertAll(def => (Def)def), null, buildableDef.statBases.Select(sb => sb.stat.ValueToString(sb.value, sb.stat.toStringNumberSense)).ToArray()); helpDef.HelpDetailSections.Add( baseStats ); #endregion #region ThingDef Specific var thingDef = buildableDef as ThingDef; if( thingDef != null ) { #region Ingestible Stats // Look at base stats if( thingDef.IsNutritionSource ) { string[] ingestibleStats = { "Nutrition".Translate() + ": " + thingDef.ingestible.nutrition.ToString( "0.###" ), "Joy".Translate() + ": " + thingDef.ingestible.joy.ToString( "0.###" ) }; helpDef.HelpDetailSections.Add( new HelpDetailSection( null, ingestibleStats ) ); } #endregion #region Body Part Stats if( (!thingDef.thingCategories.NullOrEmpty()) && (thingDef.thingCategories.Contains( ThingCategoryDefOf.BodyPartsAndImplants )) && (thingDef.IsImplant()) ) { var hediffDef = thingDef.GetImplantHediffDef(); #region Efficiency if( hediffDef.addedPartProps != null ) { helpDef.HelpDetailSections.Add( new HelpDetailSection( "BodyPartEfficiency".Translate(), new[] { hediffDef.addedPartProps.partEfficiency.ToString( "P0" ) } ) ); } #endregion #region Capacities if( (!hediffDef.stages.NullOrEmpty()) && (hediffDef.stages.Exists( stage => ( (!stage.capMods.NullOrEmpty()) ) )) ) { HelpDetailSection capacityMods = new HelpDetailSection( "CapacityModifiers".Translate(), hediffDef.stages.Where(s => !s.capMods.NullOrEmpty()) .SelectMany(s => s.capMods) .Select(cm => cm.capacity) .ToList() .ConvertAll(def => (Def)def), null, hediffDef.stages .Where(s => !s.capMods.NullOrEmpty()) .SelectMany(s => s.capMods) .Select( cm => (cm.offset > 0 ? ": +" : ": ") + cm.offset.ToString("P0")) .ToArray()); helpDef.HelpDetailSections.Add( capacityMods ); } #endregion #region Components (Melee attack) if( (!hediffDef.comps.NullOrEmpty()) && (hediffDef.comps.Exists( p => ( (p.compClass == typeof( HediffComp_VerbGiver )) ) )) ) { foreach( var comp in hediffDef.comps ) { if( comp.compClass == typeof( HediffComp_VerbGiver ) ) { if( !comp.verbs.NullOrEmpty() ) { foreach( var verb in comp.verbs ) { if( verb.verbClass == typeof( Verb_MeleeAttack ) ) { helpDef.HelpDetailSections.Add( new HelpDetailSection( "MeleeAttack".Translate( verb.meleeDamageDef.label ), new[] { "MeleeWarmupTime".Translate() + verb.defaultCooldownTicks, "StatsReport_MeleeDamage".Translate() + verb.meleeDamageBaseAmount } ) ); } } } } } } #endregion #region Body part fixed or replaced var recipeDef = thingDef.GetImplantRecipeDef(); if( !recipeDef.appliedOnFixedBodyParts.NullOrEmpty() ) { helpDef.HelpDetailSections.Add( new HelpDetailSection( "AutoHelpSurgeryFixOrReplace".Translate(), recipeDef.appliedOnFixedBodyParts.ToList().ConvertAll( def => (Def)def ) ) ); } #endregion } #endregion #region Cost List // What other things are required? if( !thingDef.costList.NullOrEmpty() ) { HelpDetailSection costs = new HelpDetailSection( "AutoHelpCost".Translate(), thingDef.costList.Select(tc => tc.thingDef).ToList().ConvertAll(def => (Def)def), null, thingDef.costList.Select(tc => ": " + tc.count.ToString()).ToArray()); helpDef.HelpDetailSections.Add( costs ); } #endregion #region Stuff Cost // What stuff can it be made from? if( (thingDef.costStuffCount > 0) && (!thingDef.stuffCategories.NullOrEmpty()) ) { helpDef.HelpDetailSections.Add( new HelpDetailSection( "AutoHelpStuffCost".Translate( thingDef.costStuffCount.ToString() ), thingDef.stuffCategories.ToList().ConvertAll( def => (Def)def ) ) ); } #endregion #region Recipes & Research // Get list of recipes var recipeDefs = thingDef.AllRecipes; if( !recipeDefs.NullOrEmpty() ) { HelpDetailSection recipes = new HelpDetailSection( "AutoHelpListRecipes".Translate(), recipeDefs.ConvertAll(def => (Def)def)); helpDef.HelpDetailSections.Add( recipes ); } // Add list of required research var researchDefs = buildableDef.GetResearchRequirements(); if( !researchDefs.NullOrEmpty() ) { HelpDetailSection reqResearch = new HelpDetailSection( "AutoHelpListResearchRequired".Translate(), researchDefs.ConvertAll(def => (Def)def)); helpDef.HelpDetailSections.Add( reqResearch ); } // Build help for unlocked recipes associated with building recipeDefs = thingDef.GetRecipesUnlocked( ref researchDefs ); if( (!recipeDefs.NullOrEmpty()) && (!researchDefs.NullOrEmpty()) ) { HelpDetailSection unlockRecipes = new HelpDetailSection( "AutoHelpListRecipesUnlocked".Translate(), recipeDefs.ConvertAll<Def>(def => (Def)def)); HelpDetailSection researchBy = new HelpDetailSection( "AutoHelpListResearchBy".Translate(), researchDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( unlockRecipes ); helpDef.HelpDetailSections.Add( researchBy ); } // Build help for locked recipes associated with building recipeDefs = thingDef.GetRecipesLocked( ref researchDefs ); if( (!recipeDefs.NullOrEmpty()) && (!researchDefs.NullOrEmpty()) ) { HelpDetailSection unlockRecipes = new HelpDetailSection( "AutoHelpListRecipesLocked".Translate(), recipeDefs.ConvertAll<Def>(def => (Def)def)); HelpDetailSection researchBy = new HelpDetailSection( "AutoHelpListResearchBy".Translate(), researchDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( unlockRecipes ); helpDef.HelpDetailSections.Add( researchBy ); } #endregion #region Facilities // Get list of facilities that effect it var affectedBy = thingDef.GetCompProperties( typeof( CompAffectedByFacilities ) ); if( (affectedBy != null) && (!affectedBy.linkableFacilities.NullOrEmpty()) ) { HelpDetailSection facilitiesAffecting = new HelpDetailSection( "AutoHelpListFacilitiesAffecting".Translate(), affectedBy.linkableFacilities.ConvertAll<Def>(def => (Def)def)); } // Get list of buildings effected by it if( thingDef.HasComp( typeof( CompFacility ) ) ) { var effectsBuildings = DefDatabase< ThingDef >.AllDefsListForReading .Where( f => ( ( f.HasComp( typeof( CompAffectedByFacilities ) ) )&& ( f.GetCompProperties( typeof( CompAffectedByFacilities ) ) != null )&& ( f.GetCompProperties( typeof( CompAffectedByFacilities ) ).linkableFacilities != null )&& ( f.GetCompProperties( typeof( CompAffectedByFacilities ) ).linkableFacilities.Contains( thingDef ) ) ) ).ToList(); if( !effectsBuildings.NullOrEmpty() ) { var facilityProperties = thingDef.GetCompProperties( typeof( CompFacility ) ); List<string> facilityStats = new List<string>(); facilityStats.Add( "AutoHelpMaximumAffected".Translate( facilityProperties.maxSimultaneous.ToString() ) ); // Look at stats modifiers foreach( var stat in facilityProperties.statOffsets ) { facilityStats.Add( stat.stat.LabelCap + ": " + stat.stat.ValueToString( stat.value, stat.stat.toStringNumberSense ) ); } HelpDetailSection facilityDetailSection = new HelpDetailSection( "AutoHelpFacilityStats".Translate(), facilityStats.ToArray()); HelpDetailSection facilitiesAffected = new HelpDetailSection( "AutoHelpListFacilitiesAffected".Translate(), effectsBuildings.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( facilityDetailSection ); helpDef.HelpDetailSections.Add( facilitiesAffected ); } } #endregion #region Joy // Get valid joy givers var joyGiverDefs = DefDatabase< JoyGiverDef >.AllDefsListForReading .Where( j => ( ( j.thingDef == thingDef )&& ( j.jobDef != null ) ) ).ToList(); if( !joyGiverDefs.NullOrEmpty() ) { List<string> joyStats = new List<string>(); foreach( var joyGiverDef in joyGiverDefs ) { // Get job driver stats joyStats.Add( joyGiverDef.jobDef.reportString ); joyStats.Add( "AutoHelpMaximumParticipants".Translate( joyGiverDef.jobDef.joyMaxParticipants.ToString() ) ); joyStats.Add( "AutoHelpJoyKind".Translate( joyGiverDef.jobDef.joyKind.LabelCap ) ); if( joyGiverDef.jobDef.joySkill != null ) { joyStats.Add( "AutoHelpJoySkill".Translate( joyGiverDef.jobDef.joySkill.LabelCap ) ); } } HelpDetailSection joyDetailSection = new HelpDetailSection( "AutoHelpListJoyActivities".Translate(), joyStats.ToArray()); helpDef.HelpDetailSections.Add( joyDetailSection ); } #endregion } #endregion return helpDef; }
static HelpDef HelpForRecipe( ThingDef thingDef, RecipeDef recipeDef, HelpCategoryDef category ) { var helpDef = new HelpDef(); helpDef.keyDef = thingDef.defName +"_" + recipeDef.defName; helpDef.defName = helpDef.keyDef + "_RecipeDef_Help"; helpDef.label = recipeDef.label; helpDef.category = category; var s = new StringBuilder(); s.AppendLine( recipeDef.description ); s.AppendLine(); #region Base Stats s.AppendLine( "WorkAmount".Translate() + " : " + GenText.ToStringWorkAmount( recipeDef.WorkAmountTotal( (ThingDef) null ) ) ); s.AppendLine(); #endregion #region Skill Requirements if( ( recipeDef.skillRequirements != null )&& ( recipeDef.skillRequirements.Count > 0 ) ) { s.AppendLine( "MinimumSkills".Translate() ); foreach( var sr in recipeDef.skillRequirements ) { s.Append( "\t" ); s.AppendLine( "BillRequires".Translate( new object[] { sr.minLevel.ToString( "####0" ), sr.skill.label.ToLower() } ) ); } s.AppendLine(); } #endregion #region Ingredients // List of ingredients if( ( recipeDef.ingredients != null )&& ( recipeDef.ingredients.Count > 0 ) ) { s.Append( "Ingredients".Translate() ); s.AppendLine( ":" ); foreach( var ing in recipeDef.ingredients ) { if( !GenText.NullOrEmpty( ing.filter.Summary ) ) { s.Append( "\t" ); s.AppendLine( recipeDef.IngredientValueGetter.BillRequirementsDescription( ing ) ); } } s.AppendLine(); } #endregion #region Products // List of products if( ( recipeDef.products != null )&& ( recipeDef.products.Count > 0 ) ) { s.AppendLine( "AutoHelpListRecipeProducts".Translate() ); foreach( var ing in recipeDef.products ) { s.Append( "\t" ); s.Append( ing.thingDef.LabelCap ); s.Append( " : " ); s.AppendLine( ing.count.ToString() ); } s.AppendLine(); } #endregion #region Things & Research // Add things it's on var thingDefs = recipeDef.GetThingsCurrent(); BuildDefDescription( s, "AutoHelpListRecipesOnThings".Translate(), thingDefs.ConvertAll<Def>( def => (Def)def ) ); // Add research required var researchDefs = recipeDef.GetResearchRequirements(); BuildDefDescription( s, "AutoHelpListResearchRequired".Translate(), researchDefs ); // What things is it on after research thingDefs = recipeDef.GetThingsUnlocked( ref researchDefs ); BuildDefWithDefDescription( s, "AutoHelpListRecipesOnThingsUnlocked".Translate(), "AutoHelpListResearchBy".Translate(), thingDefs.ConvertAll<Def>( def => (Def)def ), researchDefs.ConvertAll<Def>( def => (Def)def ) ); // Get research which locks recipe thingDefs = recipeDef.GetThingsLocked( ref researchDefs ); BuildDefWithDefDescription( s, "AutoHelpListRecipesOnThingsLocked".Translate(), "AutoHelpListResearchBy".Translate(), thingDefs.ConvertAll<Def>( def => (Def)def ), researchDefs.ConvertAll<Def>( def => (Def)def ) ); #endregion helpDef.description = s.ToString(); return helpDef; }
static HelpDef HelpForAdvancedResearch( AdvancedResearchDef advancedResearchDef, HelpCategoryDef category ) { var helpDef = new HelpDef(); helpDef.defName = advancedResearchDef.defName + "_AdvancedResearchDef_Help"; helpDef.keyDef = advancedResearchDef; helpDef.label = advancedResearchDef.label; helpDef.description = advancedResearchDef.description; if( advancedResearchDef.helpCategoryDef == null ) { advancedResearchDef.helpCategoryDef = category; } if( advancedResearchDef.IsHelpEnabled ) { helpDef.category = advancedResearchDef.helpCategoryDef; } #region Base Stats HelpDetailSection totalCost = new HelpDetailSection( null, new [] {"AutoHelpTotalCost".Translate( advancedResearchDef.TotalCost.ToString() )}); helpDef.HelpDetailSections.Add( totalCost ); #endregion #region Research, Buildings, Recipes and SowTags // Add research required var researchDefs = advancedResearchDef.GetResearchRequirements(); if( !researchDefs.NullOrEmpty() ) { HelpDetailSection researchRequired = new HelpDetailSection( "AutoHelpListResearchRequired".Translate(), researchDefs.ConvertAll<Def>( def =>(Def)def ) ); helpDef.HelpDetailSections.Add( researchRequired ); } // Add buildings it unlocks var thingDefs = advancedResearchDef.GetThingsUnlocked(); if( !thingDefs.NullOrEmpty() ) { HelpDetailSection thingsUnlocked = new HelpDetailSection( "AutoHelpListThingsUnlocked".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ) ); helpDef.HelpDetailSections.Add( thingsUnlocked ); } // Add recipes it unlocks var recipeDefs = advancedResearchDef.GetRecipesUnlocked( ref thingDefs ); if( (!recipeDefs.NullOrEmpty()) && (!thingDefs.NullOrEmpty()) ) { HelpDetailSection recipesUnlocked = new HelpDetailSection( "AutoHelpListRecipesUnlocked".Translate(), recipeDefs.ConvertAll<Def>( def =>(Def)def ) ); helpDef.HelpDetailSections.Add( recipesUnlocked ); HelpDetailSection recipesOnThingsUnlocked = new HelpDetailSection( "AutoHelpListRecipesOnThings".Translate(), thingDefs.ConvertAll<Def>(def => (Def)def)); helpDef.HelpDetailSections.Add( recipesOnThingsUnlocked ); } // Add plants and sow tags it unlocks var sowTags = advancedResearchDef.GetSowTagsUnlocked( ref thingDefs ); if( (!sowTags.NullOrEmpty()) && (!thingDefs.NullOrEmpty()) ) { HelpDetailSection plantsUnlocked = new HelpDetailSection( "AutoHelpListPlantsUnlocked".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ) ); helpDef.HelpDetailSections.Add( plantsUnlocked ); HelpDetailSection recipesOnThingsUnlocked = new HelpDetailSection( "AutoHelpListPlantsIn".Translate(), sowTags.ToArray() ); helpDef.HelpDetailSections.Add( recipesOnThingsUnlocked ); } #endregion #region Lockouts // Add buildings it locks thingDefs = advancedResearchDef.GetThingsLocked(); if( !thingDefs.NullOrEmpty() ) { HelpDetailSection thingsLocked = new HelpDetailSection( "AutoHelpListThingsLocked".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ) ); helpDef.HelpDetailSections.Add( thingsLocked ); } // Add recipes it locks recipeDefs = advancedResearchDef.GetRecipesLocked( ref thingDefs ); if( (!recipeDefs.NullOrEmpty()) && (!thingDefs.NullOrEmpty()) ) { HelpDetailSection recipesLocked = new HelpDetailSection( "AutoHelpListRecipesLocked".Translate(), recipeDefs.ConvertAll<Def>( def =>(Def)def ) ); helpDef.HelpDetailSections.Add( recipesLocked ); HelpDetailSection recipesOnThings = new HelpDetailSection( "AutoHelpListRecipesOnThings".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ) ); helpDef.HelpDetailSections.Add( recipesOnThings ); } // Add plants and sow tags it locks sowTags = advancedResearchDef.GetSowTagsLocked( ref thingDefs ); if( (!sowTags.NullOrEmpty()) && (!thingDefs.NullOrEmpty()) ) { HelpDetailSection plantsLocked = new HelpDetailSection( "AutoHelpListPlantsLocked".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ) ); helpDef.HelpDetailSections.Add( plantsLocked ); HelpDetailSection plantsIn = new HelpDetailSection( "AutoHelpListPlantsIn".Translate(), sowTags.ToArray() ); helpDef.HelpDetailSections.Add( plantsIn ); } #endregion advancedResearchDef.HelpDef = helpDef; return helpDef; }
public void DrawHelpEntry( ref Vector2 cur, int nestLevel, Rect view, HelpDef helpDef ) { bool selected = SelectedHelpDef == helpDef; if( selected && _jump ) { SelectionScrollPos.y = cur.y; _jump = false; } if( DrawEntry( ref cur, nestLevel, view, helpDef.LabelCap, State.Leaf, selected ) ) { SelectedHelpDef = helpDef; } }
static HelpDef HelpForResearch( ResearchProjectDef researchProjectDef, HelpCategoryDef category ) { var helpDef = new HelpDef(); helpDef.defName = researchProjectDef.defName + "_ResearchProjectDef_Help"; helpDef.keyDef = researchProjectDef.defName; helpDef.label = researchProjectDef.label; helpDef.category = category; var s = new StringBuilder(); s.AppendLine( researchProjectDef.description ); s.AppendLine(); #region Base Stats s.AppendLine( "AutoHelpTotalCost".Translate( researchProjectDef.totalCost.ToString() ) ); s.AppendLine(); #endregion #region Research, Buildings, Recipes and SowTags // Add research required var researchDefs = researchProjectDef.GetResearchRequirements(); BuildDefDescription( s, "AutoHelpListResearchRequired".Translate(), researchDefs.ConvertAll<Def>( def =>(Def)def ) ); // Add buildings it unlocks var thingDefs = researchProjectDef.GetThingsUnlocked(); BuildDefDescription( s, "AutoHelpListThingsUnlocked".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ) ); // Add recipes it unlocks var recipeDefs = researchProjectDef.GetRecipesUnlocked( ref thingDefs ); BuildDefWithDefDescription( s, "AutoHelpListRecipesUnlocked".Translate(), "AutoHelpListRecipesOnThingsUnlocked".Translate(), recipeDefs.ConvertAll<Def>( def =>(Def)def ), thingDefs.ConvertAll<Def>( def =>(Def)def ) ); // Look in advanced research to add plants and sow tags it unlocks var sowTags = researchProjectDef.GetSowTagsUnlocked( ref thingDefs ); BuildDefWithStringDescription( s, "AutoHelpListPlantsUnlocked".Translate(), "AutoHelpListPlantsIn".Translate(), thingDefs.ConvertAll<Def>( def =>(Def)def ), sowTags ); #endregion #region Lockouts // Get advanced research which locks researchDefs = researchProjectDef.GetResearchedLockedBy(); BuildDefDescription( s, "AutoHelpListResearchLockout".Translate(), researchDefs.ConvertAll<Def>( def =>(Def)def ) ); #endregion helpDef.description = s.ToString(); return helpDef; }
public IHelpDefView SecondaryView( HelpDef def ) { return null; }
public void Draw(ref Vector2 cur, Vector3 colWidths, IHelpDefView window = null) { // calculate height of row, or fetch from cache if (!_heightSet) { List <float> heights = new List <float>(); if (!Prefix.NullOrEmpty()) { heights.Add(Text.CalcHeight(Prefix, colWidths.x)); } heights.Add(Text.CalcHeight(Def.LabelStyled(), colWidths.y)); if (!Suffix.NullOrEmpty()) { heights.Add(Text.CalcHeight(Suffix, colWidths.z)); } _height = heights.Max(); _heightSet = true; } // draw text if (!Prefix.NullOrEmpty()) { Rect prefixRect = new Rect(cur.x, cur.y, colWidths.x, _height); Widgets.Label(prefixRect, Prefix); } if (!Suffix.NullOrEmpty()) { Rect suffixRect = new Rect(cur.x + colWidths.x + colWidths.y + 2 * HelpDetailSection._columnMargin, cur.y, colWidths.z, _height); Widgets.Label(suffixRect, Suffix); } Rect labelRect; if (Def.IconTexture() != null) { Rect iconRect = new Rect(cur.x + colWidths.x + (Prefix.NullOrEmpty() ? 0 : 1) * HelpDetailSection._columnMargin, cur.y + 2f, 16f, 16f); labelRect = new Rect(cur.x + colWidths.x + 20f + (Prefix.NullOrEmpty() ? 0 : 1) * HelpDetailSection._columnMargin, cur.y, colWidths.y - 20f, _height); Def.DrawColouredIcon(iconRect); Widgets.Label(labelRect, Def.LabelStyled()); } else { labelRect = new Rect(cur.x + colWidths.x + (Prefix.NullOrEmpty() ? 0 : 1) * HelpDetailSection._columnMargin, cur.y, colWidths.y, _height); Widgets.Label(labelRect, Def.LabelStyled()); } // def interactions (if any) // if we have a window set up to catch jumps, and there is a helpdef available, draw a button on the def text. HelpDef helpDef = Def.GetHelpDef(); if ( (window != null) && (helpDef != null) ) { TooltipHandler.TipRegion(labelRect, Def.description + (Def.description.NullOrEmpty() ? "" : "\n\n") + "JumpToTopic".Translate()); if (Widgets.InvisibleButton(labelRect)) { if (window.Accept(helpDef)) { window.JumpTo(helpDef); } else { window.SecondaryView(helpDef).JumpTo(helpDef); } } } if ( (helpDef == null) && (!Def.description.NullOrEmpty()) ) { TooltipHandler.TipRegion(labelRect, Def.description); } cur.y += _height - MainTabWindow_ModHelp.LineHeigthOffset; }