Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weekly report fix #1032

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

gnegno84
Copy link
Contributor

@gnegno84 gnegno84 commented Apr 21, 2021

There are some issues with the weekly report due to racing conditions of the update of the GameState that is used as reference in the weekly report.

The idea is to create a small snapshot of the GameState that can be used to fix this issue.
In order to do that we need to add a new event, update the WeeklyFundingScreen and ScoreScreen, and refactor the GameState handling of the weeklyUpdate event.

Please, double check if what i've done is legit/correct from a c++ point of view (pointers etc...) as I still have a lot to learn.

Ps: in this PR i've added also the label coloring in WeeklyFundingScreen that was depending on.

The zero values for position/size are to underline the fact that are calculated values
…late the size of the fields depending on the text to show
It takes a GameState and creates a partial copy of it
Some of the logic has been removed (the isWeeklyUpkeek case)
…fore and after the snapshot of the status.

The idea is to update the player balance and the economy of human factions.
Then create the snapshot (and send it with the GameStatusUpdateEvent)
Then update the funding modifiers/current balance/weekly score reset
Copy link
Collaborator

@JonnyH JonnyH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done a quick initial pass, still need to actually build and test and possibly poke more nitpicks :p

<alignment horizontal="left" vertical="centre"/>
<font>smalfont</font>
</label>

<label id="FUNDING_NEW_VALUE">
<position x="0" y="0"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having an empty position doest seem right here, the goal of the form xml files is that they can be altered to reskin the game, and so just setting the position in code, instead of using a value relative to an anchor in the xml, limits that.

Possibly the same with the zero sized stuff above, I don't think this screen can reflow (ie each line has a set contents and can't flow to a new line and push everything else down anyway, so having a zero size just makes it less clear to whoever's reading the xml expecting it to relate to the final output)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. It's not the best solution.
What do you suggest?

game/state/playerstatesnapshot.cpp Show resolved Hide resolved
game/state/playerstatesnapshot.cpp Show resolved Hide resolved
game/state/playerstatesnapshot.cpp Show resolved Hide resolved
game/state/playerstatesnapshot.h Show resolved Hide resolved
game/ui/city/scorescreen.cpp Show resolved Hide resolved
game/ui/city/scorescreen.cpp Show resolved Hide resolved
game/ui/city/weeklyfundingscreen.cpp Show resolved Hide resolved

menuform->findControlTyped<Label>("TITLE")->setText(tr("WEEKLY FUNDING ASSESSMENT"));

UString ratingDescription;
const Colour deepBlueColor = {4, 73, 130, 255};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to think of a way to expose things like this to the modding system. Maybe allow named colours in the form files or something? But that's on me not this PR

const auto player = state->getPlayer();
const auto government = state->getGovernment();
int currentIncome = player->income;
int currentIncome = state.playerIncome;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be const?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one could change during the execution of the code (e.g: zeroed when funding are cut due to hostile relationships)

@FilmBoy84 FilmBoy84 added WIP Work In Progress. This is not a complete feature/fix. Check it out, maybe you have something to add? STALLED Work In Progress but for whatever reason, nothing's been done for a while. New coders may be needed! labels Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STALLED Work In Progress but for whatever reason, nothing's been done for a while. New coders may be needed! WIP Work In Progress. This is not a complete feature/fix. Check it out, maybe you have something to add?
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants