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

Multiple bg images zone #4005

Merged
merged 9 commits into from
Aug 23, 2020

Conversation

fdipilla
Copy link
Contributor

Related Ticket(s)

Short roundup of the initial problem

Give the user the possibility of using multiple background images for each player

What will change with this Pull Request?

  • Instead of trying to use the player id to load the background image I added a new property to the player called zoneId
  • Small fix so the zones default correctly
  • Now tablezone1.jpg is contemplated so the images are loaded this way
image effect
tablezone.jpg default, all players
tablezone0.jpg ignored
tablezone1.jpg Player 1
tablezone2.jpg Player 2
tablezone3.jpg Player 3
tablezoneN.jpg Player N

Screenshots

Copy link
Member

@ebbit1q ebbit1q left a comment

Choose a reason for hiding this comment

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

Your pull request is not synced with master, you should have the remote for the main project in your git repo and do a git merge --strategy-option=ours [main master] to make sure no conflicts arise on master while you are working on this or a future pull request.

I see this fixes the issues in the current version, though I wonder if it could also be possible to have the pictures be layed out in a fashion that is dependent on their position instead of the player id.

I added some comments, be sure to use const & wherever possible for optimization.

@@ -104,6 +104,8 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
connect(settingsCache, SIGNAL(horizontalHandChanged()), this, SLOT(rearrangeZones()));
connect(settingsCache, SIGNAL(handJustificationChanged()), this, SLOT(rearrangeZones()));

zoneId = 0;
Copy link
Member

Choose a reason for hiding this comment

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

initialize this together with the rest 5 lines up please

@@ -802,6 +802,27 @@ Player *TabGame::addPlayer(int playerId, const ServerInfo_User &info)
gameMenu->insertMenu(playersSeparator, newPlayer->getPlayerMenu());

players.insert(playerId, newPlayer);

int i = 1;
Copy link
Member

Choose a reason for hiding this comment

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

declare in for statement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use it a few lines below for this newPlayer->setZoneId(i);, maybe should I give the variable a more significant name?

Copy link
Member

Choose a reason for hiding this comment

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

no you should move that inside the loop

for (i = 1; i <= players.count(); ++i) {
bool aPlayerHasThisZone = false;
QMapIterator<int, Player *> playerIterator(players);
while (playerIterator.hasNext()) {
Copy link
Member

Choose a reason for hiding this comment

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

we prefer for (auto &item : array) loops over java style iterators in new pull requests

}
}

if (!spectators.contains(playerId)) {
Copy link
Member

Choose a reason for hiding this comment

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

this check can be done earlier I think

@@ -107,3 +121,8 @@ void ThemeManager::themeChangedSlot()

emit themeChanged();
}

QBrush ThemeManager::getExtraTableBgBrush(QString extraNumber, QBrush fallbackBrush)
Copy link
Member

Choose a reason for hiding this comment

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

You should use references with & for these functions.


QBrush ThemeManager::getExtraTableBgBrush(QString extraNumber, QBrush fallbackBrush)
{
return loadExtraBrush(TABLEZONE_BG_NAME + extraNumber, fallbackBrush);
Copy link
Member

Choose a reason for hiding this comment

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

it'd be preferable to store these in an array or map instead of needing to load them repeatedly.

@ZeldaZach
Copy link
Member

Hey @fdipilla thanks for helping to improve on Cockatrice! I feel this is a duplicate of PR #3990 so I'll be closing it for now, but if you find there's more to bring to the table please let us know!

Feel free to reach out at https://cockatrice.us/discord anytime :)

@ZeldaZach ZeldaZach closed this Aug 23, 2020
@ebbit1q ebbit1q requested a review from ZeldaZach August 23, 2020 18:55
@ZeldaZach ZeldaZach reopened this Aug 23, 2020
@ZeldaZach ZeldaZach marked this pull request as ready for review August 23, 2020 19:55
@ZeldaZach ZeldaZach merged commit b0c7b90 into Cockatrice:master Aug 23, 2020
@tooomm
Copy link
Member

tooomm commented Aug 24, 2020

It's also mentioned in the wiki docs 👍

@ebbit1q
Copy link
Member

ebbit1q commented Aug 24, 2020

I honestly thought this was already merged months ago....

@tooomm
Copy link
Member

tooomm commented Aug 24, 2020

The first version was. #3990

@ebbit1q
Copy link
Member

ebbit1q commented Aug 24, 2020

I know, and I thought this fix was already added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

the default tablezone tablezone.jpg, all players is not being honored in multiplayer (spectating)
4 participants