mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-26 08:33:54 -07:00
Major Directory Refactoring (#5118)
* refactored cardzone.cpp, added doc and changed if to switch case * started moving every files into different folders * remove undercase to match with other files naming convention * refactored dialog files * ran format.sh * refactored client/tabs folder * refactored client/tabs folder * refactored client/tabs folder * refactored client folder * refactored carddbparser * refactored dialogs * Create sonar-project.properties temporary file for lint * Create build.yml temporary file for lint * removed all files from root directory * removed all files from root directory * added current branch to workflow * fixed most broken import * fixed issues while renaming files * fixed oracle importer * fixed dbconverter * updated translations * made sub-folders for client * removed linter * removed linter folder * fixed oracle import * revert card_zone documentation * renamed db parser files name and deck_view imports * fixed dlg file issue * ran format file and fixed test file * fixed carddb test files * moved player folder in game * updated translations and format files * fixed peglib import * format cmake files * removing vcpkg to try to add it back later * tried fixing vcpkg file * renamed filter to filters and moved database parser to cards folder * reverted translation files * reverted oracle translated * Update cockatrice/src/dialogs/dlg_register.cpp Co-authored-by: tooomm <tooomm@users.noreply.github.com> * Update cockatrice/src/client/ui/window_main.cpp Co-authored-by: tooomm <tooomm@users.noreply.github.com> * removed empty line at file start * removed useless include from tab_supervisor.cpp * refactored cardzone.cpp, added doc and changed if to switch case * started moving every files into different folders * remove undercase to match with other files naming convention * refactored dialog files * ran format.sh * refactored client/tabs folder * refactored client folder * refactored carddbparser * refactored dialogs * removed all files from root directory * Create sonar-project.properties temporary file for lint * Create build.yml temporary file for lint * added current branch to workflow * fixed most broken import * fixed issues while renaming files * fixed oracle importer * fixed dbconverter * updated translations * made sub-folders for client * removed linter * removed linter folder * fixed oracle import * revert card_zone documentation * renamed db parser files name and deck_view imports * fixed dlg file issue * ran format file and fixed test file * fixed carddb test files * moved player folder in game * updated translations and format files * fixed peglib import * reverted translation files * format cmake files * removing vcpkg to try to add it back later * tried fixing vcpkg file * pre-updating of cockatrice changes * removed empty line at file start * reverted oracle translated * Update cockatrice/src/dialogs/dlg_register.cpp Co-authored-by: tooomm <tooomm@users.noreply.github.com> * Update cockatrice/src/client/ui/window_main.cpp Co-authored-by: tooomm <tooomm@users.noreply.github.com> * removed useless include from tab_supervisor.cpp --------- Co-authored-by: tooomm <tooomm@users.noreply.github.com>
This commit is contained in:
parent
d1e0f9dfc5
commit
fa999880ee
261 changed files with 735 additions and 729 deletions
|
|
@ -1,207 +0,0 @@
|
|||
#ifndef TABLEZONE_H
|
||||
#define TABLEZONE_H
|
||||
|
||||
#include "abstractcarditem.h"
|
||||
#include "selectzone.h"
|
||||
|
||||
/*
|
||||
* TableZone is the grid based rect where CardItems may be placed.
|
||||
* It is the main play zone and can be customized with background images.
|
||||
*
|
||||
* TODO: Refactor methods to make more readable, extract some logic to
|
||||
* private methods (Im looking at you TableZone::reorganizeCards())
|
||||
*/
|
||||
class TableZone : public SelectZone
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void sizeChanged();
|
||||
|
||||
private:
|
||||
static const int TABLEROWS = 3;
|
||||
|
||||
/*
|
||||
Margins between table edges and cards, paddings between cards
|
||||
*/
|
||||
static const int MARGIN_LEFT = 20;
|
||||
static const int MARGIN_RIGHT = 15;
|
||||
static const int MARGIN_TOP = 10;
|
||||
static const int MARGIN_BOTTOM = 30;
|
||||
static const int PADDING_X = 35;
|
||||
static const int PADDING_Y = 30;
|
||||
|
||||
/*
|
||||
Minimum width of the table zone including margins.
|
||||
*/
|
||||
static const int MIN_WIDTH = MARGIN_LEFT + (5 * CARD_WIDTH) + MARGIN_RIGHT;
|
||||
|
||||
/*
|
||||
Offset sizes when cards are stacked on each other in the grid
|
||||
*/
|
||||
static const int STACKED_CARD_OFFSET_X = CARD_WIDTH / 3;
|
||||
static const int STACKED_CARD_OFFSET_Y = PADDING_Y / 3;
|
||||
|
||||
/*
|
||||
Width of the box line drawn in the margin around the active player's area
|
||||
*/
|
||||
static const int BOX_LINE_WIDTH = 10;
|
||||
|
||||
/*
|
||||
Default inactive mask and border gradient
|
||||
*/
|
||||
static const QColor BACKGROUND_COLOR;
|
||||
static const QColor FADE_MASK;
|
||||
static const QColor GRADIENT_COLOR;
|
||||
static const QColor GRADIENT_COLORLESS;
|
||||
|
||||
/*
|
||||
Size and shape variables
|
||||
*/
|
||||
int width;
|
||||
int height;
|
||||
int currentMinimumWidth;
|
||||
|
||||
/*
|
||||
Internal cache for widths of stacks of cards by row and column.
|
||||
*/
|
||||
QMap<int, int> cardStackWidth;
|
||||
|
||||
/*
|
||||
Holds any custom background image for the TableZone
|
||||
*/
|
||||
QPixmap backgroundPixelMap;
|
||||
|
||||
/*
|
||||
If this TableZone is currently active
|
||||
*/
|
||||
bool active;
|
||||
|
||||
bool isInverted() const;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
Loads in any found custom background and updates
|
||||
*/
|
||||
void updateBg();
|
||||
|
||||
public slots:
|
||||
/**
|
||||
Reorganizes CardItems in the TableZone
|
||||
*/
|
||||
void reorganizeCards();
|
||||
|
||||
public:
|
||||
/**
|
||||
Constructs TableZone.
|
||||
|
||||
@param _p the Player
|
||||
@param parent defaults to null
|
||||
*/
|
||||
TableZone(Player *_p, QGraphicsItem *parent = nullptr);
|
||||
|
||||
/**
|
||||
@return a QRectF of the TableZone bounding box.
|
||||
*/
|
||||
QRectF boundingRect() const;
|
||||
|
||||
/**
|
||||
Render the TableZone
|
||||
|
||||
@param painter
|
||||
@param option
|
||||
*/
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
/**
|
||||
Toggles the selected items as tapped.
|
||||
*/
|
||||
void toggleTapped();
|
||||
|
||||
/**
|
||||
See HandleDropEventByGrid
|
||||
*/
|
||||
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint);
|
||||
|
||||
/**
|
||||
Handles the placement of cards
|
||||
*/
|
||||
void handleDropEventByGrid(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &gridPoint);
|
||||
|
||||
/**
|
||||
@return CardItem from grid location
|
||||
*/
|
||||
CardItem *getCardFromGrid(const QPoint &gridPoint) const;
|
||||
|
||||
/**
|
||||
@return CardItem from coordinate location
|
||||
*/
|
||||
CardItem *getCardFromCoords(const QPointF &point) const;
|
||||
|
||||
QPointF closestGridPoint(const QPointF &point);
|
||||
|
||||
static int clampValidTableRow(const int row);
|
||||
|
||||
/**
|
||||
Removes a card from view.
|
||||
|
||||
@param position card position
|
||||
@param cardId id of card to take
|
||||
@param canResize defaults to true
|
||||
@return CardItem that has been removed
|
||||
*/
|
||||
CardItem *takeCard(int position, int cardId, bool canResize = true);
|
||||
|
||||
/**
|
||||
Resizes the TableZone in case CardItems are within or
|
||||
outside of the TableZone constraints.
|
||||
*/
|
||||
void resizeToContents();
|
||||
|
||||
int getMinimumWidth() const
|
||||
{
|
||||
return currentMinimumWidth;
|
||||
}
|
||||
void setWidth(qreal _width)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
width = _width;
|
||||
}
|
||||
qreal getWidth() const
|
||||
{
|
||||
return width;
|
||||
}
|
||||
void setActive(bool _active)
|
||||
{
|
||||
active = _active;
|
||||
update();
|
||||
}
|
||||
|
||||
protected:
|
||||
void addCardImpl(CardItem *card, int x, int y);
|
||||
|
||||
private:
|
||||
void paintZoneOutline(QPainter *painter);
|
||||
void paintLandDivider(QPainter *painter);
|
||||
|
||||
/*
|
||||
Calculates card stack widths so mapping functions work properly
|
||||
*/
|
||||
void computeCardStackWidths();
|
||||
|
||||
/*
|
||||
Mapping functions for points to/from gridpoints.
|
||||
*/
|
||||
QPointF mapFromGrid(QPoint gridPoint) const;
|
||||
QPoint mapToGrid(const QPointF &mapPoint) const;
|
||||
|
||||
/*
|
||||
Helper function to create a single key from a card stack location.
|
||||
*/
|
||||
int getCardStackMapKey(int x, int y) const
|
||||
{
|
||||
return x + (y * 1000);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue