public override void Refresh() { var sb = new StringBuilder("Province name: ").Append(Game.selectedProvince); if (Game.devMode) { sb.Append("\nID: ").Append(Game.selectedProvince.ID); sb.Append("\nNeighbors: ").Append(Game.selectedProvince.AllNeighbors().ToString(", ")); } sb.Append("\nPopulation (with families): ").Append(Game.selectedProvince.getFamilyPopulation()); sb.Append("\nAverage loyalty: ").Append(Game.selectedProvince.AllPops.GetAverageProcent(x => x.loyalty)); //sb.Append("\nMajor culture: ").Append(Game.selectedProvince.getMajorCulture()); //sb.Append("\nGDP: ").Append(Game.selectedProvince.getGDP()); sb.Append("\nResource: "); if (Game.selectedProvince.getResource() == null) { sb.Append("none "); } else { sb.Append(Game.selectedProvince.getResource()); } //sb.Append("\nTerrain: ").Append(Game.selectedProvince.getTerrain()); //sb.Append("\nRural overpopulation: ").Append(Game.selectedProvince.GetOverpopulation()); sb.Append("\nCores: ").Append(Game.selectedProvince.getCoresDescription()); sb.Append("\nCultures: ").Append(Game.selectedProvince.AllPops.Group(x => x.culture, y => y.population.Get()) .OrderByDescending(x => x.Value.get()).ToString(", ", 2)); sb.Append("\nClasses: ").Append(Game.selectedProvince.AllPops.Group(x => x.Type, y => y.population.Get()) .OrderByDescending(x => x.Value.get()).ToString(", ", 0)); if (Game.selectedProvince.getModifiers().Count > 0) { sb.Append("\nModifiers: ").Append(ToStringExtensions.ToString(Game.selectedProvince.getModifiers())); } Text text = btnOwner.GetComponentInChildren <Text>(); text.text = "Owner: " + Game.selectedProvince.Country; btnBuild.interactable = ProductionType.allowsForeignInvestments.checkIftrue(Game.Player, Game.selectedProvince, out btnBuild.GetComponent <ToolTipHandler>().text); btnBuild.GetComponent <ToolTipHandler>().AddText("\nHotkey is " + "B" + " button"); btMobilize.interactable = Province.doesCountryOwn.checkIftrue(Game.Player, Game.selectedProvince, out btMobilize.GetComponent <ToolTipHandler>().text); btMobilize.GetComponent <ToolTipHandler>().AddText("\nHotkey is " + "M" + " button"); //if (Game.devMode) // sb.Append("\nColor: ").Append(province.getColorID()); btAttackThat.interactable = Diplomacy.canAttack.isAllTrue(Game.selectedProvince, Game.Player, out btAttackThat.GetComponent <ToolTipHandler>().text); btAttackThat.GetComponent <ToolTipHandler>().AddText("\nHotkey is " + "T" + " button"); btGrandIndependence.interactable = Province.canGetIndependence.isAllTrue(Game.selectedProvince, Game.Player, out btGrandIndependence.GetComponent <ToolTipHandler>().text); generaltext.text = sb.ToString(); }
private void refresh(bool callRebuildDropDown) { table.Refresh(); movementsText.text = ToStringExtensions.ToString(Game.Player.Politics.AllMovements.OrderByDescending(x => x.getRelativeStrength(Game.Player).get())); if (movementsText.preferredHeight > 90 && movementsText.preferredHeight < 130) { movementsText.text += "\n\n\n\n"; } movementsHorizontalScrollBar.value = 0; if (ReferenceEquals(selectedReformType, null)) { voteButton.interactable = false; voteButton.GetComponentInChildren <Text>().text = "Select reform"; descriptionText.text = "Select reform from left"; forceDecisionButton.GetComponent <ToolTipHandler>().SetText(""); voteButton.GetComponent <ToolTipHandler>().SetText(""); } else //did selected reform { if (callRebuildDropDown) // meaning changed whole reform { rebuildDropDown(); } descriptionText.text = selectedReformType.ShortName + " reforms " + selectedReformType.FullName + "\nCurrently: "; // todo fix that mess in 3 places var isUnemploymentReformType = selectedReformType.Value as UnemploymentSubsidies.UnemploymentReformValue; if (isUnemploymentReformType == null) { var isUBIReform = selectedReformType.Value as UBI.UBIReformValue; if (isUBIReform == null) { var isPovertyAid = selectedReformType.Value as PovertyAid.PovertyAidReformValue; if (isPovertyAid == null) { // default text descriptionText.text += selectedReformType.Value; var isNamedReformType = selectedReformType.Value as INameable; if (isNamedReformType != null) { descriptionText.text += isNamedReformType.FullName; } } else { descriptionText.text += isPovertyAid.ToString(Game.Player.market); } } else { descriptionText.text += isUBIReform.ToString(Game.Player.market); } } else { descriptionText.text += isUnemploymentReformType.ToString(Game.Player.market); } descriptionText.text += "\nSelected: "; if (selectedReformType == selectedReformValue) { descriptionText.text += "current"; forceDecisionButton.interactable = false; voteButton.interactable = false; } else { //else { var isUnempValue = selectedReformValue as UnemploymentSubsidies.UnemploymentReformValue; if (isUnempValue != null) { descriptionText.text += isUnempValue.ToString(Game.Player.market); } else { var isPvrtREf = selectedReformValue as PovertyAid.PovertyAidReformValue; if (isPvrtREf != null) { descriptionText.text += isPvrtREf.ToString(Game.Player.market); } else { var isUBIRfr = selectedReformValue as UBI.UBIReformValue; if (isUBIRfr != null) { descriptionText.text += isUBIRfr.ToString(Game.Player.market); } else { var isNamedReformValue = selectedReformValue as INameable; if (isNamedReformValue != null) { descriptionText.text += isNamedReformValue.FullName; } else { descriptionText.text += selectedReformValue; } } } } } Procent procentPopulationSayedYes = new Procent(0f); Procent procentVotersSayedYes = Game.Player.Provinces.getYesVotes(selectedReformValue, ref procentPopulationSayedYes); Dictionary <PopType, int> divisionPopulationResult = new Dictionary <PopType, int>(); Dictionary <PopType, int> divisionVotersResult = Game.Player.Provinces.getYesVotesByType(selectedReformValue, ref divisionPopulationResult); RefreshInfoAboutVotes(procentVotersSayedYes, procentPopulationSayedYes, divisionVotersResult, divisionPopulationResult); // Control buttons interactability && tooltips if (selectedReformValue != null) { if (procentVotersSayedYes.get() >= Options.votingPassBillLimit && Game.Player.government != Government.Despotism) { // can vote for reform voteButton.interactable = selectedReformValue.IsAllowed(Game.Player, selectedReformValue, out voteButton.GetComponent <ToolTipHandler>().text); forceDecisionButton.GetComponent <ToolTipHandler>().SetText(voteButton.GetComponent <ToolTipHandler>().GetText()); forceDecisionButton.interactable = false; voteButton.GetComponentInChildren <Text>().text = "Vote for " + selectedReformValue; } else // not enough votes for reform or is despotism { voteButton.interactable = false; forceDecisionButton.interactable = selectedReformValue.IsAllowed(Game.Player, selectedReformValue, out forceDecisionButton.GetComponent <ToolTipHandler>().text); voteButton.GetComponent <ToolTipHandler>().SetText(forceDecisionButton.GetComponent <ToolTipHandler>().GetText()); voteButton.GetComponentInChildren <Text>().text = "Not enough votes"; if (Game.Player.government == Government.Despotism) { forceDecisionButton.GetComponent <ToolTipHandler>().text += "\n\nPeople wouldn't be that angry if you force decisions as Despot"; } else { forceDecisionButton.GetComponent <ToolTipHandler>().text += "\n\nForcing decision against people's desires will drop loyalty!"; } } } } } }