Exemple #1
0
        public static void DrawTechLevel(TechLevel techlevel, Rect visibleRect)
        {
            // determine positions
            var xMin = (NodeSize.x + NodeMargins.x) * TechLevelBounds[techlevel].min - NodeMargins.x / 2f;
            var xMax = (NodeSize.x + NodeMargins.x) * TechLevelBounds[techlevel].max - NodeMargins.x / 2f;

            GUI.color   = Assets.TechLevelColor;
            Text.Anchor = TextAnchor.MiddleCenter;

            // lower bound
            if (TechLevelBounds[techlevel].min > 0 && xMin > visibleRect.xMin && xMin < visibleRect.xMax)
            {
                // line
                Widgets.DrawLine(new Vector2(xMin, visibleRect.yMin), new Vector2(xMin, visibleRect.yMax), Assets.TechLevelColor, 1f);

                // label
                // NOTE: This is a massive copout, but just don't draw these labels if zoomlevel != 1;
                if (MainTabWindow_ResearchTree.Instance.ZoomLevel - 1f < 1e-4)
                {
                    var labelRect = new Rect(
                        xMin + TechLevelLabelSize.y / 2f - TechLevelLabelSize.x / 2f,
                        visibleRect.center.y - TechLevelLabelSize.y / 2f,
                        TechLevelLabelSize.x,
                        TechLevelLabelSize.y);
                    UI.RotateAroundPivot(-90, labelRect.center);
                    Widgets.Label(labelRect, techlevel.ToStringHuman());
                    UI.RotateAroundPivot(90, labelRect.center);
                }
            }

            // upper bound
            if (TechLevelBounds[techlevel].max <Size.x && xMax> visibleRect.xMin && xMax < visibleRect.xMax)
            {
                // label
                var labelRect = new Rect(
                    xMax - TechLevelLabelSize.y / 2f - TechLevelLabelSize.x / 2f,
                    visibleRect.center.y - TechLevelLabelSize.y / 2f,
                    TechLevelLabelSize.x,
                    TechLevelLabelSize.y);
                UI.RotateAroundPivot(-90, labelRect.center);
                Widgets.Label(labelRect, techlevel.ToStringHuman());
                UI.RotateAroundPivot(90, labelRect.center);
            }

            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
        }
Exemple #2
0
        public static void DrawTechLevel(TechLevel techlevel, Rect visibleRect)
        {
            // determine positions
            var xMin = (NodeSize.x + NodeMargins.x) * TechLevelBounds[techlevel].min - NodeMargins.x / 2f;
            var xMax = (NodeSize.x + NodeMargins.x) * TechLevelBounds[techlevel].max - NodeMargins.x / 2f;

            GUI.color   = Assets.TechLevelColor;
            Text.Anchor = TextAnchor.MiddleCenter;

            // lower bound
            if (TechLevelBounds[techlevel].min > 0 && xMin > visibleRect.xMin && xMin < visibleRect.xMax)
            {
                // line
                Widgets.DrawLine(new Vector2(xMin, visibleRect.yMin), new Vector2(xMin, visibleRect.yMax),
                                 Assets.TechLevelColor, 1f);

                // label
                var labelRect = new Rect(
                    xMin + TechLevelLabelSize.y / 2f - TechLevelLabelSize.x / 2f,
                    visibleRect.center.y - TechLevelLabelSize.y / 2f,
                    TechLevelLabelSize.x,
                    TechLevelLabelSize.y);

                VerticalLabel(labelRect, techlevel.ToStringHuman());
            }

            // upper bound
            if (TechLevelBounds[techlevel].max <Size.x && xMax> visibleRect.xMin && xMax < visibleRect.xMax)
            {
                // label
                var labelRect = new Rect(
                    xMax - TechLevelLabelSize.y / 2f - TechLevelLabelSize.x / 2f,
                    visibleRect.center.y - TechLevelLabelSize.y / 2f,
                    TechLevelLabelSize.x,
                    TechLevelLabelSize.y);

                VerticalLabel(labelRect, techlevel.ToStringHuman());
            }

            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
        }
Exemple #3
0
        public override void DoEffect(Pawn usedBy)
        {
            base.DoEffect(usedBy);

            // Get Tech Level & appropriate techs
            TechLevel techLevel = parent.GetComp <CompBlueprint>().techLevel;
            List <ResearchProjectDef> techList = DefDatabase <ResearchProjectDef> .AllDefsListForReading.FindAll((ResearchProjectDef x) => ((x.techLevel == techLevel) && (!x.IsFinished) && (x.CanStartNow)));

            ResearchProjectDef chosenResearchProject = techList.RandomElement <ResearchProjectDef>(); // TODO: weigh the selection

            if (chosenResearchProject == null)
            {
                // RESEARCH IS NULL! Do nothing.
                Log.Error("No research has been selected because none fit the conditions.");
                return;
            }

            if (Faction.OfPlayer.def.techLevel >= techLevel)
            {
                researchPercentage = 1f; //100% of base cost
                endMessage         = "The " + techLevel.ToStringHuman() + " technology blueprint revealed everything about " + chosenResearchProject.label.ToString() + ".";
            }
            else
            {
                researchPercentage = 0.34f; //34% of base cost
                endMessage         = "The " + techLevel.ToStringHuman() + " technology blueprint is complicated, but it helped understand " + chosenResearchProject.label.ToString() + ".";
            }

            // Change current project just the time to add research points then restore it
            ResearchProjectDef storedResearchProject = Find.ResearchManager.currentProj;

            Find.ResearchManager.currentProj = chosenResearchProject;

            ResearchGainAmount = chosenResearchProject.CostApparent * researchPercentage / 0.007f / chosenResearchProject.CostFactor(usedBy.Faction.def.techLevel);

            Find.ResearchManager.ResearchPerformed(ResearchGainAmount, null);

            Find.ResearchManager.currentProj = storedResearchProject;

            // Feedback top left
            Messages.Message(endMessage, MessageTypeDefOf.PositiveEvent); // Adds a message top left
        }
        private float DrawToggle(float posX, float posY, TechLevel techLevel)
        {
            bool    toggle   = TechLevelVisibility[techLevel];
            Vector2 position = new Vector2(posX, posY);
            Rect    box      = new Rect(position, buttonSize);
            var     curFont  = Text.Font;

            Text.Font = GameFont.Tiny;
            TooltipHandler.TipRegionByKey(box, techLevel.ToStringHuman());
            Text.Font = curFont;
            Color color = toggle ? Color.Lerp(ResearchTree_Assets.ColorCompleted[techLevel], Widgets.WindowBGFillColor, 0.2f) : ResearchTree_Assets.ColorAvailable[techLevel];

            if (Widgets.ButtonImage(box, ContentFinder <Texture2D> .Get("UI/dot", true), color, ResearchTree_Assets.ColorCompleted[techLevel]))
            {
                TechLevelVisibility[techLevel] = !TechLevelVisibility[techLevel];
            }
            return(posX + rowHeight);
        }
Exemple #5
0
 public override string RequirementExplanation(DivineJobDef def, DivineJobsComp comp, Pawn pawn)
 {
     if (IsRequirementMet(def, comp, pawn))
     {
         return("DivineJobs_JobRequirement_AddedParts_Success".Translate(CountAddedParts(pawn), minAmount, minTechLevel.ToStringHuman().CapitalizeFirst()));
     }
     else
     {
         return("DivineJobs_JobRequirement_AddedParts_Failed".Translate(CountAddedParts(pawn), minAmount, minTechLevel.ToStringHuman().CapitalizeFirst()));
     }
 }
        public override bool CanSign(Alliance alliance, AllianceAgreementDef allianceAgreementDef, Pawn speaker, out string reason)
        {
            if (!base.CanSign(alliance, allianceAgreementDef, speaker, out reason))
            {
                return(false);
            }

            if ((int)speaker.Faction?.def.techLevel < (int)MinFactionTechLevel)
            {
                reason = "DefenseContractCompProperties_FactionTechLevelLack".Translate(speaker.Faction.Name, speaker.Faction.def.techLevel.ToStringHuman(), MinFactionTechLevel.ToStringHuman());
                return(false);
            }

            return(true);
        }
Exemple #7
0
        public override void Draw(Rect canvas)
        {
            UserInterface.CurrentPage = "ApparelFilterPageTitle".UiTranslate();

            const float splitCanvasHight = 60f;
            Rect        top    = canvas.TopPartPixels(canvas.height - splitCanvasHight);;
            Rect        bottom = canvas.BottomPartPixels(splitCanvasHight); // 2 buttons

            Listing_Styled imui = new();

            imui.Begin(top, elementHeight: UserInterface.ElementHeight, gapSize: UserInterface.GapSize);

            // with recipes checkbox
            _ = imui.DubsCheckbox("WithRecipe".UiTranslate(), ref _recipeOnly);

            // target parameter
            imui.SameLinePercent(0.5f, 0.5f);
            imui.Label("TargetParameter".UiTranslate());
            if (imui.ButtonText(_targetColumn))
            {
                var options = _table.Columns.Select(x => new FloatMenuOption(x.Name, delegate()
                {
                    _targetColumn = x.Name;
                })).ToList();
                Find.WindowStack.Add(new FloatMenu(options));
            }

            // techLevel parameter
            imui.SameLinePercent(0.5f, 0.5f);
            imui.Label("TechLevel".ParserTranslate());
            if (imui.ButtonText(_techLevel?.ToStringHuman().CapitalizeFirst() ?? "Any".UiTranslate()))
            {
                TechLevel[] techLevels = (TechLevel[])Enum.GetValues(typeof(TechLevel));

                var options = techLevels.Select(x => new FloatMenuOption(x.ToStringHuman().CapitalizeFirst(), delegate()
                {
                    _techLevel = x;
                })).ToList();

                options.Insert(0, new FloatMenuOption("Any".UiTranslate(), delegate()
                {
                    _techLevel = null;
                }));

                Find.WindowStack.Add(new FloatMenu(options));
            }


            // order
            _ = imui.DubsCheckbox("OrderByDescending".UiTranslate(), ref _orderByDescending);

            // order
            _ = imui.TextFieldNumericLabeled("CountPerLayer".UiTranslate(), ref _countPerLayer, ref _countPerLayerBuf, 1f);
            imui.End();

            imui.Begin(bottom, elementHeight: 25f);
            // dump
            string btnSaveName = "SaveAndOpen".UiTranslate();

            if (Settings.SaveAndOpenAction != SaveAndOpenAction.Nothing)
            {
                btnSaveName += ". ";
                switch (Settings.SaveAndOpenAction)
                {
                case SaveAndOpenAction.OpenDirectory:
                    btnSaveName += "SaveAction_OpenDirectory".UiTranslate();
                    break;

                case SaveAndOpenAction.OpenDocument:
                    btnSaveName += "SaveAction_OpenDocument".UiTranslate();
                    break;
                }
            }
            if (imui.ButtonText(btnSaveName))
            {
                Table  filtered = ApparelFilter.FilterApparels(_table, _targetColumn, _orderByDescending, _recipeOnly, _countPerLayer, _techLevel);
                string fileName = $"{TableManager.SavePath}\\ApparelFiltered_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.xlsx";
                filtered.Export(fileName, TableManager.XlsxFormat);
                TableManager.OpenAction(fileName);
            }
            // back
            if (imui.ButtonText("Previous".UiTranslate()))
            {
                Close();
            }
            imui.End();
        }