mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
[Game] Show color icons in counters menu (#6947)
This commit is contained in:
parent
7f30728f87
commit
0d7047a728
1 changed files with 29 additions and 0 deletions
|
|
@ -10,10 +10,27 @@
|
|||
#include "move_menu.h"
|
||||
#include "pt_menu.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/card/relation/card_relation.h>
|
||||
#include <libcockatrice/utility/zone_names.h>
|
||||
|
||||
/**
|
||||
* @brief Creates a circular icon filled with the specified color.
|
||||
*/
|
||||
static QIcon createCircleIcon(const QColor &color)
|
||||
{
|
||||
QPixmap pixmap(32, 32);
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter painter(&pixmap);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(color);
|
||||
painter.drawEllipse(pixmap.rect());
|
||||
|
||||
return QIcon(pixmap);
|
||||
}
|
||||
|
||||
CardMenu::CardMenu(PlayerLogic *_player, const CardItem *_card, bool _shortcutsActive)
|
||||
: player(_player), card(_card), shortcutsActive(_shortcutsActive)
|
||||
{
|
||||
|
|
@ -77,9 +94,21 @@ CardMenu::CardMenu(PlayerLogic *_player, const CardItem *_card, bool _shortcutsA
|
|||
mCardCounters = new QMenu;
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
QColor color = SettingsCache::instance().cardCounters().color(i);
|
||||
QIcon circleIcon = createCircleIcon(color);
|
||||
|
||||
auto *tempAddCounter = new QAction(this);
|
||||
tempAddCounter->setIconVisibleInMenu(true);
|
||||
tempAddCounter->setIcon(circleIcon);
|
||||
|
||||
auto *tempRemoveCounter = new QAction(this);
|
||||
tempRemoveCounter->setIconVisibleInMenu(true);
|
||||
tempRemoveCounter->setIcon(circleIcon);
|
||||
|
||||
auto *tempSetCounter = new QAction(this);
|
||||
tempSetCounter->setIconVisibleInMenu(true);
|
||||
tempSetCounter->setIcon(circleIcon);
|
||||
|
||||
aAddCounter.append(tempAddCounter);
|
||||
aRemoveCounter.append(tempRemoveCounter);
|
||||
aSetCounter.append(tempSetCounter);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue