MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / begin

Method begin

game/ui/city/weeklyfundingscreen.cpp:31–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29WeeklyFundingScreen::~WeeklyFundingScreen() = default;
30
31void WeeklyFundingScreen::begin()
32{
33 // Validate that we can recieve funding
34 if (state->fundingTerminated)
35 {
36 fw().stageQueueCommand({StageCmd::Command::POP});
37 return;
38 }
39
40 menuform->findControlTyped<Label>("TEXT_FUNDS")->setText(state->getPlayerBalance());
41 menuform->findControlTyped<Label>("TEXT_DATE")->setText(state->gameTime.getLongDateString());
42 menuform->findControlTyped<Label>("TEXT_WEEK")->setText(state->gameTime.getWeekString());
43
44 menuform->findControlTyped<Label>("TITLE")->setText(tr("WEEKLY FUNDING ASSESSMENT"));
45
46 UString ratingDescription;
47
48 const auto player = state->getPlayer();
49 const auto government = state->getGovernment();
50 int currentIncome = player->income;
51
52 if (government->isRelatedTo(player) == Organisation::Relation::Hostile)
53 {
54 ratingDescription =
55 tr("The Senate has declared total hostility to X-COM and there will be no further "
56 "funding. Furthermore, the Senate will take any steps necessary to destroy the "
57 "X-COM organization if it refuses to cease operation.");
58
59 currentIncome = 0;
60 }
61 else if (state->totalScore.getTotal() < -2400)
62 {
63 ratingDescription = tr("The Senate considers the performance of X-COM to be so abysmal "
64 "that it will cease funding from now on.");
65
66 currentIncome = 0;
67 }
68 else
69 {
70 const int rating = state->weekScore.getTotal();
71 const int modifier = state->calculateFundingModifier();
72
73 int neutralRatingThreshold = 0;
74 if (!state->weekly_rating_rules.empty())
75 {
76 // last entry should be smallest positive value that gives funding increase
77 neutralRatingThreshold = state->weekly_rating_rules.back().first;
78 }
79
80 const int availableGovFunds = government->balance / 2;
81
82 if (availableGovFunds < currentIncome)
83 {
84 // Reduce this week's income if government doesn't have enough funds
85 currentIncome = (availableGovFunds < 0) ? 0 : availableGovFunds;
86
87 ratingDescription = tr("Unfortunately the Senate has to limit X-COM funding due to the "
88 "poor state of government finances.");

Callers

nothing calls this directly

Calls 13

trFunction · 0.85
formatFunction · 0.85
stageQueueCommandMethod · 0.80
getPlayerBalanceMethod · 0.80
getLongDateStringMethod · 0.80
getWeekStringMethod · 0.80
getPlayerMethod · 0.80
getGovernmentMethod · 0.80
isRelatedToMethod · 0.80
emptyMethod · 0.80
setTextMethod · 0.45

Tested by

no test coverage detected