Compare commits

...

838 Commits

Author SHA1 Message Date
tooomm
ead1143f2e Prettier settings dialog (#4357)
* prevent stretched layout in settings

* restore layout of settings pages with already expanding elements

* Support full screen resolution and set a minimum that works well no matter the screen size

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
Co-authored-by: ZeldaZach <zahalpern+github@gmail.com>
2022-01-16 21:06:52 -05:00
ebbit1q
2fc85e0c08 use hashed passwords in all commands (#4493)
* protocol changes

* server changes

* client changes for password reset and registration

* add hashed password to change password in client

* always use hashed password to log in

* add warning to client when using plain text password

* require real password for changing email on server

this is backwards compatible as users logged in with a real password on
older clients will not need this, only users logged in with a hashed
password

* implement password dialog when changing email

* require min password length

* use qstringlist to build query instead

* use clear instead of = ""

* add max to password dialog

* use proper const ness in abstractclient

* reject too long passwords instead of trimming
2022-01-16 20:32:30 -05:00
ebbit1q
fcafcb340a remove all instances of the type long (#4519)
the long type has different sizes across operating systems and should
not be used

in the timeline an overflow could occur if the width in pixels
multiplied by the total amount of milliseconds in the replay is larger
than 2^31 which is easy enough considering with only 500 pixels width
you'll reach this number with only 1.2 hours of replay (about 4 million
millis), note that this would be windows exclusive as *nix uses 64 bits

~~qt-json's own repo suggests using qt5's implementation instead, testing
revealed this is quite a bit faster, contrary to #3480~~ testing proved
this to not be compatible with older qt versions

servatrice uses the qthread usleep function which used to be protected
but is now public

cockatrice is not compatible with qt4 and hasn't been for a while
2022-01-16 18:05:24 -05:00
ebbit1q
ae9b8b8f34 miscellaneous refactors (#4521) 2022-01-16 17:58:53 -05:00
ebbit1q
994704d353 implement max lengths for input dialogs that are sent to the server (#4522)
* implement max lengths for input dialogs that are sent to the server

* missed a double setMaxLength

* implement max string lengths server side

* add custom getText dialog with max length

* fix deck storage tab and miscellaneous server side

* add max size for deck uploads

* final pass on client side limits
2022-01-16 17:57:01 -05:00
Zach H
d61c604bf4 Address macOS issue where right-clicking a username in the main chat (#4523)
* Address macOS issue where right-clicking a username in the main chat (or game chat) areas would pop up a seemingly empty user profile. This is because the resize event is overridden and doesn't actually attempt to resize based on the size hint of the dialog. Now that we're explicit with the call, this resize should be forced and have comparable results to popping up user profile from the user list.

* use datetime for calculating account age (#4526)

* use datetime for calculating account age

make translating easier by using tr multiples
automatically account for leap days

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2022-01-16 16:51:13 -05:00
tooomm
baaf22d0c4 UI: Improve alignment in user info (#4524)
* fix alignment

* tweaking

* lint

* limit flag to one column

* lint

* cleanup

* Update userinfobox.cpp

* re-add manual window resizing

* Update cockatrice/src/userinfobox.cpp

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2022-01-16 22:49:41 +01:00
tooomm
368ff1793f CI: Add Debian 11 (#4525)
* add debian 11

* rename debian10

* fix space

* Update Dockerfile
2022-01-16 16:46:04 -05:00
dependabot[bot]
3253ad64fd Bump follow-redirects from 1.14.5 to 1.14.7 in /webclient (#4527)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.5 to 1.14.7.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.5...v1.14.7)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-16 16:32:22 -05:00
ebbit1q
1e70989f38 add password hash test (#4528)
* clangify tests

* add password hash test

* properly use googletest semantics
2022-01-16 16:32:11 -05:00
ebbit1q
f6634de18d replace fixed size of criteria in log tab (#4515)
it's now a max size with expanding policy, looks fine I guess
fixes #4510
2022-01-11 21:35:18 -05:00
ebbit1q
7903cd520a perform restartLayout conditionally (#4513)
* Revert "Fixed layout on Deck Editor not using last layout. It was reseting layout on ctor. (#4420)"

This reverts commit 3bc90003b3.

* restart layout on fresh installs
2022-01-08 16:03:53 -05:00
ebbit1q
26d1fcc944 simplify search string (#4516) 2022-01-08 16:02:54 -05:00
ebbit1q
59d4e64a8d use multiline input dialog for annotations (#4517) 2022-01-08 16:02:25 -05:00
ebbit1q
1347d88ddb also forgot this in #4496 (#4514) 2022-01-08 16:01:54 -05:00
ebbit1q
6981cca2ae use qt round for better cross platform consistency (#4518)
* use qt round for better cross platform consistency

* remove unnecessary casts
2022-01-08 16:01:15 -05:00
ebbit1q
4d6c9ede8c missed this in #4496 (#4512) 2022-01-07 00:34:56 -05:00
ebbit1q
e845c95816 remove ccache from mac builds (#4505) 2021-12-27 22:23:11 -05:00
ebbit1q
a9f2fc427b allow servatrice to exit early based on commandline options (#4504) 2021-12-26 16:47:37 +01:00
ebbit1q
07e6aadbbe deprecate the gender property from the protocol entirely (#4496)
* deprecate the gender property from the protocol entirely

* use obsolete instead of deprecated

* add the database migration

* update internal database version as well
2021-12-14 01:51:57 -05:00
tooomm
86881bbbc3 CI: Little tweaks to web (#4488) 2021-12-07 23:01:46 -05:00
Jeremy Letto
1f15445c69 connect reset password to login view (#4489) 2021-12-07 22:57:12 -05:00
ebbit1q
811ee54c76 Fix move (#4491)
* wip fix card moving on server

* fix flipped cards being moved as -1

* fix cards from hand being moved as -1
2021-12-07 22:56:58 -05:00
ebbit1q
d1a40fd36e fix regression in local games (#4490) 2021-12-07 22:54:36 -05:00
ebbit1q
a3d3aaaca8 fix server crash on receiving email without @ (#4492) 2021-11-30 19:44:20 -08:00
tooomm
c5aaa0bc2e CI: Add webclient (#4478) 2021-11-26 16:55:53 -05:00
Jeremy Letto
6dc9f004ce fix tests, add golden command (#4486)
Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-11-26 16:55:12 -05:00
Jeremy Letto
6ce346af4a Webatrice: KnownHosts component (#4456)
* refactor dexie services for future schema updates

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-11-25 22:12:23 -05:00
ZeldaZach
37879c4255 Re-lint on linux 2021-11-23 02:49:11 -05:00
Zach H
0683d1aced Support Server requests for MFA, Render failed UI statuses to user, C… (#4483)
* Support Server requests for MFA, Render failed UI statuses to user, Connect to KnownHosts component
2021-11-23 02:45:08 -05:00
Joseph Chamish
73c5956ece Dev/jchamish/forgotpassword (#4481)
* Implementation of Forgotten Password Reset

* Update webclient/src/hooks/useReduxEffect.tsx

Co-authored-by: Zach H <zahalpern+github@gmail.com>
2021-11-19 21:00:05 -05:00
Zach H
7c27e955d5 Support all OS development for linters and prevent linting while in dev mode (#4480) 2021-11-19 20:59:55 -05:00
Jeremy Letto
6ef394000b fix file line returns (#4482)
Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-11-18 19:46:49 -05:00
Aren Kasner
755a09bd83 country dropdown (#4479) 2021-11-16 16:55:30 -05:00
ZeldaZach
8b1daa21ef Revert "fix card moving on server (#4413)"
This reverts commit c25bf491e4.
2021-11-15 00:54:21 -05:00
ebbit1q
691bcb9338 comment out new feature from feature list (#4477)
we don't have an official release for a version that has this feature
yet
2021-11-15 00:44:16 -05:00
Joseph Chamish
911a303326 Fix the additional line endings (#4476) 2021-11-14 22:16:13 -05:00
Johannes
5652b56b45 Respect device pixel ratio when scaling card imgs (#4467) 2021-11-13 17:01:27 -05:00
Zach H
26acfd5102 Update packages & cleanup (#4475) 2021-11-13 15:30:49 -05:00
Zach H
f789e02096 Add ESLint & Run it against the system (#4470) 2021-11-13 14:56:15 -05:00
Zach H
43eee6b32e Support HashedPassword workflow for logins (#4469)
* Support HashedPassword workflow for logins

* Address comments in PR
2021-11-13 10:37:13 -06:00
ebbit1q
45d86e7ab7 allow login using hashed passwords (#4464)
* Support getting a user's password salt via initial websocket connection (added to Event_ServerIdentification)

* Nonsense stuff to figure out later

* move passwordhasher to correct location

* protobuf changes

* add ext to protobuf

* implement request password salt server side

* add supportspasswordhash to server identification

* check backwards compatibility

* reset some changes to master

* implement get password salt client side

* implement checking hashed passwords on server login

* check for registration requirement on getting password salt

* properly check password salt response and show errors

* remove unused property

* add password salt to list of response types

Co-authored-by: ZeldaZach <zahalpern+github@gmail.com>
2021-11-09 20:00:41 -05:00
ebbit1q
b0845837c2 add extra null check to set active card (#4460) 2021-11-04 22:20:20 -04:00
ebbit1q
a10226d096 finalise fedora support (#4461) 2021-11-04 22:20:00 -04:00
ParkTandem
5e3a524401 add eslint config (#4457) 2021-11-02 19:01:06 -05:00
gus
b095d9b82f Fixed issue #4332 - changed error message for replay folder download (#4455) 2021-11-02 02:08:41 +01:00
Jeremy Letto
4cb7240f9a small improvements (#4452)
Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-10-31 22:21:24 -04:00
Zach H
a87c66885c Webatrice: Account Registration form (pt2) (#4454)
Co-authored-by: ParkTandem <93353951+ParkTandem@users.noreply.github.com>
2021-10-31 22:15:51 -04:00
Zach H
ac300b0b6d Support password reset workflow on Webatrice (#4445)
* Support password reset workflow. Also fix issue where a user would be disconnected "randomly" if they had a failed login, then successful one. Refactored a bit on Status Labels since they weren't really necessary and added complexity.

* Disconnect in default cases where we don't know what to do, but shouldn't stay connected to the server
2021-10-31 22:03:38 -04:00
ebbit1q
013bb8269f set fedora 35 to be allowed failure (#4448)
it currently doesn't build at all yet
2021-10-31 17:55:10 -04:00
ebbit1q
7712862036 add ubuntu 21.10 to ci (#4446)
* add ubuntu 21.10 to ci

remove ubuntu 20.10

* forgot to update dockerfile

* add googletest from repos

* update downloaded gtest

ideally this should just grab the master version

* fix hash

* fix cmake issue
2021-10-30 22:15:50 -04:00
tooomm
656e3230de CI: Xcode update, fix Big Sur build (#4449)
* xcode update

* 12.5.1 --> 13.0

* Revert "12.5.1 --> 13.0"

This reverts commit 671ee2afe4.
2021-10-30 16:00:52 +02:00
ebbit1q
915c14f6cf add fedora 35 to ci (#4447)
remove fedora 33
2021-10-29 22:15:08 -04:00
Aren Kasner
ed32e72dc1 login page created (#4444)
login page html and css created with Seavor
2021-10-25 23:36:20 -04:00
Jeremy Letto
d684a9c5fc new login design (#4442)
* new login design

* remove effects file (wrong direction)

* add Known Hosts dropdown component

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-10-25 14:28:43 -04:00
ebbit1q
6f360374cc change the order in which the password challenge is performed (#4439)
this will force the user to always perform the challenge, meaning no
information on the account is leaked in case of failures
2021-10-23 20:18:08 -04:00
ebbit1q
bbbf3e2a65 don't reset pt if there is nothing to reset (#4438)
* don't reset pt if there is nothing to reset

when the client resets the pt of a card it intentionally does not
include cards that already have the correct pt, this can lead to the
client sending an empty command to the server, which will be rejected

* clangify
2021-10-23 20:04:52 -04:00
Zach H
b1ef8220ee Support Registration on Webatrice with a baseline of handling. (#4436)
* Support Registration on Webatrice with a baseline of handling. Still needs to support activation tokens & unit testing.

* Add support for account activation with token

* Activate Account refactor

* Fix typo

* Add Unit Testing for Commands/Events

* Changes based on review feedback
2021-10-20 21:07:35 -05:00
Jeremy Letto
ebebb9c4bb add Material UI theme support (#4437)
* add Material UI theme support

* add primary color palette

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-10-20 20:03:05 -04:00
Jeremy Letto
586f23cfa9 Webatrice websocket refactor (#4435)
* add unit tests for websocket events

* add unit tests for KeepAliveService, clean up keepAlive termination flow

* put keepAlive command in protobuf service and expose thru webClient

* secure wss

* rename files tsx to ts

* add localhost support for ws/wss connection

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-10-17 20:52:59 -04:00
Jeremy Letto
f75ff2a7c8 cleanup and unit tests (#4434)
* put socket.updateHistory behind SessionCommand

* rename /websocket files from .tsx to .ts

* add unit tests to websocket commands

* complete unit tests for webClient commands

* secure wss

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-10-17 16:15:09 -04:00
Jeremy Letto
e9ba195d7d Refactor websocket into separate services, clean up socket status communication (#4433)
* Refactor websocket into separate services, clean up socket status communication

* cleanup

* add EOF lines

* fix keepalive logged in check

* undo change

* fix keepalive connection check

* cleanup

* add typings

* secure connection

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-10-17 01:07:30 -04:00
Jeremy Letto
19333c53f6 secure webclient socket (#4432)
Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-10-14 21:58:34 -04:00
Jeremy Letto
36e5a399d5 Webatrice: card import wizard (#4397) 2021-10-14 21:42:35 -04:00
Bruno Mendes
dde0f568d9 Show country flag in user list of webclient (#4431) 2021-10-14 20:59:06 -04:00
Rafael Ritzel Tischler
3bc90003b3 Fixed layout on Deck Editor not using last layout. It was reseting layout on ctor. (#4420) 2021-09-14 16:41:04 -04:00
Danny Piper
689f65b38a Fix for poor performance with large decks (#4347)
* Fix for #4284

-> The menus have the update menu thing emitted when they get triggered.
| -> works surprising well https://youtu.be/KOOmhxvHA2c is a demo on a 10000ish card deck

* changed my comment to make sense

* fix to the issues that @ebbit1q found

what caued them idk

* Revert "fix to the issues that @ebbit1q found"

This reverts commit 20b1ad9f7a.

* actual fix for the issues @ebbit1q found

* its dirty but works

* fix cards in zoneviews not having a menu

* deleted isempty check as it is updated after the check

* key binds should work now

-> menus updated on zone change/attach/retranslate UI if selected

* clangify

* remove updateCardMenu from carditem entirely

updateCardMenu is done by the player and having it in carditem led to it
often being run multiple times, I've opted to instead run it in the
player and remove the signal entirely

the new logic updates the cardMenu every time a card is set as the
activeCard in the game tab

additionally a cardmenu can change while selected if the selected card:
moves zone, is flipped, or is attached (it receives the unattach action)

this is done in the player instead now, checking if the card is the
activeCard

this however exposes a flaw in the selection management where if you
unselect a card the activeCard is set to nullptr, this was an existing
bug and causes the action on selected cards to suddenly disappear, even
if there are other cards selected!

* revert null test of aCardMenu

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2021-09-14 16:35:47 -04:00
tooomm
154e1084ba CI: Separate C++ linting (#4400)
* separate cpp lint

* made executable
2021-09-14 16:11:56 -04:00
tooomm
6df5cece04 CI: Update Qt version (Windows) (#4407)
* qt patch update

* qt 5.15

* fix qtdir export

* cleanup
2021-09-14 16:11:29 -04:00
ebbit1q
c8bb8b0aae add reset paths button to settings (#4384) 2021-09-14 16:10:40 -04:00
ebbit1q
1e995cd97c add option to delete a user's messages (#4362)
* add option to delete a user's messages

add optional parameter remove_messages to the ban and warn commands
add event for clients to redact messages
implement server side command and message handling
implement server history removal
todo: client side implementation

add option to remove messages to moderator action dialogs

add storage of message beginnings to chatview

add redactMessage command
handle Event_RemoveMessages on rooms

this approach is favored over parsing the chatroom after the fact but
will use additional memory to store the block indexes

this also leaves a problem in that user messages from the chat backlog
are not removed in the same way because they don't have a user
associated with them

add workaround for old qt versions

add action for users to remove messages from users in chats

add chat history to userMessagePositions with regex

proper const usage for userName

allow removing the messages of unregistered users

add menus to usernames in chat history

this allows you to remove user messages on chat history as well
this also allows moderators to take actions on users in chat history

Apply suggestions from code review

* readd missing call to handler
2021-09-14 16:05:20 -04:00
ebbit1q
c25bf491e4 fix card moving on server (#4413)
* wip fix card moving on server

* fix flipped cards being moved as -1
2021-09-14 15:48:46 -04:00
ZeldaZach
affc288144 Use gmail over googlemail in all cases, as they're the same alias 2021-08-27 23:17:26 -04:00
Zach H
051be37419 Server Config Whitelist Email Providers (#4416)
* Support registration domain whitelist (registration/emailproviderwhitelist) that, if set, will require a user to have an email with one of the specified domain providers. Will require client updates to see the Whitelist message, otherwise they'll be greeted with a default alert.

This also works to remove the pain of Google Email addresses and their infinite combination of usernames for the same account (i.e. remove periods and everything after the first plus sign).

* Make blacklist response show custom dialog
2021-08-18 21:18:53 -04:00
Aren Kasner
c0bd49cf13 Fixed VCPKG folder for windows (#4406)
update vcpkg submodule
2021-08-04 03:23:42 +02:00
tooomm
2fe572c398 CI: Update Xcode versions (#4403) 2021-07-27 18:42:54 +02:00
Michael Stanaszak
904e740460 #4316: Wording change: CMC --> MV (#4388)
Co-authored-by: tooomm <tooomm@users.noreply.github.com>
Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2021-07-27 17:30:55 +02:00
ebbit1q
00add2a527 add gtest from arch repos so it doesn't have to download it (#4378) 2021-07-27 16:42:28 +02:00
Zach H
bbe43d4246 Prevent users from being able to upload super large files via Sockets, which could inadvertently deny access to the server (#4398) 2021-07-25 20:28:14 -04:00
ebbit1q
0280fea3e6 apply chat flood prevention in games next to rooms (#4387)
* apply chat flood prevention in games next to rooms

* add limit to private messages as well
2021-06-28 01:57:46 -04:00
Joseph Chamish
a65ce8694c selection of known hosts to form (#4379) 2021-06-15 03:12:17 -04:00
Jeremy Letto
c9ddd042fc Webatrice: Update nav (#4380)
* wip: subnav debug

* nav redesign

* remove unnecessary code

* remove subnav

* add leaveRoom button

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-06-15 03:12:04 -04:00
ebbit1q
da9222929b add werror flags when making a debug build using llvm (#4344)
* add werror flags when making a debug build using llvm

this would get bugs like
https://github.com/Cockatrice/Cockatrice/pull/4337
get signalled earlier to us

* fix error: 'Servatrice_DatabaseInterface::registerUser' hides overloaded virtual function

* remove unused field

* mac machines have 3 cores

see
https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources

* typo
2021-06-01 21:57:37 -04:00
marsnicholas
b858e36183 Closes all library views when shuffled (#4261) (#4324) 2021-06-01 21:53:43 -04:00
ebbit1q
ebe2c494aa remove the stop dump zone command from the protocol (#4326)
the stop dump zone command was implemented as a courtesy to other
players in order to take into account when they would stop looking at
unknown information

however, this can be abused, a malicious client can send this command
whenever they would like

cockatrice is not a physical tabletop nor does it aim to be, if you can
take a screenshot of your deck and then close the view, you are not
cheating as you have been given this information

in order to prevent anyone from abusing this we should remove the
command from the protocol, this means servers will ignore this message
and clients will get a little invalid command reply in their debug log

the extension id will remain reserved

shuffling your deck will always invalidate any card view looking at
those cards

if players wish to signal that they stopped looking at their deck for
whatever reason they should just use the chat instead, optionally using
one of the chat macros
2021-06-01 21:52:20 -04:00
Jeremy Letto
fac7bfaa92 Webatrice: Nav Update (#4367) 2021-06-01 20:47:19 -04:00
Jeremy Letto
0d05f9097d Webatrice updates (#4366) 2021-05-21 21:23:30 -04:00
Jeremy Letto
8db9475804 Cleanup and refactor (#4361)
* fix three panel layout height issue

* rename websocket/services to websocket/persistence, implement LeaveRoom

* cleanup

* add new line eof

* move route components from /components to /containers

* remove duplicate style

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-05-18 23:06:41 -04:00
ebbit1q
294229622d tell the filter widget that games can have 0 players now (#4359) 2021-05-18 23:03:58 -04:00
Jeremy Letto
5cf9023a21 move and rename src/websocket/instanceServices to src/api (#4360)
Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-05-17 21:59:32 -04:00
ebbit1q
66d24f086e properly enable notification checkboxes (#4356) 2021-05-17 02:37:12 +02:00
tooomm
19a7c4092c Update ci-builds.yml (#4358) 2021-05-16 23:12:49 +02:00
ebbit1q
b27cb58727 it is not possible to add a link to the wiki to this description (#4354) 2021-05-14 22:44:02 -04:00
tooomm
472f401590 Templates: Add Transifex link (#4351) 2021-05-14 19:29:11 +02:00
tooomm
744099277a Readme: Improve CI badge (#4352)
* Improve CI badge

* fix toc
2021-05-14 18:00:30 +02:00
ebbit1q
dff25a175b fix status badge (#4350) 2021-05-13 12:51:50 -04:00
ebbit1q
61f1141fe8 fix #3840 (#4348) 2021-05-13 12:51:34 -04:00
tooomm
0a73162bcf Beta releases: collapsable list of changes (#4339)
* add collapsable list

* make it show commit count

* why not have it also know the release type and name

* update the template as well

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2021-05-12 17:27:20 +02:00
ebbit1q
5f32892e75 check if player is null when updating card menu (#4346) 2021-05-12 09:51:56 -04:00
ebbit1q
ae7437750b do not edit the zone currently iterated on (#4345)
this can cause the iterator to become invalidated which will crash but
because of the data not always being moved it will often still work as
intended, giving the idea that it is random
2021-05-10 13:21:12 -04:00
Zach H
046a3649ed Revert "add werror flags when making a debug build using llvm (#4338)" (#4343)
This reverts commit 890810f5b9.

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2021-05-10 11:32:23 -04:00
ebbit1q
890810f5b9 add werror flags when making a debug build using llvm (#4338)
this would get bugs like
https://github.com/Cockatrice/Cockatrice/pull/4337
get signalled earlier to us
2021-05-10 02:11:40 -04:00
Zach H
8fb561b4c4 Fix regression from #4281 which caused crash with QList and GCC race time (#4341) 2021-05-09 14:50:48 -04:00
Zach H
b9c4b496e4 Fix regression from #4281 which caused crash if card was null (#4340) 2021-05-09 13:10:13 -04:00
ebbit1q
ff6f28390a fix macos update logic (#4337) 2021-05-08 23:16:52 -04:00
ebbit1q
e034de9083 don't log in users while giving them an error for missing the clientid (#4335) 2021-05-08 18:12:05 -04:00
ebbit1q
ecf57b4226 add fedora 34 and ubuntu 21.04 (#4331)
* add fedora 34 and ubuntu 21.04

* remove qt5-default from ubuntu 21.04

apparently it's not required?

* disable tests on fedora 34
2021-05-08 00:24:38 -04:00
ebbit1q
63fe34437a fix deprecation of QMutex::Recursive in favor of QRecursiveMutex (#4328) 2021-05-01 18:51:17 -04:00
ebbit1q
1062894397 change number dialog defaults (#4318) 2021-04-18 14:50:24 -04:00
ebbit1q
5969656429 check multiple file extension inclusions for custom cards (#4308) 2021-04-16 11:23:46 -04:00
ebbit1q
ad0f313c9d add menus for top and bottom actions (#4314)
* add menus for top and bottom actions

* style points

* github online editor is literally the worst

* add moving cards from bottom of deck to hand

fix getting multiple cards from the bottom
note that moving cards from the bottom of the deck does not get
remembered by or disrupt undoing draws

* Apply suggestions from code review

Co-authored-by: tooomm <tooomm@users.noreply.github.com>

Co-authored-by: tooomm <tooomm@users.noreply.github.com>
2021-04-16 11:23:28 -04:00
ebbit1q
6c004155ff fix local games no longer working (#4315) 2021-04-15 01:00:41 -04:00
tooomm
88a8ee09bd pass reset Small fixes (#4310) 2021-04-12 13:28:47 -04:00
ebbit1q
7d1f082b27 add _fill_with_ template notation to picture loader (#4287) 2021-04-01 23:37:11 -04:00
ebbit1q
1c48656623 fix #4249 (#4285)
ignore "deck" at start of a list
add tests
add tests to clangify.sh
2021-04-01 23:35:36 -04:00
ebbit1q
b940e17fe7 catch nullptr on websocket connections (#4300)
* catch nullptr on websocket connections

* clangify
2021-04-01 23:34:49 -04:00
ebbit1q
8e954b10e6 add more info to dialogs (#4293)
* add more info to dialogs

adds descriptive strings to the register, password reset request,
password reset challenge request, password reset token dialogs
adds tip to set manager to use ctrl a to select all sets
change sizes in set manager
moves default server info to settings instead of having it hardcoded in
each dialog

* make sets manager smaller

* clangify

* cleanup
2021-04-01 23:34:25 -04:00
ebbit1q
1b4543aa11 Fix 4294 (#4302)
* save forgot password settings when opening dialog

* add restore password menu item
2021-04-01 01:46:53 -04:00
ebbit1q
406c0b17ae remove arch workaround (#4295) 2021-03-25 22:36:01 -04:00
ebbit1q
09de56ac87 send hidden info to judge instead of player (#4297) 2021-03-25 22:35:46 -04:00
ebbit1q
07ea2d4334 add button to open themes location to settings (#4289)
* add button to open themes location to settings

botton creates directory if it doesn't exist yet
themes path is no longer hardcoded but included in settings
themes now default to None  the default theme is no longer required
themes set to None  will not look for empty directories anymore
this is backwards compatible
users with a nonexistant theme (Default) set will get the new None  theme

* remove default theme from install instructions
2021-03-21 13:11:34 -04:00
Zach Reizner
c5fac2ee35 fix off-by-one maxUsers check on session init (#4292)
The returned number of users from `getUsersWithAddress` will include the already connected user. The predicate `>= maxUsers` is incorrectly assuming that the new user is not already counted by `getUsersWithAddress`. This change corrects this off-by-one error by only closing connections after their are strictly too many users.
2021-03-21 13:08:36 -04:00
mix irving
a5b8245227 [webclient] remove duplicate services files (#4269) 2021-03-13 14:54:36 -05:00
omegaula
073349fd05 Always look at top card (#4238)
* Add option to always look at top card of deck

Similar to "always reveal", but reveals card only to the owner,
not all players.

* Add option to always look at top card of deck

Similar to "always reveal", but reveals card only to the owner,
not all players.

* Update bug_report.md (#4246)

* Update bug_report.md

* reproduction steps

* Update to address review comments

* Clangify

* set playerId on dumpEvent

Co-authored-by: tooomm <tooomm@users.noreply.github.com>
Co-authored-by: ebbit1q <ebbit1q@gmail.com>
Co-authored-by: Zach H <zahalpern+github@gmail.com>
2021-03-13 14:54:13 -05:00
ebbit1q
00ed5c370c implement a maximum amount of cardmenus generated for views (#4262) 2021-03-13 14:44:57 -05:00
ebbit1q
8e1d7d12e0 allow multiple zoneviews (#4263) 2021-03-13 14:43:50 -05:00
ebbit1q
1811f7305e only invalidate undoDrawList up to moved card (#4280) 2021-03-13 14:41:09 -05:00
ebbit1q
06bfc0291a Create game as spectator (#4281)
* refactoring

* allow for creation of games as spectator

allow setting the amount of games per user to none
remove limit on amount of games when creating a game as judge as
spectator

* refactor common/server_player.cpp

* do not close games with spectating host automatically

* remove check that filters out 0 player games

this check didn't really do anything, deleted games are removed before
it would be reached

* don't transfer host to spectators

this seems to cause a bug, also present on master
2021-03-13 14:39:25 -05:00
tooomm
b722864caf fix qt (#4279) 2021-03-09 11:17:07 -05:00
ebbit1q
18e27ef932 temporary workaround for arch libc version requiring upgraded host (#4258)
see https://bugs.archlinux.org/task/69563#comment196582
2021-03-08 12:18:58 -05:00
ebbit1q
7e3a669af0 use correct settings group for command interval settings (#4257)
the settings command_counting_interval and
max_command_count_per_interval are now in the [security] group as hinted
by their location in servatrice.ini.example

check values of comand interval settings before use
2021-03-08 12:18:22 -05:00
ebbit1q
aa6a0313e9 don't sort split card halves alphabetically (#4244)
* don't sort split card halves alphabetically

fixes #4241
introduces new issue: aftermath cards are now switched upside down

* use list instead of multimap to enforce preservation of a given order
2021-03-08 12:14:43 -05:00
ebbit1q
9bbe2f36bc disallow rich text in deck comments (#4273) 2021-02-26 11:17:25 -05:00
tooomm
0c7830b53c exclude webclient (#4270) 2021-02-25 13:15:48 -05:00
mix irving
2b0a9975be [webclient] add postinstall script for copy_shared_files (#4268) 2021-02-24 19:14:02 -05:00
ebbit1q
df0b867d9e fix my mistake in meld regex (#4266) 2021-02-24 18:45:09 -05:00
ebbit1q
d27f108cbd typo (#4260) 2021-02-20 01:32:31 -05:00
tooomm
fd0076e920 Improve release template (#4250)
* Update release_template.md

* reworks and adding highlights

* prep

* adjust according to script

* comment over placeholder

* remove tags, uniform style

* tweak

* Update .ci/release_template.md

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2021-02-17 02:33:14 +01:00
tooomm
db5f6e01c9 template: screenshot hint (#4256)
* screenshot hint

* better wording
2021-02-15 20:55:30 +01:00
tooomm
f3255180ec skip .md only changes (#4251) 2021-02-10 14:29:12 -05:00
tooomm
039d058770 Update bug_report.md (#4246)
* Update bug_report.md

* reproduction steps
2021-02-07 12:26:22 -05:00
ebbit1q
401fdcaf7a move changing x coord to after check for token deletion (#4236)
fixes #4235
reverts #4216
2021-01-30 16:44:12 -05:00
ctrlaltca
1bfcca91be add window icons in wayland (#4232)
Co-authored-by: Fabio Bas <fabio.bas@officineinformatiche.net>
2021-01-28 15:21:11 -05:00
ebbit1q
3edb862561 update version number to 2.8.1 (#4229) 2021-01-27 20:49:13 -05:00
ZeldaZach
00c0162da3 Change release name/number for 2.8.0 and make it a forced update 2021-01-26 14:56:29 -05:00
ZeldaZach
6fa5f4f9a5 Translations from Transifex 2021-01-26 14:50:05 -05:00
ebbit1q
db528c6762 Release templates (#4226)
* add creation of release templates to ci and update guide

* touchups to markdown

* correct create release property

* correctly set fetch-depth and release body

* fix replacements, remove arrows

* check if there are no betas

* add extra output

* typo
2021-01-25 19:53:34 -05:00
ebbit1q
0c54cdf6bc set release upload_url correctly during configure (#4225)
correctly set prerelease flag
set prerelease names to their tag instead of full release name
detect version for use in release name during configuration
2021-01-24 16:52:19 -05:00
ebbit1q
b63145c0a1 merge build workflows (#4197)
* merge build workflows

* fix mac version comparisons
2021-01-24 15:20:06 -05:00
Joseph Chamish
1ddc9cc929 Structure change (#4220)
* Structure change

* Remove duplicate folders from previous structure

* Cleanup websocket protocol

* Updating from based off PR

* Fixup - remove wrong files during conflict and get the websocket working

* renaming tsx to ts

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2021-01-20 18:50:18 -05:00
knitknit
a0deb73df6 Fix #2771: Do not change x coordinates of moved card if it will be destroyed when it leaves the table (#4216) 2021-01-02 22:45:11 -05:00
Jeremy Letto
0457e65751 Webatrice P.O.C. (#3854)
* port webclient POC into react shell

* Abstract websocket messaging behind redux store

* refactor architecture

* add rooms store

* introduce application service layer and login form

* display room messages

* implement roomSay

* improve Room view styling

* display room games

* improve gameList update logic

* hide protected games

* improve game update logic

* move mapping to earlier lifecycle hook

* add autoscroll to bottom

* tabs to spaces, refresh guard

* implement server joins/leaves

* show users in room

* add material-ui to build

* refactor, add room joins/leaves to store and render

* begin using Material UI components

* fix spectatorsCount

* remove unused package

* improve Server and Room styling

* fix scroll context

* route on room join

* refactor room path

* add auth guard

* refactor authGuard export

* add missing files

* clear store on disconnect, add logout button to Account view

* fix disconnect handling

* Safari fixes

* organize current todos

* improve login page and server status tracking

* improve login page

* introduce sorting arch, refine reducers, begin viewLogHistory

* audit fix for handlebars

* implement moderator log view

* comply with code style rules

* remove original POC from codebase

* add missing semi

* minor improvements, begin registration functionality

* retry as ws when wss fails

additionally, dont mutate the default options when connecting

* retain user/pass in WebClient.options for login

* take protocol off of options, make it a connect param that defaults to wss

* cleanup server page styling

* match wss logic with desktop client

* add virtual scroll component, add context menu to UserDisplay

* revert VirtualTable on messages

* improve styling for Room view

* add routing to Player view

* increase tooltip delay

* begin implementing Account view

* disable app level contextMenu

* implement buddy/ignore list management

* fix gitignore

Co-authored-by: Jay Letto <jeremy.letto@merrillcorp.com>
Co-authored-by: skwerlman <skwerlman@users.noreply.github.com>
Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
2020-12-31 17:08:15 -05:00
saadbruno
d5b36e8b8a Disabled strict mode for MySQL on the docker-compose file (#4214) 2020-12-28 16:43:45 -05:00
ebbit1q
f595a61d50 fix #4198 (#4209) 2020-12-09 02:08:00 -05:00
Joel Bethke
dbf6cd745e cmake: Minor updates (#4204) 2020-12-07 11:50:32 -05:00
ebbit1q
0ce813b826 restore saved previous server (#4206)
fix #3617
2020-12-05 21:36:27 -05:00
tooomm
77be6a120c fix broken image (#4202) 2020-12-01 16:57:27 -05:00
tooomm
37053cc909 Remove AppVeyor config (#4200)
* readability

* update ci badge for windows

* Delete .appveyor.yml
2020-12-01 22:38:50 +01:00
Zach H
34e951298f Address a handful of warnings from #6095 (#4199) 2020-12-01 11:30:22 -05:00
Joel Bethke
8845a23d5d CI: Fix up Windows builds and add GitHub Actions for Windows (#4193)
* ci: Add vcpkg submodule

* cmake: Fix NSIS not detecting platform arch

* cmake: Add QTDIR(64|32)

This change adds a new var for QTDIR(32|64) which makes it easier
to specify a specific directory for Qt, rather than having to edit
the prefix path directly, which can get pretty messy. Functionally,
this shouldn't affect any builds that are already finding Qt as
part of path, and should not affect Linux/macOS.

* cmake: Bump min cmake version

* ci: Add GitHub Actions for Windows
2020-11-30 23:54:50 -05:00
Derek Chiang
38606bdb87 Display a system tray notification when a player joins your game (#4194)
* Display a system tray notification when a player joins your game

* Display game ID in join message
2020-11-29 21:11:35 -05:00
Joel Bethke
56a51c7834 ui: Fix Qt depreaction warnings (#4195) 2020-11-29 02:33:13 -05:00
tooomm
402c09e028 Update CONTRIBUTING and more travis removing (#4179) 2020-11-28 03:14:15 -05:00
ebbit1q
9e702ec358 update link to master builds on appveyor (#4180) 2020-11-28 03:13:42 -05:00
Joel Bethke
c047a8ae3c ui: Add shortcut for "Save deck as..." (#4188)
Fixes: #4174
2020-11-26 22:22:44 +01:00
tooomm
b4740ad395 Update README.md (#4189)
* Update README.md

* don't run on .md-only changes
2020-11-26 13:14:00 -05:00
tooomm
99b0abe7fe GitHub Actions: don't run on .md only changes (#4183) 2020-11-25 21:14:05 -05:00
leiftw
b0239c11ab Fix typo in #L135 to conform with #L138 (#4182) 2020-11-24 14:58:28 -05:00
ebbit1q
46cf50d468 add ubuntu 20.10 Groovy Gorilla (#4178) 2020-11-23 18:09:02 -05:00
Zach H
9f9581c2be Support MTGJSONv5 format in Oracle downloader (#4162)
* Fix #4043, Support MTGJSONv5 format in Oracle downloader

* Auto redirect V4 downloads to V5, as we won't support V4 after this change

* clangify >_>

* Remove null values and account for IDs missing

* fix split cards and double faced cards somewhat

* do not consider double faced cards duplicates

* fix promo double sided cards

* typo

* fix alternative versions of cards with (letter)

* zach says this is more readable

* pre qt 5.10 compatibility

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2020-11-23 16:12:41 -05:00
tooomm
f3cf1f0dde pin badge to master (#4177) 2020-11-23 13:23:47 -05:00
tooomm
2f62671d8a More changes to GitHub Actions (#4175) 2020-11-23 12:27:35 -05:00
tooomm
589fbcdcd5 clearify wording (#4173) 2020-11-23 12:24:49 -05:00
ebbit1q
51b24bb92c refactor getting game age (#4095) 2020-11-22 20:28:56 -05:00
Zach H
6e00db4ef6 Fix racetime condition with token cloning (#4156)
* Fix #2820 by removing (this->setCursor) as this was null by the time we hit this component due to a racetime condition.

* check if card player pointer is valid before setting cursor

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2020-11-22 20:25:23 -05:00
ebbit1q
0d842b5a35 Resurrect 2655 (#4136)
* fix #2640

* clangify

Co-authored-by: Fabio Bas <ctrlaltca@gmail.com>
2020-11-22 20:23:18 -05:00
ebbit1q
8441cb7ba9 refactor pingClockTimeout (#4169)
* refactor pingClockTimeout

try to see if it changes #3954

* use lcoks and unlocks again
2020-11-22 20:21:43 -05:00
ebbit1q
4aaedf64d2 add github actions (#4164) 2020-11-22 20:20:48 -05:00
Zach H
45d838a0b3 Search full subdirectory for custom databases (#4137)
* Fix #2324 by allowing for iteration & symlinks

* Ensure alphabetical sorting
2020-11-22 20:06:25 -05:00
ebbit1q
ca5f1dd434 do some guesswork if cards can't be found (#4131)
modify up the simplifyCardName function to ignore right halves
add guessCard function that prioritises full card names the simple ones
fix imports for misformatted split cards or double faced cards
introduces a small concession: not completely formatted names with a
shared name on the left side will get mixed up, eg "bind" but not "Bind"
this should be fine considering how this would fix a lot more cards
2020-11-22 19:57:51 -05:00
tooomm
d07bf1211a Improve dialogs (#4153) 2020-11-13 16:01:44 -05:00
Zach H
0966a8e90f Fix #566 by allowing for DeckName/Comments to be resized to the max, and even hidden! (#4157) 2020-11-13 15:36:20 -05:00
ebbit1q
68074b0f74 check if node is a dir before deletion (#4165) 2020-11-13 14:55:01 -05:00
ebbit1q
f11f072e0a add missing mysql connector dependencies to docker images (#4160) 2020-11-08 19:35:54 -05:00
tooomm
3064621a7e Add exclude term to search hints (#4038) 2020-11-02 18:44:19 -05:00
tooomm
0405c82cb2 File name cleanup (#4154) 2020-11-01 19:03:08 -05:00
knitknit
8e9d4e3a67 Retain lastDrawList if a card is being moved within hand, e.g. hand reordering only. (#4152) 2020-11-01 15:02:17 -05:00
tooomm
ef78fdf342 Fix resizing for game filter dialog (#4149) 2020-10-29 20:21:01 -04:00
Kaitlin
a49c4865bb Add game filtering for spectator attributes (#4127) 2020-10-27 15:49:02 -04:00
fdipilla
1a94261490 Multiple background images on all zones (#4144) 2020-10-23 15:36:02 -04:00
Zach H
e10446f5b8 Remove annoying spectator log messages (#4138) 2020-10-22 16:46:50 +02:00
rivten
2081639970 fix infinite loop when card file save fails, instead stop the execution just like the other errors in the call (#4143) 2020-10-21 10:31:57 -04:00
ebbit1q
8cbc4c91f6 free qprocess on oracle update fail (#4134)
* free qprocess on oracle update fail

reload the database whenever oracle exits
search for oracle in ../oracle so you can use it from the build dir

* only ask for the db updater once
2020-10-21 10:31:18 -04:00
tooomm
b8cd3af21f CONTRIBUTING: little changes (#4141) 2020-10-14 11:19:37 -04:00
tooomm
1e8464c1d4 README: add discord badge and adjust downloads (#4142) 2020-10-14 11:18:59 -04:00
tooomm
5df069ab19 userlists --> account (#4139) 2020-10-12 17:18:11 -04:00
ebbit1q
752ba7d905 add face down to the string if the card is face down (#4130) 2020-10-06 16:51:20 -04:00
ebbit1q
9cf7621102 rename selected card menu (#4132) 2020-10-06 16:49:29 -04:00
Zach H
9330774632 Add Gitter/Discord info to Contributing (#4126) 2020-10-02 14:53:21 -04:00
ebbit1q
e33f802ae8 update CONTRIBUTING.md (#4125) 2020-10-02 13:54:12 -04:00
ebbit1q
48c6458766 remove nonfunctional mana artifact detection code (#4121)
mana artifacts will use the stack and be placed in the normal tablerow
if you want to put it with your lands you're free to do so, as long as
you promise to not say oh this should not be here three turns after
shatterstorm resolved
2020-10-02 12:14:44 -04:00
ebbit1q
35fe6f624c apply clang format to proto files (#4123)
* add proto files to clangify

* apply clangify to proto files

* remove blocksonsingleline, it didn't actually do anything

also add missing space to the travis warning, emoji are monospace too
2020-10-02 12:14:05 -04:00
ebbit1q
e2251fe06b update sfmt to version 1.5.1 from 1.4.1 (#4124) 2020-10-02 12:13:12 -04:00
ebbit1q
a5511190a3 add missing cardlink for the flip messages in the message log (#4122) 2020-10-02 12:12:13 -04:00
Kaitlin
eba9c097f6 Add dropdown for game age filtering (#4092)
* Part 1 for #3067: Basic combo box (dropdown) filtering mechanism for game age.

* Apply suggestions from draft review

# Conflicts:
#	cockatrice/src/gamesmodel.cpp
#	cockatrice/src/gamesmodel.h

* switch to using QTime

* check for games older than a day

* formatting for casts and more unnecessary cosmetic changes

* ebbit1q fixes

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2020-09-30 23:46:10 -04:00
tooomm
58d024d067 fix update message (#4116) 2020-09-29 22:00:09 -04:00
ebbit1q
be7b172e55 skip misprints marked with † (#4107) 2020-09-26 21:56:45 -04:00
Kaitlin
a8b79fd020 Fix show-buddies-only filter loading, and add handling for creator name filter storage/loading. (#4105) 2020-09-26 21:55:13 -04:00
ebbit1q
14fcb2e5d7 skip duplicate nonpromos (#4097)
* consider cards with frameEffects promos

* skip duplicates entirely

all cards that are not "promo" or something like it will only retain the first copy instead of parsing all of them and keeping the last
2020-09-22 16:09:59 -04:00
ebbit1q
02935be14f fix QByteArray::append(QString) deprecation in qt 5.15.1 (#4102) 2020-09-22 16:09:48 -04:00
Zach H
bec02b4952 Judges can talk in games (#4091) 2020-09-09 13:20:59 -04:00
Kaitlin
79f590c99a Fix #3957: Properly set filters to defaults on initial load and disable "Clear filters" button if filters are set to defaults. (#4088)
* Fix #3957: Properly set filters to defaults on initial load and disable "Clear filters" button if filters are set to defaults

* Reuse resetFilterParameters() in GamesProxyModel constructor, and remove "off" designation for player min/max (as a default of 1/99 is enforced by the UI).
2020-09-09 11:24:54 -04:00
Kaitlin
ade3e81682 Move "Games shown" text to top, to match user count list. (#4089)
Fixes last part of #3068 that isn't already handled by #4088.
2020-09-08 14:34:36 -04:00
ebbit1q
45cbdad5fb bump version to 2.7.6 (#4076)
fixes #4075
2020-08-24 14:04:56 -04:00
Zach H
3536fa8a75 Fix #4072 by changing outdated HTTP to HTTPS calls within the codebase (#4073) 2020-08-23 17:24:26 -04:00
fdipilla
b0c7b9078d Multiple bg images zone (#4005) 2020-08-23 15:55:53 -04:00
ebbit1q
964207d04f make custom sets directory configurable (#4047) 2020-08-23 13:24:30 -04:00
ebbit1q
feee9cc328 fix #4070 (#4071) 2020-08-22 20:30:56 -04:00
olegshtch
4a563a131b Update test card database to v4 (#4064) 2020-08-21 18:18:53 -04:00
ZeldaZach
69f035f017 translation updates 2020-08-16 15:18:21 -04:00
olegshtch
daa89a9fb4 Run tests on WIndows CI (#4056)
* Run tests on Windows CI.

* Add message logger

* Skip tests that cannot be linked.

* Fix test call

* Fix mock link issue on MSVC

* Fix PATH variable to find libraries for tests

* Fail test step on test errors
2020-08-14 12:45:15 -04:00
olegshtch
44297dcd1c Fix release tests (#4063) 2020-08-13 10:18:01 -04:00
tooomm
80f613a77a travis: update macos 10.15 images (#4059) 2020-08-06 10:43:54 -04:00
olegshtch
776aa5c0ff Enable parallel compilation. (#4057) 2020-08-03 01:30:03 -04:00
olegshtch
446f9be24d Fix unresolved symbols when link tests to system libgtest-dev (#4055) 2020-07-30 14:52:44 -04:00
awlangham
5d9d91262b Added horizontal layout and stretch for player icon (#4052) 2020-07-28 01:22:02 -04:00
awlangham
fe63dfa762 Made user information window resizable (#4009) 2020-07-23 18:04:15 -04:00
ebbit1q
a76a3e5db6 Change method of opening directories to be the same for all oses, including linux (#4046)
* add opening directory in file browser to linux

this uses QDesktopServices to open the url "file://[location]"
by default this is
"file://$HOME/.local/share/Cockatrice/Cockatrice/pics/CUSTOM"

any distro that has a file browser should have an accompanying mime type
specifying the file handler for the file:// protocol using the
inode/directory mime type

see https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html

if a user were to have removed their mime database this will not work and
it will fail with nothing but a log message, this would be rare and not
worth checking in my opinion

* make opening directories the same for all oses

* sort headers
2020-07-16 11:22:24 +02:00
Lee Tran
faecfd65fe fix message when moving cards to bottom of library (#4006) 2020-07-09 17:25:25 -04:00
tooomm
0063493066 Remove gitlab config (#4037)
* revert #2345

* remove gitlab yml
2020-07-01 17:36:04 +02:00
tooomm
2a7268c088 move db udpate (#4015) 2020-06-29 10:25:17 +02:00
ebbit1q
7fa1936d0f qt 5.15 compatibility (#4027) 2020-06-19 10:50:09 -04:00
ebbit1q
0f0e0193c1 update fedora 31 to 32 (#4024) 2020-06-09 03:07:34 -04:00
ebbit1q
0337f58088 add extra exceptions to plaintext imports (#4018)
this specifically to support imports from mtg arena that have a set code
and then a collectors number like (ABC) 123 at the end, this pr strips
that from the card name (we don't use it anyway)

fixes #4011
2020-06-02 10:56:01 -04:00
ebbit1q
53c6440cac make sure no //es are added to maintypes (#4017) 2020-06-02 10:55:05 -04:00
tooomm
28f3229a0e remove storm phrasing (#4001) 2020-05-18 15:27:53 -04:00
ZeldaZach
3dff63069e translation updates 2020-05-17 18:25:55 -04:00
kopcion
1eea8e9a37 Refactor messagelogwidget (#3875) 2020-05-17 18:15:30 -04:00
Rocangus
2de863f645 Spell Out Entire Counter Names With First Letter Capitalized (#3997) 2020-05-17 17:24:17 -04:00
tooomm
dc8603596d fix outdated version number (#3999) 2020-05-17 13:39:30 +02:00
fdipilla
fd0620445c Different backgrounds per player (#3990) 2020-05-14 20:31:12 -04:00
ebbit1q
04274d2497 add ubuntu 20.04 to travis (#3989) 2020-05-13 13:42:08 -04:00
Mikael Palmujoki
c69e77f330 Docker-Compose support for Windows (#3974)
* Add docker-compose document that works out of the box for Windows, and a storage location for the mysql-database.

* Documented Windows support in Readme file
2020-05-08 15:22:39 -04:00
Kaitlin
1988e4558f Change filter hint text to "Games shown: X / Y" and fix user-game segfault (#3973) 2020-05-08 15:15:54 -04:00
Zach H
9246c190fa Enhance Shortcut Menu (#3987) 2020-05-08 15:10:36 -04:00
ctrlaltca
d30691559a Some improvements to Servatice network code (#3969)
* Some improvements to Servatice network code

1. fix crash on fuzzy connection (tcp server only)
2. ensure websockets are parent()ed to avoid leaking them
3. quick catch disconnect()ed sockets instead of waiting for a socket error to happen
4. supporto mulltiple connection pools on the websocket server; they are still bound to the same thread due to a qt5 limitation.
2020-04-24 16:26:59 -04:00
Olxinos
46fe0cd725 prevent checkboxes' labels from being clipped in settings (#3968)
Merged, thank you
2020-04-24 18:33:26 +02:00
ebbit1q
45d62b6880 skip all duplicate promos instead of just stars (#3965) 2020-04-23 11:24:39 -04:00
Olxinos
db85ec48c7 Minor fixes to some std::sort calls (#3967) 2020-04-23 11:23:59 -04:00
ctrlaltca
1976c4caed macOS: test a simple way to bypass apptranslocation (#3944) 2020-04-08 17:34:57 -04:00
Kaitlin
2c3eab9b0c Fix #3068: Add hint text about game list filters (#3946)
Kaitlin Huben <kaitlin.huben+gitlab@gmail.com>
2020-04-07 17:55:36 -04:00
ctrlaltca
27b7ebe208 Oracle / card xml improvements (#3934)
* fix #1610

* fix #2679; partially fix #3647

* Fix tests

* Remove debug code
2020-03-30 21:56:03 +02:00
Zach H
a135ad064a Handle Release Channels better as we host more packages now (#3922) 2020-03-26 13:41:38 -04:00
ebbit1q
e8d5715f7a More OS support (#3915) 2020-03-20 15:32:12 -04:00
Zach H
9cec0852bb Remove force update appveyor (#3920)
According to https://help.appveyor.com/discussions/questions/16192-build-tag-annotation-overwritten, we don't need force_update to push the files up. This will preserve name/description of the release
2020-03-20 14:04:17 -04:00
ctrlaltca
ca618c6cc1 Travis: skip cleanup before deploy (#3919) 2020-03-20 12:23:49 -04:00
ctrlaltca
c5e0b08800 Cmake: get release name from github page instead of using APIs (#3916)
APIs are limited
2020-03-19 15:59:48 -04:00
ZeldaZach
568a4973fa make sh executable 2020-03-19 11:52:09 -04:00
ctrlaltca
5508699e92 Fix openssl name for windows x64 (#3914) 2020-03-19 10:09:29 -04:00
ZeldaZach
71dd6b8a30 Fix missing QDate
Signed-off-by: ZeldaZach <zahalpern+github@gmail.com>
2020-03-18 17:57:40 -04:00
ebbit1q
18a07274d4 clangify everything with the new header sorting (#3908) 2020-03-18 17:36:02 -04:00
ctrlaltca
1eb766b9d8 Fix dynamic loading of openssl libraries on windows (#3912) 2020-03-18 17:22:49 -04:00
ZeldaZach
e84409c0cf Translation Updates 2020-03-16 22:01:57 -04:00
Phillip Wheatley
91dc8b3b08 Add configuration option to send desktop notification on buddy presence (#3886) 2020-03-16 21:49:11 -04:00
Xenos6666
63b4f9b2f0 Add keyboard shorcuts to focus and unfocus chat (#3898)
* Added keyboard shorcuts to focus and unfocus chat

* Fixed format

* Changed the Esc behavior to work on any QLineEdit in the main Window and ignore shortcut conflicts

* Fixed a conflict with shortcuts

* Configurable unfocus shortcut and format fixes

* minor style fix
2020-03-16 21:48:05 -04:00
Phillip Wheatley
7285f24a29 Docker-compose setup for Servatrice (#3887)
* Docker compose for servatrice

* Update README.md

* Clean up docker-compose specific configuration
2020-03-16 21:40:58 -04:00
ebbit1q
17efe8c003 add pauper to the list of checked formats in search (#3901)
* add pauper to the list of checked formats without a short form

l:p remains reserved for pioneer

* throw out weird hardcoded formats

this will at least still work whenever a format gets added
the shorthands are still kept
2020-03-16 20:56:30 -04:00
ebbit1q
1815094249 Keep stars but only sometimes, add scheme cards back (#3904)
* ignore stars and promos but only sometimes

this will correct #3706 and #3715 being a bit overzealous in removing
cards and thus fix scheme cards being removed in entirety
fix #3845
note that this causes a lot more cards to be added that are in promo
sets, if these promo sets should prove to be problematic they should be
disabled somehow as having them as an option is still nice.

* remove debug lines
2020-03-16 20:42:27 -04:00
ebbit1q
a80c756dcb update deprecated methods in qt5.14 and protobuf 3.4 (#3906) 2020-03-16 20:41:41 -04:00
tooomm
361833e023 clarify language setting (#3897) 2020-02-19 10:54:55 -05:00
ctrlaltca
632e44b0b7 Fix missing languages in oracle dropdown (#3896) 2020-02-18 22:33:41 +01:00
skwerlman
8dd1e39ea9 support mtgo .dek files (#3889)
* support mtgo .dek files

they use plain text internally so we just need to reveal them in the load dialog

* formatting
2020-02-04 08:11:24 -05:00
Phillip Wheatley
0f18fa9546 Hide games created/hosted by people on your Ignore List (#3883)
* Implement filter for games created by ignored users.
2020-01-13 10:13:36 -05:00
ebbit1q
7bfefee073 add deck hash copying functions (#3882) 2020-01-13 10:11:19 -05:00
skwerlman
0ff7472ce5 fix password length checks (#3884)
unit testing when
2020-01-13 09:54:55 -05:00
Zach H
8fb0baa449 Trim tokens as this is our most common issue (#3870)
Signed-off-by: ZeldaZach <zahalpern+github@gmail.com>
2019-11-23 14:18:28 -05:00
skwerlman
57c02dcd5a GitHub: Switch to new issue template system (#3862) 2019-11-22 23:54:28 -05:00
tooomm
b072b540a2 Travis: more appealing thank you message (#3858) 2019-11-22 23:53:47 -05:00
kopcion
cd431594e2 Issue 3015 - store timestamp when password is reset (#3863)
* Added few unsigned to ints in order to get rid of warnings.
Added column to users table, for when password is changed(issue#3015).
Moved password length check to separate method, to make it cleaner.
* Added migration file and changed schema version to 27 due to servatrice.sql schema modification.
* Make password length configurable.
2019-11-22 23:52:45 -05:00
tooomm
e4c98e2ab8 Travis: update config for dpl v2 (#3853) 2019-11-05 17:39:00 -05:00
tooomm
32b557b862 readme: fix toc link (#3859)
* fix toc link

* adjust order
2019-11-03 23:15:08 -05:00
Zach H
e690b45f27 Create FUNDING.yml 2019-11-02 23:52:14 -04:00
tooomm
eadcdc6f7c link to new AllPrintings file (#3851) 2019-11-02 23:51:10 -04:00
ebbit1q
b187fb52e0 add pioneer (#3856) 2019-11-02 23:48:17 -04:00
tooomm
7e89933552 bump version number (#3857) 2019-11-02 23:47:55 -04:00
ZeldaZach
096a472ed0 translations 2019-10-21 19:09:28 -04:00
tooomm
365b0a31ed Travis: add Mojave deploy target and release a zipped .dmg (#3819)
* add osx mojave build+deploy

* add job names, change variables

* add zipping to packaging step

* see #3814

* update to high sierra

* update homebrew

* xcode 11.1

* [skip ci] add link to config explorer
2019-10-21 19:06:40 -04:00
skwerlman
e8fd2ce2aa add support for adventures to oracle (#3836)
* add support for adventures to oracle

this causes cockatrice to correctly fetch the front of the card for the adventure portion rather than sending lots of bad requests to scryfall

* treat adventures more like split cards

* dont hardcode `maintype: creature`
2019-10-09 01:05:30 -04:00
ebbit1q
a3fc9b6ee5 add move top card to stack keybind (#3827) 2019-10-09 00:10:23 -04:00
ebbit1q
9eebc590c1 [WIP] add shortcuts for readying and sideboarding in the lobby (#3832)
* add shortcuts for readying and sideboarding in the lobby

* clangify
2019-10-08 23:59:48 -04:00
ebbit1q
f840dcbd66 Increase macos version, drop sierra support (#3837)
800b0f4b2f homebrew no longer provides a bottle for protobuf, which is so big we can't do without a precompiled version. This means we can no longer support sierra 10.12 and have to use high sierra 10.13, this does not seems like a very painful grade however as there are no differences in hardware requirements between the two and any user on sierra can upgrade to high sierra if they wanted to.
2019-10-08 23:55:47 -04:00
ebbit1q
8879fc2e39 fix compiling on gcc 9 (#3830) 2019-10-02 15:48:49 -04:00
ebbit1q
cd29e2f252 add disable tearoffmenu option (#3826) 2019-10-02 14:58:22 -04:00
ctrlaltca
bcf505c98b Oracle: fix crash on no card type; fix #3815 (#3816) 2019-10-02 14:54:51 -04:00
tooomm
933f3e1392 update os name (#3814) 2019-10-02 14:54:10 -04:00
Ashley Davis
ba0462b24f Update Dockerfile to include missing lib, not build dbconv, and use ENTRYPOINT (#3808) 2019-09-09 17:06:28 +02:00
ctrlaltca
7e8a63cd62 Settings: default to current chosen directory while opening file dialogs (#3810) 2019-09-09 09:23:38 +02:00
tooomm
03e109ef12 wait > sleep (#3806) 2019-09-05 15:44:14 +02:00
ebbit1q
257f2eb34c warning message is way too scary (#3805)
People keep complaining they can't compile on ubuntu 16.04 because of this warning message, while it just disables 2 "prettyness" warnings and only in the automatically generated code by protobuf which should never be a problem anyway!
original pr: #3432
2019-09-05 15:43:51 +02:00
Zach H
53728598fe translation updates (#3804) 2019-08-31 21:36:13 -04:00
ctrlaltca
3b98eb77f5 Close all player-associated zoneviews when he quits; fix #3799 (#3800) 2019-08-27 20:07:33 -04:00
ctrlaltca
b6df5a4ac3 Deal with recent Qt methods deprecation (#3801)
* Deal with recent Qt methods deprecation

 * Use std::sort, std::less instead of qSort/qLess
 * Use QFontMetrics::horizontalAdvance instead of ::width
 * Use qApp->primaryScreen() instead of QDesktopWidget
 * use lambas instead of QSignalMapper
 * Use QTreeWidgetItem::setForeground instead of ::setTextColor
 * Use QDir::setPath instead of operator=(QString)
 * Use QList::swapItemsAt instead of ::swap

* fix error
2019-08-27 20:06:54 -04:00
ctrlaltca
f54165025e Add a new command to reverse turn order (#3802) 2019-08-27 20:04:27 -04:00
ctrlaltca
013137c418 Fix #3783 (#3785) 2019-07-17 10:05:00 -04:00
ebbit1q
faf02100a5 add 4BB to nonenglish sets (#3786) 2019-07-17 10:04:19 -04:00
tooomm
a8b34d51a5 travis: separate lint build (#3778)
* Create travis-lint.sh

* separate lint

* Update travis-lint.sh

* Update travis-lint.sh

* use default image

* call lint externally

* add xenial again for tests

* Update .travis.yml

* fix path

* move test to docker build

* remove --format argument test / passed

* add test label

* use bash command

* source > execute
2019-07-13 15:39:51 -04:00
Rob Blanckaert
2ef3e6fc93 Enable tear-off on menus. (#3772) 2019-07-11 22:53:43 -04:00
ebbit1q
a3a1e20074 replace old mulligan with new behavior (#3773) 2019-07-11 22:53:09 -04:00
tooomm
ce54aa6813 remove fedora package support (#3752) 2019-07-11 16:05:42 -04:00
ebbit1q
5139039402 add homebrew cache to cache (#3776)
* add homebrew cache to cache

* use same image

* ruuun travis, ruunn

* remove extra space

* do these dashes do this?

* trigger ci

* these dashes confuse me, consistency is like woosh
2019-07-11 09:21:35 -04:00
ctrlaltca
f4adf79ad9 Message log: remove all workarounds; fix #3553 (#3760)
* Remove workarounds in messagelog
2019-07-07 22:27:50 -04:00
ebbit1q
f10f9ada3a properly capitalize set types like Duel Deck and From the Vault (#3770)
* properly capitalize set types like Duel Deck and From the Vault

* add more tiny words

* update macos for travis (slower build times)
2019-06-30 12:08:07 -04:00
ctrlaltca
965a6cdde7 fix #3755 (#3756) 2019-06-12 14:50:26 +02:00
tooomm
62c0825874 fix grammar (#3754) 2019-06-09 19:01:32 +02:00
tooomm
4e918f0f5d move brackets out of link tags (#3753) 2019-06-09 19:00:53 +02:00
tooomm
3e3154a58c version bump to 2.7.2 (#3751) 2019-06-09 19:00:04 +02:00
Zach H
22e2e442f5 updated translations for 2.7.1 (#3750) 2019-06-08 12:38:59 -04:00
ctrlaltca
c0c4a6df50 Fix card database load after update (#3748) 2019-06-08 14:48:34 +02:00
ctrlaltca
36ba9c2d94 fix #2786 (#3747) 2019-06-08 10:15:33 +02:00
ctrlaltca
1288795de9 fix #3735 (#3746) 2019-06-08 10:14:58 +02:00
Zach H
0380de9571 add trans strings for upstream (#3745) 2019-06-04 17:41:58 -04:00
ebbit1q
6ac3852995 grammar fixes (#3727) 2019-06-04 17:33:36 -04:00
ctrlaltca
1d8fb79e11 Misc startup improvement (#3740)
* Misc startup improvement

* fix paths

* clangiftw

* reworked save sets dialog

* Unified load and save steps for tokens and spoilers; added "finished" page

* linting1

* linting2

* wording

* undo layout change

* wording

* fix spoiler path again

* simplify phrase

* lint

* lint fix

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2019-06-02 21:47:37 -04:00
tooomm
e084bd18a9 fix aftermath (#3742) 2019-06-02 12:05:54 +02:00
ctrlaltca
7c3cc527f6 fix windows style (#3739) 2019-06-01 16:08:44 +02:00
ctrlaltca
218aec07f8 Split buttons in the deck editor (#3709) 2019-05-31 11:54:32 -04:00
ctrlaltca
ada13f6578 Card Database converter (#3694)
* Database converter

* Fix win compilation and NSIS installer

* Maybe fix windows again

* Re-fix windows
2019-05-31 11:48:30 -04:00
Rob Blanckaert
8682367b52 View hand window (#3731)
* Roar

* Add View Hand menu to player

* Add shortcut

* reorder right click menu
2019-05-31 16:53:24 +02:00
tooomm
a80f3b77da use Qt 5.12 LTS (#3732) 2019-05-30 12:02:10 +02:00
tooomm
fd8bf66acd style (#3728) 2019-05-27 21:17:57 +02:00
ctrlaltca
115ed78059 Update Translations (#3717)
* Extract new strings from translations

* fetch new translations
2019-05-10 23:13:34 +02:00
ctrlaltca
00ca69fced Add v4 xsd (#3710) 2019-05-09 09:38:52 +02:00
ctrlaltca
6c21855f98 Token dialog fixes (#3711)
* Token dialog fixes

* clangify

* edit custom tokens

* Fix in-game token dialog
2019-05-09 09:37:27 +02:00
ebbit1q
3830c85ce6 skip more cards (#3715)
closes #3713
2019-05-09 09:37:04 +02:00
ctrlaltca
0dc4cc7e03 propose to save deck before loading a new one; fix #3699 (#3707) 2019-05-05 22:38:53 +02:00
ctrlaltca
8f5bfd1f87 Oracle: skip cards with a star in the collectors' number (#3706)
* Oracle: skip cards with a star in the collectors' number

* clangify
2019-05-05 22:38:31 +02:00
ctrlaltca
95d6efcdbf Dont create dummy card infos for unkown cards (#3708) 2019-05-05 22:37:48 +02:00
skwerlman
63cf0ae764 Fail cmake if protoc doesn't exist (#3705)
fix #3704
2019-05-04 23:33:38 -04:00
tooomm
f1e79707e8 work around confusing new default badge label (#3701) 2019-05-01 17:29:15 -04:00
ebbit1q
9073cb53a8 add !sflang! property for card image urls (#3670)
update translations
add translation for the sflang property to supported languages
2019-04-18 13:01:50 -04:00
skwerlman
d018070891 Fix cipt check for shock lands (#3678)
* Fix #3410

The oracle text for shock lands has changed such that they no longer get `cipt`. This fixes that.

* fix whitespace

* use shorter check
2019-04-09 13:12:15 -04:00
tooomm
837924b819 reword (#3682) 2019-04-06 23:12:21 -04:00
tooomm
00cfb1347a Update ISSUE_TEMPLATE.md (#3679) 2019-04-04 14:52:48 -04:00
ctrlaltca
0ce2e61db9 Fix filters (#3676) 2019-04-02 23:02:34 -04:00
ebbit1q
1854e3440b add ci: filter for color identity to help page (#3673) 2019-03-27 22:57:12 -04:00
ebbit1q
a0260eb0b2 add italian renaissance to nonenglish sets (#3672) 2019-03-27 22:56:52 -04:00
ebbit1q
c874f201c3 add a bunch of parents to dialogs (#3658)
* add a bunch of parents to dialogs

works on #3651

* use game as parent instead

* add more parents

* fix create token dialog modality

* add parent to game information window

* replace a bunch of nullptrs with the magic of sed

* add parent to tip of the day and counters

* reorder game ptr

* set parent for life counter

* clangify
2019-03-26 14:54:47 -04:00
tooomm
7072f24103 update link (#3665)
repo got moved
2019-03-22 16:11:36 -04:00
ebbit1q
eb4914d36f include a list of priorities for maincardtypes in oracle (#3663)
fix #3662
2019-03-16 15:00:34 -04:00
James Le Cuirot
6d27631764 Add USE_CCACHE option to CMake so that ccache can be forcibly disabled (#3661) 2019-03-14 16:19:55 -04:00
Rob Blanckaert
a522255baf - Chnage some hard-coded colors to take into account their background. (#3654)
- Change some SVGs from black to white if their background is too dark.
2019-03-13 16:11:30 -07:00
ebbit1q
7eb2e36740 workaround for foreign card arts getting priority by default (#3652)
fixes #3623
2019-03-12 10:12:31 +01:00
ctrlaltca
2d8f01b2e9 Show current counter value on "set counter" dialog (#3650)
* fix point 10 of issue #655

* clanfigyism
2019-03-11 00:33:19 +01:00
ctrlaltca
6f95556632 Fix related cards menu in deck editor (#3649) 2019-03-10 23:15:24 +01:00
ctrlaltca
0326f0d4c9 Permit use of up/down keys to increment/decrement counter value; Fix #3618 (#3646)
* Fix #3618

* clanfigy me softly

* fix unused var and params

* Frce the dialog being modal; ensure self deletion

* More qt-like behavior

* Restore dialogSemaphore logic
2019-03-10 22:22:19 +01:00
ctrlaltca
389f7fdc25 Shortcuts preference pane (#3641)
* Shortcuts preference pane

* Honor and glory to the hypnoclangifier

* clanfigy: exclude deleted files from being checked

* keep the olf translation context to be able to reuse old translations

* Fix gcc; extract translations

* Moved generic buttons after the groupbox

* Update current item on "clear/reset all"

* Sequenceedit: make buttons larger and translatable, add text

* Event filter

* Don't filter arrow keys; added placeholder text

* group counters
2019-03-10 21:49:33 +01:00
ebbit1q
11b2942d09 try to use fabs instead of abs to see if flatpack cares (#3638) 2019-03-10 18:49:18 +01:00
ctrlaltca
52cc725de4 Fix crash on card relation to inexistent card; fix #3637 (#3640)
* Fix crash on card relation to inexistent card; fix #3637

But that whole loop is a logic mess

* Check if related cards exists before creating the menu entry

* honor and glory to the hypnoclanfigier
2019-03-10 18:47:24 +01:00
Rob Blanckaert
a304d4235d Fix #3614 (#3633) 2019-03-07 22:48:03 -05:00
tooomm
4d7024e066 version bump to 2.7.1 (#3635) 2019-03-07 22:47:41 -05:00
Rob Blanckaert
4ce928eb41 Allow more characters in bare searches (#3632) 2019-03-07 12:21:30 +01:00
Rob Blanckaert
b172172be1 Fix #3587 (#3634) 2019-03-07 12:21:08 +01:00
ctrlaltca
5fd86954d6 fix #3621 (#3628) 2019-03-06 19:18:19 -05:00
Rob Blanckaert
55c4207182 Fix related cards popup (#3613) 2019-03-04 02:19:37 -05:00
ebbit1q
440311c939 set word wrapping (#3612)
fix #3605
2019-03-04 02:17:33 -05:00
Zach Halpern
81059fa3d8 translations 2019-03-04 01:49:43 -05:00
Zach Halpern
9f856acba0 revert
Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2019-03-04 01:34:13 -05:00
Zach Halpern
69474bad22 revision version 2019-03-04 01:33:49 -05:00
ebbit1q
fafdb65453 prioritize creature on maincardtype (#3611) 2019-03-04 01:32:19 -05:00
Rob Blanckaert
477faafb84 Adjust fontsize up on highdpi displays (#3610) 2019-03-04 01:32:09 -05:00
ebbit1q
abe4f5ca60 don't remove pt! 🔥🔥🔥🔥 (#3606)
* don't remove pt! 🔥🔥🔥🔥

* apply water to burns

* clangify

* fix clientside

* clangify

* missed qdebug

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2019-03-04 00:55:54 -05:00
Rob Blanckaert
a86aeb00c5 Fix 3598 (#3607)
* Fix 3598

* spelling
2019-03-03 22:03:35 -05:00
Zach H
754b9bdc5a Won't change if autoconnect enabled (#3602)
* Only will auto-select RR if autoconnect is not checked off.

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Only will auto-select RR if autoconnect is not checked off.

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* On disconnect, un-check autoconnect. Better naming.

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2019-03-03 21:57:48 -05:00
Rob Blanckaert
5a3f2fcff7 Allow /\ in simple searches. (#3604) 2019-03-03 21:48:20 -05:00
ebbit1q
9411396b97 rework pt setting (#3584)
* rework pt setting

save pt as a string serverside
set the pt of cards that enter the battlefield to empty (was -1/0)
implement old behaviour as changePT clientside
display old pt to messagelog
add new keybind for new set behaviour (default ctrl+shift+p)
add flow pt actions and keybinds that increase while decreasing
put more braces everywhere
various refactors like adding consts and for loops
remove a single superfluous semicolon
does not change the way pt is displayed client side
does not fix 3455 fully

* fix drawing of pt

remove search for / in carditem's paint() (crash)
ptstring is now always orange unless it's a faceup card with a pt that
matches the cardinfo pt
set changept to remove the pt if the field is empty
set changept to keep the old value if one side is empty
return in changept for +0/+0
clean up some if statements

* return on change to +0/+0

* change log message for empty original pts

* typo

* remove changept

add parsept to unify reading pt strings
change setpt behavior to be an "upgraded" version of the old setpt
add arbitrary strings as anything that starts with /

* clangify

* remove debug lines

* add tip of the day

* add missing images

* clangify
2019-03-03 16:24:57 -05:00
Zach Halpern
18ad3cf4a5 Disable auto connect when updating 2019-03-03 16:14:08 -05:00
Rob Blanckaert
a7f19f7848 Fix some dark mode colors. (#3596)
* Pick a link color that looks good in both light and dark mode

* Fix up chat log colors
2019-03-03 05:24:10 -05:00
Rob Blanckaert
63839eb464 Fixes #3590 (#3595) 2019-03-01 18:11:09 -05:00
Rob Blanckaert
eb60fec8e2 Filter Strings for Deck Editor search (#3582)
* Add MagicCards.info like fitler parser.

* Use FilterString whenever one of [:=<>] is in the edit box.

* Opts

* Opt

* - Capture errors
- Allow querying any property by full name

* clang format

* Update cockatrice/src/filter_string.cpp

Co-Authored-By: basicer <basicer@basicer.com>

* - Some refactoring for clarity
- More filters
- Add filter help

* Clangify

* Add icon

* Fix test name

* Remove stay debug

* - Add Rarity filter
- Make " trigger filter string mode

* You have to pass both filter types

* clangify

* - Allow filtering by legality
- Import legality into card.xml

* Add format filter to filtertree

* More color search options

* RIP extended

* More fixes

* Fix c:m

* set syntax help parent

* Fix warning

* add additional explanations to syntax help

* Allow multiple ands/ors to be chained

* Cleanup and refactor

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Move utility into guards

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* I heard you like refactors so I put a refactor inside your refactor (#3594)

* I heard you like refactors so I put a refactor inside your refactor

so you can refactor while you refactor

* clangify

* Update tab_deck_editor.h
2019-03-01 14:30:32 -05:00
Zach Halpern
4427ad1451 Don't use hardcoded index
Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2019-02-28 00:34:12 -05:00
Zach H
e77e439c4b Minor cleanup & set RR default for new clients (#3591)
* Minor cleanup & set RR default for new clients

* Handle case of no entries

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Use RR as default on rebuilds

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2019-02-28 00:10:10 -05:00
Rob Blanckaert
45b16ba78d macOS: Fix qt5.12 scale issues and dark mode (#3588)
* Maybe fix QT 5.12 scale.

* Use Palette colors
2019-02-24 10:05:09 -08:00
Rob Blanckaert
e68305d7bf - CardItems have dummy CardInfos if they arent in the database (#3589)
- If a CardInfo has no sets, add a dummy one to try to download it by non-set specific templates.
2019-02-23 19:52:38 -05:00
Zach Halpern
c2150fd9bd Update translations
Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2019-02-22 16:49:06 -05:00
Rob Blanckaert
ea8201af5c Judge mode (#3531)
* Judge mode

* Use seperate judge icon

* Fix clang init ordering complaint

* Create gavel.svg

* Add judge level

* Adjust judge permissions.

* - Tag events caused by judges
- Allow judges access to card right click menus.

* Allow judges to  change phase / turn.

* Remove gavel from pawn

* Make judge action text black.

* Create scales

* Rename scales to scales.svg

* Use scales

* remove gavel

* - Address PR feedback
- Fix sort order

* Zach

* add option to servatrice.ini
2019-02-21 14:00:00 -05:00
Rob Blanckaert
9d27b36704 Make v4 Cockatrice XML importer convert picURL to picurl to match v3 behavior and allow picURL images to load. (#3585) 2019-02-21 03:48:03 -08:00
Rob Blanckaert
d519f992d2 Updater for websockets (#3581)
* Dont clobber password when pulling down server list.
* Force download server list on client update.
2019-02-19 00:24:35 -08:00
Rob Blanckaert
1b3da22dd7 Merge pull request #3579 from basicer/messagelog-tweaks
Tweaks to message log.
2019-02-11 16:42:51 -08:00
tooomm
317f29b321 update appveyor badge (#3576) 2019-02-11 22:32:11 +01:00
Rob Blanckaert
c32f2190bd - Mill cards in correct order
- Roll up shuffles into bottom message
- Remove unused variable
2019-02-11 02:12:56 -08:00
Rob Blanckaert
d49ec0088f Fix shuffle (#3578) 2019-02-10 21:06:30 -05:00
tooomm
5b197c072e Git clone depth 15 (#3577) 2019-02-10 20:54:47 -05:00
Zach H
294b4332cc zach deployment key (#3575) 2019-02-10 15:57:53 -05:00
Zach H
6d6b7b4537 Merge pull request #3574 from Cockatrice/tooomm-patch-2 2019-02-10 14:46:30 -05:00
tooomm
b3fd5857f8 bump app version to 2.7.0 2019-02-10 13:29:12 +01:00
Zach H
78c18b7db6 new translations (#3573) 2019-02-08 21:03:03 -05:00
ctrlaltca
099d524a42 Smoother trice (#3566) 2019-02-08 20:57:17 -05:00
Rob Blanckaert
612edae5f6 Click replay timeline to seek. (#3570)
* Click replay timeline to seek.

* Fix seek for long games

* Erase log when rewinding

* zach cleanup

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2019-02-08 20:32:56 -05:00
Rob Blanckaert
b065ada633 Fix unbalanced save() restore() in cards (#3571) 2019-02-08 14:24:55 +01:00
ctrlaltca
e4bac025dd remove debug (#3572) 2019-02-08 11:57:24 +01:00
ctrlaltca
923b4acdbc Make the xml parser less strict about xml problems (#3567)
* Make the xml parser less strict about xml problems

* clanfigy me harder
2019-02-08 01:50:54 -05:00
ctrlaltca
2703db75d0 Update card menu when its counters change (#3565) 2019-02-08 01:50:34 -05:00
Rob Blanckaert
d932581f4a Move to bottom of library in random order. (#3549)
* - Allow shuffling a subset of a zone
- When moving cards to the bottom of library, shuffle them after
- Process events in the correct order serverside

* Zach fixes

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Comments + additional guard
2019-02-07 14:08:44 -05:00
ctrlaltca
6e3fd30fcb Add install mode to logger; fix #3558 (#3563)
## Related Ticket(s)
- Fixes #3558

![schermata 2019-02-06 alle 08 45 25](https://user-images.githubusercontent.com/1631111/52327211-98419900-29eb-11e9-9d15-69f59fc9d379.png)
2019-02-06 12:27:32 +01:00
ctrlaltca
46b34d6515 Add websocket feature (#3562)
* add websocket feature

* Added 2.7.0_min_version
2019-02-06 03:08:59 -05:00
Rob Blanckaert
073c531855 Connect from commandline (#3556)
* - Use Qt argument parser
- Add --connect command line option.

* Better version info
2019-02-06 03:08:24 -05:00
ctrlaltca
9118871afb Fix mistyped signal name; (#3561) 2019-02-06 02:39:31 -05:00
tooomm
a7d485d6f5 keep wrong project domain for proper settings storage (#3560)
* update project domain

* revert + comment/hint

* better wording
2019-02-05 23:57:35 -05:00
Rob Blanckaert
a719e3b306 Log number of cards revealed to other players. (#3555) 2019-02-05 02:33:11 -05:00
Rob Blanckaert
2bf444e4b7 Add shortcut for next phase with action (#3548)
* Add shortcut for next phase with action

* zach cleanup

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* cleanup and niceties

* clangify

* rename cleanup

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2019-02-03 22:57:41 +01:00
Rob Blanckaert
c1d25bf58b Add /servatrice to websocket URL to help out reverse proxies. (#3551)
Remove unused define
Use websocket port from default servers if given.
2019-02-03 22:50:19 +01:00
Rob Blanckaert
544c66edde Make server 12-factor compatible. (#3546)
* Docker

* Herokuize

* Use mysql method with database_url

* cleanup
2019-02-03 21:58:54 +01:00
Zach H
5a4f020196 Merge pull request #3550 from ctrlaltca/fix_hghlight 2019-02-03 13:35:30 -05:00
Fabio Bas
ec081b8b03 Fix active player game area highlightning 2019-02-03 19:15:30 +01:00
Rob Blanckaert
9a8c81cf5e Client Websockets (#3545)
* Websockets

* Add setting to get websocket IP from header

* Add QT version guard

* Minor cleanup

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* - Make QWebSocket required
- Remove QWEBSOCEKT_LIB guards
- Only TCP on port 4747
- Fix peerName lookup

* fix check

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Update CMakeLists.txt

* Update CMakeLists.txt
2019-02-03 11:43:22 +01:00
Rob Blanckaert
5e38214675 Playing a tableRow 3 card from the stack puts it to grave. (#3547)
* Playing a tableRow 3 card from the stack puts it to grave.

* move to top by resetting pos

* Zach touch

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2019-02-03 11:33:38 +01:00
ebbit1q
ba985f97e5 removes the pt of face down cards (#3542)
* removes the pt of face down cards

Instead of setting the pt of a hidden card to the value only known to
you, it's reset to nothing.
Resetting a card while it's already reset does nothing.
Removing the pt of a card is logged as "player removes the pt of card."
instead of "player sets the pt of card to ." (note the missing value).

* reset unknown cards to nothing instead

* replace cardname with card id for unknown cards

fixes #3543

* prefix #
2019-02-02 20:33:29 -05:00
Rob Blanckaert
c9c0fb28ee Counter expressions (#3534)
* Add peglib

* - Add expression engine
- Take an expression when setting a counter

* Shift + Click = Middleclick for counters

* minor cleanup for clangify

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Added tip entry
2019-02-02 13:56:49 -05:00
Filip Sufitchi
6e1b0a7590 Fix up Dockerfile to use ubuntu:bionic and actually build (#3540)
* Fix up Dockerfile to use ubuntu:bionic and actually build

* Remove commented PPA

* Fix up Dockerfile to use ubuntu:bionic and actually build

* cleanup

* fixup merge
2019-01-31 19:01:17 -05:00
ebbit1q
3562a48984 Merge pull request #3536 from ebbit1q/fix_3500
fix #3500
2019-01-30 18:01:11 +01:00
ebbit1q
bb4ca4db4a set default minumum player count for multi column layout to 4 (#3535)
fixes #3533
does not change existing settings
2019-01-30 15:29:24 +01:00
ebbit1q
c51377ca2a fix #3500 2019-01-30 15:13:27 +01:00
ctrlaltca
c3d94a51ec fix #3498 (#3527) 2019-01-27 12:51:03 -05:00
Rob Blanckaert
7cd9b9c0c8 Unconcede (#3515) 2019-01-27 12:50:41 -05:00
ctrlaltca
0dcf97d29d Bump version to 2.6.3 (#3525)
## Short roundup of the initial problem
A beta release for 2.6.3 has been relesed, but the codebase is still at 2.6.2

## What will change with this Pull Request?
Bumped version to 2.6.3
2019-01-27 12:11:22 +01:00
ctrlaltca
ebc881fa1c fix #3523 (#3524) 2019-01-27 11:42:22 +01:00
ebbit1q
37f9f62f03 correctly report exit code in clangify (#3520) 2019-01-25 21:41:39 +01:00
Zach H
1ace060e34 zach's turn to run the show (#3521) 2019-01-25 13:36:43 -05:00
ebbit1q
495e232c22 add the amount of cards logged to the reveal cards event (#3516)
* add the amount of cards logged to the reveal cards event

sets cardname to the amount for the call if not 1 for the fromstr only
add braces for single line statements

* zach cleanup
2019-01-24 08:53:05 +01:00
ctrlaltca
ed70099e36 Rework of the card database, xml format and oracle parser (#3511)
* CardDB: merge all card properties in a new structure

* Pre Json parser changes

 * Cockatrice: use qt's builtin json support
 * Move qt-json src dir from cockatrice to oracle
 * Add dummy cockatricexml4 parser (yet to be implemented)

* Implement a new parser and xml format

 * cockatricexml4: new xml parser following the "generic properties hash" pattern;
 * oracleimporter: refactor the parsing code to better adapt to cockatricexml4; rewrote split cards parsing
 * carddb: change "colors" from a stringlist to a string
 * carddb: move the getMainCardType() method to the cockatricexml3 parser
 *

* CardInfo: show all properties (stil missing: nice name + translation)

* Rework the "add related card" feature so that it doesn't change the card name in the carddb

Also, fix token count display

* Picture loader: Added support for transform cards

* Fix side information for flip cards

Mtgjson uses side a/b for flip cards, while scryfall doesn't

* Pictureloader: dynamic tag resolution from card properties

Examples old => new
* !cardid! => !set:muid!
* !uuid!   => !set:uuid!
* !collectornumber! => !set:num!
New examples:
 * !prop:type!
 * !prop:manacost!

* Start moving mtg-related property names to a specific file

* Clangify

* Fix tests

* Make gcc an happy puppy

* Revert "Make gcc an happy puppy"

This reverts commit 446ec5f27516c4d3b32dbfc79557f4827c5c5bdf.

* Some gcc fixes

* Share set list between different db parsers, so they won't overwrite one each other

* All glory to the hypnoclangifier!

* Fix test compilation

* Cleanup edited files in the prior PR. (#3519)

* Cleanup edited files in the prior PR.

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Fix includes

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Update carddatabase.h
2019-01-23 18:17:10 -05:00
ctrlaltca
19180243aa Workaround fedora compilation problem on Travis; fix #3508 (#3512)
* attempt fix fedora by downgrading qt

* fix
2019-01-22 10:28:20 +01:00
Rob Blanckaert
a08cf9379b Disable darkmode on MacOS (#3513) 2019-01-22 10:28:06 +01:00
ebbit1q
1c6b43c545 fix typo in shortcut name (#3509)
In #3439 the shortcuts got some overhaul but this shortcut wasn't
correctly renamed.
This fix will clear users' original shortcut for increasing toughness.
An improvement over the current state of it not working at all and being
unable to set to the default shortcut.
Fixes #3506
2019-01-19 05:15:22 -05:00
Zach H
41bfbf2e83 Force Oracle run on new install/update (#3497)
* Force Oracle run on new install/update

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Add settings option to disable such a check

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2019-01-14 01:11:05 -05:00
ctrlaltca
273d5d89b7 Fix shortcuts on mac; fix #3482 (#3491)
* hopefully fix #3482

* Travis:uUse the most recent osx_image; use homebrew support in travis
2019-01-08 15:20:29 -05:00
Zach H
b0e643ecc0 Several download URLs have arrived! (#3494)
* Cockatrice Picture loader uses better defined URLs now
URLs are defined on the Card Management tab
Instead of Primary/Backup, you can now define a list of URLs
List of URLs can be drag/dropped for priority ordering
Oracle now uses scryfallId > mtgjsonUUID for !uuid!

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Simplify to QStringList and remove metacall

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* fix issues brought up by Dae. Also fix how the defaults load to account for first time users.

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* clangify

* Fix save settings on row moved (#3495)

* merge model fix, and reclangify

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Sources > Resources

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2019-01-08 15:18:06 -05:00
ctrlaltca
4eda7cda9e Make deck editor filter translatable ; extracted new translations; Fix #3488 (#3490)
* Fix #3488 ; extracted new translations

* Make operators translatable, too
2019-01-07 21:50:36 -05:00
ctrlaltca
463ef13fe0 Update version to 2.6.2 (#3492)
## Short roundup of the initial problem
We released 2.6.2, but CMake still thinks it's 2.6.1

## What will change with this Pull Request?
Update CMake version to 2.6.2
2019-01-07 09:12:27 -05:00
Caledor
ce140041e3 Switch from (s) to plural form whenever possible in message log (#3487)
* Use plural form whenever possible

Change for "%1 draws %2 card(s)" is self explanatory

Change for "look top X" switches var %2 and %3 so i can skip %3 for singular and translate as "top card", as explained in tr comment

For "counter(s)" i just moved it into %3 (each color) since plural form is already used there.

* clangify

* manual clangify attempt

* Add missing tr

* More missing tr
2019-01-06 20:48:20 +01:00
ebbit1q
84f6da103f remove all dos line endings (#3489) 2019-01-06 13:46:18 -05:00
ctrlaltca
2621cc09ac Optimize json parsing (#3480) 2018-12-30 19:05:40 -05:00
ebbit1q
40f787be14 add an ignore button to sort warning (#3463)
* add an ignore button to sort warning

* change warning message

* formatting
2018-12-30 18:51:03 -05:00
Caledor
59300e61fc Minor translation issue fix (#3481) 2018-12-28 15:59:11 -05:00
Zach H
ab1c4cb1d7 Use scryfall urls (#3474) 2018-12-20 18:49:53 -05:00
Zach Halpern
4616dd47bc preferences sym not dir 2018-12-20 18:26:46 -05:00
Zach H
94fe64c6c1 Update translations (#3475)
Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
2018-12-20 18:26:00 -05:00
ctrlaltca
65f41e520e [WIP] Basic mtgjsonv4 support (#3458)
* Basic mtgjsonv4 support

* Fix set type

* [WIP] Oracle: use zx instead of zip

* clanfigy fixes

* Fix reading last block of xz

* Added back zip support

* [WIP] adding xz on ci + fixes

* typo

* resolve conflict

* Make gcc an happy puppy

* test appveyor build

* appveyor maybe

* Appveyor: add  xz bindir

* Update ssl version (the old one is not available anymore)

* Windows is a really shitty platform to code on.

* test vcpkg

* again

* gosh

* nowarn

* warning 2

* static

* Maybe

* cmake fix

* fsck this pain

* FindWin32SslRuntime: add vcpkg path

* Appveyor: cache support, force usable of openssl from vcpkg

* updated as suggested

* ouch

* Import card uuids and expose this property as !uuid! for card image download

* Minor style fixes

* address changed URL
2018-12-20 18:05:03 -05:00
ebbit1q
cee69705d8 fix rpm builds in travis (#3472)
* add rpm build option to travis compile

* better argument parsing
2018-12-12 13:26:13 +01:00
tooomm
3a05bcfb29 fix deployment on travis (#3468)
## Short roundup of the initial problem
Deployment conditions weren't met, because the $BUILDTYPE variable doesn't exist anymore.
@ebbit1q changed that, and there is a flag now that you pass to the compile script instead.

## What will change with this Pull Request?
- Remove that condition
It's not needed because we make sure via the build config itself that on tags no debug builds are run. This was a double check basically to prevent debug builds beeing deployed.
2018-12-07 11:48:06 -05:00
ebbit1q
e921cf88f9 place the os nametag after the version (#3465)
When i added the appended os nametags I didn't account for the dots inside the version, this will place the nametag before the last dot instead of after the first dot.
2018-12-05 19:34:56 -05:00
ebbit1q
952f13dec4 update macos (#3461)
Set travis image to xcode9.2: this image uses sierra instead of
el_capitan, el_capitan no longer builds.
Disable homebrew autoupdates, this gives a major speedup.
2018-11-28 15:51:36 -05:00
ebbit1q
ed2a3f92e0 fix travis format checking again (#3451)
Set the exit code properly, "$?" does not work after "if !".
Move "set -e" to after format checks.
2018-11-25 19:29:24 -05:00
ebbit1q
f1563c5604 add fedora docker image to travis compilation (#3447)
* add fedora docker image to travis compilation

fixes #1746

* add dockerfile

* would you like to please install for me? [y/n]

* remove bc dependency

* save cache separately for different docker builds

* add development packages to fedora dockerfile

* add package names

* use env values to make these all look the same

* set docker image name correctly

* add missing dependency

* minor oversight, add %% to remove all braces in check schema
2018-11-25 11:25:47 +01:00
ebbit1q
06081bd940 add keybinds to mill cards (#3439)
* add keybinds to mill cards

Add functions to move single card from top of deck to the graveyard and
exile.
Add keybinds to move single or multiple cards from top of deck to exile
or graveyard.
Add new keybinds to settings menu.
Move settings menu items around for a better fit.
Rename a few of the items in the settings menu.
Add default keybinds: ctrl alt d/e for single/multiple cards from top of
deck to the graveyard. No defaults are set for moving to exile.

* fix shortcut menu

* fix missing tag

* rename mismatched functions

* fixed your typos

* refactor shortcutsettings

correct a lot of typos
optimize a lot of functions
this could merit a pr on its own

* set mill keybinds

* refactor add related card actions

I found a function that was completely unintelligible so I made it
remotely legible and removed the duplication.

* shorten line by 17 characters

replace a lot of function calls with just a single reference

* add brackets

add brackets to all single line if statements etc.
readability improvements
2018-11-23 22:21:20 -05:00
ebbit1q
843b9df939 fix a bug from #3412 (#3454)
check if the card returned any info at all
2018-11-23 22:19:06 -05:00
ebbit1q
c7b8f3e923 Corrections to 3438 (#3452)
* correct previous misstake in #3438

wrong, this fixes that.

* add checking for second argument to --package

nice to have

* split find result into path and file
2018-11-22 17:32:18 -05:00
ebbit1q
964bb0974c add more clang-format focus to CONTRIBUTING.md (#3442)
* add more clang-format focus to CONTRIBUTING.md

Add more clang-format instructions and instructions on clangify.sh.
Move clang-format instructions to the section Formatting and make other format topics a subheader of it to articulate focus on it.
Add section about our ci formatting for people that look at this file after their test failed.
fixes #3065
also fixes #3340

* grammar

* grammar
2018-11-21 23:00:35 +01:00
ebbit1q
3f40a51cdb move package files to unique name (#3438) 2018-11-21 22:59:46 +01:00
tooomm
d9b11858fb exclude mac debug on tagged release (#3443)
leftover from #3433
2018-11-21 22:57:16 +01:00
ebbit1q
ec61d1f012 travis ci format check hotfix (#3449)
* set error message to be conditional

#3443 fails on the git merge base for "some reason" but at least this error message should be clearer.

* fix issues created earlier in #3433

split version from actual diff
remove --color-diff argument as apparently it isn't supported
2018-11-21 21:18:01 +01:00
Zach H
af2bce7141 add token creations from graveyard/exile (#3445) 2018-11-21 03:53:35 -05:00
ebbit1q
6b6c6c71ca add ccache to docker compilation (#3446)
* add ccache to docker image

* test commit please ignore
2018-11-20 14:55:20 +01:00
ebbit1q
57f15a9e98 fix building packages on travis-docker (#3441)
* add docker compilation to travis

add new matrix entry in .travis.yml for compiling on 18.04
add Dockerfile in .ci to build ubuntu 18.04 inside docker
remove release entry for uvuntu 16.04 to not conflict
refactor .travis.yml
refactor travis-comile.sh
merge travis-dependencies.sh into the travis.yml
remove travis-dependencies.sh

* enable debugging on travis-compile.sh

* set ubuntu16 buildtype to "Debug"

set buildtype Debug for as requirement for "test"
add --debug and --release flags to travis-compile.sh

* make output prettier

edit the format warning message and clangify.sh output

* fix clangify.sh

fix --cf-version flag
fix directory argument parsing
add directory parsing details to --help
add examples to --help

* test making packages

move dockerfile for bionic to make room for possibly other files
add missing file dependency
set macos brew to use protobuf --without-python@2

* remove test

* rm old Dockerfile
2018-11-16 18:32:00 +01:00
ebbit1q
72ed98e404 add docker compilation to travis (#3433)
* add docker compilation to travis

add new matrix entry in .travis.yml for compiling on 18.04
add Dockerfile in .ci to build ubuntu 18.04 inside docker
remove release entry for uvuntu 16.04 to not conflict
refactor .travis.yml
refactor travis-comile.sh
merge travis-dependencies.sh into the travis.yml
remove travis-dependencies.sh

* enable debugging on travis-compile.sh

* set ubuntu16 buildtype to "Debug"

set buildtype Debug for as requirement for "test"
add --debug and --release flags to travis-compile.sh

* make output prettier

edit the format warning message and clangify.sh output

* fix clangify.sh

fix --cf-version flag
fix directory argument parsing
add directory parsing details to --help
add examples to --help
2018-11-16 15:44:22 +01:00
ebbit1q
f70699d3de Improve clangify.sh (#3435)
* Improve clangify.sh

Separated from #3433 merge this branch first!

* fix error codes on -n and -t

fix output on -n
format -h message

* separate color diff from diff
2018-11-13 09:21:08 +01:00
ctrlaltca
638ee1af4a This should fix appveyor compilation (#3434) 2018-11-12 18:50:38 +01:00
ebbit1q
8028bad7b1 set common protobuf files to compile with other tags in debug (#3432)
* set common protobuf files to compile with other tags in debug

force the same flags as release on debug builds
fixes #3431

* check for version first

* use Protobuf_VERSION instead of calling protoc --version

* lower verion requirement

* set tags to disable certain warnings instead of removing all
2018-11-09 11:05:11 +01:00
ebbit1q
e1e9caf0ef Load plain improvements (#3422)
* improve loading from plain text

Fixes the loadFromStream_Plain function that is used to load plain text
decklists.
The rewritten function uses more regexes and is a bit cleaner.
This fixes multiple bugs with loading the various sources of decklists.
Note that the new function still has a few issues that are shared with
the original version like creating duplicate cards.

* clang format comments

apparently clang-format even complains about the spacing in your
comments

* refactor loading_from_clipboard tests

Remove all heap allocation and use references.
Use std::pair and std::string so gtest will show the cardnames in error messages.
(note that using QPair or QString does not work with gtest)
Improve the last two testcases to include weird names; and name and
comments testing.
Remove empty header file.

* fix compatibility with more formats

skip "sideboard" line
include everything in mainboard when there are multiple empty lines
add removal of the mwdeck cardversion selector in round braces
add replacal of lowercase ae combination that should never occur
Set cardname to lowercase as apparently our checks are hardcoded to only
accept lowercase.

* remove bugged test

The current load from plain is simply broken, removed checking the
comments for correct contents.

* rework load_from_clipboard tests again

rework the test to have less code duplication
add more tests and more special cases
note that text is still all lowercase

* improve loading from plain text

Fixes the loadFromStream_Plain function that is used to load plain text
decklists.
The rewritten function uses more regexes and is a bit cleaner.
This fixes multiple bugs with loading the various sources of decklists.
Note that the new function still has a few issues that are shared with
the original version like creating duplicate cards.

* clang format comments

apparently clang-format even complains about the spacing in your
comments

* refactor loading_from_clipboard tests

Remove all heap allocation and use references.
Use std::pair and std::string so gtest will show the cardnames in error messages.
(note that using QPair or QString does not work with gtest)
Improve the last two testcases to include weird names; and name and
comments testing.
Remove empty header file.

* fix compatibility with more formats

skip "sideboard" line
include everything in mainboard when there are multiple empty lines
add removal of the mwdeck cardversion selector in round braces
add replacal of lowercase ae combination that should never occur
Set cardname to lowercase as apparently our checks are hardcoded to only
accept lowercase.

* remove bugged test

The current load from plain is simply broken, removed checking the
comments for correct contents.

* rework load_from_clipboard tests again

rework the test to have less code duplication
add more tests and more special cases
note that text is still all lowercase

* remove forcing of lowercase cardnames

Cardnames in DeckList::loadFromStream_Plain will no longer be forced
lowercase if they aren't found in the database.
Empty lines in the comments of plaintext decklists will not be skipped.
The loading_from_clipboard_test gets its functions declared in a
separate header "clipboard_testing.h".
Add more edgecase tests.
Refactor code.

* add old QHash version support

QT 5.5 does not support using initializer lists for QHash.
Implement a preprocessor version check for conditionally using inserts
instead of a const with initializer list.

* add old QHash version support

QT 5.5 does not support using initializer lists for QHash.
Implement a preprocessor version check for conditionally using [] access
instead of a const with initializer list.

* add qHash on QRegularExpression below QT 5.6

Apparently QRegularExpression can't be hashed in lower QT versions,
so we add our own hash function, and everyone lived happily ever after,
and none the wiser.

* add header guards to clipboard_testing.h
2018-11-07 06:05:25 -05:00
tooomm
8b7a287b44 clarify min req (#3426) 2018-11-07 08:32:20 +01:00
tooomm
0cd671c022 Improve hints for manage sets dialog (#3419) 2018-10-31 21:14:47 -04:00
ebbit1q
051fcff284 add more precise rules to CONTRIBUTING.md (#3423)
Add extra rules that clang-format enforces, like the order of includes and the way single line comments should be formatted.
Correct some grammar ( what is up with the translation section ordering steps out of order?? ).
This is a web edit.
2018-10-31 21:14:05 -04:00
ebbit1q
4e3d499162 improve translating section of CONTRIBUTING.md (#3424)
Remove the weird out of order numbering and replace it with just chapters for specific users.
Add a bit of explanation to adding translations as a developer.

This is just a recommendation for an improvement, jumplist could be added and/or #3423 merged with this. (it fixes the typos)
2018-10-30 17:45:04 -04:00
tooomm
7e6c4d8a6c fix appveyor dependencies (#3420)
ty @ctrlaltca
2018-10-28 13:11:51 -04:00
ebbit1q
986e405ca7 add new brace guidelines and clang-format info (#3414)
Add new brace guidelines, correct code sample.
Add detail to indentation guidelines.
Add basic clang-format information and a link to the documentation on llvm.

closes #3413 
A quick edit to the contributing guide from the web ui, hope it comes out right.
2018-10-25 09:54:17 -04:00
ebbit1q
75203cf385 add reset power and toughness option #3402 (#3412)
* add reset power and toughness function on cards

Add actResetPT to set the power and toughness in the same way as
actSetPT but instead of prompting the user it will fetch the original
pt from the card info for each card.
Add the new command to the card rmb list, keybinds and settings.

* changed style to .clang-format

Please change the contributing guidelines to use this style instead.
2018-10-20 23:33:35 -04:00
Dane Johnson
bc2cb59c50 Fix blank line between comments issue (#3407)
* Added failing test to demonstrate issue with dec loading

* Prevents empty lines between comments from being interpreted as the start of the sideboard
2018-10-08 11:26:08 -04:00
Henry Lancelle
cf9fdcd09e Translate curly apostrophe to ASCII apostrophe (#3395) (#3401)
* Translate curly apostrophe to ASCII apostrophe (#3395)

Treats the curly apostrophe as a straight apostrophe when searching in
the deck editor search bar.

* Moved logic for handeling translation to CardDatabaseDisplayModel.

This implementation was done with strings instead of characters because
the curly apostrophes and quotes are considered multi-characters.
Thus, the method of iterating through the string and replacing
the characters with the proper translations was difficult to cleanly
implement.

* clang-tidy modifications

* Implemented faster algorithm for string translation.

Optimized the algorithm for string translation, before it would compute
in O(N*M) time where N is the size of the string and M is the size of
the translation table.  Now it will compute in O(N) time where N is the
length of the string.

* Renaming variables and methods.

* Fixed character literal type, was unicode, is now wide.
2018-10-03 09:15:02 +02:00
Lee Tran
eb4b1e74f1 Disable saving of decks when the deck is empty (#3384)
* Disable saving of decks when the deck is empty

* Replace tabs with spaces to conform with coding conventions

* Remove whitespace at end of line to satisfy the CI robot overlords

* Improve logic to check if deck is empty, fix functionality when a deck is loaded

* Fix code style issues

* Disable more menus when the deck is empty

* Streamline code for disabling save menus when the deck is empty

* Fix save-disabling when loading a deck from the clipboard

* Enable saving deck directly after loading deck
2018-09-21 10:46:31 -04:00
Lee Tran
70005a6f1d Enable the creation and using of shortcuts to move cards from the top of the library to play face down. (#3388) 2018-09-07 09:14:34 +02:00
ctrlaltca
1415a4dafa Fix servatrice linking under FreeBSD - fix #3376 (#3377)
Fix servatrice linking under FreeBSD - fix #3376
2018-09-06 12:20:20 +02:00
tooomm
8b567427c2 update proto links (#3380)
repo moved, see https://github.com/protocolbuffers/protobuf/issues/4796
2018-09-01 13:27:41 -04:00
tooomm
3605a2ca0e bump min qt requirement (#3375) 2018-08-30 02:08:48 -04:00
Alessandro Marzialetti
c58abadff1 fix: cockatrice quits properly when the window is closed (#3329) 2018-08-27 15:01:53 +02:00
tooomm
135c02ea41 travis: more cleanup (#3336)
* add links to build image update history

* remove cmake from apt

* remove bc from apt

* remove clang-format from apt

* test clang-format

* Revert "test clang-format"

This reverts commit b2f12da427.

* remove protobuf from apt

* Revert "remove protobuf from apt"

This reverts commit 9162c8800c.

* remove qt from apt

* test with versions which differ from what xenial provides

* Revert "test with versions which differ from what xenial provides"

This reverts commit 6192e58169.

* Revert "remove qt from apt"

This reverts commit 0d9aff1c4c.

* conditions v1 are the default now

https://blog.travis-ci.com/2018-07-18-build-stages-officially-released

* add new job names

https://docs.travis-ci.com/user/customizing-the-build/?utm_source=blog&utm_medium=web&utm_campaign=build_stages_ga#Naming-Jobs-within-Matrices

* disable mail

* clang-format version

* remove clang source

* cmake version

* macOS: remove clang-format

formatting only checked on linux build

* add compiler info

* cmake version2

* remove fast_finish

only useful if allowed failures are configured in the matrix:
https://docs.travis-ci.com/user/customizing-the-build/#fast-finishing
2018-08-27 10:50:55 +02:00
Andrew Zwicky
ed01752cb4 [WIP] Card image loading: Fallback on 404 (#3367)
* 2479: Running clang-format

Reformatting files to be in line with style guidelines.

* 2479: Updates to remove set/url indices

This change removes set and Url indices in favor
of check for empty lists and removing items from them
instead.

* 2479: TransformUrl will now error on missing fields

If transformUrl is called with a template, and the card/set
is missing something required by that template, it will now
return an empty string, instead of the template with an empty
string substituted in.

* 2479: clang-format updates

* 2479: Fixing omission of ! from two properties

* 2479: Adding prefix on debug messages

Adding PictureLoader: to the front of each debug message
from this file, so that it can be more easily filtered out
by grep in the log of a running application.

* 2479: Remove outdated comment

* 2479: Remove unused method from intermediate work

* 2479: Updating QDebug messages to be more consistent

* 2479: clang-format updates

* 2479: Remove repeated code, replace with call to nextUrl

This removes some redundant code that is better replaced with a call
to nextUrl, in case the code needed to populate the nextUrl changes
significantly.

* 2479: Adding more detailed comments

* 2479: Refactor transformUrl

Refactor transformUrl to do everything in a single loop instead
of two almost identical loops.  set information is populated if
present, but is added with empty strings if absent.
2018-08-22 09:52:38 +02:00
Zach H
e341337ce0 Revert "[WIP] Fallback on 404" (#3364) 2018-08-11 09:06:18 -04:00
Zach H
e09ea1e683 Merge pull request #3363 from andrewzwicky/fallback_on_404 2018-08-11 09:05:21 -04:00
Andrew Zwicky
cbd430555f 2479: Working Url traversal
Url checking is now working as expected.  In set order,
starting with custom sets, then going in priority
order by url template order, Urls will checked, and the
first successful one will be used.
2018-08-09 23:50:01 -05:00
Andrew Zwicky
8239539946 2479:
Initial work on downloading cards through fallback URLs.

This change will add in the ability to proceed to the next URL
should the first one fail.  First trial shows that it's working,
but needs more refinement.
2018-08-08 22:42:22 -05:00
Andrew Zwicky
e467698d72 2497: Forgot to check in .h file 2018-08-05 17:43:28 -05:00
Andrew Zwicky
846b426a7c 2497: Start to implement fallback on card image urls
Return a list instead of a single url.  This is the start
of getting many possible urls instead of one.  Functionally
identical except that the primary url will be attempted for
cards without a muid.
2018-08-05 16:21:53 -05:00
tooomm
f1eab4e26a remove unused beta file endings (#3338) 2018-08-02 21:31:32 +02:00
David Szabo
283ce23111 Manage sets window: "Enable all/selected" button toggling never disabled (#3337)
## Related Ticket(s)
- Fixes #3314 

## Short roundup of the initial problem
When the view was sorted in the manage sets window, the "Enable/Disable All" buttons never toggled to "Enable/Disable selected" buttons, even when more sets were selected.

## What will change with this Pull Request?
- Selected sets can be enabled/disabled in sorted view as well
2018-07-25 14:39:42 +02:00
tooomm
451e1874a7 UI dialog tweaks: filter + create game(s) (#3351)
* vbox --> grid layout
2018-07-25 08:21:29 +02:00
tooomm
69c103ede3 missing features dlg: better update hint (#3352)
## Short roundup of the initial problem
People missed the hint on how to resolve missing features on their own, because update hint was hidden behind the `Show details` label.

## What will change with this Pull Request?
- Update hint is more prominently placed and not hidden behind a label
- It's translatable now
- Wording update to reflect UI change

## Screenshots
<!-- simply drag & drop image files directly into this description! -->
- before
![missing_features](https://user-images.githubusercontent.com/9874850/43153756-74cfd9f0-8f72-11e8-9e0f-fbf47b13f324.png)
- after
![missing_features_new](https://user-images.githubusercontent.com/9874850/43153761-78bec4e0-8f72-11e8-9853-ccc1ecb7f558.png)
2018-07-24 21:05:42 +02:00
tooomm
ac0f92bac6 bump to 2.6.1 (#3342) 2018-07-21 10:56:39 -04:00
Zach H
aa308717de translation pulls (#3335) 2018-07-17 20:19:40 -04:00
tooomm
2d0d29fb5c appveyor: version updates + tweaks (#3334)
* version updates

- qt to 5.11.x
- openssl to 1.0.2o
- protobuf to 3.6

* undo protobuf change

* reapply with proper semver

* only qt latest

* combined env, protobuf 3.6

* slim build matrix config down

* fix env

* test

* fix env -eq

* test if script changes work

* /2

* enable cache again

* fix

* final
2018-07-17 20:12:39 -04:00
tooomm
cba1ca8d5b remove Qt guards (#3328)
* remove version guards

* clangify

* [skip ci] README wording

* add cmake requirement to readme

* remove return

* remove min req from README
2018-07-17 20:08:42 -04:00
tooomm
c12c3c071f NSIS: Show hint when user installs 32bit Cockatrice on 64bit Windows (#3331)
* hint for 32bit

* final wording
2018-07-17 07:40:45 +02:00
tooomm
d37d73017f nsis: add sleep timer to ensure unlocking of vc_redist (#3325)
* add 3s sleep + log hint
2018-07-14 15:49:41 +02:00
tooomm
a766aa7d8a appveyor: reduce version string to basic info (#3324)
## Short roundup of the initial problem
It was mostly out of date because we have to manually update it with our current version number.
The use of that is suspect anyway, since it only displays in the appveyor build overview.
It also had a redundant info about the branch.

## What will change with this Pull Request?
- remove hard coded version number
- remove branch
- cleanup build trigger from [#3300](https://github.com/Cockatrice/Cockatrice/pull/3300/files#diff-11c909939117928998b102a1fff7d363)
- more readable style

## Screenshots
I did some tests, so don't be confused about the different styles displayed in the history:
<!-- simply drag & drop image files directly into this description! -->
![version](https://user-images.githubusercontent.com/9874850/42664150-876175ac-8639-11e8-9df5-3fdd775440ed.png)
2018-07-13 17:29:16 +02:00
ctrlaltca
b61c07a205 Check for both 32 and 64bit cockatrice when uninstalling (#3323) 2018-07-12 23:58:56 +02:00
ctrlaltca
c01aad6767 Travis: minor changes (#3321)
Use the xenial version of llvm's toolchain for clang-format
Add qt5.5's websocket library for servatrice
2018-07-11 17:43:33 +02:00
tooomm
d0d662f73a switch to xenial (#3320) 2018-07-11 14:52:19 +02:00
Zach H
3ae363cf4b force 2.6.1 (#3316) 2018-07-02 21:49:24 -04:00
tooomm
4796110afb updates (#3311) 2018-06-29 16:06:55 -04:00
ctrlaltca
dc727cb620 NSIS: misc fixes [wip] (#3300)
NSIS: misc fixes
2018-06-25 18:34:58 +02:00
David Szabo
87eb132af1 Tips close with the main window (#3305)
* tips close with main window

* null verification added
2018-06-24 19:37:30 -04:00
ctrlaltca
2354a6f89d Fix cards loading bug (#3307) 2018-06-24 17:49:26 -04:00
tooomm
1618e89c41 travis: remove unneeded debug builds on tags for faster release deployment (#3266)
* add hint

* enable condition for debug

* enable new conditions
2018-06-21 19:40:12 -04:00
ctrlaltca
e223f07462 fix #3235 (#3302) 2018-06-21 18:56:53 -04:00
ctrlaltca
f70e87c5a0 Fix #3285 (#3299) 2018-06-19 22:55:01 +02:00
ctrlaltca
0b3e86e307 Fix "reinstall" button in updater, fix #3293 (#3297) 2018-06-19 19:57:44 +02:00
ctrlaltca
a5ea4f7da2 Add ability to edit chat macros, Fix #3296 (#3298) 2018-06-19 19:15:13 +02:00
tooomm
4e75a74bfd readme: fix linebreaks (#3292)
## Short roundup of the initial problem
Everything was mixed in one single line.

## What will change with this Pull Request?
- introduce line brakes to keep the wanted look

## Screenshots
<!-- simply drag & drop image files directly into this description! -->
before: https://github.com/Cockatrice/Cockatrice/tree/2018-06-17-Release-2.6.0#run
after: https://github.com/Cockatrice/Cockatrice/tree/tooomm-patch-2#run

---

Should the `webatrice` webclient be listed there as well?
2018-06-18 07:58:04 -04:00
Zach H
c7072cd543 translations push (#3291) 2018-06-17 18:23:05 -04:00
Zach H
5e0bfc3193 translations (#3290) 2018-06-17 18:13:02 -04:00
tooomm
b316a5d541 new icons (#3289) 2018-06-17 18:09:58 -04:00
Zach H
e147bd6cea add feature list requirement (#3287)
* add feature list requirement

* version update

* version bump
2018-06-17 18:06:12 -04:00
David Szabo
d36f86c523 Duplicate cards & empty setlist (#3283)
* Card duplicates handled

* clangify

* kinda works, some cards are still duplicated

* separate card entries grouped together

* clangify
2018-06-16 22:42:22 -04:00
David Szabo
81803e2612 Search in "Manage sets" window (#3229)
* search field added; sortfilterproxy displayed in treeview

* searching works properly

* moving with filter on works; view isnt't updated yet

* clangify & view updating figured out

* moving disabled when sorting is active

* drag&drop disabled when view sorted

* clangified

* foreach replaced

* button rename & SORT_RESET defined

* changed variable names

* 'x' button added & searchlabel text modified

* 'enabled' column won't grow anymore

* column resize improvement

* button hint & restore original order added

* moving with filter on works; view isnt't updated yet

* sort disable build in column headers (3 clicks)

* codacy fix

* typo + wording

* background color for warning

* buttons moved down a bit

* clicking "default order" button will hide the warning text
2018-06-10 11:00:42 -04:00
Bers
91b3c7343d fixed 2 warning-errors on archlinux(gcc 8.1): implicit fallthrough, ignored qualifiers (#3270) 2018-06-09 10:28:17 +02:00
ctrlaltca
1276c8dd46 Add -DWARNING_AS_ERROR=1 option to cmake script (#3275) 2018-06-06 08:43:04 +02:00
ctrlaltca
89ab7f1f67 Fix #3252 (#3269) 2018-06-02 02:41:10 -04:00
tooomm
664d717e17 skip branches with open pull requests (#3265)
See https://www.appveyor.com/docs/appveyor-yml/
2018-05-28 19:29:19 -04:00
tooomm
494dfc2f4b actCancel remove (#3261) 2018-05-25 21:59:52 -04:00
tooomm
3a05d063af connect dialog: button reworks (#3243) 2018-05-25 21:59:42 -04:00
ctrlaltca
f97959febc fix #3257 (#3258) 2018-05-24 15:46:02 +02:00
David Szabo
b3df71ae41 0 values in power/toughness filters won't match non-zero values anymore (#3250)
## Related Ticket(s)
- Fixes #3212 

## What will change with this Pull Request?
- `0` input on power/toughness filters will only return `0` values
- `relationCheck` method will only get called after simple string comparison failed
- due to their similar structure `acceptPower` and `acceptToughness` methods has been merged
2018-05-24 00:18:53 +02:00
tooomm
ec4a99e47b remove empty languages (#3253)
## What will change with this Pull Request?
- cleanup of empty and unused languages files (catalan, lithuanian, hebrew, ukrainian)
- reflect language removing on transifex
2018-05-23 10:32:41 +02:00
skwerlman
ad66a48b8e ensure column ordering is consistent (#3249) 2018-05-18 18:07:39 -04:00
David Szabo
7a2558d834 vs version number increased for appveyor build (#3251) 2018-05-18 18:06:33 -04:00
Bers
3b3f5a639c Hide non-existent card values in infowidget and cardframe (#3239) 2018-05-15 01:53:53 -04:00
tooomm
9acf606e93 settings dialog: fewer space (#3245) 2018-05-15 01:53:01 -04:00
ctrlaltca
4cdd17945d Servatrice: make listening host configurable; fix #3241 (#3242)
* fix #3241

* clangify
2018-05-12 23:54:03 +02:00
ctrlaltca
c06fc562a1 Cmake scripts refactoring; fix #3225 (#3230)
* fix #3225

* Servatrice: use websockets as an optional component (for qt < 5.3)

* Attempt++
2018-05-12 23:28:22 +02:00
tooomm
73fb9ee03e update file rules (#3232) 2018-05-10 22:07:22 +02:00
tooomm
4e10ce7473 smaller clear pic button (#3220) 2018-05-04 03:48:53 -04:00
ctrlaltca
a7f4aace9c Extract the xml parser from carddatabase (#3223) 2018-05-04 03:46:08 -04:00
David Szabo
9727699e26 braces are only left for split cards (#3217)
* braces are only left for split cards

* condition for braces modified
2018-05-02 21:20:58 -04:00
Zach H
2520d07ef2 log moderation stats in the uptime table (#3215) 2018-05-02 17:31:54 -04:00
tooomm
661e00f563 log cleanup (#3207) 2018-05-02 16:07:43 -04:00
ctrlaltca
2780270911 macOS: fix qt plugin installation (#3216)
* Osx: fix qt plugin installation

* Add make install step to travis debug build

* only install under osx

* Add "styles" plugins (for native look'n'feel)

* Osx: upgrade qt from 5.5 to current (5.10.1)

* Fix osx on travis

The qt homebrew formula now installs three qt* symlinks (qt, qt5, qt5@5.x) so we can't use/don't need bash globbing anymore
2018-05-02 15:57:35 -04:00
tooomm
8a5baa4637 connect dialog tweaks (#3211) 2018-04-23 14:30:46 -04:00
tooomm
f5eb05b682 bump version number (#3205)
* bump version number

* bump
2018-04-18 19:50:26 -04:00
tooomm
f309ddf28a README updates (#3203) 2018-04-16 20:08:26 -04:00
David Szabo
67a2a8cf08 datetime display fixed for OSs with non-English localization (#3204) 2018-04-16 20:07:30 -04:00
Zach H
1fbdea0f35 translation updates (#3200) 2018-04-16 02:42:58 -04:00
David Szabo
cc2a0fa0d0 server site added to connect window (#3190) 2018-04-10 19:05:13 -04:00
tooomm
034e79dd36 typo (#3187) 2018-04-10 12:51:57 -04:00
tooomm
5c03f18c72 add hint about how to contact server admins (#3186) 2018-04-10 12:40:24 -04:00
Zach H
61e509585f Server List from JSON (#3165) 2018-04-09 22:38:21 -04:00
tooomm
0c10b66a2d prettify spoiler settings (#3180) 2018-04-09 17:15:37 -04:00
tooomm
7758145e71 comment explanation out (#3181) 2018-04-09 16:47:44 -04:00
ctrlaltca
37ab7b8fb1 Add a note about bug #3135 (#3184) 2018-04-09 16:47:08 -04:00
tooomm
42d15c39a0 change vcredist install option from "/quiet" to "/passive" (#3175) 2018-04-07 12:32:20 -04:00
tooomm
a0d84114de fix space (#3172) 2018-04-06 15:01:04 -04:00
tooomm
706054ea96 readme: link update (#3173) 2018-04-06 15:00:46 -04:00
tooomm
7d5a33b12c bump version number (#3174) 2018-04-06 15:00:32 -04:00
tooomm
a056a882c3 flip rename (client side) (#3149) 2018-04-05 22:42:54 -04:00
tooomm
f89f6438c9 Update ISSUE_TEMPLATE.md (#3171) 2018-04-05 22:42:36 -04:00
tooomm
e25b7e9eb8 button label wording (#3168) 2018-04-04 04:45:28 -04:00
Zach H
ca2e05952e add rooster ranges, remove woogerworks (#3163) 2018-04-03 18:41:10 -04:00
David Szabo
2fcb02cadd untranslated string comparison fixed (#3164) 2018-04-02 23:04:52 -04:00
David Szabo
e1394bd851 Feature/3139 new features for tips (#3152)
* "Tip of the Day" option added to Help menu

* Tip of the Day setting moved

* If no new tips are availabe, don't show tip of the day again

* list storing try #1

* first unseen tip shown first

* lastShownTip removed

* fixed next/previous buttons

* spaces > tab

* "Show this window on startup" is not checked by default
2018-04-01 04:52:26 -04:00
ctrlaltca
6374d157fc Fix Appveyor builds (#3151)
* fix appveyor builds
2018-03-24 16:05:08 +01:00
tooomm
5df547ee53 update template (#3150) 2018-03-23 23:37:11 -04:00
David Szabo
2a9d76f090 Colors on split cards sorted in WUBRG order (#3128) 2018-03-07 20:26:47 -05:00
Zach H
5859fa2f20 translation updates (#3124) 2018-03-02 16:50:10 -05:00
David Szabo
312caae062 Tip of the Day (#3118)
* Basic tip of the day with sample widget added

* "Show tips on startup" option added to settings

* tip cycling implemented

* Structure of the tipOfTheDay class and resource created

* tip getter function modified

* Resources added, feature works properly

* clangified

* accidental modification rolled back

* zach cleanup

* tips to spaces; cmake list combined

* cleanup img

* fix copy

* remove TOTD as QObject so we can copy construct it

* prevent mem leaks in dlg

* changed order of 'next' and 'previous' buttons

* Date and tip numbers added; content wraps around

* useless sizepolicy removed

* link support added & clangified

* Initial tips & memory management updates
2018-03-02 03:11:18 -05:00
David Szabo
281e52eaa9 power and toughness values displayed after card flip (#3120) 2018-03-01 12:28:30 -05:00
Zach H
66958b5975 clangify only the different files (#3122) 2018-02-28 13:20:53 -05:00
David Szabo
941a06e107 Custom image file path corrected (#3119) 2018-02-25 23:22:41 -05:00
David Szabo
7cfbf114b7 "Show related card" option added to ingame context menu (#3115) 2018-02-19 01:12:25 -05:00
David Szabo
2409eae940 left, right, and S shortcuts modified to use shift (#3116) 2018-02-19 00:38:51 -05:00
Vafthrudnir
3d2c7b6670 Right-click menu added for card database view (#3113) 2018-02-15 03:25:44 -05:00
Vafthrudnir
65ef66cfa7 Braces left in for split mana costs in xml (#3108) 2018-02-13 22:37:24 -05:00
Zach H
019295931a Merge pull request #3109 from Vafthrudnir/hotfix/oracle_button_text_correction 2018-02-13 20:50:30 -05:00
Vafthrudnir
c8a10a9997 Mnemonic created 2018-02-14 02:40:46 +01:00
Vafthrudnir
4e8a09517c Button text changed to "Save" from "Next" 2018-02-14 02:36:54 +01:00
Vafthrudnir
f302154df7 Hotfix/2950 delete filters with keyboard (#3097)
* Shortcut setting checks for invalid keys

* Different message shown for invalid keys and used keys; warning message is displayed on start if conflic is detected

* Only shortcuts related to deck-builder are checked
2018-02-13 02:51:14 -05:00
Vafthrudnir
11ad677fe8 Sending card name to chat on shift+click (#3106) 2018-02-13 02:50:37 -05:00
Vafthrudnir
8084ab605f Tablerow fixed for non-mana generating artifacts (#3104) 2018-02-12 18:04:11 -05:00
Vafthrudnir
af5a04abf1 "Comment" field made resizable in deck builder window (#3105)
* solution with splitter

* Made prettier

* Useless parameter removed

* clangified

* c++11 cleanup
2018-02-11 13:49:58 -05:00
Vafthrudnir
3426a6b201 'Rarity' property added to split cards in xml (#3102) 2018-02-09 23:45:59 +01:00
Vafthrudnir
51eeac0541 Mana cost filtering for split cards (#3098) 2018-02-08 14:15:42 -05:00
Nick Beeuwsaert
2206328406 Add custom QStyle class to tab bar to fix render issue on macOS. (#3095)
* Add custom QStyle class to tab bar to fix render issue on macOS. fixes #3070

* clangify
2018-02-08 15:39:29 +01:00
Vafthrudnir
501e82f712 Split card handling added to cmc filter (#3090) 2018-02-07 11:37:10 -05:00
tooomm
ab3989aeba Consistent use of 'beta' tag across the project (#3089) 2018-02-07 11:33:14 -05:00
Vafthrudnir
a0d6a342d3 Loyalty filter added (#3087) 2018-02-07 11:33:01 -05:00
Zach H
35159ef61a Clang script (#3085) 2018-02-06 08:45:13 -05:00
Zach H
fcfb2b12b7 remove extra copies (#3081) 2018-02-06 05:06:51 -05:00
Vafthrudnir
4cbec71882 Relation checks added to relevant fields in card filter (#3080)
* comments and <=, >=, == support added
2018-02-06 05:05:30 -05:00
Zach H
b58aa459a4 change file names to end with win32/64 instead of x86/x86_64 (#3079) 2018-02-05 23:39:55 +01:00
Zach H
8a8b580501 translations (#3078) 2018-02-05 12:22:49 -05:00
Zach H
c9525af624 this is backwards (#3077) 2018-02-05 11:39:10 -05:00
tooomm
aba47719b2 properly display logical connectors (#3072)
they should not get transalted as well
2018-02-04 13:47:12 -05:00
Vafthrudnir
b6b4d7e4a0 Automatic focus change after filter selection (#3074) 2018-02-04 13:46:35 -05:00
Vafthrudnir
63d0f5af43 Start in maximized window on first start (#3075) 2018-02-04 13:07:37 -05:00
ctrlaltca
517420cccb Replace CardInfo* and Carset* with smart pointers (#3053)
* Replace CardInfo* and Carset* with smart pointers

* fixes to help memory & c++11 stuff
2018-02-02 12:52:47 -05:00
tooomm
3e418ba3c6 travis: temporary downgrade mac builds to qt5.5 (#3066)
`qt@5.7` is no longer available: https://github.com/Homebrew/homebrew-core/pull/23165#issuecomment-362270835
2018-02-01 19:09:46 +01:00
dino572
c1bd50f186 Fix mwDeck edition tag parsing on deck load (#3057)
* Update decklist.cpp

Changed parsing code, line 565 and 567
2018-01-31 23:29:18 +01:00
tooomm
d13cf65a10 contributing: add toc + little tweaks (#3030) 2018-01-27 13:45:27 -05:00
ctrlaltca
994a643d9c Travis: enable ccache usage under macOS; halves compilation time (#3052) 2018-01-27 13:43:48 -05:00
ctrlaltca
e127cb74b6 Fixed most issues from codacy (#3050) 2018-01-27 13:31:44 -05:00
Dave
3c3e6ae68a Domain change (#3051)
.es es no mas

Server and database from .es is now active on cockatrice.dr4ft.com
2018-01-27 17:30:40 +01:00
ctrlaltca
b29bd9e070 Clang-format (#3028)
* 1/3 Add .clang-format file and travis compilation check

* 2/3 Run clang-format

* 3/3 Fix compilation problems due to include reordering

* 3bis/3 AfterControlStatement: false
2018-01-27 10:41:32 +01:00
tooomm
8dbdd24c8e fix cmake 3.10 (#3048) 2018-01-25 20:39:10 +01:00
tooomm
04ab3d7f13 fix release run on tags (#3046) 2018-01-23 12:58:56 -05:00
tooomm
03d0a84ef5 "edit sets" --> "manage sets" rename (#3044) 2018-01-22 12:42:10 -05:00
tooomm
14a0c53fc1 travis update (osx + linux) (#3041) 2018-01-21 17:07:25 -05:00
woogerboy21
da7c7c1f83 Update Servatrice MySQL Search Path (#3039)
Removed the older versions of the mysql library install paths and updated to reflect the 5.7 product paths.
2018-01-21 11:05:13 -05:00
Zach H
261d3ac591 better null check (#3036) 2018-01-20 14:54:34 -05:00
ctrlaltca
55029b6b68 Travis: remove sudo (#3037) 2018-01-20 16:50:06 +01:00
Zach H
bc52882ac4 Fix Bad Gameplay (#3034) 2018-01-19 20:34:14 -05:00
Zach H
d1b95aad16 move to slot (#3032) 2018-01-19 19:04:48 -05:00
Zach H
691bf36fbe Disable sideboard button w/o deck (#3025) 2018-01-19 10:50:18 -05:00
Zach H
5a823becf1 Contributing Doc Updates (#3009) 2018-01-19 08:38:37 -05:00
Zach H
feeaba1d62 2.4.1 beta -> 2.5.0 beta (#3024)
Big changes so we will go to 2.5.0 for next release
2018-01-18 19:28:51 -05:00
Zach H
ebec30dd1c Add No annotations export option w/ shortcut (#3013) 2018-01-18 19:25:30 -05:00
Zach H
5757d60b1d Smarter Mana Cost sorting & small cleanup (#3008) 2018-01-18 19:25:10 -05:00
skwerlman
81fcc3c11a remove builds for 1610 and 1704 (#3023)
ubuntu turned off the repo servers :(
2018-01-18 19:24:43 -05:00
Zach H
34bec90193 Fix deck loader with spaces (#3007) 2018-01-18 19:23:13 -05:00
Zach H
dcc632e0d4 Fix a crash (#3011) 2018-01-18 11:53:57 -05:00
Zach H
7a150c558d Trim all inputs (except password) (#3018)
* Trim all inputs (except password)

* missed )
2018-01-17 18:57:13 +01:00
ctrlaltca
3a11aebb21 windows/appveyor compilation updates (#3020) 2018-01-17 18:20:05 +01:00
Zach H
8825e2932a fix linux crash (#3014) 2018-01-13 04:20:12 -05:00
ctrlaltca
cd558a9722 Even out db collation to utfmb4_unicode_ci; fix #2835 ; fix #2218 (#2915) 2018-01-13 04:02:22 -05:00
tooomm
cc822dd8df card filter: add clear button and placeholder text (#3003) 2018-01-11 16:43:08 -05:00
Kyle Grammer
6fc1aaef90 Add comp architecture (#2968) 2018-01-10 22:19:07 -05:00
tooomm
c8122c94ef adjust custom naming, clickable commit hash in brackets (#2981) 2018-01-10 13:38:51 -05:00
tooomm
e6e6932dbb card filter: alphabetical ordering for keywords (#2987) 2018-01-10 13:37:39 -05:00
tooomm
d124e6ac22 deck editor: add placeholder text to search (#3000) 2018-01-10 13:33:37 -05:00
tooomm
7efab80d9b token creation context menu improvements (#2999) 2018-01-10 13:32:29 -05:00
Zach H
d19744236e Automatic Spoiler Season (#2991)
* oracle now can be run in spoiler or normal mode

* tests for travis

* only run on relaunch

* spoilers in client (not oracle now) and tray icon shows when done

* spoiler status will be checked before downloading spoiler file

* only download if they care about spoilers

* reload db on spoiler download

* manual update button, code cleanup, and fix enabling sets when new

* cleanup, nullchecks, and fixes to spoiler

* reload DB even if not in spoiler season; necessary as we have a check elsewhere to prevent the reload if spoiler check happens

* Implement changes from 2991#issuecomment-356169374

* Change implicit nullptrs, alert on file deletion, minor changes

* make reload thread safe and minor changes from 2991#issuecomment-356450302

* Fix locking

* Disable update now button while process running
2018-01-10 13:27:43 -05:00
tooomm
51ec593759 fix space (#2990) 2018-01-02 22:57:23 -05:00
Zach H
87c978937d replace beta semvar correctly (#2980) 2017-12-28 21:30:17 -05:00
tooomm
dfaa85847c add tag (#2979) 2017-12-28 20:02:30 -05:00
tooomm
74dbf75c5b fix var call (#2978) 2017-12-28 19:21:42 -05:00
tooomm
f0f73c8f77 ci: deployment config for beta+stable (#2976) 2017-12-28 18:33:16 -05:00
ctrlaltca
3af2be4539 removed win xp support; update qt to 5.9 for win 32bit (#2975) 2017-12-19 09:09:20 +01:00
tooomm
5b8e0dc8ec add group key (#2967)
as announced here: https://blog.travis-ci.com/2017-12-01-new-update-schedule-for-linux-build-images
2017-12-18 18:17:31 -05:00
Zach H
b75882b6b9 Allow non-db cards to be moved around (#2960) 2017-12-18 14:17:54 -05:00
Zach H
2abfd3b4a9 Update Rarity Filters & Refactoring (#2962) 2017-12-17 19:42:54 -05:00
Zach H
014b9947fe clear search bar if all filters cleared (#2961) 2017-12-17 17:48:57 -05:00
Zach H
ec4e6d53df allow backspace button to remove a filter (#2959) 2017-12-17 17:39:41 -05:00
Zach H
0eae4dbe54 add checkbox option to clear log (#2963) 2017-12-17 17:32:31 -05:00
Zach H
297f1f2555 remove untap option, combine w/ tap (#2964) 2017-12-17 17:31:31 -05:00
tooomm
7e80f4b4ae oracle: fix wording for token download (#2946) 2017-12-15 15:42:30 -05:00
Kyle Grammer
6e24f59826 Fixing split card from UNH with wrong name in database (fix #2947) (#2949) 2017-12-15 15:37:32 -05:00
Kyle Grammer
5e00faed5d Fix for Aftermath and Split Cards when sending to Tappedout; fix #2942 (#2944) 2017-12-10 17:56:49 -05:00
John Robe
6c038a91e4 Deck export (#2938)
* Added “export deck” option to export deck to decklist.org for viewing/printing. Implemented using a new menu item, added shortcut ability, and functionality to parse the deck correctly and add main/sideboard cards to decklist. Per issue #2931
2017-12-05 22:34:19 -05:00
tooomm
4d641eb0e7 version number bump to next patch (#2920) 2017-11-19 20:22:12 -05:00
tooomm
59824cf4dd update finish (#2923) 2017-11-19 20:22:02 -05:00
tooomm
b615b5b33e Translation Updates (#2918) 2017-11-19 15:11:37 -05:00
tooomm
3dc2526f0a update download wording (#2912) 2017-11-04 20:17:18 -04:00
tooomm
6bc39a4f6f yml config documentation (#2899)
* little fix

* add config hints

* doc link
2017-11-04 20:16:41 -04:00
John Hill
422c899cdb Sorting by P/T numerically (#2901) 2017-11-04 13:11:46 -04:00
Gavin Bisesi
e96a250bf1 Fix easy changes link in readme (#2897)
Using these two labels because github tells contributors to look for them.
2017-11-02 15:17:29 +01:00
TaylorShiells
563e96e051 Update Readme.md (Style Guide) / FMRM feedback (#2905)
This change establishes the Google Developer Documentation Style Guide as the official style guide for the ReadMe. This will provide a starting point for editors or writers looking to work on documentation. This edit also does an initial patch on the readme based on that style guide
2017-11-01 13:08:17 -04:00
ctrlaltca
4baaf978f5 Deck editor: force default file extension on file save; fix #2829 (#2910) 2017-10-31 15:34:56 -04:00
ctrlaltca
6b6ba9a8f1 Update translations (#2890)
* Translations

* update and test codacy change
2017-10-09 19:16:23 +02:00
tooomm
fcb0daf80f more ignore for appveyor (#2892)
* add dockerfile and license to ignorelist

* fixed space
2017-10-09 19:15:36 +02:00
tooomm
a3ca459526 exclude translation files from codacy (#2891)
* exclude translation files from codacy

* update appveyor ignore config

add codacy.yml
2017-10-09 16:40:05 +02:00
tooomm
17202e8dba AppVeyor: prevent unnecessary builds (#2888)
* prevent unnecessarybuilds

* readd qt5 string

sadly this is needed as of now:
ff6b0f86ec/cockatrice/src/releasechannel.cpp (L59-L68)

* wrap asterisks

* fixed with validator

https://ci.appveyor.com/tools/validate-yaml

* complete link

* add helpful links

this should not trigger a appveyor build

* add space in readme

this should not trigger a appveyor build

* highlight c++ types

this should not trigger a appveyor build

* remove empty line

this should not trigger a appveyor build

* declutter dockerignore

this should not trigger a appveyor build
2017-10-09 11:19:56 +02:00
ctrlaltca
ff6b0f86ec Appveyor updates (#2885)
* Appveyor updates

Remove unused stuff (mysql, choco)
Use MSVC 2015
Upgrade Qt to 5.9, protobuf to 3.4.1

* stick qith qt 5.6 for winxp 32bit compatibility; zlib test

* Appveyor is using a randmon clone path for pulls, get it from an env variable
2017-10-05 08:38:09 +02:00
Zach H
96b30da492 fix deckstats.net regex (#2886) 2017-10-04 23:36:42 -04:00
tooomm
9cbdc4195e change to https (#2863) 2017-10-04 12:46:43 -04:00
tooomm
ada262b826 betaXYZ to betaX (#2882) 2017-10-04 12:45:28 -04:00
Alessandro Marzialetti
78e299fdfd Fixed life points not showing (#2868) (#2881) 2017-10-04 12:44:36 -04:00
skwerlman
cf5cd21c50 Update .gitlab-ci.yml (#2876)
Remove support for Fedora 22 (been EOL for a while)
Add support for Ubuntu 17.04 and 17.10

Note that debug builds for 17.04 and 17.10 are still affected by issue #2343, and so always fail.
2017-10-03 15:28:47 +02:00
woogerboy21
b684c12964 Correct VS2017 Compile Issue (#2878)
A line in the servatrice CMAKE file was removed in a prior commit causing a compile error in newer versions of visual studio.  This returns the line.
2017-10-03 09:23:33 -04:00
tooomm
df8c38b649 add link to project roadmap (#2872) 2017-10-01 00:23:06 -04:00
tooomm
1424de2c54 remove old TODO file (#2870) 2017-09-29 20:51:41 -04:00
ctrlaltca
7875407795 servatrice: case-insensitve check for email and token challenge; fix #2857 (#2860) 2017-09-28 15:34:35 -04:00
tooomm
ef89104503 add colourless keyword to deck filter (#2858)
extends #2737 for missing term (add colourless)
2017-09-27 14:03:58 +02:00
ctrlaltca
ccee0aa3fd Cmake: remove old unneeded POLICIES (fix Appveyor) (#2859) 2017-09-22 17:47:05 +02:00
John Hill
a6d3229e74 If playing online, don't change your life/mana counters if you click on your opponent's (#2839) 2017-08-19 00:43:18 -06:00
tooomm
93d8ac10ff Fix broken README links after #2826
copying --> license
2017-08-14 08:25:20 -04:00
tooomm
04d84f9d9a repo cleanup (#2826) 2017-08-11 21:42:45 -04:00
tooomm
2557a2183d .travis folder (#2805) 2017-08-06 23:56:31 -04:00
John Hill
e694cbe854 add ability to clone from stack (#2824) 2017-08-06 23:56:17 -04:00
John Hill
3963570838 Mana counter shortcut (#2821) 2017-08-06 21:09:25 -04:00
John Hill
dd05b86bc9 initial way of getting rid of warning (#2817) 2017-08-06 21:04:03 -04:00
tooomm
af3423e67d split up string and argument (#2822) 2017-08-06 20:51:54 -04:00
John Hill
7c8daf68ea Add version label to Oracle Importer (#2818) 2017-08-06 14:03:19 -04:00
John Hill
6b1ea9186a Double click token (#2815) 2017-07-31 22:50:32 -04:00
tooomm
e90c389212 remove mention-bot config file (#2814) 2017-07-31 18:08:25 -04:00
John Hill
556d19ff70 Clone in exile and graveyard (#2813) 2017-07-31 00:34:24 -04:00
Lee Matos
838ab888db clarify docker build happens inside of the repo folder (#2807)
I intuited that this was the case, but being more explicit might help other docker newbies to understand what's happening.
2017-07-15 13:51:02 -04:00
tooomm
1cb3d88e35 flag updates (#2804) 2017-07-14 21:30:27 -04:00
ctrlaltca
1366e5970e Portable mode for windows (#2794)
* Portable mode for windows

* fix start menu in portable mode

* Make gcc an happy puppy

* Clean old installation if we are installing over an old portable mode installation

* Default to Desktop\CockatricePortable

* Settings dialog fixes

* wording
2017-07-08 11:22:29 +02:00
tooomm
1565309146 enable caching for ci (#2799)
* enable cache

* caching on mac

* fix ci caching on mac

* fix

* add mac cache

* added homebrew cache and pretty print yaml (+ structural ordering)

* cleanup

* fix ccache on mac

* testing workaround

https://github.com/travis-ci/travis-ci/issues/7456#issuecomment-296505058

* try xcode7.3 instead of workaround

* cache timout value

more time for cache to upload
2017-07-07 16:17:18 +02:00
Psithief
b05ed0376a Fixes #2712 (#2797)
When checking unknown sets, consider sets with an empty long name, 
set type and release date as 'incomplete'/'partial' sets.
Do not mark partial sets as known, or ask the user to enable them.
Instead, silently enable partial sets.
When a partial set becomes complete, the user is prompted to enable the
set as before. If they choose not to enable, those partial sets are 
disabled, as we can no longer assume they are disabled by default.
2017-07-07 00:45:46 -04:00
Psithief
61893faf3b Slightly more accurate XSD. (#2787)
XML 1.0 does not provide a method that allows elements with minimum
occurances and variable occurances in any order, so we are stuck
with xs:sequence.
2017-06-29 20:52:44 -04:00
Zach H
e8dbdc3c6d Add token creation for opponent board items (#2744) 2017-06-28 23:09:10 -04:00
tritoch
5abfda49be Import spoiler.xml as spoiler.xml and overwrite existing (#2784) 2017-06-28 22:54:09 -04:00
tritoch
bcda502b46 Loyalty now string, xsd fix (#2785)
Card with `X` loyalty was printed, loyalty now string
2017-06-28 21:42:08 -04:00
Psithief
03bb02f75b Improved XSD (#2781) 2017-06-26 14:42:13 -04:00
Psithief
bfcc48f5bf Check for .xlhq (CCGHQ naming scheme) files (#2778) 2017-06-22 22:59:33 -04:00
Psithief
ae15f5df06 Handling of tokens/related cards improved. (#2773) 2017-06-20 18:35:06 -04:00
tooomm
029a4a39ad readme: https link + layout tweak (#2768) 2017-06-13 15:34:50 +02:00
Zach H
9ddb18a35e Make deck list appear if deck loaded (#2745) 2017-06-12 12:25:52 +02:00
woogerboy21
2094910b7a More descriptive reason for "to many requests" when registering (#2760)
* More descriptive reason for "to many requests" when registering

Currently the only way for a user to get a response of "to many registration attempts"  is by the servers configuration to restrict the number of registration attempts but the error message presented to the user is very vague as to why they have been denied.  This PR updates the reasoning.  I'm open for suggestions on any clarity recommendations.

* Added more clarity

Updated error message to include email address information for even greater clarity.
2017-06-12 12:12:36 +02:00
tooomm
b36c349f9b remove unused define (#2757) 2017-06-11 00:42:09 -04:00
Zach H
99e7458f9b make not set to untap normally more distinct (#2746) 2017-06-04 14:02:35 -04:00
Zach H
0a57229886 keep client version persistant (#2750) 2017-06-04 13:59:37 -04:00
Zach H
f3f83882e0 Model col widths off deck editor & disable button if no tokens in deck (#2751) 2017-06-04 13:58:34 -04:00
Zach H
d970b9e50f fix card not showing correctly in games (#2752) 2017-06-04 13:57:47 -04:00
Zach H
b0d8a31a2e remove invalid connect (#2753) 2017-06-04 13:57:21 -04:00
ctrlaltca
03a7a9fafb Webclient: fix some bugs (#2742)
* Handle room join and leave events + case sensitive userlist sort; fix #2307

* Webclient: add autoscroll, but only if already at the bottom; fix #2306
2017-05-31 23:04:59 -04:00
tooomm
4c953acebc exchange dl stat page (#2743) 2017-05-30 08:32:58 +02:00
tritoch
c5ac61c797 Colorless for color filter (#2737)
* Colorless for color filter

Add 'colorless' as an option for color filter in deck editor / card list.

* Remove empty quote check

Empty quote does not work here. Add 'none' as optional string instead.

* Add C to colorless filters
2017-05-30 08:19:11 +02:00
ctrlaltca
f75caa7245 Webclient overhaul (#2735)
Migrate from protobuf.js 5.x to 6.x (remove long.js and bytebuffer.js)
Upgrade jQuery from 1.x to 3.x
Upgrade jQueryUI to 1.12.x
Use minimized version of js libraries
Disable debug messages
Fix default value for Event_RoomSay’s RoomMessageType field
2017-05-29 14:12:36 +02:00
tooomm
87060dc5c7 created_at to published_at (#2723) 2017-05-22 16:00:38 +02:00
backendr
62681f7f8d contect menu fix (#2719) 2017-05-18 17:03:21 -04:00
Zach H
b53cd33eed Smarter Clipboard Pasting/Parsing (#2706) 2017-05-14 14:35:40 -04:00
backendr
405a719412 Better scrolling in reveal zones (#2716) 2017-05-14 19:01:50 +02:00
Zach H
aca6917d42 Merge pull request #2672 from Cockatrice/tooomm-update_msg_rework
update msg rework
2017-05-13 16:06:53 -04:00
tooomm
73e2c3d32f Publish --> Release 2017-05-13 14:49:35 +02:00
tooomm
7f273b547b add missing tr() 2017-05-13 13:24:04 +02:00
backendr
77e0cddbae counter context sensative (#2714) 2017-05-13 11:48:26 +02:00
backendr
d9230d6c6b Message Log Widget changes (#2709)
* Message Log Widget changes

* Gravard now logs as before

* removed redundant QString()
2017-05-13 11:47:43 +02:00
Zach H
f00bcc9179 Merge pull request #2691 from Cockatrice/tooomm-dl_badges
github dl badges in README
2017-05-10 14:23:33 -04:00
skwerlman
b47e262e7f limit gitlab builds to master (#2711) 2017-05-10 08:53:11 +02:00
woogerboy21
1811bad835 Fix room chat history (#2698)
Looks like an addition to the table shifted things.  We probably  should look into some how use the actual column names (if it can be done).  But for now this should fix the server room chat history.
2017-05-09 23:22:48 -04:00
tooomm
41ebf7a9ad space 2017-05-09 12:47:19 +02:00
tooomm
7f01f921f7 added dl count for latest release 2017-05-09 12:46:41 +02:00
Zach H
d347e54526 Merge pull request #2688 from backendr/ignore_first_server_message
Prevent emitting initial server message event
2017-05-08 19:46:17 -04:00
tooomm
256e40a9ee Merge branch 'master' into tooomm-dl_badges 2017-05-08 10:05:24 +02:00
Zach H
5f4490ec4e Merge pull request #2695 from Cockatrice/tooomm-hq_badges
updated badges (gitter+licence)
2017-05-07 18:54:45 -04:00
tooomm
2fb2481211 updated badges 2017-05-07 12:45:53 +02:00
tooomm
d585b9f1d6 http --> https 2017-05-06 21:47:22 +02:00
Zach H
c745f41cb9 Merge pull request #2692 from Cockatrice/tooomm-cmake_2.3.18
cmake - bump version number
2017-05-06 12:54:50 -04:00
tooomm
5b07f6d6d8 bump version number 2017-05-06 18:21:31 +02:00
tooomm
39779be7bb add alltime dl count 2017-05-06 16:03:27 +02:00
tooomm
70f1c97a27 github dl badges 2017-05-06 15:46:11 +02:00
Zach H
a49373eded Merge pull request #2686 from backendr/log_changes
Log Colors
2017-05-05 21:48:02 -04:00
backendr
55dcf4a845 Log refresh 2017-05-06 00:40:41 +02:00
backendr
b140721d50 Add flag for checking inital server message 2017-05-06 00:18:49 +02:00
Zach H
c96f234b6d Merge pull request #2683 from ctrlaltca/fix_2682
Remove unneeded debug
2017-05-05 13:42:02 -04:00
Fabio Bas
a4e78bbfa2 remove debug 2017-05-05 15:23:59 +02:00
Zach H
fd3d62284d Merge pull request #2670 from ctrlaltca/load_tokens
Improved token loading, removed card price code
2017-05-05 00:24:48 -04:00
Zach H
16bc8b764b remove all of pricing 2017-05-04 23:29:43 -04:00
Fabio Bas
36f6907fa3 Improved token loading 2017-05-04 23:28:51 -04:00
tooomm
339945e089 fix custom build + displaying name (#2668)
* fix custom build name

* remove html and argument from tr()
2017-04-30 16:20:29 +02:00
tooomm
faeb3f8daf fix 2017-04-30 15:17:03 +02:00
tooomm
e04010f00b further tweaks and uniform style 2017-04-30 15:06:32 +02:00
tooomm
cbd9d2c4fc better wording (#2674) 2017-04-29 22:15:43 -04:00
tooomm
fdc82708c6 extend updater description in menu (#2673) 2017-04-29 20:13:33 -04:00
tooomm
8f7691b47a next round 2017-04-29 22:55:49 +02:00
tooomm
ca2e3e5eab trial_error 2017-04-29 22:45:25 +02:00
tooomm
da42d9e049 fix 2017-04-29 22:32:07 +02:00
tooomm
f18679bfff fix attempt 2017-04-29 22:06:53 +02:00
tooomm
970b67cdb6 update message rework 2017-04-29 20:57:52 +02:00
ctrlaltca
3c5e38bd14 Hide some icons for spectators; fix #2589 (#2656)
* fix #2589

* Additional fix
2017-04-29 15:06:30 +02:00
ctrlaltca
b20c60e603 fix #2332 (#2650) 2017-04-29 12:21:37 +02:00
Zach H
12c9e4b81a allow placement below top X cards (#2666)
Close #2666
2017-04-27 20:32:24 -04:00
Zach H
7c1a18da5e Add "Random card from graveyard" (#2652) 2017-04-26 18:12:56 -04:00
ctrlaltca
df211748ca Add clear button to deck editor (#2654) 2017-04-26 15:20:35 -04:00
ctrlaltca
ce77d51a8f Fix crash on logger; make log window modalless (#2659) 2017-04-26 15:05:24 -04:00
tooomm
9dd3a04a08 improve provided info in "edit sets" (#2641) 2017-04-25 15:46:37 -04:00
Zach H
62d8f5a039 change cards from sb<->mb with double-click (#2606) 2017-04-25 14:05:25 -04:00
Fabio Bas
2c551bdd35 Revert "fix #2332"
This reverts commit 0fd77346df.
2017-04-25 19:35:07 +02:00
Fabio Bas
0fd77346df fix #2332 2017-04-25 18:58:01 +02:00
ctrlaltca
a46c7156dd fix_crash (#2649) 2017-04-25 18:13:45 +02:00
ctrlaltca
3c54499a40 sort edit sets better (#2648) 2017-04-25 11:40:47 -04:00
ctrlaltca
160d66d890 show tokens all sets (#2646) 2017-04-25 11:32:51 -04:00
ctrlaltca
3f3839d70a fix deck card backs (#2645) 2017-04-25 11:32:00 -04:00
ctrlaltca
ab94d2c91d Token Dialog Revamp (#2639) 2017-04-25 00:29:57 -04:00
ctrlaltca
8ad448a23c fix #2600 (#2638) 2017-04-25 00:29:32 -04:00
ctrlaltca
acb40bc738 Fix #2608; fix #2609; fix #2611 (#2636) 2017-04-24 22:20:44 +02:00
ctrlaltca
f2a887a6a4 fix #2623 (#2634) 2017-04-24 22:20:19 +02:00
ctrlaltca
29904c49da Specify reason when on game leave; fix #2624 (#2633)
* fix #2624

* feedback++
2017-04-24 22:20:08 +02:00
Fabio Bas
38ad71b06a fix ox compilation 2017-04-24 21:59:09 +02:00
Fabio Bas
7f057612bf possibily fix osx shortcut problem 2017-04-24 20:39:11 +02:00
ctrlaltca
9d2494e6e2 Update README.md adding link to guidelines; fix #2627 (#2635) 2017-04-24 15:52:30 +02:00
tritoch
23d27cff77 Handle 'aftermath' cards like 'split' cards (#2626) 2017-04-22 14:36:22 -04:00
Zach H
176ea444ba revert clear focus (#2619) 2017-04-21 17:52:14 +02:00
ctrlaltca
3e12a5f67f Update CONTRIBUTING.md (#2613)
* Update CONTRIBUTING.md

* Update CONTRIBUTING.md

"wait for CI upload" should be "wait for CI to upload"
"update again the version number" should be "update the version number again"
2017-04-21 14:26:55 +02:00
ctrlaltca
3356b2ede7 Change version in about window and installer name (#2570)
* Change version in about window and installer name

* Change version in about window and installer name

* Cmake get version updates

* dev snapshot format changed

* alignment changes
2017-04-20 13:41:18 +02:00
Zach H
5f3a3f535a clear focus only if needed (#2604) 2017-04-20 05:21:30 -04:00
Zach H
e2e9c5ab96 disable join if spec disabled (#2605) 2017-04-20 03:01:28 -04:00
skwerlman
dd36187864 fix header markdown in TODO.md (#2592) 2017-04-16 21:38:55 -04:00
Zach H
dc6c375220 clear focus when changing phases (#2583) 2017-04-15 14:37:01 -04:00
tritoch
2e9a0bdd4d Fix Pre-release / Dev build link (#2584) 2017-04-11 18:06:13 -04:00
Zach H
1413337b24 Add CONTRIBUTING note on making prereleases (#2576) 2017-04-07 20:59:06 -04:00
Zach H
3b7990b569 fix travis build (#2575)
* fix travis build

* rename dir
2017-04-07 14:41:33 +02:00
Zach H
657e1ac9e6 fix c style casting (#2561) 2017-04-05 15:45:58 -04:00
tooomm
ee154da598 clean transifex translations up (#2566) 2017-04-03 16:35:10 -04:00
Zach H
b3c1a87f60 better bool checking (#2564) 2017-04-01 21:29:23 -04:00
Mark McDonald
9cbae8c707 Decklist testing (#2537) 2017-04-01 01:24:16 -04:00
Zach H
ef7670a1e6 translation file updates (#2559)
* translation file updates

* translation updates
2017-03-31 15:29:43 -04:00
Zach H
d7e5b29d41 Dev channel to GitHub (#2557) 2017-03-31 14:47:49 -04:00
skwerlman
6d07709174 add .gitlab-ci.yml (#2345)
* add .gitlab-ci.yml

* Update to fix issues

fix artifact selection
fix rpm builds
mostly fix debian builds (still have cmake issue)
update to conform with #2373
combined rc and debug stages (more efficient as one stage)
add unused deploy section (can be finished/configured later)

* remove old bintray bits

* fix issues

simplify `mkdir` command
remove bintray deploy
2017-03-31 09:53:00 +02:00
Zach H
51230ade1a correct key (#2553) 2017-03-30 03:35:48 -04:00
tooomm
0e6c3c9561 better description for issue template (#2541)
* more general description for issue template

* fix

* rephrase

* remove part about filename

* fix typos
2017-03-29 11:12:31 -04:00
Zach H
56ec219808 appveyor key change (#2551) 2017-03-28 15:02:34 -04:00
Zach H
fab3d24757 Travis/Appveyor publish to GitHub Releases (#2550) 2017-03-28 13:37:59 -04:00
Zach H
87ebea7b0f fix memory leak (#2549) 2017-03-28 13:13:42 -04:00
tooomm
a273f55b6f exchange tr() for QString() (#2547) 2017-03-27 15:07:17 -04:00
Zach H
06c3edf4c6 cancel downloads from updater (#2534)
* cancel downloads from updater - fix #2534

* fix double popup
2017-03-25 16:35:43 -04:00
Gavin Bisesi
6f30304271 Change stable channel downloads to use only github api and links (#2515)
* Change stable channel downloads to use only github api and links

Ref #2502
2017-03-25 16:35:04 -04:00
tooomm
3374576831 fix toc (#2538) 2017-03-25 16:17:47 -04:00
Gavin Bisesi
54911eebc1 Merge pull request #2536 from Cockatrice/ReadmeUpdate-ZZ
Update README.md

[skip ci]
2017-03-24 16:42:22 -04:00
Zach H
b3563a897e Update README.md
Remove bintray
2017-03-24 16:40:08 -04:00
Gavin Bisesi
1879b906e5 Merge pull request #2532 from ZeldaZach/listover
Temp fix for crash on logging - QList instead of QVector hides whatever double-free bug we're causing
2017-03-24 15:51:26 -04:00
Zach H
559d4bd47f use list over vector 2017-03-23 00:45:52 -04:00
Gavin Bisesi
b99ae7f463 Merge pull request #2501 from Cockatrice/refactor-chatview
Remove direct usages of TabSupervisor from Chatview
2017-03-22 22:22:19 -04:00
Gavin Bisesi
f5a5ea0434 ChatView: Initialize fields in declared order 2017-03-22 21:52:15 -04:00
woogerboy21
2f23a9cb2f Smarter rooms (#2484)
* Added VIP only room

* Added DONATOR room.

* Extended Room to include privilege level.

* Updated room join logic

* Updated server tab permissions column display based on perm+privlevel definitions

* Fixed new client -> old server blank permissions column on server tab

Added the ability for registered user - VIP/DONATOR/PRIVILEGED room.
2017-03-22 21:45:16 -04:00
Zach H
317ac05919 logbuffer crash fix (#2524) 2017-03-22 21:39:16 -04:00
Zach H
f688c046ab Size constraints for Settings Dialog (#2513) 2017-03-22 21:25:40 -04:00
Zach H
141e6df50a Updater dialog changes (#2504) 2017-03-22 21:23:25 -04:00
Gavin Bisesi
8ac2a5870d Un-const non-pointer return types 2017-03-22 21:12:42 -04:00
Gavin Bisesi
a3f4012d1a Reduce TabSupervisor direct usage in UserContextMenu 2017-03-22 20:44:05 -04:00
Gavin Bisesi
c5aa75d4d1 Reduce data dependency for GamesProxyModel 2017-03-22 20:44:05 -04:00
Gavin Bisesi
d65a444ac5 Remove direct usages of TabSupervisor from Chatview
- There still might be inherited usages
- It's still used in the ctor

Areas to test
- Mentions
- Chat notifications
- Username clickable links
2017-03-22 20:44:05 -04:00
tooomm
2c3b85aed3 fix translators link (#1987) 2017-03-22 16:26:59 -04:00
Zach H
85985a9433 Add support for multi-selection in set editor (#2441) 2017-03-22 15:49:38 -04:00
woogerboy21
33e8a2ea95 Fix mysql appveyor (#2529) 2017-03-21 16:42:14 -04:00
Zach H
5ebc9ca360 allow auto connect (#2522) 2017-03-20 18:21:20 -04:00
Zach H
4feb43cdcc changes to connection dialog (#2503) 2017-03-19 20:24:58 -04:00
Zach H
b5b9527c13 Font size defaults (#2521) 2017-03-19 20:20:06 -04:00
Zach H
a2a7561613 allow max font size to be defined by user (#2488) 2017-03-19 14:13:20 -04:00
tooomm
1cc50b2793 remove travis deployment to bintray (#2516) 2017-03-19 12:58:31 -04:00
Zach H
2d401e4aba remove bintray deploy (#2511) 2017-03-19 12:56:16 -04:00
Zach H
0da2bdd7aa additional null checks in player, gameselector, remoteclient, log (#2514) 2017-03-19 12:55:55 -04:00
Zach H
212a7d00db better null checking decklist (#2510) 2017-03-18 20:56:49 -04:00
Zach H
3b2eff2551 file filenames so window updater works (#2500)
* file filenames so window updater works
2017-03-18 18:48:40 -04:00
Zach H
fb194db766 additional null checks & parsing (#2506)
* additional null checks & parsing
2017-03-18 18:48:23 -04:00
Zach H
127a91147c rename from update to check (#2505) 2017-03-18 18:46:19 -04:00
Zach H
2048aac387 STDout debugging (#2499) 2017-03-17 20:45:13 -04:00
Zach H
a8a4557738 auto_connect toggle fix (#2485) 2017-03-16 16:59:48 -04:00
Zach H
a7dbc2e1f6 Fix token window resize (#2480) 2017-03-15 15:53:57 -04:00
Zach H
4cfcca33db Server Connect Remade (#2452)
* Save multiple server configurations
* Each server has its own password/port storage

Close #2452
2017-03-14 17:51:51 -04:00
Zach H
37b43f9916 make settings size vary based on sizeHint() (#2472) 2017-03-14 17:48:02 -04:00
830 changed files with 176496 additions and 109000 deletions

16
.ci/ArchLinux/Dockerfile Normal file
View File

@@ -0,0 +1,16 @@
from archlinux:latest
RUN pacman --sync --refresh --sysupgrade --needed --noconfirm \
base-devel \
ccache \
cmake \
git \
gtest \
mariadb-libs \
protobuf \
qt5-base \
qt5-multimedia \
qt5-svg \
qt5-tools \
qt5-websockets \
&& pacman --sync --clean --clean --noconfirm

24
.ci/Debian10/Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
FROM debian:10
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ccache \
clang-format \
cmake \
file \
g++ \
git \
liblzma-dev \
libmariadb-dev-compat \
libprotobuf-dev \
libqt5multimedia5-plugins \
libqt5sql5-mysql \
libqt5svg5-dev \
libqt5websockets5-dev \
protobuf-compiler \
qt5-default \
qtbase5-dev \
qtmultimedia5-dev \
qttools5-dev-tools \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

24
.ci/Debian11/Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
FROM debian:11
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ccache \
clang-format \
cmake \
file \
g++ \
git \
liblzma-dev \
libmariadb-dev-compat \
libprotobuf-dev \
libqt5multimedia5-plugins \
libqt5sql5-mysql \
libqt5svg5-dev \
libqt5websockets5-dev \
protobuf-compiler \
qtmultimedia5-dev \
qttools5-dev \
qttools5-dev-tools \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

21
.ci/Fedora34/Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
FROM fedora:34
RUN dnf install -y \
@development-tools \
ccache \
cmake \
desktop-file-utils \
file \
gcc-c++ \
git \
hicolor-icon-theme \
libappstream-glib \
mariadb-devel \
protobuf-devel \
qt5-{qttools,qtsvg,qtmultimedia,qtwebsockets}-devel \
rpm-build \
sqlite-devel \
wget \
xz-devel \
zlib-devel \
&& dnf clean all

21
.ci/Fedora35/Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
FROM fedora:35
RUN dnf install -y \
@development-tools \
ccache \
cmake \
desktop-file-utils \
file \
gcc-c++ \
git \
hicolor-icon-theme \
libappstream-glib \
mariadb-devel \
protobuf-devel \
qt5-{qttools,qtsvg,qtmultimedia,qtwebsockets}-devel \
rpm-build \
sqlite-devel \
wget \
xz-devel \
zlib-devel \
&& dnf clean all

View File

@@ -0,0 +1,24 @@
FROM ubuntu:bionic
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ccache \
clang-format \
cmake \
file \
g++ \
git \
liblzma-dev \
libmariadb-dev-compat \
libprotobuf-dev \
libqt5multimedia5-plugins \
libqt5sql5-mysql \
libqt5svg5-dev \
libqt5websockets5-dev \
protobuf-compiler \
qt5-default \
qtmultimedia5-dev \
qttools5-dev \
qttools5-dev-tools \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

View File

@@ -0,0 +1,25 @@
FROM ubuntu:focal
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ccache \
clang-format \
cmake \
file \
g++ \
git \
liblzma-dev \
libmariadb-dev-compat \
libprotobuf-dev \
libqt5multimedia5-plugins \
libqt5sql5-mysql \
libqt5svg5-dev \
libqt5websockets5-dev \
protobuf-compiler \
qt5-default \
qtmultimedia5-dev \
qttools5-dev \
qttools5-dev-tools \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

View File

@@ -0,0 +1,24 @@
FROM ubuntu:hirsute
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ccache \
clang-format \
cmake \
file \
g++ \
git \
liblzma-dev \
libmariadb-dev-compat \
libprotobuf-dev \
libqt5multimedia5-plugins \
libqt5sql5-mysql \
libqt5svg5-dev \
libqt5websockets5-dev \
protobuf-compiler \
qtmultimedia5-dev \
qttools5-dev \
qttools5-dev-tools \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

View File

@@ -0,0 +1,24 @@
FROM ubuntu:impish
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ccache \
clang-format \
cmake \
file \
g++ \
git \
liblzma-dev \
libmariadb-dev-compat \
libprotobuf-dev \
libqt5multimedia5-plugins \
libqt5sql5-mysql \
libqt5svg5-dev \
libqt5websockets5-dev \
protobuf-compiler \
qtmultimedia5-dev \
qttools5-dev \
qttools5-dev-tools \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

152
.ci/compile.sh Executable file
View File

@@ -0,0 +1,152 @@
#!/bin/bash
# This script is to be used by the ci environment from the project root directory, do not use it from somewhere else.
# Read arguments
while [[ "$@" ]]; do
case "$1" in
'--')
shift
;;
'--format')
CHECK_FORMAT=1
shift
;;
'--install')
MAKE_INSTALL=1
shift
;;
'--package')
MAKE_PACKAGE=1
shift
if [[ $# != 0 && $1 != -* ]]; then
PACKAGE_TYPE="$1"
shift
fi
;;
'--suffix')
shift
if [[ $# == 0 ]]; then
echo "::error file=$0::--suffix expects an argument"
exit 1
fi
PACKAGE_SUFFIX="$1"
shift
;;
'--server')
MAKE_SERVER=1
shift
;;
'--test')
MAKE_TEST=1
shift
;;
'--debug')
BUILDTYPE="Debug"
shift
;;
'--release')
BUILDTYPE="Release"
shift
;;
'--ccache')
USE_CCACHE=1
shift
;;
*)
if [[ $1 == -* ]]; then
echo "::error file=$0::unrecognized option: $1"
exit 3
fi
BUILDTYPE="$1"
shift
;;
esac
done
# Check formatting using clang-format
if [[ $CHECK_FORMAT ]]; then
echo "::group::Run linter"
source ./.ci/lint.sh
echo "::endgroup::"
fi
set -e
# Setup
./servatrice/check_schema_version.sh
mkdir -p build
cd build
if [[ ! $CMAKE_BUILD_PARALLEL_LEVEL ]]; then
CMAKE_BUILD_PARALLEL_LEVEL=2 # default machines have 2 cores
fi
# Add cmake flags
if [[ $MAKE_SERVER ]]; then
flags+=" -DWITH_SERVER=1"
fi
if [[ $MAKE_TEST ]]; then
flags+=" -DTEST=1"
fi
if [[ $BUILDTYPE ]]; then
flags+=" -DCMAKE_BUILD_TYPE=$BUILDTYPE"
fi
if [[ $PACKAGE_TYPE ]]; then
flags+=" -DCPACK_GENERATOR=$PACKAGE_TYPE"
fi
if [[ $(uname) == "Darwin" ]]; then
if [[ $USE_CCACHE ]]; then
# prepend ccache compiler binaries to path
PATH="/usr/local/opt/ccache/libexec:$PATH"
fi
# Add qt install location when using homebrew
flags+=" -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5/"
fi
# Compile
if [[ $USE_CCACHE ]]; then
echo "::group::Show ccache stats"
ccache --show-stats
echo "::endgroup::"
fi
echo "::group::Configure cmake"
cmake --version
cmake .. $flags
echo "::endgroup::"
echo "::group::Build project"
cmake --build .
echo "::endgroup::"
if [[ $USE_CCACHE ]]; then
echo "::group::Show ccache stats again"
ccache --show-stats
echo "::endgroup::"
fi
if [[ $MAKE_TEST ]]; then
echo "::group::Run tests"
cmake --build . --target test
echo "::endgroup::"
fi
if [[ $MAKE_INSTALL ]]; then
echo "::group::Install"
cmake --build . --target install
echo "::endgroup::"
fi
if [[ $MAKE_PACKAGE ]]; then
echo "::group::Create package"
cmake --build . --target package
echo "::endgroup::"
if [[ $PACKAGE_SUFFIX ]]; then
echo "::group::Update package name"
../.ci/name_build.sh "$PACKAGE_SUFFIX"
echo "::endgroup::"
fi
fi

146
.ci/docker.sh Normal file
View File

@@ -0,0 +1,146 @@
#!/bin/bash
# This script is to be used by the ci environment from the project root directory, do not use it from somewhere else.
# Creates or loads docker images to use in compilation, creates RUN function to start compilation on the docker image.
# --get loads the image from a previously saved image cache, will build if no image is found
# --build builds the image from the Dockerfile in .ci/$NAME
# --save stores the image, if an image was loaded it will not be stored
# requires: docker
# uses env: NAME CACHE BUILD GET SAVE (correspond to args: <name> --set-cache <cache> --build --get --save)
# sets env: RUN CCACHE_DIR IMAGE_NAME RUN_ARGS RUN_OPTS BUILD_SCRIPT
# exitcode: 1 for failure, 2 for missing dockerfile, 3 for invalid arguments
export BUILD_SCRIPT=".ci/compile.sh"
project_name="cockatrice"
save_extension=".tar.gz"
image_cache="image"
ccache_cache=".ccache"
# Read arguments
while [[ "$@" ]]; do
case "$1" in
'--build')
BUILD=1
shift
;;
'--get')
GET=1
shift
;;
'--save')
SAVE=1
shift
;;
'--set-cache')
CACHE=$2
if ! [[ -d $CACHE ]]; then
echo "could not find cache path: $CACHE" >&2
exit 3
fi
shift 2
;;
*)
if [[ $1 == -* ]]; then
echo "unrecognized option: $1"
return 3
fi
NAME="$1"
shift
;;
esac
done
# Setup
if ! [[ $NAME ]]; then
echo "no build name given" >&2
return 3
fi
export IMAGE_NAME="${project_name,,}_${NAME,,}" # lower case
docker_dir=".ci/$NAME"
if ! [[ -r $docker_dir/Dockerfile ]]; then
echo "could not find Dockerfile in $docker_dir" >&2
return 2 # even if the image is cached, we do not want to run if there is no way to build this image
fi
if ! [[ $CACHE ]]; then
echo "cache dir is not set!" >&2
else
if ! [[ -d $CACHE ]]; then
echo "could not find cache dir: $CACHE" >&2
mkdir -p $CACHE
unset GET # the dir is empty
fi
if [[ $GET || $SAVE ]]; then
img_dir="$CACHE/$image_cache"
img_save="$img_dir/$IMAGE_NAME$save_extension"
if ! [[ -d $img_dir ]]; then
echo "could not find image dir: $img_dir" >&2
mkdir -p "$img_dir"
fi
fi
export CCACHE_DIR="$CACHE/$ccache_cache"
if ! [[ -d $CCACHE_DIR ]]; then
echo "could not find ccache dir: $CCACHE_DIR" >&2
mkdir -p "$CCACHE_DIR"
fi
fi
# Get the docker image from previously stored save
if [[ $GET ]]; then
if [[ $img_save ]] && docker load --input "$img_save"; then
echo "loaded image"
docker images
unset BUILD # do not overwrite the loaded image with build
unset SAVE # do not overwrite the stored image with the same image
if [[ $(find "$CCACHE_DIR" -type f -print -quit) ]]; then # check contents of ccache
echo "setting ccache to readonly"
export RUN_ARGS="$RUN_ARGS -e CCACHE_READONLY=1 -e CCACHE_NOSTATS=1" # do not overwrite ccache
else
echo "ccache is empty: $(find "$CCACHE_DIR")" >&2
fi
else
echo "could not load cached image, building instead" >&2
BUILD=1
fi
fi
# Build the docker image from dockerfile
if [[ $BUILD ]]; then
if docker build --tag "$IMAGE_NAME" "$docker_dir"; then
echo "built image"
docker images
else
echo "could not build image $IMAGE_NAME" >&2
return 1
fi
fi
# Save docker image to cache (compressed)
if [[ $SAVE ]]; then
if [[ $img_save ]] && docker save --output "$img_save" "$IMAGE_NAME"; then
echo "saved image to: $img_save"
else
echo "could not save image $IMAGE_NAME" >&2
fi
fi
# Set compile function, runs the compile script on the image, passes arguments to the script
function RUN ()
{
echo "running image:"
if docker images | grep "$IMAGE_NAME"; then
args="--mount type=bind,source=$PWD,target=/src -w=/src"
if [[ $CCACHE_DIR ]]; then
args+=" --mount type=bind,source=$CCACHE_DIR,target=/.ccache -e CCACHE_DIR=/.ccache"
fi
docker run $args $RUN_ARGS "$IMAGE_NAME" bash "$BUILD_SCRIPT" $RUN_OPTS $@
return $?
else
echo "could not find docker image: $IMAGE_NAME" >&2
return 3
fi
}

69
.ci/lint_cpp.sh Executable file
View File

@@ -0,0 +1,69 @@
#!/bin/bash
# fetch master branch
git fetch origin master
# unshallow if needed
echo "Finding merge base"
if ! git merge-base origin/master HEAD; then
echo "Could not find merge base, unshallowing repo"
git fetch --unshallow
fi
# Check formatting using clangify
echo "Checking your code using clang-format..."
diff="$(./clangify.sh --diff --cf-version --branch origin/master)"
err=$?
case $err in
1)
cat <<EOM
***********************************************************
*** ***
*** Your code does not comply with our style guide. ***
*** ***
*** Please correct it or run the "clangify.sh" script. ***
*** Then commit and push those changes to this branch. ***
*** Check our CONTRIBUTING.md file for more details. ***
*** ***
*** Thank you ❤️ ***
*** ***
***********************************************************
Used clang-format version:
${diff%%
*}
The following changes should be made:
${diff#*
}
Exiting...
EOM
exit 2
;;
0)
cat <<EOM
***********************************************************
*** ***
*** Your code complies with our style guide! ***
*** ***
*** Awesome 👍 ***
*** ***
***********************************************************
Exiting...
EOM
exit 0
;;
*)
echo ""
echo "Something went wrong in our formatting checks: clangify returned $err" >&2
echo ""
;;
esac

50
.ci/name_build.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/bash
# used by the ci to rename build artifacts
# renames the file to [original name][SUFFIX].[original extension]
# where SUFFIX is either available in the environment or as the first arg
# if MAKE_ZIP is set instead a zip is made
# expected to be run in the build directory
builddir="."
findrx="Cockatrice-*.*"
if [[ $1 ]]; then
SUFFIX="$1"
fi
# check env
if [[ ! $SUFFIX ]]; then
echo "::error file=$0::SUFFIX is missing"
exit 2
fi
set -e
# find file
found="$(find "$builddir" -maxdepth 1 -type f -name "$findrx" -print -quit)"
path="${found%/*}" # remove all after last /
file="${found##*/}" # remove all before last /
if [[ ! $file ]]; then
echo "::error file=$0::could not find package"
exit 1
fi
if ! cd "$path"; then
echo "::error file=$0::could not get file path"
exit 1
fi
# set filename
name="${file%.*}" # remove all after last .
new_name="$name$SUFFIX."
if [[ $MAKE_ZIP ]]; then
filename="${new_name}zip"
echo "creating zip '$filename' from '$file'"
zip "$filename" "$file"
else
extension="${file##*.}" # remove all before last .
filename="$new_name$extension"
echo "renaming '$file' to '$filename'"
mv "$file" "$filename"
fi
ls -l "$PWD/$filename"
echo "::set-output name=path::$PWD/$filename"
echo "::set-output name=name::$filename"

112
.ci/prep_release.sh Executable file
View File

@@ -0,0 +1,112 @@
#!/bin/bash
# sets the properties of ci releases
# this doesn't have to be 100% foolproof
# the releases are first made as drafts and will be vetted by a human
# it just has to provide a template
# this requires the repo to be unshallowed
template_path=".ci/release_template.md"
body_path="/tmp/release.md"
beta_regex='beta'
name_regex='set\(GIT_TAG_RELEASENAME "([[:print:]]+)")'
whitespace='^\s*$'
if [[ $1 ]]; then
TAG="$1"
fi
# check env
if [[ ! $TAG ]]; then
echo "::error file=$0::TAG is missing"
exit 2
fi
# create title
if [[ $TAG =~ $beta_regex ]]; then
echo "::set-output name=is_beta::yes"
title="$TAG"
echo "creating beta release '$title'"
elif [[ ! $(cat CMakeLists.txt) =~ $name_regex ]]; then
echo "::error file=$0::could not find releasename in CMakeLists.txt"
exit 1
else
echo "::set-output name=is_beta::no"
name="${BASH_REMATCH[1]}"
version="${TAG##*-}"
title="Cockatrice $version: $name"
no_beta=1
echo "::set-output name=friendly_name::$name"
echo "creating full release '$title'"
fi
echo "::set-output name=title::$title"
# add release notes template
if [[ $no_beta ]]; then
body="$(cat "$template_path")"
if [[ ! $body ]]; then
echo "::warning file=$0::could not find release template"
fi
body="${body//--REPLACE-WITH-RELEASE-TITLE--/$title}"
else
body="--REPLACE-WITH-COMMIT-COUNT-- commits have been included over the previous --REPLACE-WITH-PREVIOUS-RELEASE-TYPE--
<details>
<summary><b>show changes</b></summary>
--REPLACE-WITH-GENERATED-LIST--
</details>"
fi
# add git log to release notes
all_tags="
$(git tag)" # tags are ordered alphabetically
before="${all_tags%%
$TAG*}" # strip line with current tag an all lines after it
# note the extra newlines are needed to always have a last line
if [[ $all_tags == $before ]]; then
echo "::warning file=$0::could not find current tag"
else
while
previous="${before##*
}" # get the last line
# skip this tag if this is a full release and it's a beta or if empty
[[ $no_beta && $previous =~ $beta_regex || ! $previous ]]
do
beta_list+=" $previous" # add to list of skipped betas
next_before="${before%
*}" # strip the last line
if [[ $next_before == $before ]]; then
unset previous
break
fi
before="$next_before"
done
if [[ $previous ]]; then
if generated_list="$(git log "$previous..$TAG" --pretty="- %s")"; then
count="$(git rev-list --count "$previous..$TAG")"
[[ $previous =~ $beta_regex ]] && previousreleasetype="beta release" || previousreleasetype="full release"
echo "adding list of commits to release notes:"
echo "'$previous' to '$TAG' ($count commits)"
# --> is the markdown comment escape sequence, emojis are way better
generated_list="${generated_list//-->/→}"
body="${body//--REPLACE-WITH-GENERATED-LIST--/$generated_list}"
body="${body//--REPLACE-WITH-COMMIT-COUNT--/$count}"
body="${body//--REPLACE-WITH-PREVIOUS-RELEASE-TAG--/$previous}"
body="${body//--REPLACE-WITH-PREVIOUS-RELEASE-TYPE--/$previousreleasetype}"
if [[ $beta_list =~ $whitespace ]]; then
beta_list="-n there are no betas to delete!"
else
echo "the following betas should be deleted after publishing:"
echo "$beta_list"
fi
body="${body//--REPLACE-WITH-BETA-LIST--/$beta_list}"
else
echo "::warning file=$0::failed to produce git log"
fi
else
echo "::warning file=$0::could not find previous tag"
fi
fi
# write to file
echo "::set-output name=body_path::$body_path"
echo "$body" >"$body_path"

94
.ci/release_template.md Normal file
View File

@@ -0,0 +1,94 @@
<!-- this template comes from .ci/release_template.md -->
<!-- Don't forget to delete the previous betas after publishing this!
git push -d origin --REPLACE-WITH-BETA-LIST--
-->
<!-- This list of binaries should be updated every time the ci is changed to
include different targets -->
<pre>
<b>Pre-compiled binaries we serve:</b>
- <kbd>Windows 7/8/10 (32-bit)</kbd></i>
- <kbd>Windows 7/8/10 (64-bit)</kbd></i>
- <kbd>macOS 10.14</kbd> ("Mojave")</i>
- <kbd>macOS 10.15</kbd> ("Catalina")</i>
- <kbd>macOS 11.0</kbd> ("Big Sur")</i>
- <kbd>Ubuntu 18.04</kbd> ("Bionic Beaver")</i>
- <kbd>Ubuntu 20.04</kbd> ("Focal Fossa")</i>
- <kbd>Ubuntu 20.10</kbd> ("Groovy Gorilla")</i>
- <kbd>Ubuntu 21.04</kbd> ("Hirsute Hippo")</i>
- <kbd>Debian 10</kbd> ("Buster")</i>
- <kbd>Fedora 33</kbd></i>
- <kbd>Fedora 34</kbd></i>
<kbd>We are also packaged in Arch Linux's official community repository, courtesy of @FFY00</kbd></i>
<kbd>General linux support is available via a flatpak package (Flathub)</kbd></i>
</pre>
## General Notes
<!-- --REPLACE-WITH-RELEASE-TITLE-- should be placed here by the ci -->
We're pleased to announce the newest official release: <kbd>--REPLACE-WITH-RELEASE-TITLE--</kbd>
We hope you enjoy the changes made and we have listed all changes, with their corresponding tickets, since the last version of Cockatrice was released for your convenience.
If you ever encounter a bug, have a suggestion or idea, or feel a need for a developer to look into something, please feel free to [open a ticket](https://github.com/Cockatrice/Cockatrice/issues). ([How to create a GitHub Ticket for Cockatrice](https://github.com/Cockatrice/Cockatrice/wiki/How-to-Create-a-GitHub-Ticket-Regarding-Cockatrice))
For any information relating to Cockatrice, please take a look at our official site: **https://cockatrice.github.io**
If you'd like to help contribute to Cockatrice in any way, check out our [README](https://github.com/Cockatrice/Cockatrice#get-involved-). We're always available to answer questions you may have on how the program works and how you can provide a meaningful contribution.
## Upgrading Cockatrice
<!-- this optional section puts a warning banner for problems with updating
> ⚠️ **With this release, we no longer provide a ready-to-install binary for:**
> --DEPRECATED-OS-HERE--
-->
- Run the internal software updater: <kbd>Help → Check for Client Updates</kbd>
Don't forget to update your card database right after! (<kbd>Help → Check for Card Updates...</kbd>)
## Changelog
<!--
This list is generated and should be moved to their respective header and
possibly edited a little.
Append PR numbers of fixups to their main PR to keep the list coherent.
Put the quantity of remaining PR's below the highlights section.
Remove empty headers when done.
--REPLACE-WITH-GENERATED-LIST--
-->
<!-- Highlights of the release -->
### ⚠️ Important:
### ✨ New Features:
### 🐛 Fixed Bugs / Resolved issues:
<!-- Complete list of changes (foldable) -->
<details>
<summary>
📘 <b>Show all changes</b> (--REPLACE-WITH-COMMIT-COUNT-- commits)
</summary>
### User Interface
### Under the Hood
### Oracle
### Servatrice
### Webatrice
</details>
## Translations
- **Thanks for over 300 people contributing to 20+ different languages up to now!**
- Without the help of the community we couldn't offer that great language support... keep up the good work!
- It's actually very easy to join and help for yourself - find out more here:
- [Help us Translate Cockatrice into your native language!](https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ)
## Special Thanks
<!-- Personalise this a bit! -->
We continue to find it amazing that so many people contribute their time, knowledge, code, testing and more to the project. We'd like to thank the entire Cockatrice community for their efforts.
<!-- We'd like to especially recognize @ZeldaZach, --ADD-CONTRIBUTORS-HERE-- for their help in preparing so many amazing new features for the user base. -->

31
.clang-format Normal file
View File

@@ -0,0 +1,31 @@
IndentWidth: 4
AccessModifierOffset: -4
ColumnLimit: 120
---
Language: Cpp
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
AllowShortFunctionsOnASingleLine: None
BinPackParameters: false
AllowAllParametersOfDeclarationOnNextLine: false
IndentCaseLabels: true
PointerAlignment: Right
SortIncludes: true
IncludeBlocks: Regroup
---
Language: Proto
AllowShortFunctionsOnASingleLine: None
SpacesInContainerLiterals: false

5
.codacy.yml Normal file
View File

@@ -0,0 +1,5 @@
---
exclude_paths:
- '**/translations/*.ts'
# codacy config documentation: https://support.codacy.com/hc/en-us/articles/115002130625-Codacy-Configuration-File

View File

@@ -1,11 +1,8 @@
.git/
CONTRIBUTING.md
Dockerfile
TODO.md
build/
.github/
.tx/
cockatrice/
doc/
oracle/
sounds/
travis-compile.sh
travis-dependencies.sh
Dockerfile

View File

@@ -1,14 +1,99 @@
# Style Guide #
&nbsp; [Introduction](#contributing-to-cockatrice) | [Code Style Guide](
#code-style-guide) | [Translations](#translations) | [Release Management](
#release-management)
----
<br>
# Contributing to Cockatrice #
First off, thanks for taking the time to contribute to our project! 🎉 ❤ ️✨
The following is a set of guidelines for contributing to Cockatrice. These are
mostly guidelines, not rules. Use your best judgment, and feel free to propose
changes to this document in a pull request.
# Recommended Setups #
For those developers who like the Linux or MacOS environment, many of our
developers like working with a nifty program called [CLion](
https://www.jetbrains.com/clion/). The program's a great asset and one of the
best tools you'll find on these systems, but you're welcomed to use any IDE
you most enjoy.
Developers who like Windows development tend to find [Visual Studio](
https://www.visualstudio.com/) the best tool for the job.
[![Discord](https://img.shields.io/discord/314987288398659595?label=Discord&logo=discord&logoColor=white&color=7289da)](https://discord.gg/ZASRzKu)
[![Gitter Chat](https://img.shields.io/gitter/room/Cockatrice/Cockatrice.svg)](https://gitter.im/Cockatrice/Cockatrice)
If you'd like to ask questions, get advice, or just want to say hi,
the Cockatrice Development Team uses [Discord](https://discord.gg/ZASRzKu)
for communications in the #dev channel. If you're not into Discord, we also
have a [Gitter](https://gitter.im/Cockatrice/Cockatrice) channel available,
albeit slightly less active.
# Code Style Guide #
### Formatting and continuous integration (CI) ###
We use a separate job on the CI to check your code for formatting issues. If
your pull request failed the test, you can check the output on the checks tab.
It's the first job called "linter", you can click the "Run clangify" step to
see the output of the test.
The message will look like this:
```
***********************************************************
*** ***
*** Your code does not comply with our style guide. ***
*** ***
*** Please correct it or run the "clangify.sh" script. ***
*** Then commit and push those changes to this branch. ***
*** Check our CONTRIBUTING.md file for more details. ***
*** ***
*** Thank you ❤️ ***
*** ***
***********************************************************
```
The CONTRIBUTING.md file mentioned in that message is the file you are
currently reading. Please see [this section](#formatting) below for full
information on our formatting guidelines.
### Compatibility ###
Cockatrice is compiled on all platform using C++11, even if the majority of the
code is written in C++03.
Cockatrice is currently compiled on all platforms using <kbd>C++11</kbd>.
You'll notice <kbd>C++03</kbd> code throughout the codebase. Please feel free
to help convert it over!
For consistency, use Qt data structures where possible, such as `QString` over
`std::string` or `QList` over `std::vector`.
For consistency, we use Qt data structures where possible. For example,
`QString` over `std::string` and `QList` over `std::vector`.
### Header files ###
Do not use old C style casts in new code, instead use a [`static_cast<>`](
https://en.cppreference.com/w/cpp/language/static_cast)
or other appropriate conversion.
### Formatting ###
The handy tool `clang-format` can format your code for you, it is available for
almost any environment. A special `.clang-format` configuration file is
included in the project and is used to format your code.
We've also included a bash script, `clangify.sh`, that will use clang-format to
format all files in your pr in one go. Use `./clangify.sh --help` to show a
full help page.
To run clang-format on a single source file simply use the command
`clang-format -i <filename>` to format it in place. (Some systems install
clang-format with a specific version number appended,
`find /usr/bin -name clang-format*` should find it for you)
See [the clang-format documentation](
https://clang.llvm.org/docs/ClangFormat.html) for more information about the tool.
#### Header files ####
Use header files with the extension `.h` and source files with the extension
`.cpp`.
@@ -18,83 +103,107 @@ Use header guards in the form of `FILE_NAME_H`.
Simple functions, such as getters, may be written inline in the header file,
but other functions should be written in the source file.
Keep library includes and project includes grouped together. So this is okay:
Group project includes first, followed by library includes. All in alphabetic order.
Like this:
```c++
// Good:
#include <QList>
#include <QString>
#include "card.h"
#include "deck.h"
// Good:
// Good
#include "card.h"
#include "deck.h"
#include <QList>
#include <QString>
// Bad:
// Bad
#include <QList>
#include "card.h"
#include <QString>
#include "deck.h"
// Bad
#include "card.h"
#include "deck.h"
#include <QString>
#include <QList>
```
### Naming ###
#### Naming ####
Use `UpperCamelCase` for classes, structs, enums, etc. and `lowerCamelCase` for
function and variable names.
Member variables aren't decorated in any way. Don't prefix or suffix with
Don't use [Hungarian Notation](
https://en.wikipedia.org/wiki/Hungarian_notation).
Member variables aren't decorated in any way. Don't prefix or suffix them with
underscores, etc.
Use a separate line for each declaration, don't use a single line like this
`int one = 1, two = 2` and instead split them into two lines.
For arguments to constructors which have the same names as member variables,
prefix those arguments with underscores:
```c++
MyClass::MyClass(int _myData)
: myData(_myData)
{}
MyClass::MyClass(int _myData) : myData(_myData)
{
}
```
Pointers and references should be denoted with the `*` or `&` going with the
variable name:
```c++
// Good:
// Good
Foo *foo1 = new Foo;
Foo &foo2 = *foo1;
// Bad:
// Bad
Bar* bar1 = new Bar;
Bar& bar2 = *bar1;
```
Use `nullptr` instead of `NULL` (or `0`) for null pointers.
If you find any usage of the old keywords, we encourage you to fix it.
### Braces ###
#### Braces ####
Use K&R-style braces. Braces for function implementations go on their own
lines, but they go on the same line everywhere else:
Braces should go on their own line except for control statements, the use of
braces around single line statements is preferred.
See the following example:
```c++
int main()
{
if (someCondition) {
doSomething();
{ // function or class: own line
if (someCondition) { // control statement: same line
doSomething(); // single line statement, braces preferred
} else if (someOtherCondition1) { // else goes on the same line as a closing brace
for (int i = 0; i < 100; i++) {
doSomethingElse();
}
} else {
while (someOtherCondition) {
while (someOtherCondition2) {
doSomethingElse();
}
}
}
```
Braces can be omitted for single-statement if's and the like, as long as it is
still legible.
### Tabs ###
#### Indentation and Spacing ####
Use only spaces. Four spaces per tab.
Always indent using 4 spaces, do not use tabs. Opening and closing braces
should be on the same indentation layer, member access specifiers in classes or
structs should not be indented.
### Lines ###
All operators and braces should be separated by spaces, do not add a space next
to the inside of a brace.
Do not have trailing whitespace in your lines.
If multiple lines of code that follow eachother have single line comments
behind them, place all of them on the same indentation level. This indentation
level should be equal to the longest line of code for each of these comments,
without added spacing.
Lines should be 80 characters or less, as a soft limit.
#### Lines ####
Do not leave trailing whitespace on any line. Most IDEs check for this
nowadays and clean it up for you.
Lines should be 120 characters or less. Please break up lines that are too long
into smaller parts, for example at spaces or after opening a brace.
### Memory Management ###
@@ -130,45 +239,99 @@ as `QScopedPointer`, or, less preferably, `QSharedPointer`.
The servatrice database's schema can be found at `servatrice/servatrice.sql`.
Everytime the schema gets modified, some other steps are due:
1. Increment the value of `cockatrice_schema_version` in `servatrice.sql`;
2. Increment the value of `DATABASE_SCHEMA_VERSION` in `servatrice_database_interface.h` accordingly;
3. Create a new migration file inside the `servatrice/migrations` directory named after the new schema version.
4. Run the `servatrice/check_schema_version.sh` script to ensure everything is fine.
The migration file should include the sql statements needed to migrate the database schema and data from the previous to the new version, and an additional statement that updates `cockatrice_schema_version` to the correct value.
2. Increment the value of `DATABASE_SCHEMA_VERSION` in
`servatrice_database_interface.h` accordingly;
3. Create a new migration file inside the `servatrice/migrations` directory
named after the new schema version.
4. Run the `servatrice/check_schema_version.sh` script to ensure everything is
fine.
The migration file should include the sql statements needed to migrate the
database schema and data from the previous to the new version, and an
additional statement that updates `cockatrice_schema_version` to the correct
value.
Ensure that the migration produces the expected effects; e.g. if you add a
new column, make sure the migration places it in the same order as
servatrice.sql.
### Protocol buffer ###
Cockatrice and Servatrice exchange data using binary messages. The syntax of these messages is defined in the `proto` files in the `common/pb` folder. These files defines the way data contained in each message is serialized using Google's [protocol buffer](https://developers.google.com/protocol-buffers/).
Any change to the `proto` file should be taken with caution and tested intensively before being merged, becaus a change to the protocol could make new clients incompatible to the old server and vice versa.
Cockatrice and Servatrice exchange data using binary messages. The syntax of
these messages is defined in the `proto` files in the `common/pb` folder. These
files define the way data contained in each message is serialized using
Google's [protocol buffers](https://developers.google.com/protocol-buffers/).
Any change to the `proto` files should be taken with caution and tested
intensively before being merged, because a change to the protocol could make
new clients incompatible to the old server and vice versa.
### Translations: introduction ###
You can find more information on how we use Protobuf on [our wiki!](
https://github.com/Cockatrice/Cockatrice/wiki/Client-server-protocol)
# Reviewing Pull Requests #
After you have finished your changes to the project you should put them on a
separate branch of your fork on GitHub and open a [pull request](
https://docs.github.com/en/free-pro-team@latest/desktop/contributing-and-collaborating-using-github-desktop/creating-an-issue-or-pull-request
).
Your code will then be automatically compiled by GitHub actions for Linux and
macOS, and by Appveyor for Windows. Additionally GitHub will perform a [Linting
check](#formatting-and-continuous-integration-ci). If any issues come up you
can check their status at the bottom of the pull request page, click on details
to go to the CI website and see the different build logs.
If your pull request passes our tests and has no merge conflicts, it will be
reviewed by our team members. You can then address any requested changes. When
all changes have been approved your pull request will be squashed into a single
commit and merged into the master branch by a team member. Your change will then
be included in the next release 👍
# Translations #
Basic workflow for translations:
1. developer adds a `tr("foo")` string in the code;
2. every few days, a maintainer updates the `*_en.ts files` adding the new strings;
3. Transifex picks up the new files from github every 24 hours;
4. translators translate the new untraslated strings on Transifex;
5. before a release, a maintainer fetches the updated translations from Transifex.
1. Developer adds a `tr("foo")` string in the code;
2. Every few days, a maintainer updates the `*_en.ts files` with the new strings;
3. Transifex picks up the new files from GitHub every 24 hours;
4. Translators translate the new untranslated strings on Transifex;
5. Before a release, a maintainer fetches the updated translations from Transifex.
### Translations (for developers) ###
### Using Translations (for developers) ###
All the user-interface strings inside Cockatrice's source code must be written in
english language. Translations to other languages are managed using [Transifex](https://www.transifex.com/projects/p/cockatrice/).
All the user-interface strings inside Cockatrice's source code must be written
in English(US).
Translations to other languages are managed using [Transifex](
https://www.transifex.com/projects/p/cockatrice/).
If you're about to propose a change that adds or modifies any translatable string
in the code, you don't need to take care of adding the new strings to the
translation files. Every few days, or when a lot of new strings have been added,
someone from the development team will take care of extracing all the new strings,
adding them to the english translation files and making them available to
translators on Transifex.
Adding a new string to translate is as easy as adding the string in the
'tr("")' function, the string will be picked up as translatable automatically
and translated as needed.
For example, setting the text of a label in the way that the string
`"My name is:"` can be translated:
```c++
nameLabel.setText(tr("My name is:"));
```
### Translations (for maintainers) ###
To translate a string that would have plural forms you can add the amount to
the tr call, also you can add an extra string as a hint for translators:
```c++
QString message = tr("Everyone draws %n cards", "pop up message", amount);
```
See [QT's wiki on translations](
https://doc.qt.io/qt-5/i18n-source-translation.html#handling-plurals)
#### Step 2: updating *_en.ts files ####
If you're about to propose a change that adds or modifies any translatable
string in the code, you don't need to take care of adding the new strings to
the translation files.
Every few days, or when a lot of new strings have been added, someone from the
development team will take care of extracting all the new strings and adding
them to the english translation files and making them available to translators
on Transifex.
When new translatable strings have been added to the code, it would be nice to
### Maintaining Translations (for maintainers) ###
When new translatable strings have been added to the code, a maintainer should
make them available to translators on Transifex. Every few days, or when a lot
of new strings have been added, a maintainer should take care of extracing all
of new strings have been added, a maintainer should take care of extracting all
the new strings and add them to the english translation files.
To update the english translation files, re-run cmake enabling the appropriate
@@ -190,29 +353,111 @@ You should then notice that the following files have uncommitted changes:
cockatrice/translations/cockatrice_en.ts
oracle/translations/oracle_en.ts
It's now suggested to disable the parameter using:
It is recommended to disable the parameter afterwards using:
```sh
cmake .. -DUPDATE_TRANSLATIONS=OFF
```
Now you are ready to propose your change. Once your change gets merged,
Transifex will pick up the modified files automatically (checks every 24 hours)
and update the interface where translators will be able to translate the new
strings.
Now you are ready to propose your change.
#### Step 5: fetch new translations from Transifex ####
Once your change gets merged, Transifex will pick up the modified files
automatically (checked every 24 hours) and update the interface where
translators will be able to translate the new strings.
Before rushing out a new release, it would be nice to fetch the most up to date
### Releasing Translations (for maintainers) ###
Before rushing out a new release, a maintainer should fetch the most up to date
translations from Transifex and commit them into the Cockatrice source code.
This can be done manually from the Transifex web interface, but it's quite time
consuming.
As an alternative, you can install the Transifex CLI:
As an alternative, you can install the Transifex CLI:
http://docs.transifex.com/developer/client/
You'll then be able to use a git-like cli command to push and pull translations
from Transifex to the source code and vice versa.
### Translations (for translators) ###
### Adding Translations (for translators) ###
Please have a look at the specific [FAQ for translators](https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ).
As a translator you can help translate the new strings on [Transifex](
https://www.transifex.com/projects/p/cockatrice/).
Please have a look at the specific [FAQ for translators](
https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ).
# Release Management #
### Publishing A New Release ###
We use [GitHub Releases](https://github.com/Cockatrice/Cockatrice/releases) to
publish new stable versions and betas.
Whenever a git tag is pushed to the repository github will create a draft
release and upload binaries automatically.
To create a tag, simply do the following:
```bash
git checkout master
git remote update -p
git pull
git tag $TAG_NAME
git push $UPSTREAM $TAG_NAME
```
You should define the variables as such:
```
`$UPSTREAM` - the remote for git@github.com:Cockatrice/Cockatrice.git
`$TAG_NAME` should be formatted as:
- `YYYY-MM-DD-Release-MAJ.MIN.PATCH` for **stable releases**
- `YYYY-MM-DD-Development-MAJ.MIN.PATCH-beta.X` for **beta releases**<br>
With *MAJ.MIN.PATCH* being the NEXT release version!
```
This will cause a tagged release to be established on the GitHub repository,
with the binaries being added to the release whenever they are ready.
The release is initially a draft, where the path notes can be edited and after
all is good and ready it can be published on GitHub.
If you use a SemVer tag including "beta", the release that will be created at
GitHub will be marked as a "Pre-release" automatically.
The target of the `.../latest` URL will not be changed in that case, it always
points to the latest stable release and not pre-releases/betas.
If you accidentally push a tag incorrectly (the tag is outdated, you didn't
pull in the latest branch accidentally, you named the tag wrong, etc.) you can
revoke the tag by doing the following:
```bash
git push --delete upstream $TAG_NAME
git tag -d $TAG_NAME
```
You can also do this on GitHub, you'll also want to delete the new release.
In the first lines of [CMakeLists.txt](
https://github.com/Cockatrice/Cockatrice/blob/master/CMakeLists.txt)
there's an hardcoded version number and pretty name used when compiling from
master or custom (not tagged) versions.
While on tagged versions these numbers are overridden by the version numbers
coming from the tag title, it's good practice to increment the ones at CMake
after every full release to stress that master is ahead of the last stable
release.
The preferred flow of operation is:
* Just before a release, make sure the version number in CMakeLists.txt is set
to the same release version you are about to tag.
* This is also the time to change the pretty name in CMakeLists.txt called
GIT_TAG_RELEASENAME and commit and push these changes.
* Tag the release following the previously described syntax in order to get it
correctly built and deployed by CI.
* Wait for the configure step to create the release and update the patch
notes.
* Check on the github actions page for build progress which should be the top
listed [here](
https://github.com/Cockatrice/Cockatrice/actions?query=event%3Apush+-branch%3Amaster
).
* When the build has been completed you can verify all uploaded files on the
release are in order and hit the publish button.
* After the release is complete, update the CMake version number again to the
next targeted beta version, typically increasing `PROJECT_VERSION_PATCH` by
one.
When releasing a new stable version, all previous beta releases (and tags)
should be deleted. This is needed for Cockatrice to update users of the "Beta"
release channel correctly to the latest stable version as well.
This can be done the same way as revoking tags, mentioned above.

12
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [ZeldaZach]
patreon: mtgjson
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ["paypal.me/zachhalpern"]

View File

@@ -1,11 +0,0 @@
<b>OS:</b>
*Override this line with the exact operating system you are running! (e.g. "Win 7 SP1", "OS X 10.8.5", "Ubuntu 15.10" ...)*
<b>Cockatrice version:</b>
*Put your Cockatrice version number & build date here! You find them inside the app: `Help` --> `About Cockatrice` (e.g. "2d53ce9 (2016-02-18)"). If you can't access this menu for any reason, please include the full filename of the installer you used.*
___
<br>
*Explain your Issue/Request/Suggestion in detail here!*

33
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,33 @@
---
name: "🐛 Bug Report"
about: Report an issue encountered while using Cockatrice
title: ''
labels: 'Bug'
assignees: ''
---
<!-- READ THIS BEFORE POSTING
Go to "Help → View Debug Log" in Cockatrice and copy all information at the
top (above the separation line) below "System Information" in this ticket!
If you can't start Cockatrice to access these details, make
sure to post your OS and the file name of the setup binary instead. -->
**System Information:**
_______________________________________________________________________________________
<!-- Explain your issue in detail here! Please attach screenshots if possible. -->
_______________________________________________________________________________________
<!-- Describe the sequence of actions needed to experience the bug -->
**Steps to reproduce:**
- Do A
- Do B
- Do C ...

9
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,9 @@
blank_issues_enabled: false
contact_links:
- name: 💬 Discord Community (Get help with server issues, e.g. Login)
url: https://discord.gg/3Z9yzmA
about: Need help with using the client? Want to find some games? Try the Discord server!
- name: 🌐 Translations (Help improve the localization of the app)
url: https://www.transifex.com/cockatrice/cockatrice/
# it is not possible to add a link to the wiki to this description
about: For more information and guidance check our Translation FAQ on our wiki!

View File

@@ -0,0 +1,23 @@
---
name: "💡 Feature Request"
about: Request a new feature
title: ''
labels: 'Feature Request'
assignees: ''
---
<!--
Please search the issue tracker for similar issues before posting!
If your request is related to another request (but not the same!) list it here
-->
**Similar Requests**
<!-- Describe your feature idea here in detail -->
**Description of New Feature**
<!-- If your feature requires some context, provide it here -->
**Additional Context**

View File

@@ -9,4 +9,4 @@
- and this
## Screenshots
*(simply drag & drop image files directly into this description!)*
<!-- simply drag & drop image files directly into this description! -->

398
.github/workflows/desktop-build.yml vendored Normal file
View File

@@ -0,0 +1,398 @@
name: Build Desktop
on:
push:
branches:
- master
paths-ignore:
- '**.md'
- 'webclient/**'
- '.github/workflows/web-*.yml'
tags:
- '*'
pull_request:
branches:
- master
paths-ignore:
- '**.md'
- 'webclient/**'
- '.github/workflows/web-*.yml'
jobs:
configure:
name: Configure
runs-on: ubuntu-latest
outputs:
tag: ${{steps.configure.outputs.tag}}
sha: ${{steps.configure.outputs.sha}}
upload_url: ${{steps.create_release.outputs.upload_url}}
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{github.token}} # needs other token https://github.com/styfle/cancel-workflow-action/issues/7
- name: Configure
id: configure
shell: bash
run: |
tag_regex='^refs/tags/'
if [[ $GITHUB_EVENT_NAME == pull-request ]]; then # pull request
sha="${{github.event.pull_request.head.sha}}"
elif [[ $GITHUB_REF =~ $tag_regex ]]; then # release
sha="$GITHUB_SHA"
tag="${GITHUB_REF/refs\/tags\//}"
echo "::set-output name=tag::$tag"
else # push to branch
sha="$GITHUB_SHA"
fi
echo "::set-output name=sha::$sha"
- name: Checkout
if: steps.configure.outputs.tag != null
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Prepare release paramaters
id: prepare
if: steps.configure.outputs.tag != null
shell: bash
env:
TAG: ${{steps.configure.outputs.tag}}
run: .ci/prep_release.sh
- name: Create release
if: steps.configure.outputs.tag != null
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{github.token}}
with:
tag_name: ${{github.ref}}
release_name: ${{steps.prepare.outputs.title}}
body_path: ${{steps.prepare.outputs.body_path}}
draft: true
prerelease: ${{steps.prepare.outputs.is_beta == 'yes'}}
build-linux:
strategy:
fail-fast: false
matrix:
# these names correspond to the files in .ci/$distro
include:
- distro: UbuntuImpish
package: DEB
- distro: UbuntuHirsute
package: DEB
test: skip
- distro: UbuntuFocal
package: DEB
test: skip # UbuntuFocal has a broken qt for debug builds
- distro: UbuntuBionic
package: DEB
- distro: ArchLinux
package: skip # we are packaged in arch already
allow-failure: yes
- distro: Debian10
package: DEB
- distro: Debian11
package: DEB
- distro: Fedora34
package: RPM
test: skip # gtest does not compile for some reason
- distro: Fedora35
package: RPM
name: ${{matrix.distro}}
needs: configure
runs-on: ubuntu-latest
continue-on-error: ${{matrix.allow-failure == 'yes'}}
env:
NAME: ${{matrix.distro}}
CACHE: /tmp/${{matrix.distro}}-cache # ${{runner.temp}} does not work?
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get cache timestamp
id: cache_timestamp
shell: bash
run: echo "::set-output name=timestamp::$(date -u '+%Y%m%d%H%M%S')"
- name: Restore cache
uses: actions/cache@v2
env:
timestamp: ${{steps.cache_timestamp.outputs.timestamp}}
with:
path: ${{env.CACHE}}
key: docker-${{matrix.distro}}-cache-${{env.timestamp}}
restore-keys: |
docker-${{matrix.distro}}-cache-
- name: Build ${{matrix.distro}} Docker image
shell: bash
run: source .ci/docker.sh --build
- name: Build debug and test
if: matrix.test != 'skip'
shell: bash
run: |
source .ci/docker.sh
RUN --server --debug --test --ccache
- name: Build release package
id: package
if: matrix.package != 'skip'
shell: bash
env:
suffix: '-${{matrix.distro}}'
type: '${{matrix.package}}'
run: |
source .ci/docker.sh
RUN --server --release --package "$type" --suffix "$suffix"
- name: Upload artifact
if: matrix.package != 'skip'
uses: actions/upload-artifact@v2
with:
name: ${{matrix.distro}}-package
path: ./build/${{steps.package.outputs.name}}
if-no-files-found: error
- name: Upload to release
if: matrix.package != 'skip' && needs.configure.outputs.tag != null
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{github.token}}
with:
upload_url: ${{needs.configure.outputs.upload_url}}
asset_path: ./build/${{steps.package.outputs.name}}
asset_name: ${{steps.package.outputs.name}}
asset_content_type: application/octet-stream
build-macos:
strategy:
fail-fast: false
matrix:
target:
- Debug
- 10.14_Mojave
- 10.15_Catalina
- 11_Big_Sur
include:
- target: Debug # tests only
os: macos-latest
xcode: 12.5.1
type: Debug
do_tests: 0 # tests do not work yet on mac
make_package: false
- target: 10.14_Mojave
os: macos-10.15 # runs on Catalina
xcode: 10.3 # allows compatibility with macOS 10.14
type: Release
do_tests: 0
make_package: true
- target: 10.15_Catalina
os: macos-10.15
xcode: 12.1
type: Release
do_tests: 0
make_package: true
- target: 11_Big_Sur
os: macos-11
xcode: 12.5.1
type: Release
do_tests: 0
make_package: true
name: macOS ${{matrix.target}}
needs: configure
runs-on: ${{matrix.os}}
continue-on-error: ${{matrix.allow-failure == 'yes'}}
env:
DEVELOPER_DIR:
/Applications/Xcode_${{matrix.xcode}}.app/Contents/Developer
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies using homebrew
shell: bash
# cmake cannot find the mysql connector
# neither of these works: mariadb-connector-c mysql-connector-c++
run: brew update && brew install protobuf
- name: Install QT using homebrew
id: brew_install_qt
continue-on-error: true
shell: bash
run: brew install qt@5 --force-bottle
- name: Install QT using actions
if: steps.brew_install_qt.outcome != 'success'
uses: jurplel/install-qt-action@v2
- name: Build on Xcode ${{matrix.xcode}}
shell: bash
env:
CMAKE_BUILD_PARALLEL_LEVEL: 3 # mac machines actually have 3 cores
run: .ci/compile.sh ${{matrix.type}} --server
- name: Test
if: matrix.do_tests == 1
shell: bash
working-directory: build
run: cmake --build . --target test
- name: Package for ${{matrix.target}}
id: package
if: matrix.make_package
shell: bash
working-directory: build
run: |
cmake --build . --target package
../.ci/name_build.sh "-macOS-${{matrix.target}}"
- name: Upload artifact
if: matrix.make_package
uses: actions/upload-artifact@v2
with:
name: macOS-${{matrix.target}}-xcode-${{matrix.xcode}}-dmg
path: ${{steps.package.outputs.path}}
if-no-files-found: error
- name: Upload to release
if: matrix.make_package && needs.configure.outputs.tag != null
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{github.token}}
with:
upload_url: ${{needs.configure.outputs.upload_url}}
asset_path: ${{steps.package.outputs.path}}
asset_name: ${{steps.package.outputs.name}}
asset_content_type: application/octet-stream
build-windows:
strategy:
fail-fast: false
matrix:
arch:
- 64
- 32
include:
- arch: 64
triplet: x64
cmake: x64
append: _64
- arch: 32
triplet: x86
cmake: Win32
name: Windows ${{matrix.arch}}
needs: configure
runs-on: windows-latest
env:
QT_VERSION: '5.15.2'
QT_ARCH: msvc2019${{matrix.append}}
CMAKE_GENERATOR: 'Visual Studio 16 2019'
steps:
- name: Add msbuild to PATH
id: add-msbuild
uses: microsoft/setup-msbuild@v1.0.2
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Restore Qt ${{env.QT_VERSION}} ${{matrix.arch}}-bit from cache
id: cache-qt
uses: actions/cache@v2
with:
key: ${{runner.os}}-QtCache-${{env.QT_VERSION}}-${{matrix.arch}}
path: ${{runner.workspace}}/Qt
- name: Install ${{matrix.arch}}-bit Qt
uses: jurplel/install-qt-action@v2
with:
cached: ${{steps.cache-qt.outputs.cache-hit}}
version: ${{env.QT_VERSION}}
arch: win${{matrix.arch}}_${{env.QT_ARCH}}
- name: Restore or setup vcpkg
uses: lukka/run-vcpkg@v6
with:
vcpkgArguments: '@${{github.workspace}}/vcpkg.txt'
vcpkgDirectory: ${{github.workspace}}/vcpkg
appendedCacheKey: ${{hashFiles('**/vcpkg.txt')}}
vcpkgTriplet: ${{matrix.triplet}}-windows
- name: Configure Cockatrice ${{matrix.arch}}-bit
shell: bash
run: |
mkdir -p build
cd build
export QTDIR="${{runner.workspace}}/Qt/${{env.QT_VERSION}}/${{env.QT_ARCH}}"
cmake .. -G "${{env.CMAKE_GENERATOR}}" -A "${{matrix.cmake}}" -DCMAKE_BUILD_TYPE="Release" -DWITH_SERVER=1 -DTEST=1
- name: Build Cockatrice ${{matrix.arch}}-bit
id: package
shell: bash
working-directory: build
run: |
cmake --build . --target package --config Release
../.ci/name_build.sh "-win${{matrix.arch}}"
- name: Run tests
shell: bash
working-directory: build
run: ctest -T Test -C Release
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: Windows-${{matrix.arch}}bit-installer
path: ./build/${{steps.package.outputs.name}}
if-no-files-found: error
- name: Upload to release
if: needs.configure.outputs.tag != null
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{github.token}}
with:
upload_url: ${{needs.configure.outputs.upload_url}}
asset_path: ./build/${{steps.package.outputs.name}}
asset_name: ${{steps.package.outputs.name}}
asset_content_type: application/octet-stream

30
.github/workflows/desktop-lint.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
name: Code Style (C++)
on:
pull_request:
branches:
- master
paths-ignore:
- '**.md'
- 'webclient/**'
- '.github/workflows/web-*.yml'
jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 20 # should be enough to find merge base
- name: Install clang-format
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang-format
- name: Run clangify
shell: bash
run: ./.ci/lint_cpp.sh

55
.github/workflows/web-build.yml vendored Normal file
View File

@@ -0,0 +1,55 @@
name: Build Web
on:
push:
branches:
- master
paths:
- '.github/workflows/web-*.yml'
- 'webclient/**'
- '!**.md'
pull_request:
branches:
- master
paths:
- '.github/workflows/web-*.yml'
- 'webclient/**'
- '!**.md'
jobs:
build-web:
name: React (Node ${{matrix.node_version}})
runs-on: ubuntu-latest
defaults:
run:
working-directory: webclient
strategy:
fail-fast: false
matrix:
node_version:
- 12
- lts/*
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{matrix.node_version}}
cache: 'npm'
cache-dependency-path: 'webclient/package-lock.json'
- name: Install dependencies
run: npm clean-install
- name: Build app
run: npm run build
- name: Test app
run: npm run test

34
.github/workflows/web-lint.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
name: Code Style (TypeScript)
on:
pull_request:
branches:
- master
paths:
- '.github/workflows/web-*.yml'
- 'webclient/**'
- '!**.md'
jobs:
ESLint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: webclient
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
cache: 'npm'
cache-dependency-path: 'webclient/package-lock.json'
- name: Install ESLint
run: npm clean-install --ignore-scripts
- name: Run ESLint
run: npm run lint

4
.gitignore vendored
View File

@@ -7,3 +7,7 @@ mysql.cnf
.idea/
*.aps
cmake-build-debug/
preferences
compile_commands.json
.vs/
.vscode/

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg.git

View File

@@ -1,5 +0,0 @@
{
"message": "@pullRequester, thanks for contributing! @reviewers are the best people to review the changes.",
"fileBlacklist": ["*.md"],
"userBlacklist": ["@mbruker", "@Psithief"],
}

View File

@@ -1,39 +0,0 @@
language: cpp
matrix:
fast_finish: true
include:
# linux debug build, trusty + gcc + qt5
- os: linux
dist: trusty
env: BUILDTYPE=Debug DIST=trusty
# osx debug build, osx + clang + qt5
- os: osx
osx_image: xcode6.4
env: BUILDTYPE=Debug
# linux trusty release build, precise + gcc + qt5
- os: linux
dist: trusty
env: BUILDTYPE=Release DIST=trusty
# osx release build, osx + gcc + qt5
- os: osx
osx_image: xcode6.4
env: BUILDTYPE=Release
script: ./travis-compile.sh
install: ./travis-dependencies.sh
cache: apt
notifications:
slack: cockatrice:dNA81maCU8SAHB7pYrCWiQg9
webhooks:
urls:
- https://webhooks.gitter.im/e/d94969c3b01b22cbdcb7
on_success: change
on_failure: change
on_start: never
deploy:
provider: bintray
file: "build/bintray_deploy.json"
user: "ctrlaltca"
key:
secure: DtVeeLoi5fZG/RvLTecRnRQGW9fVNS4Oa5iut2vJa14PdKBAJiXACQ0EzcRJFsbtby7MyMc2IVtT5skpvsaSqkpaxoBaL1YtKwJ4CTkYcm2MDWHS7UlijuxxTjI6BnaL3lcCCIeG+NHBZa3dV2YNJ1sWv6Xmiiix1ujPPW8VtnM=
on:
condition: $BUILDTYPE = Release

View File

@@ -6,25 +6,7 @@
# like the installation path, compilation flags etc..
# Cmake 3.1 is required to enable C++11 support correctly
cmake_minimum_required(VERSION 3.1)
if(POLICY CMP0020)
cmake_policy(SET CMP0020 OLD)
endif()
if(POLICY CMP0043)
cmake_policy(SET CMP0043 OLD)
endif()
if(POLICY CMP0048)
cmake_policy(SET CMP0048 OLD)
endif()
if(POLICY CMP0064)
cmake_policy(SET CMP0064 OLD)
endif()
set(PROJECT_NAME "Cockatrice")
cmake_minimum_required(VERSION 3.10)
# Default to "Release" build type
# User-provided value for CMAKE_BUILD_TYPE must be checked before the PROJECT() call
@@ -34,8 +16,37 @@ ELSE()
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Type of build")
ENDIF()
# Early detect ccache
OPTION(USE_CCACHE "Cache the build results with ccache" ON)
if(USE_CCACHE)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
# Support Unix Makefiles and Ninja
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
MESSAGE(STATUS "Found CCache ${CCACHE_PROGRAM}")
endif()
endif()
if(WIN32)
# Use vcpkg toolchain on Windows
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake
CACHE STRING "Vcpkg toolchain file")
# Qt path set by user or env var
if (QTDIR OR DEFINED ENV{QTDIR} OR DEFINED ENV{QTDIR32} OR DEFINED ENV{QTDIR64})
else()
set(QTDIR "" CACHE PATH "Path to Qt (e.g. C:/Qt/5.7/msvc2015_64)")
message(WARNING "QTDIR variable is missing. Please set this variable to specify path to Qt (e.g. C:/Qt/5.7/msvc2015_64)")
endif()
endif()
# A project name is needed for CPack
PROJECT("${PROJECT_NAME}")
# Version can be overriden by git tags, see cmake/getversion.cmake
PROJECT("Cockatrice" VERSION 2.8.1)
# Set release name if not provided via env/cmake var
if(NOT DEFINED GIT_TAG_RELEASENAME)
set(GIT_TAG_RELEASENAME "Prismatic Bridge")
endif()
# Use c++11 for all targets
set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ ISO Standard")
@@ -47,7 +58,6 @@ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
# Search path for cmake modules
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# Retrieve git version hash
include(getversion)
# Create a header and a cpp file containing the version hash
@@ -56,10 +66,28 @@ include(createversionfile)
# Define a proper install path
if(UNIX)
if(APPLE)
# MacOS X
# macOS
# Due to the special bundle structure ignore
# the prefix eventually set by the user.
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/release)
# Force ccache usage if available
get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
if(RULE_LAUNCH_COMPILE)
MESSAGE(STATUS "Force enabling CCache usage under macOS")
# Set up wrapper scripts
configure_file(${CMAKE_MODULE_PATH}/launch-c.in launch-c)
configure_file(${CMAKE_MODULE_PATH}/launch-cxx.in launch-cxx)
execute_process(COMMAND chmod a+rx
"${CMAKE_BINARY_DIR}/launch-c"
"${CMAKE_BINARY_DIR}/launch-cxx")
# Set Xcode project attributes to route compilation through our scripts
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx")
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx")
endif()
else()
# Linux / BSD
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
@@ -72,16 +100,16 @@ if(UNIX)
endif()
endif()
elseif(WIN32)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/release)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/rundir/${CMAKE_BUILD_TYPE})
endif()
# Treat warnings as errors (Debug builds only)
option(WARNING_AS_ERROR "Treat warnings as errors in debug builds" ON)
# Define proper compilation flags
IF(MSVC)
# Visual Studio:
# Support from Windows XP
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.01")
# Maximum optimization
set(CMAKE_CXX_FLAGS_RELEASE "/Ox /MD")
# Visual Studio: Maximum optimization, disable warning C4251
set(CMAKE_CXX_FLAGS_RELEASE "/Ox /MD /wd4251 ")
# Generate complete debugging information
#set(CMAKE_CXX_FLAGS_DEBUG "/Zi")
ELSEIF (CMAKE_COMPILER_IS_GNUCXX)
@@ -89,7 +117,11 @@ ELSEIF (CMAKE_COMPILER_IS_GNUCXX)
include(CheckCXXCompilerFlag)
set(CMAKE_CXX_FLAGS_RELEASE "-s -O2")
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -O0 -Wall -Wextra -Werror")
if(WARNING_AS_ERROR)
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -O0 -Wall -Wextra -Werror")
else()
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -O0 -Wall -Wextra")
endif()
set(ADDITIONAL_DEBUG_FLAGS -Wcast-align -Wmissing-declarations -Wno-long-long -Wno-error=extra -Wno-error=delete-non-virtual-dtor -Wno-error=sign-compare -Wno-error=missing-declarations)
@@ -102,7 +134,11 @@ ELSEIF (CMAKE_COMPILER_IS_GNUCXX)
ELSE()
# other: osx/llvm, bsd/llvm
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
if(WARNING_AS_ERROR)
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wextra -Werror")
else()
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wextra")
endif()
ENDIF()
# GNU systems need to define the Mersenne exponent for the RNG to compile w/o warning
@@ -110,58 +146,78 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
ADD_DEFINITIONS("-DSFMT_MEXP=19937")
ENDIF()
FIND_PACKAGE(Threads REQUIRED)
# Find Qt5
OPTION(UPDATE_TRANSLATIONS "Update translations on compile" OFF)
MESSAGE(STATUS "UPDATE TRANSLATIONS: ${UPDATE_TRANSLATIONS}")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_lib_suffix 64)
else()
set(_lib_suffix 32)
endif()
IF(WIN32)
FIND_PACKAGE(Qt5Widgets 5.4.0 REQUIRED) # For QSysInfo::buildAbi()
ELSE()
FIND_PACKAGE(Qt5Widgets 5.0.3 REQUIRED)
ENDIF()
if(DEFINED QTDIR${_lib_suffix})
list(APPEND CMAKE_PREFIX_PATH "${QTDIR${_lib_suffix}}")
elseif(DEFINED QTDIR)
list(APPEND CMAKE_PREFIX_PATH "${QTDIR}")
elseif(DEFINED ENV{QTDIR${_lib_suffix}})
list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR${_lib_suffix}}")
elseif(DEFINED ENV{QTDIR})
list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}")
endif()
IF(Qt5Widgets_FOUND)
MESSAGE(STATUS "Found Qt ${Qt5Widgets_VERSION_STRING}")
FIND_PACKAGE(Qt5Core 5.5.0 REQUIRED)
IF(Qt5Core_FOUND)
MESSAGE(STATUS "Found Qt ${Qt5Core_VERSION_STRING}")
# FIX: Qt was built with -reduce-relocations
if (Qt5_POSITION_INDEPENDENT_CODE)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
FIND_PACKAGE(Qt5LinguistTools)
IF(UPDATE_TRANSLATIONS)
IF(NOT Qt5_LUPDATE_EXECUTABLE)
MESSAGE(WARNING "Qt's lupdate not found.")
ENDIF()
ENDIF()
IF(NOT Qt5_LRELEASE_EXECUTABLE)
MESSAGE(WARNING "Qt's lrelease not found.")
ENDIF()
# guess plugins and libraries directory
set(QT_PLUGINS_DIR "${Qt5Core_DIR}/../../../plugins")
get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION)
get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH)
ELSE()
MESSAGE(FATAL_ERROR "No Qt5 found!")
ENDIF()
# Check for translation updates
OPTION(UPDATE_TRANSLATIONS "Update translations on compile" OFF)
MESSAGE(STATUS "UPDATE TRANSLATIONS: ${UPDATE_TRANSLATIONS}")
set(CMAKE_AUTOMOC TRUE)
# Find other needed libraries
FIND_PACKAGE(Protobuf REQUIRED)
IF(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
MESSAGE(FATAL_ERROR "No protoc command found!")
ELSE()
MESSAGE(STATUS "Protoc version ${Protobuf_VERSION} found!")
ENDIF()
#Find OpenSSL
IF(WIN32)
FIND_PACKAGE(Win32SslRuntime)
ENDIF()
#Find VCredist
IF(MSVC)
FIND_PACKAGE(VCredistRuntime)
ENDIF()
# Package builder
set(CPACK_PACKAGE_CONTACT "Gavin Bisesi <Daenyth+github@gmail.com>")
set(CPACK_PACKAGE_CONTACT "Zach Halpern <zahalpern+github@gmail.com>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_NAME})
set(CPACK_PACKAGE_VENDOR "Cockatrice Development Team")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_VERSION_FILENAME}")
if(UNIX)
if(APPLE)
@@ -170,7 +226,6 @@ if(UNIX)
set(CPACK_DMG_FORMAT "UDBZ")
set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}")
set(CPACK_SYSTEM_NAME "OSX")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/cockatrice/resources/appicon.icns")
else()
# linux
@@ -186,24 +241,26 @@ if(UNIX)
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://github.com/Cockatrice/Cockatrice")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5multimedia5-plugins, libqt5svg5")
ENDIF()
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
endif()
elseif(WIN32)
set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR})
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
if("${CMAKE_GENERATOR_PLATFORM}" MATCHES "(x64)")
set(TRICE_IS_64_BIT 1)
else()
set(TRICE_IS_64_BIT 0)
endif()
# Configure file with custom definitions for NSIS.
configure_file(
${CMAKE_MODULE_PATH}/NSIS.definitions.nsh.in
${PROJECT_BINARY_DIR}/NSIS.definitions.nsh
)
endif()
# Configure file with build deployment data for travis
configure_file(
${CMAKE_MODULE_PATH}/bintray_deploy.json.in
${PROJECT_BINARY_DIR}/bintray_deploy.json
)
# include vcredist into the package; NSIS will take care of running it
if(VCREDISTRUNTIME_FOUND)
INSTALL(FILES "${VCREDISTRUNTIME_FILE}" DESTINATION ./)
endif()
endif()
include(CPack)
@@ -229,6 +286,13 @@ if(WITH_ORACLE)
SET(CPACK_INSTALL_CMAKE_PROJECTS "Oracle;Oracle;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS})
endif()
# Compile dbconverter (default on)
option(WITH_DBCONVERTER "build dbconverter" ON)
if(WITH_DBCONVERTER)
add_subdirectory(dbconverter)
SET(CPACK_INSTALL_CMAKE_PROJECTS "Dbconverter;Dbconverter;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS})
endif()
# Compile tests (default off)
option(TEST "build tests" OFF)
if(TEST)

View File

@@ -1,33 +1,25 @@
FROM ubuntu:trusty
MAINTAINER Gavin Bisesi <Daenyth@gmail.com>
FROM ubuntu:bionic
MAINTAINER Zach Halpern <zahalpern+github@gmail.com>
RUN apt-get update && apt-get install -y software-properties-common
RUN apt-add-repository ppa:ubuntu-sdk-team/ppa
RUN add-apt-repository -y ppa:smspillaz/cmake-master
RUN apt-get update && apt-get install -y\
build-essential g++\
build-essential\
cmake\
git\
libprotobuf-dev\
libqt5sql5-mysql\
libmysqlclient-dev\
libqt5websockets5-dev\
protobuf-compiler\
qt5-default\
qtbase5-dev\
qttools5-dev-tools\
qttools5-dev\
libqt5sql5-mysql
qttools5-dev
ENV dir /home/servatrice/code
WORKDIR $dir
RUN mkdir oracle
COPY COPYING COPYING
COPY CMakeLists.txt CMakeLists.txt
COPY cmake/ cmake/
COPY common/ common/
COPY servatrice/ servatrice/
COPY README.md README.md
COPY . /home/servatrice/code/
WORKDIR /home/servatrice/code
WORKDIR build
RUN cmake .. -DWITH_SERVER=1 -DWITH_CLIENT=0 -DWITH_ORACLE=0 &&\
RUN cmake .. -DWITH_SERVER=1 -DWITH_CLIENT=0 -DWITH_ORACLE=0 -DWITH_DBCONVERTER=0 &&\
make &&\
make install
@@ -35,4 +27,5 @@ WORKDIR /home/servatrice
EXPOSE 4747
ENTRYPOINT [ "servatrice" ]
ENTRYPOINT [ "servatrice", "--log-to-console" ]

View File

118
README.md
View File

@@ -2,51 +2,74 @@
---
**Table of Contents** &nbsp;&nbsp; [Cockatrice](#cockatrice) | [Downloads](#downloads) | [Get Involved] (#get-involved-) | [Community](#community-resources) | [Translation](#translation-status-) | [Building](#building--) | [Running](#running) | [License](#license-)
<p align='center'>
<a href="#cockatrice"><b>Cockatrice</b></a> <b>|</b>
<a href="#download-">Download</a> <b>|</b>
<a href="#get-involved--">Get Involved</a> <b>|</b>
<a href="#community-resources">Community</a> <b>|</b>
<a href="#translations-">Translations</a> <b>|</b>
<a href="#build--">Build</a> <b>|</b>
<a href="#run">Run</a> <b>|</b>
<a href="#license-">License</a>
</p>
---
<br><pre>
<b>If you're getting started &#8674; [view our webpage](https://cockatrice.github.io/)</b><br>
<b>If you're trying to get support or suggest changes &#8674; [file an issue](https://github.com/Cockatrice/Cockatrice/issues) ([How?](https://github.com/Cockatrice/Cockatrice/wiki/How-to-Create-a-GitHub-Ticket))</b>
<b>To get started, &#8674; [view our webpage](https://cockatrice.github.io/)</b><br>
<b>To get support or suggest changes &#8674; [file an issue](https://github.com/Cockatrice/Cockatrice/issues) ([How?](https://github.com/Cockatrice/Cockatrice/wiki/How-to-Create-a-GitHub-Ticket-Regarding-Cockatrice))</b>
<b>To help with development, see how to [get involved](#get-involved-)</b>
</pre><br>
# Cockatrice
Cockatrice is an open-source multiplatform supported program for playing tabletop card games over a network. The program's server design prevents any kind of client modifications to gain an unfair advantage in a game. The client also has a built in single-player mode where you can brew without being connected to a server. This project is written in C++ and is using the Qt5 libraries.<br>
Cockatrice is an open-source, multiplatform program for playing tabletop card games over a network. The program's server design prevents users from manipulating the game for unfair advantage. The client also provides a single-player mode, which allows users to brew while offline. This project uses C++ and the Qt5 libraries.<br>
# Downloads
# Download [![Cockatrice Eternal Download Count](https://img.shields.io/github/downloads/cockatrice/cockatrice/total.svg)](https://tooomm.github.io/github-release-stats/?username=Cockatrice&repository=Cockatrice)
We offer downloads for all full releases (recommended) and the latest development versions. Full releases are checkpoints with major feature or UI enhancements between them, but currently we don't have a set schedule for releasing new updates. The development version contains the most recently added features and bugfixes, but can be more unstable. Downloads for development versions are updated automatically with every change.
Downloads are hosted on [BinTray](https://bintray.com/cockatrice/Cockatrice).
Downloads are available for full releases and the current beta version in development. There is no strict release schedule for either of them.
- Latest full release (**recommended**): [ ![Download](https://api.bintray.com/packages/cockatrice/Cockatrice/Cockatrice/images/download.svg) ](https://bintray.com/cockatrice/Cockatrice/Cockatrice/_latestVersion#files)<br>
- Latest `stable` release: [![Download from GitHub Releases](https://img.shields.io/github/release/cockatrice/cockatrice.svg)](https://github.com/cockatrice/cockatrice/releases/latest) [![DL Count on Latest Release](https://img.shields.io/github/downloads/cockatrice/cockatrice/latest/total.svg?label=downloads)](https://tooomm.github.io/github-release-stats/?username=Cockatrice&repository=Cockatrice)<br>
- Stable versions are checkpoints featuring major feature and UI enhancements.
- **Recommended for most users!**
- Latest development version: [ ![Download](https://api.bintray.com/packages/cockatrice/Cockatrice/Cockatrice-git/images/download.svg) ](https://bintray.com/cockatrice/Cockatrice/Cockatrice-git/_latestVersion#files)<br>
*Development builds may not be stable or contain several bugs. Especially if from a branch other than `master`!*
- Latest `beta` release: [![Download from GitHub Pre-Releases](https://img.shields.io/github/release/cockatrice/cockatrice/all.svg)](https://github.com/cockatrice/cockatrice/releases) [![DL Count on Latest Pre-Release](https://img.shields.io/github/downloads-pre/cockatrice/cockatrice/latest/total.svg?label=downloads)](https://tooomm.github.io/github-release-stats/?username=Cockatrice&repository=Cockatrice)
- Beta versions include the most recently added features and bugfixes, but can be unstable.
- To be a Cockatrice Beta Tester, use this version. Find more information [here](https://github.com/Cockatrice/Cockatrice/wiki/Release-Channels)!
# Get Involved [![Discord](https://img.shields.io/discord/314987288398659595?label=Discord&logo=discord&logoColor=white)](https://discord.gg/3Z9yzmA) [![Gitter Chat](https://img.shields.io/gitter/room/Cockatrice/Cockatrice)](https://gitter.im/Cockatrice/Cockatrice)
Join our [Discord community](https://discord.gg/3Z9yzmA) to connect with the project or fellow users of the app. The Cockatrice developers are also available on [Gitter](https://gitter.im/Cockatrice/Cockatrice). Come here to talk about the application, features, or just to hang out.<br>
For support regarding specific servers, please contact that server's admin or forum for support rather than asking here.<br>
# Get Involved [![Gitter chat](https://badges.gitter.im/Cockatrice/Cockatrice.png)](https://gitter.im/Cockatrice/Cockatrice)
To contribute code to the project, please review [the guidelines](https://github.com/Cockatrice/Cockatrice/blob/master/.github/CONTRIBUTING.md).
We maintain two tags for contributors to find issues to work on:
- [Good first issue](https://github.com/Cockatrice/Cockatrice/issues?utf8=%E2%9C%93&q=is%3Aopen%20is%3Aissue%20label%3A%22Good%20first%20issue%22%20): issues tagged in this way provide a simple way to get started. They don't require much experience to be worked on.
- [Help wanted](https://github.com/Cockatrice/Cockatrice/issues?utf8=%E2%9C%93&q=is%3Aopen%20is%3Aissue%20label%3A%22Help%20Wanted%22%20): This tag is used for issues that we are looking for a contributor to work on. Often this is for feature suggestions we are willing to accept, but don't have the time to work on ourselves.
[Chat](https://gitter.im/Cockatrice/Cockatrice) with the Cockatrice developers on Gitter. Come here to talk about the application, features, or just to hang out. For support regarding specific servers, please contact that server's admin or forum for support rather than asking here.<br>
For both tags, we're willing to provide help to contributors in showing them where and how they can make changes, as well as code review for changes they submit.
If you'd like to contribute code to the project, we maintain a tag for "easy" changes on our issue tracker. Issues tagged in this way provide a simple way to get started. [Issues tagged as Easy Changes](https://github.com/Cockatrice/Cockatrice/issues?q=is%3Aopen+is%3Aissue+label%3A%22Easy+Change%22)
Read the long-term project **roadmap** to see planned edits and milestones [here](https://docs.google.com/document/d/1Ewe5uSaRE2nR2pNPMaGmP6gVZdqgFbBgwSscGqIr4W0/edit).
We try to be very responsive to new issues. We'll try to give you advice on how a feature should be implemented / advice on places the codebase is doing something similar before you get too far along with a PR.
We try to be responsive to new issues. We'll provide advice on how best to implement a feature; alternately, we can show you where the codebase is doing something similar before you get too far along.
Cockatrice uses the [Google Developer Documentation Style Guide](https://developers.google.com/style/) to ensure consistent documentation. We encourage you to improve the documentation by suggesting edits based on this guide.
# Community Resources
- [Cockatrice Official Site](https://cockatrice.github.io)
- [Cockatrice Official Wiki](https://github.com/Cockatrice/Cockatrice/wiki)
- [Cockatrice Official Discord](https://discord.gg/3Z9yzmA)
- [reddit r/Cockatrice](https://reddit.com/r/cockatrice)
# Translation Status [![Cockatrice on Transiflex](https://tx-assets.scdn5.secure.raxcdn.com/static/charts/images/tx-logo-micro.c5603f91c780.png)](https://www.transifex.com/projects/p/cockatrice/)
# Translations [![Transifex Project](https://img.shields.io/badge/translate-on%20transifex-brightgreen)](https://www.transifex.com/projects/p/cockatrice/)
Cockatrice uses Transifex for translations. You can help us bring Cockatrice and Oracle to your language or just edit single wordings right from within your browser by simply visiting our [Transifex project page](https://www.transifex.com/projects/p/cockatrice/).<br>
Cockatrice uses Transifex for translations. You can help us bring Cockatrice and Oracle to your language or just edit single wordings right from within your browser by visiting our [Transifex project page](https://www.transifex.com/projects/p/cockatrice/).<br>
| Cockatrice | Oracle |
|:-:|:-:|
@@ -55,17 +78,18 @@ Cockatrice uses Transifex for translations. You can help us bring Cockatrice and
Check out our [Translator FAQ](https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ) for more information about contributing!<br>
# Building [![Travis Build Status - master](https://travis-ci.org/Cockatrice/Cockatrice.svg?branch=master)](https://travis-ci.org/Cockatrice/Cockatrice) [![Appveyor Build Status - master](https://ci.appveyor.com/api/projects/status/lp5h0dhk4mhmeps7/branch/master?svg=true)](https://ci.appveyor.com/project/Daenyth/cockatrice/branch/master)
# Build [![CI Desktop](https://github.com/Cockatrice/Cockatrice/actions/workflows/desktop-build.yml/badge.svg?branch=master&event=push)](https://github.com/Cockatrice/Cockatrice/actions/workflows/desktop-build.yml?query=branch%3Amaster+event%3Apush) [![CI Web](https://github.com/Cockatrice/Cockatrice/actions/workflows/web-build.yml/badge.svg?branch=master&event=push)](https://github.com/Cockatrice/Cockatrice/actions/workflows/web-build.yml?query=branch%3Amaster+event%3Apush)
**Detailed compiling instructions are on the Cockatrice wiki under [Compiling Cockatrice](https://github.com/Cockatrice/Cockatrice/wiki/Compiling-Cockatrice)**
**Detailed compiling instructions can be found on the Cockatrice wiki under [Compiling Cockatrice](https://github.com/Cockatrice/Cockatrice/wiki/Compiling-Cockatrice)**
Dependencies:
- [Qt](https://www.qt.io/developers/)
- [protobuf](https://github.com/google/protobuf)
Dependencies: *(for minimum requirements search our [CMake file](https://github.com/Cockatrice/Cockatrice/blob/master/CMakeLists.txt))*
- [Qt](https://www.qt.io/developers/)
- [protobuf](https://github.com/protocolbuffers/protobuf)
- [CMake](https://www.cmake.org/)
Oracle can optionally use zlib to load zipped files:
- [zlib](http://www.zlib.net/) (no https!)
Oracle can optionally use zlib and xz to load compressed files:
- [xz](https://tukaani.org/xz/)
- [zlib](https://www.zlib.net/)
To compile:
@@ -89,33 +113,53 @@ The following flags can be passed to `cmake`:
- `-DWITH_SERVER=1` Whether to build the server (default 0 = no).
- `-DWITH_CLIENT=0` Whether to build the client (default 1 = yes).
- `-DWITH_ORACLE=0` Whether to build oracle (default 1 = yes).
- `-DPORTABLE=1` Build portable versions of client & oracle (default 0 = no).
- `-DCMAKE_BUILD_TYPE=Debug` Compile in debug mode. Enables extra logging output, debug symbols, and much more verbose compiler warnings (default `Release`).
- `-DWARNING_AS_ERROR=0` Whether to treat compilation warnings as errors in debug mode (default 1 = yes).
- `-DUPDATE_TRANSLATIONS=1` Configure `make` to update the translation .ts files for new strings in the source code. Note: Running `make clean` will remove the .ts files (default 0 = no).
- `-DTEST=1` Enable regression tests (default 0 = no). Note: needs googletest, will be downloaded on the fly if unavailable. To run tests: ```make test```.
# Running
# Run
`cockatrice` is the game client
`oracle` fetches card data
`servatrice` is the server<br>
`Cockatrice` is the game client<br>
`Oracle` fetches card data<br>
`Servatrice` is the server<br>
**Servatrice Docker container**
#### Servatrice Docker container
You can run an instance of Servatrice (the Cockatrice server) using [Docker](https://www.docker.com/what-docker) and the Cockatrice Dockerfile.<br>
A Dockerfile is provided to run Servatrice (the Cockatrice server) using [Docker](https://www.docker.com/what-docker).<br>
You just need to create an image from the Dockerfile<br>
First, create an image from the Dockerfile<br>
`cd /path/to/Cockatrice-Repo/`
`docker build -t servatrice .`<br>
And then run it<br>
`docker run -i -p 4747:4747/tcp -t servatrice:latest`<br>
Please note that running this command will expose the TCP port 4747 of the docker container to permit connections to the server.<br>
More infos on how to use Servatrice with Docker can be found in our [wiki](https://github.com/Cockatrice/Cockatrice/wiki/Setting-up-Servatrice#using-docker).
>Note: Running this command exposes the TCP port 4747 of the docker container<br>
to permit connections to the server.
Find more information on how to use Servatrice with Docker in our [wiki](https://github.com/Cockatrice/Cockatrice/wiki/Setting-up-Servatrice#using-docker).
**Docker compose**
There is also a docker-compose file available which will configure and run both a MySQL server and Servatrice. The docker-compose setup scripts can be found in the `servatrice/docker` folder and vary only slightly from the default sql and server .ini files. The setup scripts can either be modified in place, or docker-compose can mount alternative files into the images, as you prefer.
To run Servatrice via docker-compose, first install docker-compose following the [install instructions](https://docs.docker.com/compose/install/). Once installed, run the following from the root of the repository:
```bash
docker-compose build # Build the Servatrice image using the same Dockerfile as above.
docker-compose up # Setup and run both the MySQL server and Servatrice.
```
>Note: Similar to the above Docker setup, this will expose TCP ports 4747 and 4748.
>Note: The first time running the docker-compose setup, the MySQL server will take a little time to run the initial setup scripts. Due to this, the Servatrice instance may fail the first few attempts to connect to the database. Servatrice is set to `restart: always` in the docker-compose.yml, which will allow it to continue attempting to start up. Once the MySQL scripts have completed, Servatrice should then connect automatically on the next attempt.
**Docker compose in Windows**
A out of box working docker-compose file has been added to help setup in Windows.
Docker in Windows requires additional steps in form of using Docker Desktop to allow resource sharing from the drive the volumes are mapped from, as well as potential workarounds needed to get file sharing working in Windows. This [StackOverflow discussion sheds some light on it](https://stackoverflow.com/questions/42203488/settings-to-windows-firewall-to-allow-docker-for-windows-to-share-drive)
# License [![GPLv2 License](https://img.shields.io/badge/License-GPLv2-blue.svg)](https://github.com/Cockatrice/Cockatrice/blob/master/COPYING)
Cockatrice is free software, licensed under the [GPLv2](https://github.com/Cockatrice/Cockatrice/blob/master/COPYING).
# License [![GPLv2 License](https://img.shields.io/github/license/Cockatrice/Cockatrice.svg)](https://github.com/Cockatrice/Cockatrice/blob/master/LICENSE)
Cockatrice is free software, licensed under the [GPLv2](https://github.com/Cockatrice/Cockatrice/blob/master/LICENSE).

27
TODO.md
View File

@@ -1,27 +0,0 @@
#TODOs
This is an unordered list of possible todo items for Cockatrice.
Note that "improve" and "write" always also means: "document and comment"
##Improve packaging:
* Improve nsis file git hash extraction, it only works if the build directory is cleared as version_string.cpp does not seem to get updated by git pull/cmake
* Create script/... for creating Linux packages (deb, rpm, ebuild, ...) or at least an official tarball/git tags; package maintainers dislike using git snapshots so much that they rather ignore software without stable tarballs.
##Scripts
* Write example init script for servatrice.
##Create developer documentation:
* Create developer manual
* Add comments to code
* Describe which components exist and how they work and interact
* Describe the *.proto files
* Comment and document servatrice.sql
* Document everything!1!!
##Else
* Update SFMT library (http://www.math.sci.hiroshima-u.ac.jp/~m-mat@math.sci.hiroshima-u.ac.jp/MT/SFMT/) in common/sfmt and adapt common/rng_sfmt.cpp
* Move hardcoded URLs (especially from oracle and cockatrice) into a config file.
* Search git log for useful information/problems/bugs/...

View File

@@ -1,101 +0,0 @@
version: 0.0.1-branch-{branch}-build-{build}
cache:
- c:\protobuf
- c:\protoc
- c:\zlib
environment:
matrix:
- vc_arch: amd64
choco_arch:
nuget_arch: x64
target_arch: x86_64
qt_ver: 5.6\msvc2013_64
bintray_path: Win64
MYSQL_DRIVER_URL: https://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.1.6-winx64.zip
MYSQL_DRIVER_ARCHIVE: mysql-connector-c-6.1.6-winx64.zip
MYSQL_DRIVER_NAME: mysql-connector-c-6.1.6-winx64
- vc_arch: amd64_x86 # cross-compile from amd64 to x86
choco_arch: --x86
nuget_arch: Win32
target_arch: x86
qt_ver: 5.6\msvc2013
bintray_path: Win32
MYSQL_DRIVER_URL: https://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.1.6-win32.zip
MYSQL_DRIVER_ARCHIVE: mysql-connector-c-6.1.6-win32.zip
MYSQL_DRIVER_NAME: mysql-connector-c-6.1.6-win32
install:
- systeminfo
- ps: |
if (Test-Path c:\protoc) {
echo "using protoc from cache"
} else {
Invoke-WebRequest "https://github.com/google/protobuf/releases/download/v2.6.1/protoc-2.6.1-win32.zip" -OutFile c:\protoc-2.6.1-win32.zip
c:\cygwin\bin\bash -lc "cd /cygdrive/c; 7z x -y protoc-2.6.1-win32.zip -oc:\protoc"
}
- ps: |
if (Test-Path c:\protobuf) {
echo "using protobuf from cache"
} else {
nuget install protobuf-v120 -OutputDirectory c:\protobuf
}
- ps: |
if (Test-Path c:\zlib) {
echo "using zlib from cache"
} else {
nuget install zlib -OutputDirectory c:\zlib
}
# install mysql connector
- curl -kLO %MYSQL_DRIVER_URL%
- 7z x %MYSQL_DRIVER_ARCHIVE% -oc:\ >nul
build_script:
- mkdir build
- cd build
- '"c:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/vcvarsall" %vc_arch%'
- path
- ps: |
$zlibinc = c:\cygwin\bin\find /cygdrive/c/zlib/ -path '*v120*/zlib.h'
$zlibinc = c:\cygwin\bin\dirname $zlibinc
$zlibinc = c:\cygwin\bin\cygpath -m $zlibinc
$zliblib = c:\cygwin\bin\find /cygdrive/c/zlib/ -path "*v120*/$env:nuget_arch/Release/zlib.lib"
$zliblib = c:\cygwin\bin\cygpath -m $zliblib
$protoinc = c:\cygwin\bin\find /cygdrive/c/protobuf/ -name 'google'
$protoinc = c:\cygwin\bin\dirname $protoinc
$protoinc = c:\cygwin\bin\cygpath -m $protoinc
$protolib = c:\cygwin\bin\find /cygdrive/c/protobuf/ -path "*/lib/$env:nuget_arch/v120/Release/libprotobuf.lib"
$protolib = c:\cygwin\bin\cygpath -m $protolib
$protoc = c:\cygwin\bin\find /cygdrive/c/protoc/ -name "protoc.exe"
$protoc = c:\cygwin\bin\cygpath -m $protoc
$mysqldll = c:\cygwin\bin\find /cygdrive/c/$env:MYSQL_DRIVER_NAME -name "libmysql.dll"
$mysqldll = c:\cygwin\bin\cygpath -m $mysqldll
Write-Output "ZLIBINC = $zlibinc"
Write-Output "ZLIBLIB = $zliblib"
Write-Output "PROTOINC = $protoinc"
Write-Output "PROTOLIB = $protolib"
Write-Output "PROTOC = $protoc"
Write-Output "MYSQLDLL = $mysqldll"
cmake .. "-GNMake Makefiles" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_PREFIX_PATH=c:/Qt/$env:qt_ver" "-DWITH_SERVER=1" "-DZLIB_INCLUDE_DIR=$zlibinc" "-DZLIB_LIBRARY=$zliblib" "-DPROTOBUF_INCLUDE_DIR=$protoinc" "-DPROTOBUF_LIBRARIES=$protolib" "-DPROTOBUF_LIBRARIES=$protolib" "-DPROTOBUF_LIBRARY=$protolib" "-DPROTOBUF_PROTOC_EXECUTABLE=$protoc" "-DMYSQLCLIENT_LIBRARIES=$mysqldll"
- nmake package
- c:\cygwin\bin\ls -l
- ps: |
$exe = dir -name *.exe
$new_name = $exe.Replace(".exe", "-${env:target_arch}_qt5.exe")
Push-AppveyorArtifact $exe -FileName $new_name
$cmake_name = $exe.Replace(".exe", "-${env:target_arch}_qt5.cmake.txt")
Push-AppveyorArtifact CMakeCache.txt -FileName $cmake_name
$json = New-Object PSObject
(New-Object PSObject | Add-Member -PassThru NoteProperty bin $new_name | Add-Member -PassThru NoteProperty cmake $cmake_name | Add-Member -PassThru NoteProperty commit $env:APPVEYOR_REPO_COMMIT) | ConvertTo-JSON | Out-File -FilePath "latest-$env:target_arch" -Encoding ASCII
Push-AppveyorArtifact "latest-$env:target_arch"
$bt_password = ConvertTo-SecureString $Env:BINTRAY_APIKEY -AsPlainText -Force
$bt_credentials = New-Object System.Management.Automation.PSCredential ($Env:BINTRAY_USER, $bt_password)
$exe -match "Cockatrice-(?<content>.*)\.exe"
$version = $matches['content']
$bt_headers = @{
"X-Bintray-Package" = "Cockatrice-git";
"X-Bintray-Version" = $version;
"X-Bintray-Publish" = 1;
"X-Bintray-Override" = 1;
}
$url = "https://api.bintray.com/content/cockatrice/Cockatrice/$env:bintray_path/$new_name"
$result = Invoke-WebRequest -Uri $url -Credential $bt_credentials -Method PUT -Headers $bt_headers -InFile "$exe"
Write-Host $result
test: off

210
clangify.sh Executable file
View File

@@ -0,0 +1,210 @@
#!/bin/bash
# This script will run clang-format on all modified, non-3rd-party C++/Header files.
# Never, ever, should this recieve a path with a newline in it. Don't bother proofing it for that.
# go to the project root directory, this file should be located in the project root directory
cd "${BASH_SOURCE%/*}/" || exit 2 # could not find path, this could happen with special links etc.
# defaults
include=("common" \
"cockatrice/src" \
"oracle/src" \
"servatrice/src" \
"tests")
exclude=("servatrice/src/smtp" \
"common/sfmt" \
"common/lib" \
"oracle/src/zip" \
"oracle/src/lzma" \
"oracle/src/qt-json")
exts=("cpp" "h" "proto")
cf_cmd="clang-format"
branch="origin/master"
# parse options
while [[ $@ ]]; do
case "$1" in
'-b'|'--branch')
branch=$2
set_branch=1
shift 2
;;
'-c'|'--color-diff')
color=" --color=always"
mode=diff
shift
;;
'-d'|'--diff')
mode=diff
shift
;;
'-h'|'--help')
cat <<EOM
A bash script to automatically format your code using clang-format.
If no options are given, all dirty source files are edited in place.
If <dir>s are given, all source files in those directories of the project root
path are formatted. To only format changed files in these directories use the
--branch option in combination. <dir> has to be a path relative to the project
root path or a full path inside $PWD.
. can not be specified as a dir, if you really want to format everything use */.
USAGE: $0 [option] [--branch <git branch or object>] [<dir> ...]
DEFAULTS:
Current includes are:
${include[@]/%/
}
Default excludes are:
${exclude[@]/%/
}
OPTIONS:
-b, --branch <branch>
Compare to this git branch and format only files that differ.
If unspecified it defaults to origin/master.
To not compare to a branch this has to be explicitly set to "".
When not comparing to a branch, git will not be used at all and every
source file in the entire project will be parsed.
-c, --color-diff
Display a colored diff. Implies --diff.
Only available on systems which support 'diff --color'.
-d, --diff
Display a diff. Implies --test.
-h, --help
Display this message and exit.
-n, --names
Display a list of filenames that require formatting. Implies --test.
-t, --test
Do not edit files in place. Set exit code to 1 if changes are required.
--cf-version
Print the version of clang-format being used before continuing.
EXIT CODES:
0 on a successful format or if no files require formatting.
1 if a file requires formatting.
2 if given incorrect arguments.
3 if clang-format could not be found.
EXAMPLES:
$0 --test \$PWD || echo "code requires formatting"
Tests if the source files in the current directory are correctly
formatted and prints an error message if formatting is required.
$0 --branch $USER/patch-2 ${include[0]}
Formats all changed files compared to the git branch "$USER/patch-2"
in the directory ${include[0]}.
EOM
exit 0
;;
'-n'|'--names')
mode=name
shift
;;
'-t'|'--test')
mode=code
shift
;;
'--cf-version')
print_version=1
shift
;;
'--')
shift
;;
*)
if next_dir=$(cd "$1" && pwd); then
if [[ ${next_dir#$PWD/} == /* ]]; then
echo "error in parsing arguments of $0: $next_dir is not in $PWD" >&2
exit 2 # input error
elif ! [[ $set_include ]]; then
include=() # remove default includes
set_include=1
fi
include+=("${next_dir#$PWD/}")
else
echo "error in parsing arguments of $0: $PWD/$1 is not a directory" >&2
exit 2 # input error
fi
if ! [[ $set_branch ]]; then
unset branch # unset branch if not set explicitly
fi
shift
;;
esac
done
# check availability of clang-format
if ! hash $cf_cmd 2>/dev/null; then
echo "could not find $cf_cmd" >&2
# find any clang-format-x.x in /usr/bin
cf_cmd=$(find /usr/bin -regex '.*/clang-format-[0-9]+\.[0-9]+' -print -quit)
if [[ $cf_cmd ]]; then
echo "found $cf_cmd instead" >&2
else
exit 3 # special exit code for missing dependency
fi
fi
if [[ $branch ]]; then
# get all dirty files through git
if ! base=$(git merge-base ${branch} HEAD); then
echo "could not find git merge base" >&2
exit 2 # input error
fi
declare -a reg
for ex in ${exts[@]}; do
reg+=(${include[@]/%/.*\\.$ex\$})
done
names=$(git diff --diff-filter=d --name-only $base | grep ${reg[@]/#/-e ^})
else
names=$(find ${include[@]} -type f -false ${exts[@]/#/-o -name *\\.})
fi
# filter excludes
names=$(<<<"$names" grep -v ${exclude[@]/#/-e ^})
if ! [[ $names ]]; then
exit 0 # nothing to format means format is successful!
fi
# optionally print version
[[ $print_version ]] && $cf_cmd -version
# format
case $mode in
diff)
declare -i code=0
for name in ${names[@]}; do
if ! $cf_cmd "$name" | diff "$name" - -p $color; then
code=1
fi
done
exit $code
;;
name)
declare -i code=0
for name in ${names[@]}; do
if ! $cf_cmd "$name" | diff "$name" - -q >/dev/null; then
echo "$name"
code=1
fi
done
exit $code
;;
code)
for name in ${names[@]}; do
$cf_cmd "$name" | diff "$name" - -q >/dev/null || exit 1
done
;;
*)
$cf_cmd -i $names
;;
esac

View File

@@ -0,0 +1,18 @@
# Find the LibExecinfo library - FreeBSD only
FIND_PATH(LIBEXECINFO_INCLUDE_DIR execinfo.h)
FIND_LIBRARY(LIBEXECINFO_LIBRARY NAMES execinfo)
IF(LIBEXECINFO_INCLUDE_DIR AND LIBEXECINFO_LIBRARY)
SET(LIBEXECINFO_FOUND TRUE)
ENDIF()
IF(LIBEXECINFO_FOUND)
IF(NOT LIBEXECINFO_FIND_QUIETLY)
MESSAGE(STATUS "Found LibExecinfo: ${EXECINFO_LIBRARY}")
ENDIF()
ELSE()
IF(LIBEXECINFO_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find LibExecinfo")
ENDIF()
ENDIF()

View File

@@ -0,0 +1,36 @@
# Find the MS Visual Studio VC redistributable package
if (WIN32)
set(VCREDISTRUNTIME_FOUND "NO")
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64-bit
set(REDIST_ARCH x64)
else()
set(REDIST_ARCH x86)
endif()
set(REDIST_FILE vcredist_${REDIST_ARCH}.exe)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
include(InstallRequiredSystemLibraries)
# Check if the list contains minimum one element, to get the path from
list(LENGTH CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS libsCount)
if (libsCount GREATER 0)
list(GET CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS 0 _path)
get_filename_component(_path ${_path} DIRECTORY)
get_filename_component(_path ${_path}/../../ ABSOLUTE)
if (EXISTS "${_path}/${REDIST_FILE}") # VS 2017
set(VCREDISTRUNTIME_FOUND "YES")
set(VCREDISTRUNTIME_FILE ${_path}/${REDIST_FILE})
endif()
endif()
if(VCREDISTRUNTIME_FOUND)
message(STATUS "Found VCredist ${VCREDISTRUNTIME_FILE}")
else()
message(WARNING "Could not find VCredist package. It's not required for compiling, but needs to be available at runtime.")
endif()
endif()

View File

@@ -1,69 +1,77 @@
# Find the OpenSSL runtime libraries (.dll) for Windows that
# will be needed by Qt in order to access https urls.
if (WIN32)
# Get standard installation paths for OpenSSL under Windows
# http://www.slproweb.com/products/Win32OpenSSL.html
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
# target win64
set(_OPENSSL_ROOT_HINTS
${OPENSSL_ROOT_DIR}
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
ENV OPENSSL_ROOT_DIR
)
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
set(_OPENSSL_ROOT_PATHS
"${_programfiles}/OpenSSL-Win64"
"C:/OpenSSL-Win64/"
)
unset(_programfiles)
else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
# target win32
set(_OPENSSL_ROOT_HINTS
${OPENSSL_ROOT_DIR}
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
ENV OPENSSL_ROOT_DIR
)
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
set(_OPENSSL_ROOT_PATHS
"${_programfiles}/OpenSSL"
"${_programfiles}/OpenSSL-Win32"
"C:/OpenSSL/"
"C:/OpenSSL-Win32/"
)
unset(_programfiles)
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
else ()
set(_OPENSSL_ROOT_HINTS
${OPENSSL_ROOT_DIR}
ENV OPENSSL_ROOT_DIR
)
endif ()
set(_OPENSSL_ROOT_HINTS_AND_PATHS
HINTS ${_OPENSSL_ROOT_HINTS}
PATHS ${_OPENSSL_ROOT_PATHS}
)
# For OpenSSL < 1.1, they are named libeay32 and ssleay32 and even if the dll is 64bit, it's still suffixed as *32.dll
# For OpenSSL >= 1.1, they are named libcrypto and libssl with no suffix
FIND_FILE(WIN32SSLRUNTIME_LIBEAY NAMES libeay32.dll libcrypto.dll ${_OPENSSL_ROOT_HINTS_AND_PATHS})
FIND_FILE(WIN32SSLRUNTIME_SSLEAY NAMES ssleay32.dll libssl.dll ${_OPENSSL_ROOT_HINTS_AND_PATHS})
IF(WIN32SSLRUNTIME_LIBEAY AND WIN32SSLRUNTIME_SSLEAY)
SET(WIN32SSLRUNTIME_LIBRARIES "${WIN32SSLRUNTIME_LIBEAY}" "${WIN32SSLRUNTIME_SSLEAY}")
SET(WIN32SSLRUNTIME_FOUND "YES")
message(STATUS "Found OpenSSL ${WIN32SSLRUNTIME_LIBRARIES}")
ELSE()
SET(WIN32SSLRUNTIME_FOUND "NO")
message(WARNING "Could not find OpenSSL runtime libraries. They are not required for compiling, but needs to be available at runtime.")
ENDIF()
MARK_AS_ADVANCED(
WIN32SSLRUNTIME_LIBEAY
WIN32SSLRUNTIME_SSLEAY
)
# Find the OpenSSL runtime libraries (.dll) for Windows that
# will be needed by Qt in order to access https urls.
if (WIN32)
# Get standard installation paths for OpenSSL under Windows
# http://www.slproweb.com/products/Win32OpenSSL.html
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
# target win64
set(_OPENSSL_ROOT_HINTS
${OPENSSL_ROOT_DIR}
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
ENV OPENSSL_ROOT_DIR
)
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
set(_OPENSSL_ROOT_PATHS
"C:/Tools/vcpkg/installed/x64-windows/bin"
"${_programfiles}/OpenSSL-Win64"
"C:/OpenSSL-Win64/"
)
unset(_programfiles)
else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
# target win32
set(_OPENSSL_ROOT_HINTS
${OPENSSL_ROOT_DIR}
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
ENV OPENSSL_ROOT_DIR
)
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
set(_OPENSSL_ROOT_PATHS
"C:/Tools/vcpkg/installed/x86-windows/bin"
"${_programfiles}/OpenSSL"
"${_programfiles}/OpenSSL-Win32"
"C:/OpenSSL/"
"C:/OpenSSL-Win32/"
)
unset(_programfiles)
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
else ()
set(_OPENSSL_ROOT_HINTS
${OPENSSL_ROOT_DIR}
ENV OPENSSL_ROOT_DIR
)
endif ()
set(_OPENSSL_ROOT_HINTS_AND_PATHS
HINTS ${_OPENSSL_ROOT_HINTS}
PATHS ${_OPENSSL_ROOT_PATHS}
)
# For OpenSSL < 1.1, they are named libeay32 and ssleay32 and even if the dll is 64bit, it's still suffixed as *32.dll
# For OpenSSL >= 1.1, they are named libcrypto and libssl with no suffix
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
# target win64
FIND_FILE(WIN32SSLRUNTIME_LIBEAY NAMES libcrypto-1_1-x64.dll libcrypto.dll libeay32.dll ${_OPENSSL_ROOT_HINTS_AND_PATHS})
FIND_FILE(WIN32SSLRUNTIME_SSLEAY NAMES libssl-1_1-x64.dll libssl.dll ssleay32.dll ${_OPENSSL_ROOT_HINTS_AND_PATHS})
else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
# target win32
FIND_FILE(WIN32SSLRUNTIME_LIBEAY NAMES libcrypto-1_1.dll libcrypto.dll libeay32.dll ${_OPENSSL_ROOT_HINTS_AND_PATHS})
FIND_FILE(WIN32SSLRUNTIME_SSLEAY NAMES libssl-1_1.dll libssl.dll ssleay32.dll ${_OPENSSL_ROOT_HINTS_AND_PATHS})
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
IF(WIN32SSLRUNTIME_LIBEAY AND WIN32SSLRUNTIME_SSLEAY)
SET(WIN32SSLRUNTIME_LIBRARIES "${WIN32SSLRUNTIME_LIBEAY}" "${WIN32SSLRUNTIME_SSLEAY}")
SET(WIN32SSLRUNTIME_FOUND "YES")
message(STATUS "Found OpenSSL ${WIN32SSLRUNTIME_LIBRARIES}")
ELSE()
SET(WIN32SSLRUNTIME_FOUND "NO")
message(WARNING "Could not find OpenSSL runtime libraries. They are not required for compiling, but needs to be available at runtime.")
ENDIF()
MARK_AS_ADVANCED(
WIN32SSLRUNTIME_LIBEAY
WIN32SSLRUNTIME_SSLEAY
)

View File

@@ -35,4 +35,4 @@
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
</plist>

View File

@@ -1 +1,2 @@
!define NSIS_SOURCE_PATH "@PROJECT_SOURCE_DIR@"
!define NSIS_SOURCE_PATH "@PROJECT_SOURCE_DIR@"
!define NSIS_IS_64_BIT @TRICE_IS_64_BIT@

View File

@@ -1,14 +1,22 @@
!include ..\..\..\NSIS.definitions.nsh
!include "MUI2.nsh"
!include "FileFunc.nsh"
Name "@CPACK_PACKAGE_NAME@"
BrandingText "@CPACK_PACKAGE_NAME@-@CPACK_PACKAGE_VERSION_MAJOR@"
BrandingText "@CPACK_PACKAGE_FILE_NAME@"
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
SetCompressor /SOLID lzma
InstallDir "$PROGRAMFILES\Cockatrice"
!define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
RequestExecutionlevel highest
SetCompressor LZMA
Var NormalDestDir
Var PortableDestDir
Var PortableMode
!include LogicLib.nsh
!include FileFunc.nsh
!include MUI2.nsh
!include x64.nsh
!define MUI_ABORTWARNING
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSIS_SOURCE_PATH}\cmake\leftimage.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSIS_SOURCE_PATH}\cmake\leftimage.bmp"
@@ -20,7 +28,9 @@ InstallDir "$PROGRAMFILES\Cockatrice"
!define MUI_FINISHPAGE_RUN_TEXT "Run 'Cockatrice' now"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${NSIS_SOURCE_PATH}\COPYING"
!insertmacro MUI_PAGE_LICENSE "${NSIS_SOURCE_PATH}\LICENSE"
Page Custom PortableModePageCreate PortableModePageLeave
!define MUI_PAGE_CUSTOMFUNCTION_PRE componentsPagePre
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
@@ -31,46 +41,171 @@ InstallDir "$PROGRAMFILES\Cockatrice"
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE English
Function .onInit
${If} ${NSIS_IS_64_BIT} == 1 #NSIS 64bit
${IfNot} ${RunningX64}
MessageBox MB_OK|MB_ICONSTOP "This version of Cockatrice requires a 64-bit Windows system."
Abort
${EndIf}
StrCpy $NormalDestDir "$ProgramFiles64\Cockatrice"
SetRegView 64
${Else} #NSIS 32bit
${If} ${RunningX64}
MessageBox MB_OK|MB_ICONEXCLAMATION \
"You are about to install a 32-bit version of Cockatrice on a 64-bit Windows system.$\n\
We advise you to use the correct 64-bit installer instead to get around potential issues.$\n$\n\
Download from our webpage: https://cockatrice.github.io"
${EndIf}
StrCpy $NormalDestDir "$ProgramFiles\Cockatrice"
${EndIf}
StrCpy $PortableDestDir "$Desktop\CockatricePortable"
${GetParameters} $9
ClearErrors
${GetOptions} $9 "/?" $8
${IfNot} ${Errors}
MessageBox MB_ICONINFORMATION|MB_SETFOREGROUND "\
/PORTABLE : Install in portable mode$\n\
/S : Silent install$\n\
/D=%directory% : Specify destination directory$\n"
Quit
${EndIf}
ClearErrors
${GetOptions} $9 "/PORTABLE" $8
${IfNot} ${Errors}
StrCpy $PortableMode 1
StrCpy $0 $PortableDestDir
${Else}
StrCpy $PortableMode 0
StrCpy $0 $NormalDestDir
${If} ${Silent}
Call RequireAdmin
${EndIf}
${EndIf}
${If} $InstDir == ""
; User did not use /D to specify a directory,
; we need to set a default based on the install mode
StrCpy $InstDir $0
${EndIf}
Call SetModeDestinationFromInstdir
FunctionEnd
Function un.onInit
${If} ${NSIS_IS_64_BIT} == 1
SetRegView 64
${EndIf}
FunctionEnd
Function RequireAdmin
UserInfo::GetAccountType
Pop $8
${If} $8 != "admin"
MessageBox MB_ICONSTOP "You need administrator rights to install Cockatrice"
SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
Abort
${EndIf}
FunctionEnd
Function SetModeDestinationFromInstdir
${If} $PortableMode = 0
StrCpy $NormalDestDir $InstDir
${Else}
StrCpy $PortableDestDir $InstDir
${EndIf}
FunctionEnd
Function PortableModePageCreate
Call SetModeDestinationFromInstdir ; If the user clicks BACK on the directory page we will remember their mode specific directory
!insertmacro MUI_HEADER_TEXT "Install Mode" "Choose how you want to install Cockatrice."
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 10u 100% 24u "Select install mode:"
Pop $0
${NSD_CreateRadioButton} 30u 50u -30u 8u "Normal installation"
Pop $1
${NSD_CreateRadioButton} 30u 70u -30u 8u "Portable mode (all files in a single folder)"
Pop $2
${If} $PortableMode = 0
SendMessage $1 ${BM_SETCHECK} ${BST_CHECKED} 0
${Else}
SendMessage $2 ${BM_SETCHECK} ${BST_CHECKED} 0
${EndIf}
nsDialogs::Show
FunctionEnd
Function PortableModePageLeave
${NSD_GetState} $1 $0
${If} $0 <> ${BST_UNCHECKED}
StrCpy $PortableMode 0
StrCpy $InstDir $NormalDestDir
Call RequireAdmin
${Else}
StrCpy $PortableMode 1
StrCpy $InstDir $PortableDestDir
${EndIf}
FunctionEnd
Function componentsPagePre
${If} $PortableMode = 0
SetShellVarContext all
# uninstall 32bit version
SetRegView 32
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString"
StrCmp $R0 "" done32
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "A previous version of Cockatrice must be uninstalled before installing the new one." IDOK uninst32
Abort
uninst32:
ClearErrors
ExecWait "$R0"
done32:
# uninstall 64bit version
${If} ${NSIS_IS_64_BIT} == 1
SetRegView 64
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString"
StrCmp $R0 "" done64
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "A previous version of Cockatrice must be uninstalled before installing the new one." IDOK uninst64
Abort
uninst64:
ClearErrors
ExecWait "$R0"
done64:
${EndIf}
${Else}
Abort
${EndIf}
FunctionEnd
Section "Application" SecApplication
SetShellVarContext all
SetOutPath "$INSTDIR"
@CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@
@CPACK_NSIS_FULL_INSTALL@
SetShellVarContext all
SetOutPath "$INSTDIR"
WriteUninstaller "$INSTDIR\uninstall.exe"
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayName" "Cockatrice"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayIcon" "$INSTDIR\cockatrice.exe"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "EstimatedSize" "$0"
SectionEnd
Section "Update configuration" SecUpdateConfig
SetShellVarContext current
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$LOCALAPPDATA\Cockatrice\cards.xml"
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "tokendatabase" "$LOCALAPPDATA\Cockatrice\tokens.xml"
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$LOCALAPPDATA\Cockatrice\decks"
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$LOCALAPPDATA\Cockatrice\pics"
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\replays" "pics" "$LOCALAPPDATA\Cockatrice\replays"
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$INSTDIR\sounds"
SectionEnd
Section "Start menu item" SecStartMenu
SetShellVarContext all
createDirectory "$SMPROGRAMS\Cockatrice"
createShortCut "$SMPROGRAMS\Cockatrice\Cockatrice.lnk" "$INSTDIR\cockatrice.exe"
createShortCut "$SMPROGRAMS\Cockatrice\Oracle.lnk" "$INSTDIR\oracle.exe"
createShortCut "$SMPROGRAMS\Cockatrice\Servatrice.lnk" "$INSTDIR\servatrice.exe"
SectionEnd
Section "un.Application" UnSecApplication
SetShellVarContext all
${If} $PortableMode = 1
${AndIf} ${FileExists} "$INSTDIR\portable.dat"
; upgrade portable mode
RMDir /r "$INSTDIR\plugins"
RMDir /r "$INSTDIR\sounds"
RMDir /r "$INSTDIR\themes"
@@ -78,6 +213,7 @@ Section "un.Application" UnSecApplication
Delete "$INSTDIR\uninstall.exe"
Delete "$INSTDIR\cockatrice.exe"
Delete "$INSTDIR\oracle.exe"
Delete "$INSTDIR\dbconverter.exe"
Delete "$INSTDIR\servatrice.exe"
Delete "$INSTDIR\Qt*.dll"
Delete "$INSTDIR\libmysql.dll"
@@ -90,6 +226,75 @@ Section "un.Application" UnSecApplication
Delete "$INSTDIR\servatrice.ini.example"
Delete "$INSTDIR\zlib*.dll"
RMDir "$INSTDIR"
${EndIf}
@CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@
@CPACK_NSIS_FULL_INSTALL@
${If} $PortableMode = 0
WriteUninstaller "$INSTDIR\uninstall.exe"
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayIcon" "$INSTDIR\cockatrice.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayName" "Cockatrice"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayVersion" "@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "EstimatedSize" "$0"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "InstallLocation" "$INSTDIR"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "NoModify" "1"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "NoRepair" "1"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "Publisher" "Cockatrice team"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "VersionMajor" "@CPACK_PACKAGE_VERSION_MAJOR@"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "VersionMinor" "@CPACK_PACKAGE_VERSION_MINOR@"
IfFileExists "$INSTDIR\vcredist_x86.exe" VcRedist86Exists PastVcRedist86Check
VcRedist86Exists:
ExecWait '"$INSTDIR\vcredist_x86.exe" /passive /norestart'
DetailPrint "Wait to ensure unlock of vc_redist file after installation..."
Sleep 3000
Delete "$INSTDIR\vcredist_x86.exe"
PastVcRedist86Check:
IfFileExists "$INSTDIR\vcredist_x64.exe" VcRedist64Exists PastVcRedist64Check
VcRedist64Exists:
ExecWait '"$INSTDIR\vcredist_x64.exe" /passive /norestart'
DetailPrint "Sleep to ensure unlock of vc_redist file after installation..."
Sleep 3000
Delete "$INSTDIR\vcredist_x64.exe"
PastVcRedist64Check:
${Else}
; Create the file the application uses to detect portable mode
FileOpen $0 "$INSTDIR\portable.dat" w
FileWrite $0 "PORTABLE"
FileClose $0
${EndIf}
SectionEnd
Section "Start menu item" SecStartMenu
${If} $PortableMode = 0
SetShellVarContext all
createDirectory "$SMPROGRAMS\Cockatrice"
createShortCut "$SMPROGRAMS\Cockatrice\Cockatrice.lnk" "$INSTDIR\cockatrice.exe"
createShortCut "$SMPROGRAMS\Cockatrice\Oracle.lnk" "$INSTDIR\oracle.exe"
createShortCut "$SMPROGRAMS\Cockatrice\Servatrice.lnk" "$INSTDIR\servatrice.exe"
${EndIf}
SectionEnd
Section "un.Application" UnSecApplication
SetShellVarContext all
RMDir /r "$INSTDIR\plugins"
RMDir /r "$INSTDIR\sounds"
RMDir /r "$INSTDIR\themes"
RMDir /r "$INSTDIR\translations"
Delete "$INSTDIR\*.exe"
Delete "$INSTDIR\*.dll"
Delete "$INSTDIR\qt.conf"
Delete "$INSTDIR\qdebug.txt"
Delete "$INSTDIR\servatrice.sql"
Delete "$INSTDIR\servatrice.ini.example"
RMDir "$INSTDIR"
RMDir "$SMPROGRAMS\Cockatrice"
@@ -105,11 +310,9 @@ Section /o "un.Configurations, decks, cards, pics" UnSecConfiguration
SectionEnd
LangString DESC_SecApplication ${LANG_ENGLISH} "Cockatrice program files"
LangString DESC_SecUpdateConfig ${LANG_ENGLISH} "Update the paths in the application settings according to the installation paths."
LangString DESC_SecStartMenu ${LANG_ENGLISH} "Create start menu items for Cockatrice and Oracle."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecApplication} $(DESC_SecApplication)
!insertmacro MUI_DESCRIPTION_TEXT ${SecUpdateConfig} $(DESC_SecUpdateConfig)
!insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} $(DESC_SecStartMenu)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
@@ -119,20 +322,3 @@ LangString DESC_UnSecConfiguration ${LANG_ENGLISH} "Configurations, decks, card
!insertmacro MUI_DESCRIPTION_TEXT ${UnSecApplication} $(DESC_UnSecApplication)
!insertmacro MUI_DESCRIPTION_TEXT ${UnSecConfiguration} $(DESC_UnSecConfiguration)
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END
Function .onInit
SetShellVarContext all
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString"
StrCmp $R0 "" done
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "A previous version of Cockatrice must be uninstalled before installing the new one." IDOK uninst
Abort
uninst:
ClearErrors
ExecWait "$R0"
done:
FunctionEnd

View File

@@ -1,28 +0,0 @@
{
"package": {
"name": "Cockatrice-git",
"repo": "Cockatrice",
"subject": "cockatrice",
"desc": "Cockatrice master branch automated builds",
"website_url": "https://github.com/Cockatrice/Cockatrice",
"issue_tracker_url": "https://github.com/Cockatrice/Cockatrice/issues",
"vcs_url": "https://github.com/Cockatrice/Cockatrice.git",
"github_use_tag_release_notes": true,
"github_release_notes_file": "RELEASE.txt",
"licenses": ["GPL-2.0"],
"labels": ["card", "tabletop", "game"],
"public_download_numbers": false,
"public_stats": true
},
"version": {
"name": "@PROJECT_VERSION@",
"desc": "Unstable builds from master",
"vcs_tag": "@GIT_COMMIT_ID@",
"gpgSign": false
},
"files": [
{ "includePattern": "build/(Cockatrice.*\\.deb)", "uploadPattern": "Ubuntu/$ENV{DIST}/$1" },
{ "includePattern": "build/(Cockatrice.*\\.dmg)", "uploadPattern": "macOS/$1" }
],
"publish": true
}

View File

@@ -1,40 +1,189 @@
find_package(Git)
if(GIT_FOUND)
# HELPER FUNCTIONS
function(get_commit_id)
# get last commit hash
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --abbrev=7 --date=short "--pretty=%h"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE res_var
OUTPUT_VARIABLE GIT_COM_ID
)
if( NOT ${res_var} EQUAL 0 )
set( GIT_COMMIT_ID "unknown")
message( WARNING "Git failed (not a repo, or no tags). Build will not contain git revision info." )
if(NOT ${res_var} EQUAL 0)
message(WARNING "Git failed (not a repo, or no tags). Build will not contain git revision info.")
return()
endif()
string( REPLACE "\n" "" GIT_COMMIT_ID "${GIT_COM_ID}" )
string(REPLACE "\n" "" GIT_COM_ID "${GIT_COM_ID}")
set(GIT_COMMIT_ID "${GIT_COM_ID}" PARENT_SCOPE)
set(PROJECT_VERSION_LABEL "custom(${GIT_COM_ID})" PARENT_SCOPE)
endfunction()
function(get_commit_date)
# get last commit date
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --date=short "--pretty=%cd"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE res_var
OUTPUT_VARIABLE GIT_COM_DATE
)
if( NOT ${res_var} EQUAL 0 )
set( GIT_COMMIT_DATE "unknown")
set( GIT_COMMIT_DATE_FRIENDLY "unknown")
message( WARNING "Git failed (not a repo, or no tags). Build will not contain git revision info." )
if(NOT ${res_var} EQUAL 0)
message(WARNING "Git failed (not a repo, or no tags). Build will not contain git revision info.")
return()
endif()
string( REPLACE "\n" "" GIT_COMMIT_DATE_FRIENDLY "${GIT_COM_DATE}" )
string( REPLACE "-" "" GIT_COMMIT_DATE "${GIT_COMMIT_DATE_FRIENDLY}" )
string(REPLACE "\n" "" GIT_COM_DATE "${GIT_COM_DATE}")
set(GIT_COMMIT_DATE_FRIENDLY "${GIT_COM_DATE}" PARENT_SCOPE)
string(REPLACE "-" "" GIT_COM_DATE "${GIT_COM_DATE}")
set(GIT_COMMIT_DATE "${GIT_COM_DATE}" PARENT_SCOPE)
endfunction()
function(get_tag_name commit)
if(${commit} STREQUAL "unknown")
return()
endif()
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --exact-match --tags ${commit}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE res_var
OUTPUT_VARIABLE GIT_TAG
ERROR_VARIABLE GIT_TAG_ERR
)
if((NOT ${res_var} EQUAL 0) OR (${GIT_TAG_ERR} MATCHES "fatal: no tag exactly matches.*"))
message(STATUS "Commit is not a release or prerelease (no git tag found)")
return()
endif()
string(REPLACE "\n" "" GIT_TAG "${GIT_TAG}")
message(STATUS "Commit is a release or prerelease, git tag: ${GIT_TAG}")
# Extract information from tag:
# YYYY-MM-DD-Release-MAJ.MIN.PATCH
# YYYY-MM-DD-Development-MAJ.MIN.PATCH-beta.X
string(REPLACE "-" ";" GIT_TAG_EXPLODED "${GIT_TAG}")
string(REPLACE "." ";" GIT_TAG_EXPLODED "${GIT_TAG_EXPLODED}")
# Sanity checks: length
list(LENGTH GIT_TAG_EXPLODED GIT_TAG_LISTCOUNT)
if(${GIT_TAG_LISTCOUNT} LESS 7 OR ${GIT_TAG_LISTCOUNT} GREATER 9)
message(WARNING "Invalid tag format, got ${GIT_TAG_LISTCOUNT} tokens")
return()
endif()
# Year
list(GET GIT_TAG_EXPLODED 0 GIT_TAG_YEAR)
if(${GIT_TAG_YEAR} LESS 2017 OR ${GIT_TAG_LISTCOUNT} GREATER 2100)
message(WARNING "Invalid tag year ${GIT_TAG_YEAR}")
return()
endif()
# Month
list(GET GIT_TAG_EXPLODED 1 GIT_TAG_MONTH)
if(${GIT_TAG_MONTH} LESS 1 OR ${GIT_TAG_MONTH} GREATER 12)
message(WARNING "Invalid tag month ${GIT_TAG_MONTH}")
return()
endif()
# Day
list(GET GIT_TAG_EXPLODED 2 GIT_TAG_DAY)
if(${GIT_TAG_DAY} LESS 1 OR ${GIT_TAG_DAY} GREATER 31)
message(WARNING "Invalid tag day ${GIT_TAG_DAY}")
return()
endif()
# Type
list(GET GIT_TAG_EXPLODED 3 GIT_TAG_TYPE)
if(NOT(${GIT_TAG_TYPE} STREQUAL "Release" OR ${GIT_TAG_TYPE} STREQUAL "Development"))
message(WARNING "Invalid tag type ${GIT_TAG_TYPE}")
return()
endif()
# Major
list(GET GIT_TAG_EXPLODED 4 GIT_TAG_MAJOR)
if(${GIT_TAG_MAJOR} LESS 0 OR ${GIT_TAG_MAJOR} GREATER 99)
message(WARNING "Invalid tag major version ${GIT_TAG_MAJOR}")
return()
endif()
# Minor
list(GET GIT_TAG_EXPLODED 5 GIT_TAG_MINOR)
if(${GIT_TAG_MINOR} LESS 0 OR ${GIT_TAG_MINOR} GREATER 99)
message(WARNING "Invalid tag minor version ${GIT_TAG_MINOR}")
return()
endif()
# Patch
list(GET GIT_TAG_EXPLODED 6 GIT_TAG_PATCH)
if(${GIT_TAG_PATCH} LESS 0 OR ${GIT_TAG_PATCH} GREATER 99)
message(WARNING "Invalid tag patch version ${GIT_TAG_PATCH}")
return()
endif()
# Label
# 7 = Stable release
# 8 = Dev release, first beta so only "beta" attached
# 9 = Dev release, subsequent beta so "beta.N" attached (N>=2)
if(${GIT_TAG_LISTCOUNT} EQUAL 8)
list(GET GIT_TAG_EXPLODED 7 GIT_TAG_LABEL)
elseif(${GIT_TAG_LISTCOUNT} EQUAL 9)
list(GET GIT_TAG_EXPLODED 7 GIT_TAG_LABEL)
list(GET GIT_TAG_EXPLODED 8 GIT_TAG_LABEL_NUM)
set(GIT_TAG_LABEL ${GIT_TAG_LABEL} ${GIT_TAG_LABEL_NUM})
string(REPLACE ";" "." GIT_TAG_LABEL "${GIT_TAG_LABEL}")
else()
SET(GIT_TAG_LABEL "")
endif()
# Override hardcoded version with the informations from the tag
set(PROJECT_VERSION_MAJOR ${GIT_TAG_MAJOR} PARENT_SCOPE)
set(PROJECT_VERSION_MINOR ${GIT_TAG_MINOR} PARENT_SCOPE)
set(PROJECT_VERSION_PATCH ${GIT_TAG_PATCH} PARENT_SCOPE)
set(PROJECT_VERSION_LABEL ${GIT_TAG_LABEL} PARENT_SCOPE)
if(${GIT_TAG_TYPE} STREQUAL "Development")
set(PROJECT_VERSION_LABEL ${GIT_TAG_LABEL} PARENT_SCOPE)
elseif(${GIT_TAG_TYPE} STREQUAL "Release")
set(PROJECT_VERSION_LABEL "" PARENT_SCOPE)
# set release name from env var
set(PROJECT_VERSION_RELEASENAME "${GIT_TAG_RELEASENAME}" PARENT_SCOPE)
endif()
endfunction()
# START OF MAIN
# fallback defaults
set(GIT_COMMIT_ID "unknown")
set(GIT_COMMIT_DATE "")
set(GIT_COMMIT_DATE_FRIENDLY "")
set(PROJECT_VERSION_LABEL "")
set(PROJECT_VERSION_RELEASENAME "")
find_package(Git)
if(GIT_FOUND)
get_commit_id()
get_commit_date()
get_tag_name(${GIT_COMMIT_ID})
else()
set( GIT_COMMIT_ID "unknown")
set( GIT_COMMIT_DATE "unknown")
set( GIT_COMMIT_DATE_FRIENDLY "unknown")
message( WARNING "Git not found. Build will not contain git revision info." )
endif()
set(PROJECT_VERSION_MAJOR "0")
set(PROJECT_VERSION_MINOR "0")
set(PROJECT_VERSION_PATCH "1~git${GIT_COMMIT_DATE}.${GIT_COMMIT_ID}")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(PROJECT_VERSION_FRIENDLY "${GIT_COMMIT_ID} (${GIT_COMMIT_DATE_FRIENDLY})")
if(PROJECT_VERSION_LABEL)
set(PROJECT_VERSION "${PROJECT_VERSION}-${PROJECT_VERSION_LABEL}")
endif()
set(PROJECT_VERSION_FRIENDLY "${PROJECT_VERSION} (${GIT_COMMIT_DATE_FRIENDLY})")
# Format: <program name>[-ReleaseName]-MAJ.MIN.PATCH[-prerelease_label]
set(PROJECT_VERSION_FILENAME "${PROJECT_NAME}")
if(PROJECT_VERSION_RELEASENAME)
set(PROJECT_VERSION_FILENAME "${PROJECT_VERSION_FILENAME}-${PROJECT_VERSION_RELEASENAME}")
endif()
set(PROJECT_VERSION_FILENAME "${PROJECT_VERSION_FILENAME}-${PROJECT_VERSION}")
message(STATUS "Project version: ${PROJECT_VERSION}")
message(STATUS "Friendly project version: ${PROJECT_VERSION_FRIENDLY}")
message(STATUS "Project version filename: ${PROJECT_VERSION_FILENAME}")

View File

@@ -4,12 +4,12 @@ project(gtest-download LANGUAGES NONE)
include(ExternalProject)
ExternalProject_Add(googletest
URL https://github.com/google/googletest/archive/release-1.7.0.zip
URL_HASH SHA1=f89bc9f55477df2fde082481e2d709bfafdb057b
URL https://github.com/google/googletest/archive/release-1.11.0.zip
URL_HASH SHA1=9ffb7b5923f4a8fcdabf2f42c6540cce299f44c0
SOURCE_DIR "${CMAKE_BINARY_DIR}/gtest-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/gtest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
)

3
cmake/launch-c.in Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
export CCACHE_CPP2=true
exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_C_COMPILER}" "$@"

3
cmake/launch-cxx.in Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
export CCACHE_CPP2=true
exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_CXX_COMPILER}" "$@"

View File

@@ -2,121 +2,132 @@
#
# provides the cockatrice binary
PROJECT(Cockatrice)
PROJECT(Cockatrice VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
SET(cockatrice_SOURCES
src/abstractcounter.cpp
src/abstractcarddragitem.cpp
src/abstractcarditem.cpp
src/abstractclient.cpp
src/abstractcounter.cpp
src/abstractgraphicsitem.cpp
src/arrowitem.cpp
src/arrowtarget.cpp
src/carddatabase.cpp
src/carddatabasemodel.cpp
src/carddbparser/carddatabaseparser.cpp
src/carddbparser/cockatricexml3.cpp
src/carddbparser/cockatricexml4.cpp
src/carddragitem.cpp
src/cardfilter.cpp
src/cardframe.cpp
src/cardinfopicture.cpp
src/cardinfotext.cpp
src/cardinfowidget.cpp
src/carditem.cpp
src/cardlist.cpp
src/cardzone.cpp
src/chatview/chatview.cpp
src/counter_general.cpp
src/customlineedit.cpp
src/deck_loader.cpp
src/decklistmodel.cpp
src/deckstats_interface.cpp
src/deckview.cpp
src/dlg_connect.cpp
src/dlg_create_token.cpp
src/dlg_creategame.cpp
src/dlg_filter_games.cpp
src/dlg_connect.cpp
src/dlg_create_token.cpp
src/dlg_edit_avatar.cpp
src/dlg_edit_password.cpp
src/dlg_edit_tokens.cpp
src/dlg_edit_user.cpp
src/dlg_filter_games.cpp
src/dlg_forgotpasswordchallenge.cpp
src/dlg_forgotpasswordrequest.cpp
src/dlg_forgotpasswordreset.cpp
src/dlg_forgotpasswordchallenge.cpp
src/dlg_register.cpp
src/dlg_load_deck_from_clipboard.cpp
src/dlg_load_remote_deck.cpp
src/dlg_manage_sets.cpp
src/dlg_register.cpp
src/dlg_settings.cpp
src/dlg_tip_of_the_day.cpp
src/dlg_update.cpp
src/dlg_viewlog.cpp
src/abstractclient.cpp
src/remoteclient.cpp
src/main.cpp
src/window_main.cpp
src/gamesmodel.cpp
src/player.cpp
src/playertarget.cpp
src/cardzone.cpp
src/selectzone.cpp
src/cardlist.cpp
src/abstractcarditem.cpp
src/carditem.cpp
src/tablezone.cpp
src/handzone.cpp
src/handcounter.cpp
src/carddatabase.cpp
src/keysignals.cpp
src/gameview.cpp
src/gameselector.cpp
src/decklistmodel.cpp
src/deck_loader.cpp
src/dlg_load_deck_from_clipboard.cpp
src/dlg_load_remote_deck.cpp
src/cardinfowidget.cpp
src/cardframe.cpp
src/cardinfopicture.cpp
src/cardinfotext.cpp
src/filter_string.cpp
src/filterbuilder.cpp
src/cardfilter.cpp
src/filtertreemodel.cpp
src/filtertree.cpp
src/messagelogwidget.cpp
src/zoneviewzone.cpp
src/zoneviewwidget.cpp
src/pilezone.cpp
src/stackzone.cpp
src/carddragitem.cpp
src/carddatabasemodel.cpp
src/setsmodel.cpp
src/window_sets.cpp
src/abstractgraphicsitem.cpp
src/abstractcarddragitem.cpp
src/dlg_settings.cpp
src/phasestoolbar.cpp
src/gamescene.cpp
src/arrowitem.cpp
src/arrowtarget.cpp
src/tab.cpp
src/tab_server.cpp
src/tab_room.cpp
src/tab_message.cpp
src/tab_game.cpp
src/tab_deck_storage.cpp
src/tab_replays.cpp
src/tab_supervisor.cpp
src/tab_admin.cpp
src/tab_userlists.cpp
src/tab_deck_editor.cpp
src/tab_logs.cpp
src/replay_timeline_widget.cpp
src/deckstats_interface.cpp
src/tappedout_interface.cpp
src/chatview.cpp
src/userlist.cpp
src/userinfobox.cpp
src/user_context_menu.cpp
src/remotedecklist_treewidget.cpp
src/remotereplaylist_treewidget.cpp
src/deckview.cpp
src/playerlistwidget.cpp
src/pixmapgenerator.cpp
src/settingscache.cpp
src/thememanager.cpp
src/localserver.cpp
src/localserverinterface.cpp
src/localclient.cpp
src/priceupdater.cpp
src/qt-json/json.cpp
src/soundengine.cpp
src/pending_command.cpp
src/pictureloader.cpp
src/shortcutssettings.cpp
src/sequenceEdit/sequenceedit.cpp
src/sequenceEdit/shortcutstab.cpp
src/filtertreemodel.cpp
src/gamescene.cpp
src/gameselector.cpp
src/gamesmodel.cpp
src/gameview.cpp
src/gettextwithmax.cpp
src/handcounter.cpp
src/handle_public_servers.cpp
src/handzone.cpp
src/keysignals.cpp
src/lineeditcompleter.cpp
src/settings/settingsmanager.cpp
src/localclient.cpp
src/localserver.cpp
src/localserverinterface.cpp
src/logger.cpp
src/main.cpp
src/messagelogwidget.cpp
src/pending_command.cpp
src/phase.cpp
src/phasestoolbar.cpp
src/pictureloader.cpp
src/pilezone.cpp
src/pixmapgenerator.cpp
src/player.cpp
src/playerlistwidget.cpp
src/playertarget.cpp
src/releasechannel.cpp
src/remoteclient.cpp
src/remotedecklist_treewidget.cpp
src/remotereplaylist_treewidget.cpp
src/replay_timeline_widget.cpp
src/selectzone.cpp
src/sequenceEdit/sequenceedit.cpp
src/setsmodel.cpp
src/settings/carddatabasesettings.cpp
src/settings/serverssettings.cpp
src/settings/messagesettings.cpp
src/settings/downloadsettings.cpp
src/settings/gamefilterssettings.cpp
src/settings/layoutssettings.cpp
src/settings/messagesettings.cpp
src/settings/serverssettings.cpp
src/settings/settingsmanager.cpp
src/settingscache.cpp
src/shortcutssettings.cpp
src/soundengine.cpp
src/spoilerbackgroundupdater.cpp
src/stackzone.cpp
src/tab.cpp
src/tab_account.cpp
src/tab_admin.cpp
src/tab_deck_editor.cpp
src/tab_deck_storage.cpp
src/tab_game.cpp
src/tab_logs.cpp
src/tab_message.cpp
src/tab_replays.cpp
src/tab_room.cpp
src/tab_server.cpp
src/tab_supervisor.cpp
src/tablezone.cpp
src/tappedout_interface.cpp
src/thememanager.cpp
src/tip_of_the_day.cpp
src/translatecountername.cpp
src/update_downloader.cpp
src/logger.cpp
src/releasechannel.cpp
src/user_context_menu.cpp
src/userconnection_information.cpp
src/userinfobox.cpp
src/userlist.cpp
src/window_main.cpp
src/zoneviewwidget.cpp
src/zoneviewzone.cpp
${VERSION_STRING_CPP}
)
)
add_subdirectory(sounds)
add_subdirectory(themes)
@@ -142,71 +153,31 @@ if(APPLE)
set(cockatrice_SOURCES ${cockatrice_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns)
ENDIF(APPLE)
set(COCKATRICE_LIBS)
# Qt5
find_package(Qt5 COMPONENTS Concurrent Multimedia Network PrintSupport Svg WebSockets Widgets REQUIRED)
set(COCKATRICE_QT_MODULES Qt5::Concurrent Qt5::Multimedia Qt5::Network Qt5::PrintSupport Qt5::Svg Qt5::Widgets Qt5::WebSockets)
# qt5 stuff
if(Qt5Widgets_FOUND)
include_directories(${Qt5Widgets_INCLUDE_DIRS})
list(APPEND COCKATRICE_LIBS Widgets)
# Qt5LinguistTools
find_package(Qt5LinguistTools)
if(Qt5LinguistTools_FOUND)
list(APPEND COCKATRICE_LIBS Qt5::LinguistTools)
# QtConcurrent
find_package(Qt5Concurrent)
if(Qt5Concurrent_FOUND)
include_directories(${Qt5Concurrent_INCLUDE_DIRS})
list(APPEND ORACLE_LIBS Concurrent)
if(NOT Qt5_LRELEASE_EXECUTABLE)
MESSAGE(WARNING "Qt's lrelease not found.")
endif()
# QtNetwork
find_package(Qt5Network)
if(Qt5Network_FOUND)
include_directories(${Qt5Network_INCLUDE_DIRS})
list(APPEND COCKATRICE_LIBS Network)
endif()
# QtMultimedia
find_package(Qt5Multimedia)
if(Qt5Multimedia_FOUND)
include_directories(${Qt5Multimedia_INCLUDE_DIRS})
list(APPEND COCKATRICE_LIBS Multimedia)
endif()
# QtPrinter
find_package(Qt5PrintSupport)
if(Qt5PrintSupport_FOUND)
include_directories(${Qt5PrintSupport_INCLUDE_DIRS})
list(APPEND COCKATRICE_LIBS PrintSupport)
endif()
# QtSvg
find_package(Qt5Svg)
if(Qt5Svg_FOUND)
include_directories(${Qt5Svg_INCLUDE_DIRS})
list(APPEND COCKATRICE_LIBS Svg)
endif()
# Qt5LinguistTools
find_package(Qt5LinguistTools)
if(Qt5LinguistTools_FOUND)
include_directories(${Qt5LinguistTools_INCLUDE_DIRS})
list(APPEND COCKATRICE_LIBS LinguistTools)
endif()
# Let cmake chew Qt5's translations and resource files
# Note: header files are MOC-ed automatically by cmake
IF(UPDATE_TRANSLATIONS)
if(UPDATE_TRANSLATIONS)
if(NOT Qt5_LUPDATE_EXECUTABLE)
MESSAGE(WARNING "Qt's lupdate not found.")
endif()
QT5_CREATE_TRANSLATION(cockatrice_QM ${translate_SRCS} ${cockatrice_TS})
ELSE()
else()
QT5_ADD_TRANSLATION(cockatrice_QM ${cockatrice_TS})
ENDIF()
QT5_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES})
# guess plugins and libraries directory
set(QT_PLUGINS_DIR "${Qt5Widgets_DIR}/../../../plugins")
get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION)
get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH)
endif()
endif()
QT5_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES})
# Declare path variables
set(ICONDIR share/icons CACHE STRING "icon dir")
set(DESKTOPDIR share/applications CACHE STRING "desktop file destination")
@@ -220,12 +191,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
# Build cockatrice binary and link it
ADD_EXECUTABLE(cockatrice WIN32 MACOSX_BUNDLE ${cockatrice_SOURCES} ${cockatrice_QM} ${cockatrice_RESOURCES_RCC} ${cockatrice_MOC_SRCS})
if(MSVC)
TARGET_LINK_LIBRARIES(cockatrice cockatrice_common Qt5::WinMain)
else()
TARGET_LINK_LIBRARIES(cockatrice cockatrice_common)
endif()
qt5_use_modules(cockatrice ${COCKATRICE_LIBS})
TARGET_LINK_LIBRARIES(cockatrice cockatrice_common ${COCKATRICE_QT_MODULES})
if(UNIX)
if(APPLE)
@@ -235,10 +201,11 @@ if(UNIX)
set(MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION})
set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
set_target_properties(cockatrice PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/Info.plist)
INSTALL(TARGETS cockatrice BUNDLE DESTINATION ./)
INSTALL(FILES ${cockatrice_QM} DESTINATION ./Cockatrice.app/Contents/Resources/translations)
INSTALL(FILES ${cockatrice_QM} DESTINATION ./cockatrice.app/Contents/Resources/translations)
else()
# Assume linux
INSTALL(TARGETS cockatrice RUNTIME DESTINATION bin/)
@@ -254,14 +221,22 @@ endif()
if(APPLE)
# these needs to be relative to CMAKE_INSTALL_PREFIX
set(plugin_dest_dir Cockatrice.app/Contents/Plugins)
set(qtconf_dest_dir Cockatrice.app/Contents/Resources)
set(plugin_dest_dir cockatrice.app/Contents/Plugins)
set(qtconf_dest_dir cockatrice.app/Contents/Resources)
get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE)
# qt5 plugins: audio, iconengines, imageformats, platforms, printsupport
install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime
FILES_MATCHING REGEX "(audio|iconengines|imageformats|platforms|printsupport)/.*\\.dylib"
REGEX ".*_debug\\.dylib" EXCLUDE)
FILES_MATCHING
PATTERN "*.dSYM" EXCLUDE
PATTERN "*_debug.dylib" EXCLUDE
PATTERN "audio/*.dylib"
PATTERN "iconengines/*.dylib"
PATTERN "imageformats/*.dylib"
PATTERN "platforms/*.dylib"
PATTERN "printsupport/*.dylib"
PATTERN "styles/*.dylib"
)
install(CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
@@ -275,7 +250,7 @@ Data = Resources\")
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\")
set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Cockatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
" COMPONENT Runtime)
endif()
@@ -284,9 +259,11 @@ if(WIN32)
set(plugin_dest_dir Plugins)
set(qtconf_dest_dir .)
install(DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/" DESTINATION ./ FILES_MATCHING PATTERN "*.dll")
# qt5 plugins: audio, iconengines, imageformats, platforms, printsupport
install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime
FILES_MATCHING REGEX "(audio|iconengines|imageformats|platforms|printsupport)/.*[^d]\\.dll")
FILES_MATCHING REGEX "(audio|iconengines|imageformats|platforms|printsupport|styles)/.*[^d]\\.dll")
install(CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
@@ -307,8 +284,3 @@ Data = Resources\")
install(FILES ${WIN32SSLRUNTIME_LIBRARIES} DESTINATION ./)
endif()
endif()
#Compile a portable version, default off
option(PORTABLE "portable build" OFF)
IF(PORTABLE)
add_definitions(-DPORTABLE_BUILD)
endif()

View File

@@ -16,16 +16,20 @@
<file>resources/icons/conceded.svg</file>
<file>resources/icons/decrement.svg</file>
<file>resources/icons/delete.svg</file>
<file>resources/icons/forgot_password.svg</file>
<file>resources/icons/increment.svg</file>
<file>resources/icons/info.svg</file>
<file>resources/icons/lock.svg</file>
<file>resources/icons/not_ready_start.svg</file>
<file>resources/icons/pencil.svg</file>
<file>resources/icons/player.svg</file>
<file>resources/icons/ready_start.svg</file>
<file>resources/icons/remove_row.svg</file>
<file>resources/icons/scales.svg</file>
<file>resources/icons/search.svg</file>
<file>resources/icons/settings.svg</file>
<file>resources/icons/spectator.svg</file>
<file>resources/icons/sync.svg</file>
<file>resources/icons/tab_changed.svg</file>
<file>resources/icons/update.png</file>
<file>resources/icons/view.svg</file>
@@ -303,10 +307,6 @@
<file>resources/countries/zm.svg</file>
<file>resources/countries/zw.svg</file>
<file>resources/genders/male.svg</file>
<file>resources/genders/female.svg</file>
<file>resources/genders/unknown.svg</file>
<file>resources/phases/untap.svg</file>
<file>resources/phases/upkeep.svg</file>
<file>resources/phases/draw.svg</file>
@@ -342,5 +342,23 @@
<file>resources/userlevels/admin_vip.svg</file>
<file>resources/userlevels/admin_vip_buddy.svg</file>
<!-- ADD TIP OF THE DAY IMAGES HERE -->
<file>resources/tips/images/accounts_tab.png</file>
<file>resources/tips/images/arrows.png</file>
<file>resources/tips/images/cockatrice_register.png</file>
<file>resources/tips/images/cockatrice_wiki.png</file>
<file>resources/tips/images/coin_flip.png</file>
<file>resources/tips/images/counter_expression.png</file>
<file>resources/tips/images/face_down.png</file>
<file>resources/tips/images/filter_games.png</file>
<file>resources/tips/images/github_logo.png</file>
<file>resources/tips/images/gitter.png</file>
<file>resources/tips/images/setpt.png</file>
<file>resources/tips/images/shortcuts.png</file>
<file>resources/tips/images/themes.png</file>
<file>resources/tips/images/tip_of_the_day.png</file>
<file>resources/tips/tips_of_the_day.xml</file>
<file>resources/help/search.md</file>
</qresource>
</RCC>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 236 KiB

After

Width:  |  Height:  |  Size: 106 KiB

View File

@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="640"
height="480"
id="svg2"
inkscape:version="0.91 r13725"
sodipodi:docname="eu.svg">
<metadata
id="metadata43">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview41"
showgrid="false"
inkscape:zoom="0.35308642"
inkscape:cx="405"
inkscape:cy="229.84832"
inkscape:window-x="695"
inkscape:window-y="86"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" />
<desc
id="desc4">European flag</desc>
<defs
id="defs6">
<g
id="s">
<g
id="c">
<path
id="t"
d="M 0,0 0,1 0.5,1 Z"
transform="matrix(0.95105652,0.30901699,-0.30901699,0.95105652,0,-1)"
inkscape:connector-curvature="0" />
<use
xlink:href="#t"
transform="scale(-1,1)"
id="use11"
x="0"
y="0"
width="100%"
height="100%" />
</g>
<g
id="a">
<use
xlink:href="#c"
transform="matrix(0.30901699,0.95105652,-0.95105652,0.30901699,0,0)"
id="use14"
x="0"
y="0"
width="100%"
height="100%" />
<use
xlink:href="#c"
transform="matrix(-0.80901699,0.58778525,-0.58778525,-0.80901699,0,0)"
id="use16"
x="0"
y="0"
width="100%"
height="100%" />
</g>
<use
xlink:href="#a"
transform="scale(-1,1)"
id="use18"
x="0"
y="0"
width="100%"
height="100%" />
</g>
</defs>
<rect
width="642.9021"
height="483.35666"
id="rect20"
x="2.8321679"
y="2.3076911"
style="fill:#003399" />
<g
transform="matrix(23.811189,0,0,23.981809,322.28322,245.88665)"
id="g22"
style="fill:#ffcc00">
<use
xlink:href="#s"
y="-6"
id="use24"
x="0"
width="100%"
height="100%" />
<use
xlink:href="#s"
y="6"
id="use26"
x="0"
width="100%"
height="100%" />
<g
id="l">
<use
xlink:href="#s"
x="-6"
id="use29"
y="0"
width="100%"
height="100%" />
<use
xlink:href="#s"
transform="matrix(-0.80901699,-0.58778525,0.58778525,-0.80901699,-3,-5.1961524)"
id="use31"
x="0"
y="0"
width="100%"
height="100%" />
<use
xlink:href="#s"
transform="matrix(-0.80901699,0.58778525,-0.58778525,-0.80901699,-5.1961524,-3)"
id="use33"
x="0"
y="0"
width="100%"
height="100%" />
<use
xlink:href="#s"
transform="matrix(0.30901699,0.95105652,-0.95105652,0.30901699,-5.1961524,3)"
id="use35"
x="0"
y="0"
width="100%"
height="100%" />
<use
xlink:href="#s"
transform="matrix(0.30901699,0.95105652,-0.95105652,0.30901699,-3,5.1961524)"
id="use37"
x="0"
y="0"
width="100%"
height="100%" />
</g>
<use
xlink:href="#l"
transform="scale(-1,1)"
id="use39"
x="0"
y="0"
width="100%"
height="100%" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.2 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.0"
width="75"
height="75"
id="svg34864">
<defs
id="defs34866" />
<g
transform="translate(-348.7552,-478.0905)"
id="layer1">
<g
transform="matrix(1.071197,0,0,1.075147,-13.30677,-36.99488)"
id="g3773">
<path
d="M 176 33 A 11 11 0 1 1 154,33 A 11 11 0 1 1 176 33 z"
transform="matrix(1.540096,0,0,1.5384,118.8893,454.0543)"
style="color:black;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
id="path3939" />
<path
d="M 373.00525,521.74399 L 373.00525,543.28159"
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:4.61774349;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path3941" />
<path
d="M 363.76467,534.05119 L 382.24582,534.05119"
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:4.61774349;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4816" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.0" width="75" height="75" id="svg34864">
<defs id="defs34866"/>
<g transform="translate(-348.755, -478.091)" id="layer1">
<g transform="matrix(1.94812, 0, 0, 1.93731, -342.43, -460.01)" id="g1872">
<path d="M 387.95009,489.60348 L 378.66214,498.89143" style="opacity: 1; color: black; fill: none; fill-opacity: 0.75; fill-rule: evenodd; stroke: black; stroke-width: 3; stroke-linecap: butt; stroke-linejoin: miter; marker: none; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 0pt; stroke-opacity: 1; visibility: visible; display: inline; overflow: visible;" id="path26867"/>
<path d="M 49.396475 36.70454 A 15.623922 16.319134 0 1 1 18.14863,36.70454 A 15.623922 16.319134 0 1 1 49.396475 36.70454 z" transform="matrix(0.48802, 0.48802, -0.467594, 0.467594, 371.609, 473.136)" style="opacity: 1; color: black; fill: none; fill-opacity: 1; fill-rule: evenodd; stroke: black; stroke-width: 4.44072; stroke-linecap: butt; stroke-linejoin: miter; marker: none; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 0pt; stroke-opacity: 1; visibility: visible; display: inline; overflow: visible;" id="path26871"/>
<path d="M 379.92823,489.70212 C 387.842,489.70212 387.842,489.70212 387.842,489.70212 L 387.842,497.61589" style="fill: none; fill-rule: evenodd; stroke: black; stroke-width: 3; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; stroke-dasharray: none; stroke-opacity: 1;" id="path27759"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Intersexual/Transgendered symbol by Gregory Maxwell. Copyright 2005. GFDL-1.2 only -->
<svg
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="210"
height="280">
<path d="M 188,38 v 20 l 14,-8 v -42 h -42 l -8,14 h 20 l -37,37 a 79,79 0 1,0 -59,141 v 22 h -27 v 23 h 27 v 27 h 23 v -27 h 27 v -23 h -27 v -22 a 79,79 0 0,0 52,-125 zm -100,27 a 57,57 0 1,1 0,114 a 57,57 0 1,1 0,-114 z"/>
<!-- 88,65 // -63,-10 -->
</svg>

Before

Width:  |  Height:  |  Size: 500 B

View File

@@ -0,0 +1,61 @@
## Syntax Help
-----
The search bar recognizes a set of special commands similar to some other card databases. Here is a list with examples. Each entry can be clicked to test the query and has a small explanation. Note that all searches are case insensitive.
<dl>
<dt>Name:</dt>
<dd>[birds of paradise](#birds of paradise) <small>(Any card name containing the words birds, of, and paradise)</small></dd>
<dd>["birds of paradise"](#%22birds of paradise%22) <small>(Any card name containing the exact phrase "birds of paradise")</small></dd>
<dt>Rules Text (<u>O</u>racle):</dt>
<dd>[o:flying](#o:flying) <small>(Any card text that has the word flying)</small></dd>
<dd>[o:"first strike"](#o:%22first strike%22) <small>(Any card text that has the exact phrase "first strike")</small></dd>
<dd>[o:"{T}" o:"add one mana of any color"](#o:%22{T}%22 o:%22add one mana of any color%22) <small>(Any card text that has a tap symbol and the phrase "add one mana of any color")</small></dd>
<dt><u>T</u>ypes:</dt>
<dd>[t:angel](#t:angel) <small>(Any card with the type angel)</small></dd>
<dd>[t:angel t:legendary](#t:angel t:legendary) <small>(Any angel that's also legendary)</small></dd>
<dd>[t:basic](#t:basic) <small>(Any card with the type basic)</small></dd>
<dd>[t:arcane t:instant](#t:arcane t:instant) <small>(Any card with the types arcane and instant)</small></dd>
<dt><u>C</u>olors:</dt>
<dd>[c:w](#c:w) <small>(Any card that is white)</small></dd>
<dd>[c:wu](#c:wu) <small>(Any card that is white or blue)</small></dd>
<dd>[c:wum](#c:wum) <small>(Any card that is white or blue, and multicolored)</small></dd>
<!--
<dd>[c!w](#c!w) <small>(Cards that are only white)</small></dd>
<dd>[c!wu](#c!wu) <small>(Cards that are only white or blue, or both)</small></dd>
<dd>[c!wum](#c!wum) <small>(Cards that are only white and blue, and multicolored)</small></dd>
<dd>[c=wubrg](#c%3Dwubrg) <small>(Cards that are all five colors)</small></dd>
-->
<dd>[c:c](#c:c) <small>(Any colorless card)</small></dd>
<dd>[ci:w](#ci:w) <small>(Any card that has white in it's color identity)</small></dd>
<dt><u>Pow</u>er, <u>Tou</u>ghness, <u>M</u>ana <u>V</u>alue:</dt>
<dd>[tou:1](#tou:1) <small>(Any card with a toughness of 1)</small></dd>
<dd>[pow>=8](#pow>=8) <small>(Any card with a power greater than or equal to 8)</small></dd>
<dd>[mv=7](#mv=7) <small>(Any card with a mana value equal to 7)</small></dd>
<dt><u>R</u>arity:</dt>
<dd>[r:mythic](#r:mythic) <small>(Any card that has the mythic-rare rarity)</small></dd>
<dt><u>F</u>ormat:</dt>
<dd>[f:standard](#f:standard) <small>(Any card that can be played in standard)</small></dd>
<dd>[banned:modern](#banned:modern) <small>(Any card that is banned in modern)</small></dd>
<dd>[restricted:vintage](#restricted:vintage) <small>(Any card that is restricted in vintage)</small></dd>
<dd>[legal:pauper](#legal:pauper) <small>(Any card that is legal in pauper)</small></dd>
<dt><u>E</u>dition:</dt>
<dd>[set:lea](#set:lea) <small>(Cards that appear in Alpha, which has the set code LEA)</small></dd>
<dd>[e:lea,leb](#e:lea,leb) <small>(Cards that appear in Alpha or Beta)</small></dd>
<dd><a href="#e:lea,leb -(e:lea e:leb)">e:lea,leb -(e:lea e:leb)</a> <small>(Cards that appear in Alpha or Beta but not in both editions)</small></dd>
<dt>Negate:</dt>
<dd>[c:wu -c:m](#c:wu -c:m) <small>(Any card that is white or blue, but not multicolored)</small></dd>
<dt>Branching:</dt>
<dd>[t:sliver or o:changeling](#t:sliver or o:changeling) <small>(Any card that is either a sliver or has changeling)</small></dd>
<dt>Grouping:</dt>
<dd><a href="#t:angel -(angel or c:w)">t:angel -(angel or c:w)</a> <small>(Any angel that doesn't have angel in its name and isn't white)</small></dd>
</dl>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48pt" height="48pt" viewBox="0 0 48 48" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:#000000;fill-opacity:1;" d="M 24 2 C 17.398438 2 12 7.398438 12 14 L 12 16 C 9.789063 16 8 17.789063 8 20 L 8 40 C 8 42.210938 9.789063 44 12 44 L 36 44 C 38.210938 44 40 42.210938 40 40 L 40 20 C 40 17.789063 38.210938 16 36 16 L 36 14 C 36 7.398438 30.601563 2 24 2 Z M 24 6 C 28.4375 6 32 9.5625 32 14 L 32 16 L 16 16 L 16 14 C 16 9.5625 19.554688 6 24 6 Z M 23.9375 19.9375 C 29.929688 19.9375 30 24.398438 30 25.25 C 30 29.71875 25.125 29.96875 25.375 33.875 L 21.875 33.875 C 21.578125 28.632813 26.0625 28.398438 26.0625 25.4375 C 26.0625 23.3125 24.632813 23.125 23.9375 23.125 C 21.859375 23.125 21.757813 25.09375 21.75 25.5 L 17.8125 25.5 C 17.820313 24.554688 18.015625 19.9375 23.9375 19.9375 Z M 23.6875 35.9375 C 25.671875 35.9375 25.875 37.765625 25.875 38.0625 C 25.875 38.351563 25.671875 40.125 23.6875 40.125 C 21.632813 40.125 21.5 38.351563 21.5 38.0625 C 21.5 37.765625 21.671875 35.9375 23.6875 35.9375 Z "/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="100"
height="100"
id="svg2858"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="info.svg">
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Triangle"
style="display:inline">
<path
sodipodi:type="arc"
style="fill:#aaaaaa;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
id="path3758-1"
sodipodi:cx="53.900002"
sodipodi:cy="78.5"
sodipodi:rx="46.5"
sodipodi:ry="46.5"
d="M 100.4,78.5 A 46.5,46.5 0 1 1 7.4000015,78.5 46.5,46.5 0 1 1 100.4,78.5 z"
transform="matrix(1.05866,0,0,1.05866,-7.0617752,-32.704809)" />
<g
style="font-size:133.49534607px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:1.06498075;stroke-opacity:1;font-family:'Magic:the Gathering';-inkscape-font-specification:'Magic:the Gathering'"
id="text3759">
<path
d="m 46.854005,16.085692 c 0.977733,-2.411704 1.683885,-4.193378 2.118456,-5.345028 0.369355,-1.1514901 0.771318,-1.9988718 1.205891,-2.5421482 0.456264,-0.4344718 1.347101,-0.825571 2.672514,-1.1732989 1.23846,-0.2823765 2.705082,-0.4670623 4.399871,-0.5540578 0.369346,8.46e-5 0.727854,8.46e-5 1.075524,0 1.694737,8.46e-5 2.672485,0.5758696 2.933248,1.7273567 -3e-5,0.1956326 -3e-5,0.3803183 0,0.5540579 -3e-5,1.3254743 -0.662726,2.9224633 -1.98809,4.7909703 -1.520969,2.238035 -3.43301,4.24785 -5.736128,6.029453 -2.32489,1.760018 -4.551983,2.781222 -6.681286,3.063614 -1.260224,-0.543125 -1.977239,-1.075454 -2.151048,-1.59699 -1.3e-5,-0.08684 -1.3e-5,-0.184616 0,-0.293325 -1.3e-5,-0.434484 0.228128,-1.010269 0.684424,-1.727357 0.521453,-0.890765 1.010327,-1.868513 1.466624,-2.933247 z M 31.372977,37.856906 c 2.650785,-0.716962 6.159814,-1.651255 10.527099,-2.802881 4.280354,-1.173242 7.398284,-1.803346 9.3538,-1.890315 0.08689,5.8e-5 0.173803,5.8e-5 0.260733,0 1.06464,5.8e-5 1.82511,0.358566 2.281415,1.075524 0.260711,0.630161 0.391077,1.520998 0.391099,2.672514 -2.2e-5,0.260787 -2.2e-5,0.532384 0,0.814791 -0.173844,1.586178 -0.260755,2.781204 -0.260733,3.58508 l 0,39.533656 c 1.238459,1e-5 2.976678,-0.673549 5.214662,-2.020681 1.673009,-0.977736 2.868034,-1.46661 3.58508,-1.466624 0.173791,1.4e-5 0.304158,0.04347 0.3911,0.130367 0.543162,0.369385 0.814759,0.771348 0.814791,1.20589 -3.2e-5,1.151583 -1.868617,2.66166 -5.605762,4.530238 -1.238507,0.717023 -3.063637,1.922912 -5.475395,3.617671 -2.49871,1.781679 -4.769259,3.204846 -6.811652,4.269505 -0.347658,0.347644 -0.923443,0.662696 -1.727357,0.945157 -0.260745,0.08691 -0.532342,0.130366 -0.814791,0.130367 -0.521477,-10e-7 -1.010351,-0.271598 -1.466623,-0.814791 C 41.856611,91.111641 41.7697,81.594892 41.76971,62.8221 c -1e-5,-1.955468 -1e-5,-4.008739 0,-6.15982 -1e-5,-2.129283 -0.08692,-4.128235 -0.260734,-5.996861 -0.260742,-1.781634 -0.706161,-3.204801 -1.336257,-4.269504 -0.717023,-1.347075 -1.60786,-2.368279 -2.672514,-3.063614 -1.151576,-0.630057 -2.357465,-1.260161 -3.617672,-1.890315 -1.325394,-0.521416 -2.161911,-1.053746 -2.509556,-1.59699 -0.195549,-0.173771 -0.293324,-0.434504 -0.293324,-0.7822 -0.08691,-0.369319 0.01086,-0.771282 0.293324,-1.20589 z"
style=""
id="path2993" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="52pt" height="52pt" viewBox="0 0 52 52" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:#000000;fill-opacity:1;" d="M 25.605469 0.125 C 25.605469 0.125 23.265625 3.140625 23.265625 4.433594 C 23.265625 5.316406 23.765625 6.070313 24.5 6.464844 C 23.898438 6.65625 23.375 6.992188 22.960938 7.449219 C 22.011719 6.640625 20.628906 5.910156 18.710938 5.910156 C 16.640625 5.910156 14.863281 6.753906 13.355469 7.507813 C 12.601563 7.886719 11.925781 8.25 11.324219 8.496094 C 10.964844 8.09375 10.425781 7.878906 9.847656 7.878906 C 8.75 7.878906 7.878906 8.75 7.878906 9.847656 C 7.878906 10.949219 8.75 11.816406 9.847656 11.816406 C 10.757813 11.816406 11.519531 11.234375 11.757813 10.402344 C 12.578125 10.078125 13.386719 9.648438 14.21875 9.234375 C 15.671875 8.507813 17.179688 7.878906 18.710938 7.878906 C 20.496094 7.878906 21.519531 8.679688 22.097656 9.355469 C 22.074219 9.519531 22.035156 9.6875 22.035156 9.847656 C 22.035156 11.816406 23.636719 13.417969 25.605469 13.417969 C 27.574219 13.417969 29.175781 11.816406 29.175781 9.847656 C 29.175781 9.6875 29.136719 9.519531 29.113281 9.355469 C 29.691406 8.679688 30.714844 7.878906 32.5 7.878906 C 34.03125 7.878906 35.539063 8.507813 36.992188 9.234375 C 37.824219 9.648438 38.632813 10.078125 39.457031 10.402344 C 39.695313 11.234375 40.457031 11.816406 41.363281 11.816406 C 42.464844 11.816406 43.332031 10.949219 43.332031 9.847656 C 43.332031 8.75 42.464844 7.878906 41.363281 7.878906 C 40.785156 7.878906 40.246094 8.09375 39.886719 8.496094 C 39.285156 8.25 38.609375 7.886719 37.855469 7.507813 C 36.347656 6.753906 34.570313 5.910156 32.5 5.910156 C 30.585938 5.910156 29.199219 6.640625 28.253906 7.449219 C 27.835938 6.992188 27.3125 6.65625 26.714844 6.464844 C 27.445313 6.070313 27.945313 5.316406 27.945313 4.433594 C 27.945313 3.140625 25.605469 0.125 25.605469 0.125 Z M 9.539063 13.234375 C 9.25 13.332031 9.023438 13.558594 8.925781 13.847656 L 2.277344 31.515625 L 0 31.515625 C 1.445313 35.578125 5.285156 38.53125 9.847656 38.53125 C 14.410156 38.53125 18.25 35.578125 19.695313 31.515625 L 17.417969 31.515625 L 10.773438 13.847656 C 10.601563 13.402344 10.132813 13.140625 9.664063 13.234375 C 9.625 13.234375 9.578125 13.234375 9.539063 13.234375 Z M 41.054688 13.234375 C 40.761719 13.332031 40.539063 13.558594 40.441406 13.847656 L 33.792969 31.515625 L 31.515625 31.515625 C 32.960938 35.578125 36.800781 38.53125 41.363281 38.53125 C 45.925781 38.53125 49.765625 35.578125 51.210938 31.515625 L 48.933594 31.515625 L 42.285156 13.847656 C 42.117188 13.402344 41.648438 13.140625 41.179688 13.234375 C 41.140625 13.234375 41.09375 13.234375 41.054688 13.234375 Z M 21.914063 15.757813 C 21.914063 17.082031 22.589844 18.242188 23.636719 18.898438 L 23.636719 41.980469 C 21.429688 42.773438 19.796875 44.816406 19.695313 47.273438 L 15.757813 47.273438 C 14.671875 47.273438 13.789063 48.15625 13.789063 49.242188 L 13.789063 51.210938 L 37.425781 51.210938 L 37.425781 49.242188 C 37.425781 48.15625 36.539063 47.273438 35.453125 47.273438 L 31.515625 47.273438 C 31.414063 44.816406 29.785156 42.773438 27.574219 41.980469 L 27.574219 18.898438 C 28.621094 18.242188 29.300781 17.082031 29.300781 15.757813 Z M 9.847656 17.050781 L 15.328125 31.515625 L 4.371094 31.515625 Z M 41.363281 17.050781 L 46.84375 31.515625 L 35.886719 31.515625 Z "/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="520pt" height="520pt" viewBox="0 0 520 520" version="1.1">
<g id="surface1">
<path style=" stroke:none;fill-rule:nonzero;fill:#000000;fill-opacity:1;" d="M 240 0 L 240 45 C 130.078125 55.234375 43.75 147.421875 43.75 260 C 43.75 318.671875 67.03125 371.640625 105 410.625 L 159.375 361.875 C 133.203125 335.859375 116.875 299.765625 116.875 260 C 116.875 187.8125 170.46875 127.96875 240 118.125 L 240 160 L 368.125 80 Z M 415 109.375 L 361.25 158.125 C 387.421875 184.140625 403.125 220.3125 403.125 260 C 403.125 332.265625 349.609375 391.484375 280 401.25 L 280 360 L 151.875 440 L 280 520 L 280 475 C 389.921875 464.765625 476.25 372.578125 476.25 260 C 476.25 201.328125 452.96875 148.359375 415 109.375 Z "/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

View File

@@ -0,0 +1,99 @@
<tips>
<tip>
<title>Tip of the Day</title>
<text>Tip of the Day is a new feature to Cockatrice that allows users to get information about the newest features of the program and some of the most commonly asked questions!</text>
<image>tip_of_the_day.png</image>
<date>2018-03-01</date>
</tip>
<tip>
<title>Suggesting New Tips</title>
<text>You can suggest new Tips of the Day by reaching out to the development team on &lt;a href="https://gitter.im/cockatrice/cockatrice"&gt;Gitter&lt;/a&gt;!</text>
<image>gitter.png</image>
<date>2018-03-01</date>
</tip>
<tip>
<title>Reporting Bugs</title>
<text>If you encounter a bug while using Cockatrice, you can report the bug to the development team via &lt;a href="https://github.com/cockatrice/cockatrice/issues"&gt;GitHub&lt;a&gt;</text>
<image>github_logo.png</image>
<date>2018-03-01</date>
</tip>
<tip>
<title>FAQ/Troubleshooting Wiki</title>
<text>You can find answers to the most common questions and some helpful Cockatrice toubleshooting over on the &lt;a href="https://github.com/cockatrice/cockatrice/wiki"&gt;GitHub wiki&lt;a&gt;</text>
<image>cockatrice_wiki.png</image>
<date>2018-03-01</date>
</tip>
<tip>
<title>Register for a Server</title>
<text>Click on either Cockatrice (Windows) or Actions (Mac) and then Register to server... When the dialogue appears, fill out the desired server information.</text>
<image>cockatrice_register.png</image>
<date>2018-03-01</date>
</tip>
<tip>
<title>Drawing Arrows</title>
<text>You can draw arrows of different color by holding a combination of keys!
Right Click: Red Arrow
Shift + Right Click: Green Arrow
Alt + Right Click: Blue Arrow
Cmd + Right Click: Yellow Arrow
</text>
<image>arrows.png</image>
<date>2018-03-01</date>
</tip>
<tip>
<title>Filtering Games</title>
<text>Don't see all the active games? Want to see a smaller selection? Use the Game Filters to change your horizon</text>
<image>filter_games.png</image>
<date>2018-03-01</date>
</tip>
<tip>
<title>Upload Custom Avatar</title>
<text>Want to show off your hippo avatar? Need to update your password? Check out the Accounts Tab for more info!</text>
<image>accounts_tab.png</image>
<date>2018-03-01</date>
</tip>
<tip>
<title>Common Shortcuts</title>
<text>You can find a full list of shortcuts &lt;a href="https://github.com/Cockatrice/Cockatrice/wiki/Custom-Keyboard-Shortcuts"&gt;on the wiki&lt;/a&gt;, but a short list:
&lt;br&gt;Roll a die: CTRL + I
&lt;br&gt;Mulligan: CTRL + M
&lt;br&gt;Draw a card: CTRL + D
&lt;br&gt;Undo a draw: CTRL + SHIFT + D
&lt;br&gt;View Sideboard: CTRL + F3
&lt;br&gt;Change Life: CTRL + L
&lt;br&gt;All shortcuts can be customized via Settings->Shortcuts!
</text>
<image>shortcuts.png</image>
<date>2018-03-01</date>
</tip>
<tip>
<title>Changing Themes</title>
<text>Did you know Cockatrice has custom themes? You can either &lt;a href="https://github.com/Cockatrice/Cockatrice/wiki/Themes"&gt;create one yourself&lt;/a&gt; or use one of the several pre-loaded ones! Go to Settings->Appearance and try them out!</text>
<image>themes.png</image>
<date>2018-03-01</date>
</tip>
<tip>
<title>Flip of the Coin</title>
<text>You can flip a coin instead of rolling a die by rolling a 2 sided die instead!</text>
<image>coin_flip.png</image>
<date>2018-03-01</date>
</tip>
<tip>
<title>Face Down Cards</title>
<text>You can hold Shift while dragging or clicking on a card to have it enter play face down</text>
<image>face_down.png</image>
<date>2018-03-01</date>
</tip>
<tip>
<title>Counter expressions</title>
<text>When setting a counter value, you can type a math expression in the box and the counter will be set to the result.&lt;br&gt;The "x" variable contains the current counter value.</text>
<image>counter_expression.png</image>
<date>2019-02-02</date>
</tip>
<tip>
<title>Power and Toughness</title>
<text>You can add and subtract to a creature's stats.&lt;br&gt;With a card selected, set the power and toughness ( default: ctrl + p ) and enter +3/-1 to increase power by three while decreasing toughness by one.&lt;br&gt;You can also reset it to the original value ( default: ctrl + alt + 0 ).</text>
<image>setpt.png</image>
<date>2019-03-02</date>
</tip>
</tips>

View File

@@ -1,15 +1,19 @@
#include "abstractcarddragitem.h"
#include "carddatabase.h"
#include <QCursor>
#include <QGraphicsSceneMouseEvent>
#include <QDebug>
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
static const float CARD_WIDTH_HALF = CARD_WIDTH / 2;
static const float CARD_HEIGHT_HALF = CARD_HEIGHT / 2;
const QColor GHOST_MASK = QColor(255, 255, 255, 50);
AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag)
AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item,
const QPointF &_hotSpot,
AbstractCardDragItem *parentDrag)
: QGraphicsItem(), item(_item), hotSpot(_hotSpot)
{
if (parentDrag) {
@@ -27,14 +31,16 @@ AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item, const QPoint
setZValue(2000000007);
}
if (item->getTapped())
setTransform(QTransform().translate(CARD_WIDTH_HALF, CARD_HEIGHT_HALF).rotate(90).translate(-CARD_WIDTH_HALF, -CARD_HEIGHT_HALF));
setTransform(QTransform()
.translate(CARD_WIDTH_HALF, CARD_HEIGHT_HALF)
.rotate(90)
.translate(-CARD_WIDTH_HALF, -CARD_HEIGHT_HALF));
setCacheMode(DeviceCoordinateCache);
}
AbstractCardDragItem::~AbstractCardDragItem()
{
qDebug("CardDragItem destructor");
for (int i = 0; i < childDrags.size(); i++)
delete childDrags[i];
}

View File

@@ -7,24 +7,42 @@ class QGraphicsScene;
class CardZone;
class CardInfo;
class AbstractCardDragItem : public QObject, public QGraphicsItem {
class AbstractCardDragItem : public QObject, public QGraphicsItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
protected:
AbstractCardItem *item;
QPointF hotSpot;
QList<AbstractCardDragItem *> childDrags;
public:
enum { Type = typeCardDrag };
int type() const { return Type; }
enum
{
Type = typeCardDrag
};
int type() const
{
return Type;
}
AbstractCardDragItem(AbstractCardItem *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag = 0);
~AbstractCardDragItem();
QRectF boundingRect() const { return QRectF(0, 0, CARD_WIDTH, CARD_HEIGHT); }
QRectF boundingRect() const
{
return QRectF(0, 0, CARD_WIDTH, CARD_HEIGHT);
}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
AbstractCardItem *getItem() const { return item; }
QPointF getHotSpot() const { return hotSpot; }
AbstractCardItem *getItem() const
{
return item;
}
QPointF getHotSpot() const
{
return hotSpot;
}
void addChildDrag(AbstractCardDragItem *child);
virtual void updatePosition(const QPointF &cursorScenePos) = 0;
protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
};

View File

@@ -1,26 +1,26 @@
#include <QPainter>
#include <QGraphicsScene>
#include <QCursor>
#include <QGraphicsSceneMouseEvent>
#include <cmath>
#ifdef _WIN32
#include "round.h"
#endif /* _WIN32 */
#include "carddatabase.h"
#include "abstractcarditem.h"
#include "carddatabase.h"
#include "gamescene.h"
#include "main.h"
#include "pictureloader.h"
#include "settingscache.h"
#include "main.h"
#include "gamescene.h"
#include <QCursor>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
#include <algorithm>
AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, int _id, QGraphicsItem *parent)
: ArrowTarget(_owner, parent), id(_id), name(_name), tapped(false), facedown(false), tapAngle(0), bgColor(Qt::transparent), isHovered(false), realZValue(0)
: ArrowTarget(_owner, parent), id(_id), name(_name), tapped(false), facedown(false), tapAngle(0),
bgColor(Qt::transparent), isHovered(false), realZValue(0)
{
setCursor(Qt::OpenHandCursor);
setFlag(ItemIsSelectable);
setCacheMode(DeviceCoordinateCache);
connect(settingsCache, SIGNAL(displayCardNamesChanged()), this, SLOT(callUpdate()));
connect(&SettingsCache::instance(), SIGNAL(displayCardNamesChanged()), this, SLOT(callUpdate()));
cardInfoUpdated();
}
@@ -43,8 +43,16 @@ void AbstractCardItem::pixmapUpdated()
void AbstractCardItem::cardInfoUpdated()
{
info = db->getCard(name);
if(info)
connect(info, SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated()));
if (!info && !name.isEmpty()) {
QVariantHash properties = QVariantHash();
info = CardInfo::newInstance(name, "", true, QVariantHash(), QList<CardRelation *>(), QList<CardRelation *>(),
CardInfoPerSetMap(), false, -1, false);
}
if (info.data()) {
connect(info.data(), SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated()));
}
cacheBgColor();
update();
@@ -58,29 +66,25 @@ void AbstractCardItem::setRealZValue(qreal _zValue)
QSizeF AbstractCardItem::getTranslatedSize(QPainter *painter) const
{
return QSizeF(
painter->combinedTransform().map(QLineF(0, 0, boundingRect().width(), 0)).length(),
painter->combinedTransform().map(QLineF(0, 0, 0, boundingRect().height())).length()
);
return QSizeF(painter->combinedTransform().map(QLineF(0, 0, boundingRect().width(), 0)).length(),
painter->combinedTransform().map(QLineF(0, 0, 0, boundingRect().height())).length());
}
void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &translatedSize, int angle)
{
const int MAX_FONT_SIZE = SettingsCache::instance().getMaxFontSize();
const int fontSize = std::max(9, MAX_FONT_SIZE);
QRectF totalBoundingRect = painter->combinedTransform().mapRect(boundingRect());
painter->resetTransform();
QTransform pixmapTransform;
pixmapTransform.translate(totalBoundingRect.width() / 2, totalBoundingRect.height() / 2);
pixmapTransform.rotate(angle);
pixmapTransform.translate(-translatedSize.width() / 2, -translatedSize.height() / 2);
painter->setTransform(pixmapTransform);
int scale = resetPainterTransform(painter);
painter->translate(totalBoundingRect.width() / 2, totalBoundingRect.height() / 2);
painter->rotate(angle);
painter->translate(-translatedSize.width() / 2, -translatedSize.height() / 2);
QFont f;
int fontSize = round(translatedSize.height() / 8);
if (fontSize < 9)
fontSize = 9;
f.setPixelSize(fontSize);
f.setPixelSize(fontSize * scale);
painter->setFont(f);
}
@@ -91,16 +95,14 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
QPixmap translatedPixmap;
bool paintImage = true;
if(facedown)
{
if (facedown || name.isEmpty()) {
// never reveal card color, always paint the card back
PictureLoader::getPixmap(translatedPixmap, nullptr, translatedSize.toSize());
PictureLoader::getCardBackPixmap(translatedPixmap, translatedSize.toSize());
} else {
// don't even spend time trying to load the picture if our size is too small
if(translatedSize.width() > 10)
{
if (translatedSize.width() > 10) {
PictureLoader::getPixmap(translatedPixmap, info, translatedSize.toSize());
if(translatedPixmap.isNull())
if (translatedPixmap.isNull())
paintImage = false;
} else {
paintImage = false;
@@ -108,7 +110,7 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
}
painter->save();
if (paintImage) {
painter->save();
transformPainter(painter, translatedSize, angle);
@@ -128,8 +130,8 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
painter->drawRect(QRectF(0, 0, CARD_WIDTH - 1, CARD_HEIGHT - penWidth));
else
painter->drawRect(QRectF(1, 1, CARD_WIDTH - 2, CARD_HEIGHT - 1.5));
if (translatedPixmap.isNull() || settingsCache->getDisplayCardNames() || facedown) {
if (translatedPixmap.isNull() || SettingsCache::instance().getDisplayCardNames() || facedown) {
painter->save();
transformPainter(painter, translatedSize, angle);
painter->setPen(Qt::white);
@@ -140,10 +142,12 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
nameStr = "# " + QString::number(id);
else
nameStr = name;
painter->drawText(QRectF(3 * scaleFactor, 3 * scaleFactor, translatedSize.width() - 6 * scaleFactor, translatedSize.height() - 6 * scaleFactor), Qt::AlignTop | Qt::AlignLeft | Qt::TextWrapAnywhere, nameStr);
painter->drawText(QRectF(3 * scaleFactor, 3 * scaleFactor, translatedSize.width() - 6 * scaleFactor,
translatedSize.height() - 6 * scaleFactor),
Qt::AlignTop | Qt::AlignLeft | Qt::TextWrapAnywhere, nameStr);
painter->restore();
}
painter->restore();
}
@@ -153,7 +157,7 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
QSizeF translatedSize = getTranslatedSize(painter);
paintPicture(painter, translatedSize, tapAngle);
painter->save();
painter->setRenderHint(QPainter::Antialiasing, false);
transformPainter(painter, translatedSize, tapAngle);
@@ -179,10 +183,10 @@ void AbstractCardItem::setName(const QString &_name)
{
if (name == _name)
return;
emit deleteCardInfoPopup(name);
if(info)
disconnect(info, nullptr, this, nullptr);
if (info)
disconnect(info.data(), nullptr, this, nullptr);
name = _name;
cardInfoUpdated();
@@ -192,12 +196,12 @@ void AbstractCardItem::setHovered(bool _hovered)
{
if (isHovered == _hovered)
return;
if (_hovered)
processHoverEvent();
isHovered = _hovered;
setZValue(_hovered ? 2000000004 : realZValue);
setScale(_hovered && settingsCache->getScaleCards() ? 1.1 : 1);
setScale(_hovered && SettingsCache::instance().getScaleCards() ? 1.1 : 1);
setTransformOriginPoint(_hovered ? CARD_WIDTH / 2 : 0, _hovered ? CARD_HEIGHT / 2 : 0);
update();
}
@@ -212,16 +216,14 @@ void AbstractCardItem::setColor(const QString &_color)
void AbstractCardItem::cacheBgColor()
{
QChar colorChar;
if (color.isEmpty())
{
if(info)
if (color.isEmpty()) {
if (info)
colorChar = info->getColorChar();
} else {
colorChar = color.at(0);
}
switch(colorChar.toLower().toLatin1())
{
switch (colorChar.toLower().toLatin1()) {
case 'b':
bgColor = QColor(0, 0, 0);
break;
@@ -250,13 +252,16 @@ void AbstractCardItem::setTapped(bool _tapped, bool canAnimate)
{
if (tapped == _tapped)
return;
tapped = _tapped;
if (settingsCache->getTapAnimation() && canAnimate)
if (SettingsCache::instance().getTapAnimation() && canAnimate)
static_cast<GameScene *>(scene())->registerAnimationItem(this);
else {
tapAngle = tapped ? 90 : 0;
setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(tapAngle).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2));
setTransform(QTransform()
.translate((float)CARD_WIDTH / 2, (float)CARD_HEIGHT / 2)
.rotate(tapAngle)
.translate((float)-CARD_WIDTH / 2, (float)-CARD_HEIGHT / 2));
update();
}
}
@@ -265,30 +270,30 @@ void AbstractCardItem::setFaceDown(bool _facedown)
{
facedown = _facedown;
update();
emit updateCardMenu(this);
}
void AbstractCardItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if ((event->modifiers() & Qt::ControlModifier)) {
if ((event->modifiers() & Qt::AltModifier) && event->button() == Qt::LeftButton) {
emit cardShiftClicked(name);
} else if ((event->modifiers() & Qt::ControlModifier)) {
setSelected(!isSelected());
}
else if (!isSelected()) {
} else if (!isSelected()) {
scene()->clearSelection();
setSelected(true);
}
if (event->button() == Qt::LeftButton)
setCursor(Qt::ClosedHandCursor);
else if (event->button() == Qt::MidButton)
else if (event->button() == Qt::MiddleButton)
emit showCardInfoPopup(event->screenPos(), name);
event->accept();
}
void AbstractCardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::MidButton)
if (event->button() == Qt::MiddleButton)
emit deleteCardInfoPopup(name);
// This function ensures the parent function doesn't mess around with our selection.
event->accept();
}
@@ -306,4 +311,3 @@ QVariant AbstractCardItem::itemChange(QGraphicsItem::GraphicsItemChange change,
} else
return QGraphicsItem::itemChange(change, value);
}

View File

@@ -2,17 +2,18 @@
#define ABSTRACTCARDITEM_H
#include "arrowtarget.h"
#include "carddatabase.h"
class CardInfo;
class Player;
const int CARD_WIDTH = 72;
const int CARD_HEIGHT = 102;
class AbstractCardItem : public ArrowTarget {
class AbstractCardItem : public ArrowTarget
{
Q_OBJECT
protected:
CardInfo *info;
CardInfoPtr info;
int id;
QString name;
bool tapped;
@@ -20,44 +21,86 @@ protected:
int tapAngle;
QString color;
QColor bgColor;
private:
bool isHovered;
qreal realZValue;
private slots:
void pixmapUpdated();
void cardInfoUpdated();
void callUpdate() { update(); }
void callUpdate()
{
update();
}
signals:
void hovered(AbstractCardItem *card);
void showCardInfoPopup(QPoint pos, QString cardName);
void deleteCardInfoPopup(QString cardName);
void updateCardMenu(AbstractCardItem *card);
void sigPixmapUpdated();
void cardShiftClicked(QString cardName);
public:
enum { Type = typeCard };
int type() const { return Type; }
AbstractCardItem(const QString &_name = QString(), Player *_owner = 0, int _id = -1, QGraphicsItem *parent = 0);
enum
{
Type = typeCard
};
int type() const
{
return Type;
}
AbstractCardItem(const QString &_name = QString(),
Player *_owner = nullptr,
int _id = -1,
QGraphicsItem *parent = nullptr);
~AbstractCardItem();
QRectF boundingRect() const;
QSizeF getTranslatedSize(QPainter *painter) const;
void paintPicture(QPainter *painter, const QSizeF &translatedSize, int angle);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
CardInfo *getInfo() const { return info; }
int getId() const { return id; }
void setId(int _id) { id = _id; }
QString getName() const { return name; }
CardInfoPtr getInfo() const
{
return info;
}
int getId() const
{
return id;
}
void setId(int _id)
{
id = _id;
}
QString getName() const
{
return name;
}
void setName(const QString &_name = QString());
qreal getRealZValue() const { return realZValue; }
qreal getRealZValue() const
{
return realZValue;
}
void setRealZValue(qreal _zValue);
void setHovered(bool _hovered);
QString getColor() const { return color; }
QString getColor() const
{
return color;
}
void setColor(const QString &_color);
bool getTapped() const { return tapped; }
bool getTapped() const
{
return tapped;
}
void setTapped(bool _tapped, bool canAnimate = false);
bool getFaceDown() const { return facedown; }
bool getFaceDown() const
{
return facedown;
}
void setFaceDown(bool _facedown);
void processHoverEvent();
void deleteCardInfoPopup() { emit deleteCardInfoPopup(name); }
void deleteCardInfoPopup()
{
emit deleteCardInfoPopup(name);
}
protected:
void transformPainter(QPainter *painter, const QSizeF &translatedSize, int angle);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
@@ -65,5 +108,5 @@ protected:
QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value);
void cacheBgColor();
};
#endif

View File

@@ -1,28 +1,29 @@
#include "abstractclient.h"
#include "pending_command.h"
#include "client_metatypes.h"
#include "featureset.h"
#include "get_pb_extension.h"
#include "pb/commands.pb.h"
#include "pb/server_message.pb.h"
#include "pb/event_add_to_list.pb.h"
#include "pb/event_connection_closed.pb.h"
#include "pb/event_game_joined.pb.h"
#include "pb/event_list_rooms.pb.h"
#include "pb/event_notify_user.pb.h"
#include "pb/event_remove_from_list.pb.h"
#include "pb/event_replay_added.pb.h"
#include "pb/event_server_identification.pb.h"
#include "pb/event_server_message.pb.h"
#include "pb/event_server_shutdown.pb.h"
#include "pb/event_connection_closed.pb.h"
#include "pb/event_user_message.pb.h"
#include "pb/event_notify_user.pb.h"
#include "pb/event_list_rooms.pb.h"
#include "pb/event_add_to_list.pb.h"
#include "pb/event_remove_from_list.pb.h"
#include "pb/event_user_joined.pb.h"
#include "pb/event_user_left.pb.h"
#include "pb/event_game_joined.pb.h"
#include "pb/event_replay_added.pb.h"
#include "get_pb_extension.h"
#include "pb/event_user_message.pb.h"
#include "pb/server_message.pb.h"
#include "pending_command.h"
#include <google/protobuf/descriptor.h>
#include "client_metatypes.h"
#include "featureset.h"
AbstractClient::AbstractClient(QObject *parent)
: QObject(parent), nextCmdId(0), status(StatusDisconnected)
: QObject(parent), nextCmdId(0), status(StatusDisconnected), serverSupportsPasswordHash(false)
{
qRegisterMetaType<QVariant>("QVariant");
qRegisterMetaType<CommandContainer>("CommandContainer");
@@ -44,13 +45,13 @@ AbstractClient::AbstractClient(QObject *parent)
qRegisterMetaType<Event_UserMessage>("Event_UserMessage");
qRegisterMetaType<Event_NotifyUser>("Event_NotifyUser");
qRegisterMetaType<ServerInfo_User>("ServerInfo_User");
qRegisterMetaType<QList<ServerInfo_User> >("QList<ServerInfo_User>");
qRegisterMetaType<QList<ServerInfo_User>>("QList<ServerInfo_User>");
qRegisterMetaType<Event_ReplayAdded>("Event_ReplayAdded");
qRegisterMetaType<QList<QString> >("missingFeatures");
qRegisterMetaType<QList<QString>>("missingFeatures");
FeatureSet features;
features.initalizeFeatureList(clientFeatures);
connect(this, SIGNAL(sigQueuePendingCommand(PendingCommand *)), this, SLOT(queuePendingCommand(PendingCommand *)));
}
@@ -64,33 +65,60 @@ void AbstractClient::processProtocolItem(const ServerMessage &item)
case ServerMessage::RESPONSE: {
const Response &response = item.response();
const int cmdId = response.cmd_id();
PendingCommand *pend = pendingCommands.value(cmdId, 0);
if (!pend)
return;
pendingCommands.remove(cmdId);
pend->processResponse(response);
pend->deleteLater();
break;
}
case ServerMessage::SESSION_EVENT: {
const SessionEvent &event = item.session_event();
switch ((SessionEvent::SessionEventType) getPbExtension(event)) {
case SessionEvent::SERVER_IDENTIFICATION: emit serverIdentificationEventReceived(event.GetExtension(Event_ServerIdentification::ext)); break;
case SessionEvent::SERVER_MESSAGE: emit serverMessageEventReceived(event.GetExtension(Event_ServerMessage::ext)); break;
case SessionEvent::SERVER_SHUTDOWN: emit serverShutdownEventReceived(event.GetExtension(Event_ServerShutdown::ext)); break;
case SessionEvent::CONNECTION_CLOSED: emit connectionClosedEventReceived(event.GetExtension(Event_ConnectionClosed::ext)); break;
case SessionEvent::USER_MESSAGE: emit userMessageEventReceived(event.GetExtension(Event_UserMessage::ext)); break;
case SessionEvent::NOTIFY_USER: emit notifyUserEventReceived(event.GetExtension(Event_NotifyUser::ext)); break;
case SessionEvent::LIST_ROOMS: emit listRoomsEventReceived(event.GetExtension(Event_ListRooms::ext)); break;
case SessionEvent::ADD_TO_LIST: emit addToListEventReceived(event.GetExtension(Event_AddToList::ext)); break;
case SessionEvent::REMOVE_FROM_LIST: emit removeFromListEventReceived(event.GetExtension(Event_RemoveFromList::ext)); break;
case SessionEvent::USER_JOINED: emit userJoinedEventReceived(event.GetExtension(Event_UserJoined::ext)); break;
case SessionEvent::USER_LEFT: emit userLeftEventReceived(event.GetExtension(Event_UserLeft::ext)); break;
case SessionEvent::GAME_JOINED: emit gameJoinedEventReceived(event.GetExtension(Event_GameJoined::ext)); break;
case SessionEvent::REPLAY_ADDED: emit replayAddedEventReceived(event.GetExtension(Event_ReplayAdded::ext)); break;
default: break;
switch ((SessionEvent::SessionEventType)getPbExtension(event)) {
case SessionEvent::SERVER_IDENTIFICATION:
emit serverIdentificationEventReceived(event.GetExtension(Event_ServerIdentification::ext));
break;
case SessionEvent::SERVER_MESSAGE:
emit serverMessageEventReceived(event.GetExtension(Event_ServerMessage::ext));
break;
case SessionEvent::SERVER_SHUTDOWN:
emit serverShutdownEventReceived(event.GetExtension(Event_ServerShutdown::ext));
break;
case SessionEvent::CONNECTION_CLOSED:
emit connectionClosedEventReceived(event.GetExtension(Event_ConnectionClosed::ext));
break;
case SessionEvent::USER_MESSAGE:
emit userMessageEventReceived(event.GetExtension(Event_UserMessage::ext));
break;
case SessionEvent::NOTIFY_USER:
emit notifyUserEventReceived(event.GetExtension(Event_NotifyUser::ext));
break;
case SessionEvent::LIST_ROOMS:
emit listRoomsEventReceived(event.GetExtension(Event_ListRooms::ext));
break;
case SessionEvent::ADD_TO_LIST:
emit addToListEventReceived(event.GetExtension(Event_AddToList::ext));
break;
case SessionEvent::REMOVE_FROM_LIST:
emit removeFromListEventReceived(event.GetExtension(Event_RemoveFromList::ext));
break;
case SessionEvent::USER_JOINED:
emit userJoinedEventReceived(event.GetExtension(Event_UserJoined::ext));
break;
case SessionEvent::USER_LEFT:
emit userLeftEventReceived(event.GetExtension(Event_UserLeft::ext));
break;
case SessionEvent::GAME_JOINED:
emit gameJoinedEventReceived(event.GetExtension(Event_GameJoined::ext));
break;
case SessionEvent::REPLAY_ADDED:
emit replayAddedEventReceived(event.GetExtension(Event_ReplayAdded::ext));
break;
default:
break;
}
break;
}
@@ -130,9 +158,9 @@ void AbstractClient::queuePendingCommand(PendingCommand *pend)
// This function is always called from the client thread via signal/slot.
const int cmdId = getNewCmdId();
pend->getCommandContainer().set_cmd_id(cmdId);
pendingCommands.insert(cmdId, pend);
sendCommandContainer(pend->getCommandContainer());
}

View File

@@ -1,12 +1,13 @@
#ifndef ABSTRACTCLIENT_H
#define ABSTRACTCLIENT_H
#include <QObject>
#include <QVariant>
#include <QMutex>
#include "pb/response.pb.h"
#include "pb/serverinfo_user.pb.h"
#include <QMutex>
#include <QObject>
#include <QVariant>
class PendingCommand;
class CommandContainer;
class RoomEvent;
@@ -27,7 +28,8 @@ class Event_ServerShutdown;
class Event_ReplayAdded;
class FeatureSet;
enum ClientStatus {
enum ClientStatus
{
StatusDisconnected,
StatusDisconnecting,
StatusConnecting,
@@ -38,13 +40,15 @@ enum ClientStatus {
StatusRequestingForgotPassword,
StatusSubmitForgotPasswordReset,
StatusSubmitForgotPasswordChallenge,
StatusGettingPasswordSalt,
};
class AbstractClient : public QObject {
class AbstractClient : public QObject
{
Q_OBJECT
signals:
void statusChanged(ClientStatus _status);
// Room events
void roomEventReceived(const RoomEvent &event);
// Game events
@@ -69,8 +73,9 @@ signals:
void registerAccepted();
void registerAcceptedNeedsActivate();
void activateAccepted();
void sigQueuePendingCommand(PendingCommand *pend);
private:
int nextCmdId;
mutable QMutex clientMutex;
@@ -79,23 +84,39 @@ private slots:
void queuePendingCommand(PendingCommand *pend);
protected slots:
void processProtocolItem(const ServerMessage &item);
protected:
QMap<int, PendingCommand *> pendingCommands;
QString userName, password, email, country, realName, token;
int gender;
bool serverSupportsPasswordHash;
void setStatus(ClientStatus _status);
int getNewCmdId() { return nextCmdId++; }
int getNewCmdId()
{
return nextCmdId++;
}
virtual void sendCommandContainer(const CommandContainer &cont) = 0;
public:
AbstractClient(QObject *parent = 0);
AbstractClient(QObject *parent = nullptr);
~AbstractClient();
ClientStatus getStatus() const { QMutexLocker locker(&clientMutex); return status; }
ClientStatus getStatus() const
{
QMutexLocker locker(&clientMutex);
return status;
}
void sendCommand(const CommandContainer &cont);
void sendCommand(PendingCommand *pend);
const QString getUserName() {return userName;}
bool getServerSupportsPasswordHash() const
{
return serverSupportsPasswordHash;
}
const QString &getUserName() const
{
return userName;
}
static PendingCommand *prepareSessionCommand(const ::google::protobuf::Message &cmd);
static PendingCommand *prepareRoomCommand(const ::google::protobuf::Message &cmd, int roomId);
static PendingCommand *prepareModeratorCommand(const ::google::protobuf::Message &cmd);

View File

@@ -1,31 +1,48 @@
#include "abstractcounter.h"
#include "player.h"
#include "settingscache.h"
#include <QPainter>
#include <QMenu>
#include <QAction>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsSceneHoverEvent>
#include "expression.h"
#include "pb/command_inc_counter.pb.h"
#include "pb/command_set_counter.pb.h"
#include "player.h"
#include "settingscache.h"
#include "translatecountername.h"
AbstractCounter::AbstractCounter(Player *_player, int _id, const QString &_name, bool _shownInCounterArea, int _value, QGraphicsItem *parent)
: QGraphicsItem(parent), player(_player), id(_id), name(_name), value(_value), hovered(false), aDec(0), aInc(0), dialogSemaphore(false), deleteAfterDialog(false), shownInCounterArea(_shownInCounterArea)
#include <QAction>
#include <QApplication>
#include <QGraphicsSceneHoverEvent>
#include <QGraphicsSceneMouseEvent>
#include <QKeyEvent>
#include <QMenu>
#include <QPainter>
#include <QString>
AbstractCounter::AbstractCounter(Player *_player,
int _id,
const QString &_name,
bool _shownInCounterArea,
int _value,
bool _useNameForShortcut,
QGraphicsItem *parent,
QWidget *_game)
: QGraphicsItem(parent), player(_player), id(_id), name(_name), value(_value),
useNameForShortcut(_useNameForShortcut), hovered(false), aDec(nullptr), aInc(nullptr), dialogSemaphore(false),
deleteAfterDialog(false), shownInCounterArea(_shownInCounterArea), game(_game)
{
setAcceptHoverEvents(true);
shortcutActive = false;
if (player->getLocal()) {
menu = new QMenu(name);
if (player->getLocalOrJudge()) {
QString displayName = TranslateCounterName::getDisplayName(_name);
menu = new TearOffMenu(displayName);
aSet = new QAction(this);
connect(aSet, SIGNAL(triggered()), this, SLOT(setCounter()));
menu->addAction(aSet);
menu->addSeparator();
for (int i = 10; i >= -10; --i)
if (i == 0)
for (int i = 10; i >= -10; --i) {
if (i == 0) {
menu->addSeparator();
else {
} else {
QAction *aIncrement = new QAction(QString(i < 0 ? "%1" : "+%1").arg(i), this);
if (i == -1)
aDec = aIncrement;
@@ -35,10 +52,12 @@ AbstractCounter::AbstractCounter(Player *_player, int _id, const QString &_name,
connect(aIncrement, SIGNAL(triggered()), this, SLOT(incrementCounter()));
menu->addAction(aIncrement);
}
} else
menu = 0;
connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts()));
}
} else {
menu = nullptr;
}
connect(&SettingsCache::instance().shortcuts(), SIGNAL(shortCutChanged()), this, SLOT(refreshShortcuts()));
refreshShortcuts();
retranslateUi();
}
@@ -65,18 +84,27 @@ void AbstractCounter::retranslateUi()
void AbstractCounter::setShortcutsActive()
{
if (!player->getLocal()) {
return;
}
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
if (name == "life") {
shortcutActive = true;
aSet->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aSet"));
aDec->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aDec"));
aInc->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aInc"));
aSet->setShortcuts(shortcuts.getShortcut("Player/aSet"));
aDec->setShortcuts(shortcuts.getShortcut("Player/aDec"));
aInc->setShortcuts(shortcuts.getShortcut("Player/aInc"));
} else if (useNameForShortcut) {
shortcutActive = true;
aSet->setShortcuts(shortcuts.getShortcut("Player/aSetCounter_" + name));
aDec->setShortcuts(shortcuts.getShortcut("Player/aDecCounter_" + name));
aInc->setShortcuts(shortcuts.getShortcut("Player/aIncCounter_" + name));
}
}
void AbstractCounter::setShortcutsInactive()
{
shortcutActive = false;
if (name == "life") {
if (name == "life" || useNameForShortcut) {
aSet->setShortcut(QKeySequence());
aDec->setShortcut(QKeySequence());
aInc->setShortcut(QKeySequence());
@@ -85,8 +113,9 @@ void AbstractCounter::setShortcutsInactive()
void AbstractCounter::refreshShortcuts()
{
if(shortcutActive)
if (shortcutActive) {
setShortcutsActive();
}
}
void AbstractCounter::setValue(int _value)
@@ -97,8 +126,12 @@ void AbstractCounter::setValue(int _value)
void AbstractCounter::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (isUnderMouse()) {
if (event->button() == Qt::LeftButton) {
if (isUnderMouse() && player->getLocalOrJudge()) {
if (event->button() == Qt::MiddleButton || (QApplication::keyboardModifiers() & Qt::ShiftModifier)) {
if (menu)
menu->exec(event->screenPos());
event->accept();
} else if (event->button() == Qt::LeftButton) {
Command_IncCounter cmd;
cmd.set_counter_id(id);
cmd.set_delta(1);
@@ -110,12 +143,8 @@ void AbstractCounter::mousePressEvent(QGraphicsSceneMouseEvent *event)
cmd.set_delta(-1);
player->sendGameCommand(cmd);
event->accept();
} else if (event->button() == Qt::MidButton) {
if (menu)
menu->exec(event->screenPos());
event->accept();
}
}else
}
} else
event->ignore();
}
@@ -142,20 +171,60 @@ void AbstractCounter::incrementCounter()
void AbstractCounter::setCounter()
{
bool ok;
dialogSemaphore = true;
int newValue =
QInputDialog::getInt(0, tr("Set counter"), tr("New value for counter '%1':").arg(name), value, -2000000000, 2000000000, 1, &ok);
AbstractCounterDialog dialog(name, QString::number(value), game);
const int ok = dialog.exec();
if (deleteAfterDialog) {
deleteLater();
return;
}
dialogSemaphore = false;
if (!ok)
return;
Expression exp(value);
int newValue = static_cast<int>(exp.parse(dialog.textValue()));
Command_SetCounter cmd;
cmd.set_counter_id(id);
cmd.set_value(newValue);
player->sendGameCommand(cmd);
}
AbstractCounterDialog::AbstractCounterDialog(const QString &name, const QString &value, QWidget *parent)
: QInputDialog(parent)
{
setWindowTitle(tr("Set counter"));
setLabelText(tr("New value for counter '%1':").arg(name));
setTextValue(value);
qApp->installEventFilter(this);
}
bool AbstractCounterDialog::eventFilter(QObject *obj, QEvent *event)
{
Q_UNUSED(obj);
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
switch (keyEvent->key()) {
case Qt::Key_Up:
changeValue(+1);
return true;
case Qt::Key_Down:
changeValue(-1);
return true;
}
}
return false;
}
void AbstractCounterDialog::changeValue(int diff)
{
bool ok;
int curValue = textValue().toInt(&ok);
if (!ok)
return;
curValue += diff;
setTextValue(QString::number(curValue));
}

View File

@@ -1,51 +1,95 @@
#ifndef COUNTER_H
#define COUNTER_H
#include "tearoffmenu.h"
#include <QGraphicsItem>
#include <QInputDialog>
class Player;
class QMenu;
class QAction;
class QKeyEvent;
class QMenu;
class QString;
class AbstractCounter : public QObject, public QGraphicsItem {
class AbstractCounter : public QObject, public QGraphicsItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
protected:
Player *player;
int id;
QString name;
int value;
bool hovered;
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
bool useNameForShortcut, hovered;
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
private:
QAction *aSet, *aDec, *aInc;
QMenu *menu;
TearOffMenu *menu;
bool dialogSemaphore, deleteAfterDialog;
bool shownInCounterArea;
bool shortcutActive;
QWidget *game;
private slots:
void refreshShortcuts();
void incrementCounter();
void setCounter();
public:
AbstractCounter(Player *_player, int _id, const QString &_name, bool _shownInCounterArea, int _value, QGraphicsItem *parent = 0);
~AbstractCounter();
QMenu *getMenu() const { return menu; }
AbstractCounter(Player *_player,
int _id,
const QString &_name,
bool _shownInCounterArea,
int _value,
bool _useNameForShortcut = false,
QGraphicsItem *parent = nullptr,
QWidget *game = nullptr);
~AbstractCounter() override;
void retranslateUi();
int getId() const { return id; }
QString getName() const { return name; }
bool getShownInCounterArea() const { return shownInCounterArea; }
int getValue() const { return value; }
void setValue(int _value);
void delCounter();
void setShortcutsActive();
void setShortcutsInactive();
bool shortcutActive;
void delCounter();
QMenu *getMenu() const
{
return menu;
}
int getId() const
{
return id;
}
QString getName() const
{
return name;
}
bool getShownInCounterArea() const
{
return shownInCounterArea;
}
int getValue() const
{
return value;
}
};
class AbstractCounterDialog : public QInputDialog
{
Q_OBJECT
public:
AbstractCounterDialog(const QString &name, const QString &value, QWidget *parent = nullptr);
protected:
bool eventFilter(QObject *obj, QEvent *event);
void changeValue(int diff);
};
#endif

View File

@@ -1,7 +1,13 @@
#include "abstractgraphicsitem.h"
#include <QPainter>
void AbstractGraphicsItem::paintNumberEllipse(int number, int fontSize, const QColor &color, int position, int count, QPainter *painter)
void AbstractGraphicsItem::paintNumberEllipse(int number,
int fontSize,
const QColor &color,
int position,
int count,
QPainter *painter)
{
painter->save();
@@ -9,16 +15,21 @@ void AbstractGraphicsItem::paintNumberEllipse(int number, int fontSize, const QC
QFont font("Serif");
font.setPixelSize(fontSize);
font.setWeight(QFont::Bold);
QFontMetrics fm(font);
double w = fm.width(numStr) * 1.3;
double w = 1.3 *
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
fm.horizontalAdvance(numStr);
#else
fm.width(numStr);
#endif
double h = fm.height() * 1.3;
if (w < h)
w = h;
painter->setPen(QColor(255, 255, 255, 0));
painter->setBrush(QBrush(QColor(color)));
QRectF textRect;
if (position == -1)
textRect = QRectF((boundingRect().width() - w) / 2.0, (boundingRect().height() - h) / 2.0, w, h);
@@ -27,11 +38,15 @@ void AbstractGraphicsItem::paintNumberEllipse(int number, int fontSize, const QC
qreal yOffset = 20;
qreal spacing = 2;
if (position < 2)
textRect = QRectF(count == 1 ? ((boundingRect().width() - w) / 2.0) : (position % 2 == 0 ? xOffset : (boundingRect().width() - xOffset - w)), yOffset, w, h);
textRect = QRectF(count == 1 ? ((boundingRect().width() - w) / 2.0)
: (position % 2 == 0 ? xOffset : (boundingRect().width() - xOffset - w)),
yOffset, w, h);
else
textRect = QRectF(count == 3 ? ((boundingRect().width() - w) / 2.0) : (position % 2 == 0 ? xOffset : (boundingRect().width() - xOffset - w)), yOffset + (spacing + h) * (position / 2), w, h);
textRect = QRectF(count == 3 ? ((boundingRect().width() - w) / 2.0)
: (position % 2 == 0 ? xOffset : (boundingRect().width() - xOffset - w)),
yOffset + (spacing + h) * (position / 2), w, h);
}
painter->drawEllipse(textRect);
painter->setPen(Qt::black);
@@ -40,3 +55,11 @@ void AbstractGraphicsItem::paintNumberEllipse(int number, int fontSize, const QC
painter->restore();
}
int resetPainterTransform(QPainter *painter)
{
painter->resetTransform();
auto tx = painter->deviceTransform().inverted();
painter->setTransform(tx);
return tx.isScaling() ? 1.0 / tx.m11() : 1;
}

View File

@@ -3,7 +3,8 @@
#include <QGraphicsItem>
enum GraphicsItemType {
enum GraphicsItemType
{
typeCard = QGraphicsItem::UserType + 1,
typeCardDrag = QGraphicsItem::UserType + 2,
typeZone = QGraphicsItem::UserType + 3,
@@ -12,13 +13,19 @@ enum GraphicsItemType {
typeOther = QGraphicsItem::UserType + 6
};
class AbstractGraphicsItem : public QObject, public QGraphicsItem {
class AbstractGraphicsItem : public QObject, public QGraphicsItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
protected:
void paintNumberEllipse(int number, int radius, const QColor &color, int position, int count, QPainter *painter);
public:
AbstractGraphicsItem(QGraphicsItem *parent = 0) : QObject(), QGraphicsItem(parent) { }
AbstractGraphicsItem(QGraphicsItem *parent = nullptr) : QObject(), QGraphicsItem(parent)
{
}
};
int resetPainterTransform(QPainter *painter);
#endif

View File

@@ -1,25 +1,26 @@
#define _USE_MATH_DEFINES
#include <cmath>
#include "arrowitem.h"
#include "playertarget.h"
#include "carditem.h"
#include "carddatabase.h"
#include "cardzone.h"
#include "player.h"
#include "settingscache.h"
#include <QPainter>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsScene>
#include <QDebug>
#include "carddatabase.h"
#include "carditem.h"
#include "cardzone.h"
#include "color.h"
#include "pb/command_attach_card.pb.h"
#include "pb/command_create_arrow.pb.h"
#include "pb/command_delete_arrow.pb.h"
#include "player.h"
#include "playertarget.h"
#include "settingscache.h"
#include <QDebug>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
#include <cmath>
ArrowItem::ArrowItem(Player *_player, int _id, ArrowTarget *_startItem, ArrowTarget *_targetItem, const QColor &_color)
: QGraphicsItem(), player(_player), id(_id), startItem(_startItem), targetItem(_targetItem), color(_color), fullColor(true)
: QGraphicsItem(), player(_player), id(_id), startItem(_startItem), targetItem(_targetItem), color(_color),
fullColor(true)
{
qDebug() << "ArrowItem constructor: startItem=" << static_cast<QGraphicsItem *>(startItem);
setZValue(2000000005);
@@ -60,7 +61,8 @@ void ArrowItem::updatePath()
if (!targetItem)
return;
QPointF endPoint = targetItem->mapToScene(QPointF(targetItem->boundingRect().width() / 2, targetItem->boundingRect().height() / 2));
QPointF endPoint = targetItem->mapToScene(
QPointF(targetItem->boundingRect().width() / 2, targetItem->boundingRect().height() / 2));
updatePath(endPoint);
}
@@ -68,13 +70,15 @@ void ArrowItem::updatePath(const QPointF &endPoint)
{
const double arrowWidth = 15.0;
const double headWidth = 40.0;
const double headLength = headWidth / pow(2, 0.5); // aka headWidth / sqrt (2) but this produces a compile error with MSVC++
const double headLength =
headWidth / pow(2, 0.5); // aka headWidth / sqrt (2) but this produces a compile error with MSVC++
const double phi = 15;
if (!startItem)
return;
QPointF startPoint = startItem->mapToScene(QPointF(startItem->boundingRect().width() / 2, startItem->boundingRect().height() / 2));
QPointF startPoint =
startItem->mapToScene(QPointF(startItem->boundingRect().width() / 2, startItem->boundingRect().height() / 2));
QLineF line(startPoint, endPoint);
qreal lineLength = line.length();
@@ -92,10 +96,14 @@ void ArrowItem::updatePath(const QPointF &endPoint)
QPointF arrowBodyEndPoint = centerLine.pointAtPercent(percentage);
QLineF testLine(arrowBodyEndPoint, centerLine.pointAtPercent(percentage + 0.001));
qreal alpha = testLine.angle() - 90;
QPointF endPoint1 = arrowBodyEndPoint + arrowWidth / 2 * QPointF(cos(alpha * M_PI / 180), -sin(alpha * M_PI / 180));
QPointF endPoint2 = arrowBodyEndPoint + arrowWidth / 2 * QPointF(-cos(alpha * M_PI / 180), sin(alpha * M_PI / 180));
QPointF point1 = endPoint1 + (headWidth - arrowWidth) / 2 * QPointF(cos(alpha * M_PI / 180), -sin(alpha * M_PI / 180));
QPointF point2 = endPoint2 + (headWidth - arrowWidth) / 2 * QPointF(-cos(alpha * M_PI / 180), sin(alpha * M_PI / 180));
QPointF endPoint1 =
arrowBodyEndPoint + arrowWidth / 2 * QPointF(cos(alpha * M_PI / 180), -sin(alpha * M_PI / 180));
QPointF endPoint2 =
arrowBodyEndPoint + arrowWidth / 2 * QPointF(-cos(alpha * M_PI / 180), sin(alpha * M_PI / 180));
QPointF point1 =
endPoint1 + (headWidth - arrowWidth) / 2 * QPointF(cos(alpha * M_PI / 180), -sin(alpha * M_PI / 180));
QPointF point2 =
endPoint2 + (headWidth - arrowWidth) / 2 * QPointF(-cos(alpha * M_PI / 180), sin(alpha * M_PI / 180));
path = QPainterPath(-arrowWidth / 2 * QPointF(cos((phi - 90) * M_PI / 180), sin((phi - 90) * M_PI / 180)));
path.quadTo(c, endPoint1);
@@ -229,15 +237,15 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
PlayerTarget *targetPlayer = qgraphicsitem_cast<PlayerTarget *>(targetItem);
cmd.set_target_player_id(targetPlayer->getOwner()->getId());
}
if (startZone->getName().compare("hand") == 0) {
if (startZone->getName().compare("hand") == 0) {
startCard->playCard(false);
CardInfo *ci = startCard->getInfo();
if (ci && (((!settingsCache->getPlayToStack() && ci->getTableRow() == 3) ||
((settingsCache->getPlayToStack() && ci->getTableRow() != 0) &&
startCard->getZone()->getName().toStdString() != "stack"))))
CardInfoPtr ci = startCard->getInfo();
if (ci && (((!SettingsCache::instance().getPlayToStack() && ci->getTableRow() == 3) ||
((SettingsCache::instance().getPlayToStack() && ci->getTableRow() != 0) &&
startCard->getZone()->getName().toStdString() != "stack"))))
cmd.set_start_zone("stack");
else
cmd.set_start_zone(settingsCache->getPlayToStack() ? "stack" :"table");
cmd.set_start_zone(SettingsCache::instance().getPlayToStack() ? "stack" : "table");
}
player->sendGameCommand(cmd);
}

View File

@@ -9,12 +9,14 @@ class QMenu;
class Player;
class ArrowTarget;
class ArrowItem : public QObject, public QGraphicsItem {
class ArrowItem : public QObject, public QGraphicsItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
private:
QPainterPath path;
QMenu *menu;
protected:
Player *player;
int id;
@@ -22,40 +24,70 @@ protected:
QColor color;
bool fullColor;
void mousePressEvent(QGraphicsSceneMouseEvent *event);
public:
ArrowItem(Player *_player, int _id, ArrowTarget *_startItem, ArrowTarget *_targetItem, const QColor &color);
~ArrowItem();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QRectF boundingRect() const { return path.boundingRect(); }
QPainterPath shape() const { return path; }
QRectF boundingRect() const
{
return path.boundingRect();
}
QPainterPath shape() const
{
return path;
}
void updatePath();
void updatePath(const QPointF &endPoint);
int getId() const { return id; }
Player *getPlayer() const { return player; }
void setStartItem(ArrowTarget *_item) { startItem = _item; }
void setTargetItem(ArrowTarget *_item) { targetItem = _item; }
ArrowTarget *getStartItem() const { return startItem; }
ArrowTarget *getTargetItem() const { return targetItem; }
int getId() const
{
return id;
}
Player *getPlayer() const
{
return player;
}
void setStartItem(ArrowTarget *_item)
{
startItem = _item;
}
void setTargetItem(ArrowTarget *_item)
{
targetItem = _item;
}
ArrowTarget *getStartItem() const
{
return startItem;
}
ArrowTarget *getTargetItem() const
{
return targetItem;
}
void delArrow();
};
class ArrowDragItem : public ArrowItem {
class ArrowDragItem : public ArrowItem
{
Q_OBJECT
private:
QList<ArrowDragItem *> childArrows;
public:
ArrowDragItem(Player *_owner, ArrowTarget *_startItem, const QColor &_color);
void addChildArrow(ArrowDragItem *childArrow);
protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
};
class ArrowAttachItem : public ArrowItem {
class ArrowAttachItem : public ArrowItem
{
Q_OBJECT
public:
ArrowAttachItem(ArrowTarget *_startItem);
protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

View File

@@ -1,4 +1,5 @@
#include "arrowtarget.h"
#include "arrowitem.h"
#include "player.h"

View File

@@ -2,34 +2,62 @@
#define ARROWTARGET_H
#include "abstractgraphicsitem.h"
#include <QList>
class Player;
class ArrowItem;
class ArrowTarget : public AbstractGraphicsItem {
class ArrowTarget : public AbstractGraphicsItem
{
Q_OBJECT
protected:
Player *owner;
private:
bool beingPointedAt;
QList<ArrowItem *> arrowsFrom, arrowsTo;
public:
ArrowTarget(Player *_owner, QGraphicsItem *parent = 0);
ArrowTarget(Player *_owner, QGraphicsItem *parent = nullptr);
~ArrowTarget();
Player *getOwner() const { return owner; }
Player *getOwner() const
{
return owner;
}
void setBeingPointedAt(bool _beingPointedAt);
bool getBeingPointedAt() const { return beingPointedAt; }
const QList<ArrowItem *> &getArrowsFrom() const { return arrowsFrom; }
void addArrowFrom(ArrowItem *arrow) { arrowsFrom.append(arrow); }
void removeArrowFrom(ArrowItem *arrow) { arrowsFrom.removeAt(arrowsFrom.indexOf(arrow)); }
const QList<ArrowItem *> &getArrowsTo() const { return arrowsTo; }
void addArrowTo(ArrowItem *arrow) { arrowsTo.append(arrow); }
void removeArrowTo(ArrowItem *arrow) { arrowsTo.removeAt(arrowsTo.indexOf(arrow)); }
bool getBeingPointedAt() const
{
return beingPointedAt;
}
const QList<ArrowItem *> &getArrowsFrom() const
{
return arrowsFrom;
}
void addArrowFrom(ArrowItem *arrow)
{
arrowsFrom.append(arrow);
}
void removeArrowFrom(ArrowItem *arrow)
{
arrowsFrom.removeAt(arrowsFrom.indexOf(arrow));
}
const QList<ArrowItem *> &getArrowsTo() const
{
return arrowsTo;
}
void addArrowTo(ArrowItem *arrow)
{
arrowsTo.append(arrow);
}
void removeArrowTo(ArrowItem *arrow)
{
arrowsTo.removeAt(arrowsTo.indexOf(arrow));
}
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,52 +1,109 @@
#ifndef CARDDATABASE_H
#define CARDDATABASE_H
#include <QHash>
#include <QPixmap>
#include <QMap>
#include <QBasicMutex>
#include <QDate>
#include <QDataStream>
#include <QHash>
#include <QList>
#include <QXmlStreamReader>
#include <QMap>
#include <QMetaType>
#include <QSharedPointer>
#include <QStringList>
#include <QVariant>
#include <QVector>
#include <utility>
class CardDatabase;
class CardInfo;
class CardInfoPerSet;
class CardSet;
class CardRelation;
class ICardDatabaseParser;
typedef QMap<QString, QString> QStringMap;
typedef QSharedPointer<CardInfo> CardInfoPtr;
typedef QSharedPointer<CardSet> CardSetPtr;
typedef QMap<QString, CardInfoPerSet> CardInfoPerSetMap;
// If we don't typedef this, CardInfo::CardInfo will refuse to compile on OS X < 10.9
typedef QMap<QString, int> MuidMap;
Q_DECLARE_METATYPE(CardInfoPtr)
class CardSet : public QList<CardInfo *> {
class CardSet : public QList<CardInfoPtr>
{
private:
QString shortName, longName;
unsigned int sortKey;
QDate releaseDate;
QString setType;
bool enabled, isknown;
public:
CardSet(const QString &_shortName = QString(), const QString &_longName = QString(), const QString &_setType = QString(), const QDate &_releaseDate = QDate());
explicit CardSet(const QString &_shortName = QString(),
const QString &_longName = QString(),
const QString &_setType = QString(),
const QDate &_releaseDate = QDate());
static CardSetPtr newInstance(const QString &_shortName = QString(),
const QString &_longName = QString(),
const QString &_setType = QString(),
const QDate &_releaseDate = QDate());
QString getCorrectedShortName() const;
QString getShortName() const { return shortName; }
QString getLongName() const { return longName; }
QString getSetType() const { return setType; }
QDate getReleaseDate() const { return releaseDate; }
void setLongName(QString & _longName) { longName = _longName; }
void setSetType(QString & _setType) { setType = _setType; }
void setReleaseDate(QDate & _releaseDate) { releaseDate = _releaseDate; }
QString getShortName() const
{
return shortName;
}
QString getLongName() const
{
return longName;
}
QString getSetType() const
{
return setType;
}
QDate getReleaseDate() const
{
return releaseDate;
}
void setLongName(const QString &_longName)
{
longName = _longName;
}
void setSetType(const QString &_setType)
{
setType = _setType;
}
void setReleaseDate(const QDate &_releaseDate)
{
releaseDate = _releaseDate;
}
void loadSetOptions();
int getSortKey() const { return sortKey; }
int getSortKey() const
{
return sortKey;
}
void setSortKey(unsigned int _sortKey);
bool getEnabled() const { return enabled; }
bool getEnabled() const
{
return enabled;
}
void setEnabled(bool _enabled);
bool getIsKnown() const { return isknown; }
bool getIsKnown() const
{
return isknown;
}
void setIsKnown(bool _isknown);
// Determine incomplete sets.
bool getIsKnownIgnored() const
{
return longName.length() + setType.length() + releaseDate.toString().length() == 0;
}
};
class SetList : public QList<CardSet *> {
class SetList : public QList<CardSetPtr>
{
private:
class KeyCompareFunctor;
public:
void sortByKey();
void guessSortKeys();
@@ -58,106 +115,233 @@ public:
QStringList getUnknownSetsNames();
};
class CardInfo : public QObject {
class CardInfoPerSet
{
public:
explicit CardInfoPerSet(const CardSetPtr &_set = QSharedPointer<CardSet>(nullptr));
~CardInfoPerSet() = default;
private:
CardSetPtr set;
// per-set card properties;
QVariantHash properties;
public:
const CardSetPtr getPtr() const
{
return set;
}
const QStringList getProperties() const
{
return properties.keys();
}
const QString getProperty(const QString &propertyName) const
{
return properties.value(propertyName).toString();
}
void setProperty(const QString &_name, const QString &_value)
{
properties.insert(_name, _value);
}
};
class CardInfo : public QObject
{
Q_OBJECT
private:
CardInfoPtr smartThis;
// The card name
QString name;
/*
* The name without punctuation or capitalization, for better card tag name
* recognition.
*/
// The name without punctuation or capitalization, for better card name recognition.
QString simpleName;
bool isToken;
SetList sets;
QString manacost;
QString cmc;
QString cardtype;
QString powtough;
// The key used to identify this card in the cache
QString pixmapCacheKey;
// card text
QString text;
QStringList colors;
// whether this is not a "real" card but a token
bool isToken;
// basic card properties; common for all the sets
QVariantHash properties;
// the cards i'm related to
QStringList relatedCards;
QList<CardRelation *> relatedCards;
// the card i'm reverse-related to
QStringList reverseRelatedCards;
QList<CardRelation *> reverseRelatedCards;
// the cards thare are reverse-related to me
QStringList reverseRelatedCardsToMe;
QList<CardRelation *> reverseRelatedCardsToMe;
// card sets
CardInfoPerSetMap sets;
// cached set names
QString setsNames;
bool upsideDownArt;
int loyalty;
QStringMap customPicURLs;
MuidMap muIds;
QStringMap collectorNumbers;
QStringMap rarities;
// positioning properties; used by UI
bool cipt;
int tableRow;
QString pixmapCacheKey;
bool upsideDownArt;
public:
CardInfo(const QString &_name = QString(),
bool _isToken = false,
const QString &_manacost = QString(),
const QString &_cmc = QString(),
const QString &_cardtype = QString(),
const QString &_powtough = QString(),
const QString &_text = QString(),
const QStringList &_colors = QStringList(),
const QStringList &_relatedCards = QStringList(),
const QStringList &_reverseRelatedCards = QStringList(),
bool _upsideDownArt = false,
int _loyalty = 0,
bool _cipt = false,
int _tableRow = 0,
const SetList &_sets = SetList(),
const QStringMap &_customPicURLs = QStringMap(),
MuidMap muids = MuidMap(),
QStringMap _collectorNumbers = QStringMap(),
QStringMap _rarities = QStringMap()
);
~CardInfo();
inline const QString &getName() const { return name; }
inline const QString &getSetsNames() const { return setsNames; }
const QString &getSimpleName() const { return simpleName; }
bool getIsToken() const { return isToken; }
const SetList &getSets() const { return sets; }
inline const QString &getManaCost() const { return manacost; }
inline const QString &getCmc() const { return cmc; }
inline const QString &getCardType() const { return cardtype; }
inline const QString &getPowTough() const { return powtough; }
const QString &getText() const { return text; }
const QString &getPixmapCacheKey() const { return pixmapCacheKey; }
const int &getLoyalty() const { return loyalty; }
bool getCipt() const { return cipt; }
void setManaCost(const QString &_manaCost) { manacost = _manaCost; emit cardInfoChanged(this); }
void setCmc(const QString &_cmc) { cmc = _cmc; emit cardInfoChanged(this); }
void setCardType(const QString &_cardType) { cardtype = _cardType; emit cardInfoChanged(this); }
void setPowTough(const QString &_powTough) { powtough = _powTough; emit cardInfoChanged(this); }
void setText(const QString &_text) { text = _text; emit cardInfoChanged(this); }
void setColors(const QStringList &_colors) { colors = _colors; emit cardInfoChanged(this); }
explicit CardInfo(const QString &_name = QString(),
const QString &_text = QString(),
bool _isToken = false,
QVariantHash _properties = QVariantHash(),
const QList<CardRelation *> &_relatedCards = QList<CardRelation *>(),
const QList<CardRelation *> &_reverseRelatedCards = QList<CardRelation *>(),
CardInfoPerSetMap _sets = CardInfoPerSetMap(),
bool _cipt = false,
int _tableRow = 0,
bool _upsideDownArt = false);
~CardInfo() override;
static CardInfoPtr newInstance(const QString &_name = QString(),
const QString &_text = QString(),
bool _isToken = false,
QVariantHash _properties = QVariantHash(),
const QList<CardRelation *> &_relatedCards = QList<CardRelation *>(),
const QList<CardRelation *> &_reverseRelatedCards = QList<CardRelation *>(),
CardInfoPerSetMap _sets = CardInfoPerSetMap(),
bool _cipt = false,
int _tableRow = 0,
bool _upsideDownArt = false);
void setSmartPointer(CardInfoPtr _ptr)
{
smartThis = std::move(_ptr);
}
// basic properties
inline const QString &getName() const
{
return name;
}
const QString &getSimpleName() const
{
return simpleName;
}
const QString &getPixmapCacheKey() const
{
return pixmapCacheKey;
}
const QString &getText() const
{
return text;
}
void setText(const QString &_text)
{
text = _text;
emit cardInfoChanged(smartThis);
}
bool getIsToken() const
{
return isToken;
}
const QStringList getProperties() const
{
return properties.keys();
}
const QString getProperty(const QString &propertyName) const
{
return properties.value(propertyName).toString();
}
void setProperty(const QString &_name, const QString &_value)
{
properties.insert(_name, _value);
emit cardInfoChanged(smartThis);
}
bool hasProperty(const QString &propertyName) const
{
return properties.contains(propertyName);
}
const CardInfoPerSetMap &getSets() const
{
return sets;
}
const QString &getSetsNames() const
{
return setsNames;
}
const QString getSetProperty(const QString &setName, const QString &propertyName) const
{
if (!sets.contains(setName))
return "";
return sets[setName].getProperty(propertyName);
}
void setSetProperty(const QString &setName, const QString &_name, const QString &_value)
{
if (!sets.contains(setName))
return;
sets[setName].setProperty(_name, _value);
emit cardInfoChanged(smartThis);
}
// related cards
const QList<CardRelation *> &getRelatedCards() const
{
return relatedCards;
}
const QList<CardRelation *> &getReverseRelatedCards() const
{
return reverseRelatedCards;
}
const QList<CardRelation *> &getReverseRelatedCards2Me() const
{
return reverseRelatedCardsToMe;
}
const QList<CardRelation *> getAllRelatedCards() const
{
QList<CardRelation *> result;
result.append(getRelatedCards());
result.append(getReverseRelatedCards2Me());
return result;
}
void resetReverseRelatedCards2Me();
void addReverseRelatedCards2Me(CardRelation *cardRelation)
{
reverseRelatedCardsToMe.append(cardRelation);
}
// positioning
bool getCipt() const
{
return cipt;
}
int getTableRow() const
{
return tableRow;
}
void setTableRow(int _tableRow)
{
tableRow = _tableRow;
}
bool getUpsideDownArt() const
{
return upsideDownArt;
}
const QChar getColorChar() const;
const QStringList &getColors() const { return colors; }
const QStringList &getRelatedCards() const { return relatedCards; }
const QStringList &getReverseRelatedCards() const { return reverseRelatedCards; }
const QStringList &getReverseRelatedCards2Me() const { return reverseRelatedCardsToMe; }
void resetReverseRelatedCards2Me() { reverseRelatedCardsToMe = QStringList(); }
void addReverseRelatedCards2Me(QString & cardName) { reverseRelatedCardsToMe.append(cardName); }
bool getUpsideDownArt() const { return upsideDownArt; }
QString getCustomPicURL(const QString &set) const { return customPicURLs.value(set); }
int getMuId(const QString &set) const { return muIds.value(set); }
QString getCollectorNumber(const QString &set) const { return collectorNumbers.value(set); }
QString getRarity(const QString &set) const { return rarities.value(set); }
QStringMap getRarities() const { return rarities; }
QString getMainCardType() const;
// Back-compatibility methods. Remove ASAP
const QString getCardType() const;
void setCardType(const QString &value);
const QString getCmc() const;
const QString getColors() const;
void setColors(const QString &value);
const QString getLoyalty() const;
const QString getMainCardType() const;
const QString getManaCost() const;
const QString getPowTough() const;
void setPowTough(const QString &value);
// methods using per-set properties
QString getCustomPicURL(const QString &set) const
{
return getSetProperty(set, "picurl");
}
QString getCorrectedName() const;
int getTableRow() const { return tableRow; }
void setTableRow(int _tableRow) { tableRow = _tableRow; }
void setLoyalty(int _loyalty) { loyalty = _loyalty; emit cardInfoChanged(this); }
void setCustomPicURL(const QString &_set, const QString &_customPicURL) { customPicURLs.insert(_set, _customPicURL); }
void setMuId(const QString &_set, const int &_muId) { muIds.insert(_set, _muId); }
void setSetNumber(const QString &_set, const QString &_setNumber) { collectorNumbers.insert(_set, _setNumber); }
void setRarity(const QString &_set, const QString &_setNumber) { rarities.insert(_set, _setNumber); }
void addToSet(CardSet *set);
void emitPixmapUpdated() { emit pixmapUpdated(); }
void addToSet(const CardSetPtr &_set, CardInfoPerSet _info = CardInfoPerSet());
void emitPixmapUpdated()
{
emit pixmapUpdated();
}
void refreshCachedSetNames();
/**
@@ -165,17 +349,27 @@ public:
* less strict name-matching.
*/
static QString simplifyName(const QString &name);
signals:
void pixmapUpdated();
void cardInfoChanged(CardInfo *card);
void cardInfoChanged(CardInfoPtr card);
};
enum LoadStatus { Ok, VersionTooOld, Invalid, NotLoaded, FileError, NoCards };
enum LoadStatus
{
Ok,
VersionTooOld,
Invalid,
NotLoaded,
FileError,
NoCards
};
typedef QHash<QString, CardInfo *> CardNameMap;
typedef QHash<QString, CardSet *> SetNameMap;
typedef QHash<QString, CardInfoPtr> CardNameMap;
typedef QHash<QString, CardSetPtr> SetNameMap;
class CardDatabase : public QObject {
class CardDatabase : public QObject
{
Q_OBJECT
protected:
/*
@@ -194,55 +388,107 @@ protected:
SetNameMap sets;
LoadStatus loadStatus;
private:
static const int versionNeeded;
void loadCardsFromXml(QXmlStreamReader &xml);
void loadSetsFromXml(QXmlStreamReader &xml);
CardInfo *getCardFromMap(const CardNameMap &cardMap, const QString &cardName) const;
QVector<ICardDatabaseParser *> availableParsers;
private:
CardInfoPtr getCardFromMap(const CardNameMap &cardMap, const QString &cardName) const;
void checkUnknownSets();
void refreshCachedReverseRelatedCards();
public:
static const char* TOKENS_SETNAME;
CardDatabase(QObject *parent = 0);
~CardDatabase();
QBasicMutex *reloadDatabaseMutex = new QBasicMutex(), *clearDatabaseMutex = new QBasicMutex(),
*loadFromFileMutex = new QBasicMutex(), *addCardMutex = new QBasicMutex(),
*removeCardMutex = new QBasicMutex();
public:
static const char *TOKENS_SETNAME;
explicit CardDatabase(QObject *parent = nullptr);
~CardDatabase() override;
void clear();
void addCard(CardInfo *card);
void removeCard(CardInfo *card);
CardInfo *getCard(const QString &cardName) const;
QList <CardInfo *> getCards(const QStringList &cardNames) const;
void removeCard(CardInfoPtr card);
CardInfoPtr getCard(const QString &cardName) const;
QList<CardInfoPtr> getCards(const QStringList &cardNames) const;
CardInfoPtr guessCard(const QString &cardName) const;
/*
* Get a card by its simple name. The name will be simplified in this
* function, so you don't need to simplify it beforehand.
*/
CardInfo *getCardBySimpleName(const QString &cardName) const;
CardInfoPtr getCardBySimpleName(const QString &cardName) const;
CardSet *getSet(const QString &setName);
QList<CardInfo *> getCardList() const { return cards.values(); }
CardSetPtr getSet(const QString &setName);
QList<CardInfoPtr> getCardList() const
{
return cards.values();
}
SetList getSetList() const;
LoadStatus loadFromFile(const QString &fileName);
bool saveToFile(const QString &fileName, bool tokens = false);
bool saveCustomTokensToFile();
QStringList getAllColors() const;
QStringList getAllMainCardTypes() const;
LoadStatus getLoadStatus() const { return loadStatus; }
LoadStatus getLoadStatus() const
{
return loadStatus;
}
void enableAllUnknownSets();
void markAllSetsAsKnown();
void notifyEnabledSetsChanged();
public slots:
LoadStatus loadCardDatabases();
private slots:
void addCard(CardInfoPtr card);
void addSet(CardSetPtr set);
protected slots:
LoadStatus loadCardDatabase(const QString &path);
signals:
void cardDatabaseLoadingFailed();
void cardDatabaseNewSetsFound(int numUnknownSets, QStringList unknownSetsNames);
void cardDatabaseAllNewSetsEnabled();
void cardDatabaseEnabledSetsChanged();
void cardAdded(CardInfo *card);
void cardRemoved(CardInfo *card);
void cardAdded(CardInfoPtr card);
void cardRemoved(CardInfoPtr card);
};
class CardRelation : public QObject
{
Q_OBJECT
private:
QString name;
bool doesAttach;
bool isCreateAllExclusion;
bool isVariableCount;
int defaultCount;
public:
explicit CardRelation(const QString &_name = QString(),
bool _doesAttach = false,
bool _isCreateAllExclusion = false,
bool _isVariableCount = false,
int _defaultCount = 1);
inline const QString &getName() const
{
return name;
}
bool getDoesAttach() const
{
return doesAttach;
}
bool getCanCreateAnother() const
{
return !doesAttach;
}
bool getIsCreateAllExclusion() const
{
return isCreateAllExclusion;
}
bool getIsVariable() const
{
return isVariableCount;
}
int getDefaultCount() const
{
return defaultCount;
}
};
#endif

View File

@@ -1,51 +1,61 @@
#include "carddatabasemodel.h"
#include "filtertree.h"
#include <QMap>
#define CARDDBMODEL_COLUMNS 6
CardDatabaseModel::CardDatabaseModel(CardDatabase *_db, QObject *parent)
: QAbstractListModel(parent), db(_db)
CardDatabaseModel::CardDatabaseModel(CardDatabase *_db, bool _showOnlyCardsFromEnabledSets, QObject *parent)
: QAbstractListModel(parent), db(_db), showOnlyCardsFromEnabledSets(_showOnlyCardsFromEnabledSets)
{
connect(db, SIGNAL(cardAdded(CardInfo *)), this, SLOT(cardAdded(CardInfo *)));
connect(db, SIGNAL(cardRemoved(CardInfo *)), this, SLOT(cardRemoved(CardInfo *)));
connect(db, SIGNAL(cardAdded(CardInfoPtr)), this, SLOT(cardAdded(CardInfoPtr)));
connect(db, SIGNAL(cardRemoved(CardInfoPtr)), this, SLOT(cardRemoved(CardInfoPtr)));
connect(db, SIGNAL(cardDatabaseEnabledSetsChanged()), this, SLOT(cardDatabaseEnabledSetsChanged()));
cardDatabaseEnabledSetsChanged();
}
CardDatabaseModel::~CardDatabaseModel()
{
}
CardDatabaseModel::~CardDatabaseModel() = default;
int CardDatabaseModel::rowCount(const QModelIndex &/*parent*/) const
QMap<wchar_t, wchar_t> CardDatabaseDisplayModel::characterTranslation = {{L'', L'\"'},
{L'', L'\"'},
{L'', L'\''},
{L'', L'\''}};
int CardDatabaseModel::rowCount(const QModelIndex & /*parent*/) const
{
return cardList.size();
}
int CardDatabaseModel::columnCount(const QModelIndex &/*parent*/) const
int CardDatabaseModel::columnCount(const QModelIndex & /*parent*/) const
{
return CARDDBMODEL_COLUMNS;
}
QVariant CardDatabaseModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() ||
index.row() >= cardList.size() ||
index.column() >= CARDDBMODEL_COLUMNS ||
if (!index.isValid() || index.row() >= cardList.size() || index.column() >= CARDDBMODEL_COLUMNS ||
(role != Qt::DisplayRole && role != SortRole))
return QVariant();
CardInfo *card = cardList.at(index.row());
switch (index.column()){
case NameColumn: return card->getName();
case SetListColumn: return card->getSetsNames();
case ManaCostColumn: return role == SortRole ?
QString("%1%2").arg(card->getCmc(), 4, QChar('0')).arg(card->getManaCost()) :
card->getManaCost();
case CardTypeColumn: return card->getCardType();
case PTColumn: return card->getPowTough();
case ColorColumn: return card->getColors().join("");
default: return QVariant();
CardInfoPtr card = cardList.at(index.row());
switch (index.column()) {
case NameColumn:
return card->getName();
case SetListColumn:
return card->getSetsNames();
case ManaCostColumn:
return role == SortRole ? QString("%1%2").arg(card->getCmc(), 4, QChar('0')).arg(card->getManaCost())
: card->getManaCost();
case CardTypeColumn:
return card->getCardType();
case PTColumn:
return card->getPowTough();
case ColorColumn:
return card->getColors();
default:
return QVariant();
}
}
@@ -56,30 +66,39 @@ QVariant CardDatabaseModel::headerData(int section, Qt::Orientation orientation,
if (orientation != Qt::Horizontal)
return QVariant();
switch (section) {
case NameColumn: return QString(tr("Name"));
case SetListColumn: return QString(tr("Sets"));
case ManaCostColumn: return QString(tr("Mana cost"));
case CardTypeColumn: return QString(tr("Card type"));
case PTColumn: return QString(tr("P/T"));
case ColorColumn: return QString(tr("Color(s)"));
default: return QVariant();
case NameColumn:
return QString(tr("Name"));
case SetListColumn:
return QString(tr("Sets"));
case ManaCostColumn:
return QString(tr("Mana cost"));
case CardTypeColumn:
return QString(tr("Card type"));
case PTColumn:
return QString(tr("P/T"));
case ColorColumn:
return QString(tr("Color(s)"));
default:
return QVariant();
}
}
void CardDatabaseModel::cardInfoChanged(CardInfo *card)
void CardDatabaseModel::cardInfoChanged(CardInfoPtr card)
{
const int row = cardList.indexOf(card);
if (row == -1)
return;
emit dataChanged(index(row, 0), index(row, CARDDBMODEL_COLUMNS - 1));
}
bool CardDatabaseModel::checkCardHasAtLeastOneEnabledSet(CardInfo *card)
bool CardDatabaseModel::checkCardHasAtLeastOneEnabledSet(CardInfoPtr card)
{
foreach(CardSet * set, card->getSets())
{
if(set->getEnabled())
if (!showOnlyCardsFromEnabledSets)
return true;
for (const auto &set : card->getSets()) {
if (set.getPtr()->getEnabled())
return true;
}
@@ -89,66 +108,67 @@ bool CardDatabaseModel::checkCardHasAtLeastOneEnabledSet(CardInfo *card)
void CardDatabaseModel::cardDatabaseEnabledSetsChanged()
{
// remove all the cards no more present in at least one enabled set
foreach(CardInfo * card, cardList)
{
if(!checkCardHasAtLeastOneEnabledSet(card))
foreach (CardInfoPtr card, cardList) {
if (!checkCardHasAtLeastOneEnabledSet(card))
cardRemoved(card);
}
// re-check all the card currently not shown, maybe their part of a newly-enabled set
foreach(CardInfo * card, db->getCardList())
{
if(!cardList.contains(card))
foreach (CardInfoPtr card, db->getCardList()) {
if (!cardList.contains(card))
cardAdded(card);
}
}
void CardDatabaseModel::cardAdded(CardInfo *card)
void CardDatabaseModel::cardAdded(CardInfoPtr card)
{
if(checkCardHasAtLeastOneEnabledSet(card))
{
if (checkCardHasAtLeastOneEnabledSet(card)) {
// add the card if it's present in at least one enabled set
beginInsertRows(QModelIndex(), cardList.size(), cardList.size());
cardList.append(card);
connect(card, SIGNAL(cardInfoChanged(CardInfo *)), this, SLOT(cardInfoChanged(CardInfo *)));
connect(card.data(), SIGNAL(cardInfoChanged(CardInfoPtr)), this, SLOT(cardInfoChanged(CardInfoPtr)));
endInsertRows();
}
}
void CardDatabaseModel::cardRemoved(CardInfo *card)
void CardDatabaseModel::cardRemoved(CardInfoPtr card)
{
const int row = cardList.indexOf(card);
if (row == -1)
if (row == -1) {
return;
}
beginRemoveRows(QModelIndex(), row, row);
disconnect(card, 0, this, 0);
disconnect(card.data(), nullptr, this, nullptr);
card.clear();
cardList.removeAt(row);
endRemoveRows();
}
CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
: QSortFilterProxyModel(parent),
isToken(ShowAll)
: QSortFilterProxyModel(parent), isToken(ShowAll), filterString(nullptr)
{
filterTree = NULL;
filterTree = nullptr;
setFilterCaseSensitivity(Qt::CaseInsensitive);
setSortCaseSensitivity(Qt::CaseInsensitive);
dirtyTimer.setSingleShot(true);
connect(&dirtyTimer, &QTimer::timeout, this, &CardDatabaseDisplayModel::invalidate);
loadedRowCount = 0;
}
bool CardDatabaseDisplayModel::canFetchMore(const QModelIndex & index) const
bool CardDatabaseDisplayModel::canFetchMore(const QModelIndex &index) const
{
return loadedRowCount < sourceModel()->rowCount(index);
}
void CardDatabaseDisplayModel::fetchMore(const QModelIndex & index)
void CardDatabaseDisplayModel::fetchMore(const QModelIndex &index)
{
int remainder = sourceModel()->rowCount(index) - loadedRowCount;
int itemsToFetch = qMin(100, remainder);
beginInsertRows(QModelIndex(), loadedRowCount, loadedRowCount+itemsToFetch-1);
beginInsertRows(QModelIndex(), loadedRowCount, loadedRowCount + itemsToFetch - 1);
loadedRowCount += itemsToFetch;
endInsertRows();
@@ -159,13 +179,13 @@ int CardDatabaseDisplayModel::rowCount(const QModelIndex &parent) const
return qMin(QSortFilterProxyModel::rowCount(parent), loadedRowCount);
}
bool CardDatabaseDisplayModel::lessThan(const QModelIndex &left, const QModelIndex &right) const {
bool CardDatabaseDisplayModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
QString leftString = sourceModel()->data(left, CardDatabaseModel::SortRole).toString();
QString rightString = sourceModel()->data(right, CardDatabaseModel::SortRole).toString();
if (!cardName.isEmpty() && left.column() == CardDatabaseModel::NameColumn)
{
if (!cardName.isEmpty() && left.column() == CardDatabaseModel::NameColumn) {
bool isLeftType = leftString.startsWith(cardName, Qt::CaseInsensitive);
bool isRightType = rightString.startsWith(cardName, Qt::CaseInsensitive);
@@ -177,28 +197,119 @@ bool CardDatabaseDisplayModel::lessThan(const QModelIndex &left, const QModelInd
// same checks for the right string
if (isRightType && (!isLeftType || rightString.size() == cardName.size()))
return false;
} else if (right.column() == CardDatabaseModel::PTColumn && left.column() == CardDatabaseModel::PTColumn) {
QStringList leftList = leftString.split("/");
QStringList rightList = rightString.split("/");
if (leftList.size() == 2 && rightList.size() == 2) {
// cool, have both P/T in list now
int lessThanNum = lessThanNumerically(leftList.at(0), rightList.at(0));
if (lessThanNum != 0) {
return lessThanNum < 0;
} else {
// power equal, check toughness
return lessThanNumerically(leftList.at(1), rightList.at(1)) < 0;
}
}
}
return QString::localeAwareCompare(leftString, rightString) < 0;
}
int CardDatabaseDisplayModel::lessThanNumerically(const QString &left, const QString &right)
{
if (left == right) {
return 0;
}
bool okLeft, okRight;
float leftNum = left.toFloat(&okLeft);
float rightNum = right.toFloat(&okRight);
if (okLeft && okRight) {
if (leftNum < rightNum) {
return -1;
} else if (leftNum > rightNum) {
return 1;
} else {
return 0;
}
}
// try and parsing again, for weird ones like "1+*"
QString leftAfterNum = "";
QString rightAfterNum = "";
if (!okLeft) {
int leftNumIndex = 0;
for (; leftNumIndex < left.length(); leftNumIndex++) {
if (!left.at(leftNumIndex).isDigit()) {
break;
}
}
if (leftNumIndex != 0) {
leftNum = left.left(leftNumIndex).toFloat(&okLeft);
leftAfterNum = left.right(leftNumIndex);
}
}
if (!okRight) {
int rightNumIndex = 0;
for (; rightNumIndex < right.length(); rightNumIndex++) {
if (!right.at(rightNumIndex).isDigit()) {
break;
}
}
if (rightNumIndex != 0) {
rightNum = right.left(rightNumIndex).toFloat(&okRight);
rightAfterNum = right.right(rightNumIndex);
}
}
if (okLeft && okRight) {
if (leftNum != rightNum) {
// both parsed as numbers, but different number
if (leftNum < rightNum) {
return -1;
} else {
return 1;
}
} else {
// both parsed, same number, but at least one has something else
// so compare the part after the number - prefer nothing
return QString::localeAwareCompare(leftAfterNum, rightAfterNum);
}
} else if (okLeft) {
return -1;
} else if (okRight) {
return 1;
}
// couldn't parse it, just return String comparison
return QString::localeAwareCompare(left, right);
}
bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
{
CardInfo const *info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
CardInfoPtr info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
if (((isToken == ShowTrue) && !info->getIsToken()) || ((isToken == ShowFalse) && info->getIsToken()))
return false;
if (filterString != nullptr) {
if (filterTree != nullptr && !filterTree->acceptsCard(info)) {
return false;
}
return filterString->check(info);
}
return rowMatchesCardName(info);
}
bool CardDatabaseDisplayModel::rowMatchesCardName(CardInfo const *info) const {
bool CardDatabaseDisplayModel::rowMatchesCardName(CardInfoPtr info) const
{
if (!cardName.isEmpty() && !info->getName().contains(cardName, Qt::CaseInsensitive))
return false;
if (!cardNameSet.isEmpty() && !cardNameSet.contains(info->getName()))
return false;
if (filterTree != NULL)
if (filterTree != nullptr)
return filterTree->acceptsCard(info);
return true;
@@ -210,15 +321,15 @@ void CardDatabaseDisplayModel::clearFilterAll()
cardText.clear();
cardTypes.clear();
cardColors.clear();
if (filterTree != NULL)
if (filterTree != nullptr)
filterTree->clear();
invalidateFilter();
}
void CardDatabaseDisplayModel::setFilterTree(FilterTree *filterTree)
{
if (this->filterTree != NULL)
disconnect(this->filterTree, 0, this, 0);
if (this->filterTree != nullptr)
disconnect(this->filterTree, nullptr, this, nullptr);
this->filterTree = filterTree;
connect(this->filterTree, SIGNAL(changed()), this, SLOT(filterTreeChanged()));
@@ -230,15 +341,24 @@ void CardDatabaseDisplayModel::filterTreeChanged()
invalidate();
}
TokenDisplayModel::TokenDisplayModel(QObject *parent)
: CardDatabaseDisplayModel(parent)
const QString CardDatabaseDisplayModel::sanitizeCardName(const QString &dirtyName, const QMap<wchar_t, wchar_t> &table)
{
std::wstring toReturn = dirtyName.toStdWString();
for (wchar_t &ch : toReturn) {
if (table.contains(ch)) {
ch = table.value(ch);
}
}
return QString::fromStdWString(toReturn);
}
TokenDisplayModel::TokenDisplayModel(QObject *parent) : CardDatabaseDisplayModel(parent)
{
}
bool TokenDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
{
CardInfo const *info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
CardInfoPtr info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
return info->getIsToken() && rowMatchesCardName(info);
}
@@ -247,3 +367,19 @@ int TokenDisplayModel::rowCount(const QModelIndex &parent) const
// always load all tokens at start
return QSortFilterProxyModel::rowCount(parent);
}
TokenEditModel::TokenEditModel(QObject *parent) : CardDatabaseDisplayModel(parent)
{
}
bool TokenEditModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
{
CardInfoPtr info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
return info->getIsToken() && info->getSets().contains(CardDatabase::TOKENS_SETNAME) && rowMatchesCardName(info);
}
int TokenEditModel::rowCount(const QModelIndex &parent) const
{
// always load all tokens at start
return QSortFilterProxyModel::rowCount(parent);
}

View File

@@ -1,80 +1,155 @@
#ifndef CARDDATABASEMODEL_H
#define CARDDATABASEMODEL_H
#include "carddatabase.h"
#include "filter_string.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include <QList>
#include <QSet>
#include "carddatabase.h"
#include <QSortFilterProxyModel>
#include <QTimer>
class FilterTree;
class CardDatabaseModel : public QAbstractListModel {
class CardDatabaseModel : public QAbstractListModel
{
Q_OBJECT
public:
enum Columns { NameColumn, SetListColumn, ManaCostColumn, PTColumn, CardTypeColumn, ColorColumn };
enum Role { SortRole=Qt::UserRole };
CardDatabaseModel(CardDatabase *_db, QObject *parent = 0);
~CardDatabaseModel();
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
CardDatabase *getDatabase() const { return db; }
CardInfo *getCard(int index) const { return cardList[index]; }
private:
QList<CardInfo *> cardList;
CardDatabase *db;
enum Columns
{
NameColumn,
SetListColumn,
ManaCostColumn,
PTColumn,
CardTypeColumn,
ColorColumn
};
enum Role
{
SortRole = Qt::UserRole
};
CardDatabaseModel(CardDatabase *_db, bool _showOnlyCardsFromEnabledSets, QObject *parent = nullptr);
~CardDatabaseModel() override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
CardDatabase *getDatabase() const
{
return db;
}
CardInfoPtr getCard(int index) const
{
return cardList[index];
}
inline bool checkCardHasAtLeastOneEnabledSet(CardInfo *card);
private:
QList<CardInfoPtr> cardList;
CardDatabase *db;
bool showOnlyCardsFromEnabledSets;
inline bool checkCardHasAtLeastOneEnabledSet(CardInfoPtr card);
private slots:
void cardAdded(CardInfo *card);
void cardRemoved(CardInfo *card);
void cardInfoChanged(CardInfo *card);
void cardAdded(CardInfoPtr card);
void cardRemoved(CardInfoPtr card);
void cardInfoChanged(CardInfoPtr card);
void cardDatabaseEnabledSetsChanged();
};
class CardDatabaseDisplayModel : public QSortFilterProxyModel {
class CardDatabaseDisplayModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
enum FilterBool { ShowTrue, ShowFalse, ShowAll };
enum FilterBool
{
ShowTrue,
ShowFalse,
ShowAll
};
private:
FilterBool isToken;
QString cardNameBeginning, cardName, cardText;
QString searchTerm;
QString cardName, cardText;
QSet<QString> cardNameSet, cardTypes, cardColors;
FilterTree *filterTree;
FilterString *filterString;
int loadedRowCount;
QTimer dirtyTimer;
/** The translation table that will be used for sanitizeCardName. */
static QMap<wchar_t, wchar_t> characterTranslation;
public:
CardDatabaseDisplayModel(QObject *parent = 0);
explicit CardDatabaseDisplayModel(QObject *parent = nullptr);
void setFilterTree(FilterTree *filterTree);
void setIsToken(FilterBool _isToken) { isToken = _isToken; invalidate(); }
void setCardNameBeginning(const QString &_beginning) { cardNameBeginning = _beginning; invalidate(); }
void setCardName(const QString &_cardName) { cardName = _cardName; invalidate(); }
void setCardNameSet(const QSet<QString> &_cardNameSet) { cardNameSet = _cardNameSet; invalidate(); }
void setSearchTerm(const QString &_searchTerm) { searchTerm = _searchTerm; }
void setCardText(const QString &_cardText) { cardText = _cardText; invalidate(); }
void setCardTypes(const QSet<QString> &_cardTypes) { cardTypes = _cardTypes; invalidate(); }
void setCardColors(const QSet<QString> &_cardColors) { cardColors = _cardColors; invalidate(); }
void setIsToken(FilterBool _isToken)
{
isToken = _isToken;
dirty();
}
void setCardName(const QString &_cardName)
{
if (filterString != nullptr) {
delete filterString;
filterString = nullptr;
}
cardName = sanitizeCardName(_cardName, characterTranslation);
dirty();
}
void setStringFilter(const QString &_src)
{
delete filterString;
filterString = new FilterString(_src);
dirty();
}
void setCardNameSet(const QSet<QString> &_cardNameSet)
{
cardNameSet = _cardNameSet;
dirty();
}
void dirty()
{
dirtyTimer.start(20);
}
void clearFilterAll();
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
bool rowMatchesCardName(CardInfo const *info) const;
bool canFetchMore(const QModelIndex &parent) const;
void fetchMore(const QModelIndex &parent);
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
static int lessThanNumerically(const QString &left, const QString &right);
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
bool rowMatchesCardName(CardInfoPtr info) const;
bool canFetchMore(const QModelIndex &parent) const override;
void fetchMore(const QModelIndex &parent) override;
private slots:
void filterTreeChanged();
/** Will translate all undesirable characters in DIRTYNAME according to the TABLE. */
const QString sanitizeCardName(const QString &dirtyName, const QMap<wchar_t, wchar_t> &table);
};
class TokenDisplayModel : public CardDatabaseDisplayModel {
class TokenDisplayModel : public CardDatabaseDisplayModel
{
Q_OBJECT
public:
TokenDisplayModel(QObject *parent = 0);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
explicit TokenDisplayModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
};
class TokenEditModel : public CardDatabaseDisplayModel
{
Q_OBJECT
public:
explicit TokenEditModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
};
#endif

View File

@@ -0,0 +1,27 @@
#include "carddatabaseparser.h"
SetNameMap ICardDatabaseParser::sets;
void ICardDatabaseParser::clearSetlist()
{
sets.clear();
}
CardSetPtr ICardDatabaseParser::internalAddSet(const QString &setName,
const QString &longName,
const QString &setType,
const QDate &releaseDate)
{
if (sets.contains(setName)) {
return sets.value(setName);
}
CardSetPtr newSet = CardSet::newInstance(setName);
newSet->setLongName(longName);
newSet->setSetType(setType);
newSet->setReleaseDate(releaseDate);
sets.insert(setName, newSet);
emit addSet(newSet);
return newSet;
}

View File

@@ -0,0 +1,43 @@
#ifndef CARDDATABASE_PARSER_H
#define CARDDATABASE_PARSER_H
#include "../carddatabase.h"
#include <QIODevice>
#include <QString>
#define COCKATRICE_XML_XSI_NAMESPACE "http://www.w3.org/2001/XMLSchema-instance"
class ICardDatabaseParser : public QObject
{
public:
~ICardDatabaseParser() override = default;
virtual bool getCanParseFile(const QString &name, QIODevice &device) = 0;
virtual void parseFile(QIODevice &device) = 0;
virtual bool saveToFile(SetNameMap sets,
CardNameMap cards,
const QString &fileName,
const QString &sourceUrl = "unknown",
const QString &sourceVersion = "unknown") = 0;
static void clearSetlist();
protected:
/*
* A cached list of the available sets, needed to cross-reference sets from cards.
* Shared between all parsers
*/
static SetNameMap sets;
CardSetPtr internalAddSet(const QString &setName,
const QString &longName = "",
const QString &setType = "",
const QDate &releaseDate = QDate());
signals:
virtual void addCard(CardInfoPtr card) = 0;
virtual void addSet(CardSetPtr set) = 0;
};
Q_DECLARE_INTERFACE(ICardDatabaseParser, "ICardDatabaseParser")
#endif

View File

@@ -0,0 +1,457 @@
#include "cockatricexml3.h"
#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QXmlStreamReader>
#include <version_string.h>
#define COCKATRICE_XML3_TAGNAME "cockatrice_carddatabase"
#define COCKATRICE_XML3_TAGVER 3
#define COCKATRICE_XML3_SCHEMALOCATION \
"https://raw.githubusercontent.com/Cockatrice/Cockatrice/master/doc/carddatabase_v3/cards.xsd"
bool CockatriceXml3Parser::getCanParseFile(const QString &fileName, QIODevice &device)
{
qDebug() << "[CockatriceXml3Parser] Trying to parse: " << fileName;
if (!fileName.endsWith(".xml", Qt::CaseInsensitive)) {
qDebug() << "[CockatriceXml3Parser] Parsing failed: wrong extension";
return false;
}
QXmlStreamReader xml(&device);
while (!xml.atEnd()) {
if (xml.readNext() == QXmlStreamReader::StartElement) {
if (xml.name() == COCKATRICE_XML3_TAGNAME) {
int version = xml.attributes().value("version").toString().toInt();
if (version == COCKATRICE_XML3_TAGVER) {
return true;
} else {
qDebug() << "[CockatriceXml3Parser] Parsing failed: wrong version" << version;
return false;
}
} else {
qDebug() << "[CockatriceXml3Parser] Parsing failed: wrong element tag" << xml.name();
return false;
}
}
}
return true;
}
void CockatriceXml3Parser::parseFile(QIODevice &device)
{
QXmlStreamReader xml(&device);
while (!xml.atEnd()) {
if (xml.readNext() == QXmlStreamReader::StartElement) {
while (!xml.atEnd()) {
if (xml.readNext() == QXmlStreamReader::EndElement) {
break;
}
if (xml.name() == "sets") {
loadSetsFromXml(xml);
} else if (xml.name() == "cards") {
loadCardsFromXml(xml);
} else if (xml.name() != "") {
qDebug() << "[CockatriceXml3Parser] Unknown item" << xml.name() << ", trying to continue anyway";
xml.skipCurrentElement();
}
}
}
}
}
void CockatriceXml3Parser::loadSetsFromXml(QXmlStreamReader &xml)
{
while (!xml.atEnd()) {
if (xml.readNext() == QXmlStreamReader::EndElement) {
break;
}
if (xml.name() == "set") {
QString shortName, longName, setType;
QDate releaseDate;
while (!xml.atEnd()) {
if (xml.readNext() == QXmlStreamReader::EndElement) {
break;
}
if (xml.name() == "name") {
shortName = xml.readElementText(QXmlStreamReader::IncludeChildElements);
} else if (xml.name() == "longname") {
longName = xml.readElementText(QXmlStreamReader::IncludeChildElements);
} else if (xml.name() == "settype") {
setType = xml.readElementText(QXmlStreamReader::IncludeChildElements);
} else if (xml.name() == "releasedate") {
releaseDate =
QDate::fromString(xml.readElementText(QXmlStreamReader::IncludeChildElements), Qt::ISODate);
} else if (xml.name() != "") {
qDebug() << "[CockatriceXml3Parser] Unknown set property" << xml.name()
<< ", trying to continue anyway";
xml.skipCurrentElement();
}
}
internalAddSet(shortName, longName, setType, releaseDate);
}
}
}
QString CockatriceXml3Parser::getMainCardType(QString &type)
{
QString result = type;
/*
Legendary Artifact Creature - Golem
Instant // Instant
*/
int pos;
if ((pos = result.indexOf('-')) != -1) {
result.remove(pos, result.length());
}
if ((pos = result.indexOf("")) != -1) {
result.remove(pos, result.length());
}
if ((pos = result.indexOf("//")) != -1) {
result.remove(pos, result.length());
}
result = result.simplified();
/*
Legendary Artifact Creature
Instant
*/
if ((pos = result.lastIndexOf(' ')) != -1) {
result = result.mid(pos + 1);
}
/*
Creature
Instant
*/
return result;
}
void CockatriceXml3Parser::loadCardsFromXml(QXmlStreamReader &xml)
{
while (!xml.atEnd()) {
if (xml.readNext() == QXmlStreamReader::EndElement) {
break;
}
if (xml.name() == "card") {
QString name = QString("");
QString text = QString("");
QVariantHash properties = QVariantHash();
QString colors = QString("");
QList<CardRelation *> relatedCards, reverseRelatedCards;
CardInfoPerSetMap sets = CardInfoPerSetMap();
int tableRow = 0;
bool cipt = false;
bool isToken = false;
bool upsideDown = false;
while (!xml.atEnd()) {
if (xml.readNext() == QXmlStreamReader::EndElement) {
break;
}
// variable - assigned properties
if (xml.name() == "name") {
name = xml.readElementText(QXmlStreamReader::IncludeChildElements);
} else if (xml.name() == "text") {
text = xml.readElementText(QXmlStreamReader::IncludeChildElements);
} else if (xml.name() == "color") {
colors.append(xml.readElementText(QXmlStreamReader::IncludeChildElements));
} else if (xml.name() == "token") {
isToken = static_cast<bool>(xml.readElementText(QXmlStreamReader::IncludeChildElements).toInt());
// generic properties
} else if (xml.name() == "manacost") {
properties.insert("manacost", xml.readElementText(QXmlStreamReader::IncludeChildElements));
} else if (xml.name() == "cmc") {
properties.insert("cmc", xml.readElementText(QXmlStreamReader::IncludeChildElements));
} else if (xml.name() == "type") {
QString type = xml.readElementText(QXmlStreamReader::IncludeChildElements);
properties.insert("type", type);
properties.insert("maintype", getMainCardType(type));
} else if (xml.name() == "pt") {
properties.insert("pt", xml.readElementText(QXmlStreamReader::IncludeChildElements));
} else if (xml.name() == "loyalty") {
properties.insert("loyalty", xml.readElementText(QXmlStreamReader::IncludeChildElements));
// positioning info
} else if (xml.name() == "tablerow") {
tableRow = xml.readElementText(QXmlStreamReader::IncludeChildElements).toInt();
} else if (xml.name() == "cipt") {
cipt = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1");
} else if (xml.name() == "upsidedown") {
upsideDown = (xml.readElementText(QXmlStreamReader::IncludeChildElements) == "1");
// sets
} else if (xml.name() == "set") {
// NOTE: attributes must be read before readElementText()
QXmlStreamAttributes attrs = xml.attributes();
QString setName = xml.readElementText(QXmlStreamReader::IncludeChildElements);
CardInfoPerSet setInfo(internalAddSet(setName));
if (attrs.hasAttribute("muId")) {
setInfo.setProperty("muid", attrs.value("muId").toString());
}
if (attrs.hasAttribute("muId")) {
setInfo.setProperty("uuid", attrs.value("uuId").toString());
}
if (attrs.hasAttribute("picURL")) {
setInfo.setProperty("picurl", attrs.value("picURL").toString());
}
if (attrs.hasAttribute("num")) {
setInfo.setProperty("num", attrs.value("num").toString());
}
if (attrs.hasAttribute("rarity")) {
setInfo.setProperty("rarity", attrs.value("rarity").toString());
}
sets.insert(setName, setInfo);
// relatd cards
} else if (xml.name() == "related" || xml.name() == "reverse-related") {
bool attach = false;
bool exclude = false;
bool variable = false;
int count = 1;
QXmlStreamAttributes attrs = xml.attributes();
QString cardName = xml.readElementText(QXmlStreamReader::IncludeChildElements);
if (attrs.hasAttribute("count")) {
if (attrs.value("count").toString().indexOf("x=") == 0) {
variable = true;
count = attrs.value("count").toString().remove(0, 2).toInt();
} else if (attrs.value("count").toString().indexOf("x") == 0) {
variable = true;
} else {
count = attrs.value("count").toString().toInt();
}
if (count < 1) {
count = 1;
}
}
if (attrs.hasAttribute("attach")) {
attach = true;
}
if (attrs.hasAttribute("exclude")) {
exclude = true;
}
auto *relation = new CardRelation(cardName, attach, exclude, variable, count);
if (xml.name() == "reverse-related") {
reverseRelatedCards << relation;
} else {
relatedCards << relation;
}
} else if (xml.name() != "") {
qDebug() << "[CockatriceXml3Parser] Unknown card property" << xml.name()
<< ", trying to continue anyway";
xml.skipCurrentElement();
}
}
properties.insert("colors", colors);
CardInfoPtr newCard = CardInfo::newInstance(name, text, isToken, properties, relatedCards,
reverseRelatedCards, sets, cipt, tableRow, upsideDown);
emit addCard(newCard);
}
}
}
static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSetPtr &set)
{
if (set.isNull()) {
qDebug() << "&operator<< set is nullptr";
return xml;
}
xml.writeStartElement("set");
xml.writeTextElement("name", set->getShortName());
xml.writeTextElement("longname", set->getLongName());
xml.writeTextElement("settype", set->getSetType());
xml.writeTextElement("releasedate", set->getReleaseDate().toString(Qt::ISODate));
xml.writeEndElement();
return xml;
}
static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &info)
{
if (info.isNull()) {
qDebug() << "operator<< info is nullptr";
return xml;
}
QString tmpString;
xml.writeStartElement("card");
// variable - assigned properties
xml.writeTextElement("name", info->getName());
xml.writeTextElement("text", info->getText());
if (info->getIsToken()) {
xml.writeTextElement("token", "1");
}
// generic properties
xml.writeTextElement("manacost", info->getProperty("manacost"));
xml.writeTextElement("cmc", info->getProperty("cmc"));
xml.writeTextElement("type", info->getProperty("type"));
int colorSize = info->getColors().size();
for (int i = 0; i < colorSize; ++i) {
xml.writeTextElement("color", info->getColors().at(i));
}
tmpString = info->getProperty("pt");
if (!tmpString.isEmpty()) {
xml.writeTextElement("pt", tmpString);
}
tmpString = info->getProperty("loyalty");
if (!tmpString.isEmpty()) {
xml.writeTextElement("loyalty", tmpString);
}
// sets
const CardInfoPerSetMap sets = info->getSets();
for (CardInfoPerSet set : sets) {
xml.writeStartElement("set");
xml.writeAttribute("rarity", set.getProperty("rarity"));
xml.writeAttribute("muId", set.getProperty("muid"));
xml.writeAttribute("uuId", set.getProperty("uuid"));
tmpString = set.getProperty("num");
if (!tmpString.isEmpty()) {
xml.writeAttribute("num", tmpString);
}
tmpString = set.getProperty("picurl");
if (!tmpString.isEmpty()) {
xml.writeAttribute("picURL", tmpString);
}
xml.writeCharacters(set.getPtr()->getShortName());
xml.writeEndElement();
}
// related cards
const QList<CardRelation *> related = info->getRelatedCards();
for (auto i : related) {
xml.writeStartElement("related");
if (i->getDoesAttach()) {
xml.writeAttribute("attach", "attach");
}
if (i->getIsCreateAllExclusion()) {
xml.writeAttribute("exclude", "exclude");
}
if (i->getIsVariable()) {
if (1 == i->getDefaultCount()) {
xml.writeAttribute("count", "x");
} else {
xml.writeAttribute("count", "x=" + QString::number(i->getDefaultCount()));
}
} else if (1 != i->getDefaultCount()) {
xml.writeAttribute("count", QString::number(i->getDefaultCount()));
}
xml.writeCharacters(i->getName());
xml.writeEndElement();
}
const QList<CardRelation *> reverseRelated = info->getReverseRelatedCards();
for (auto i : reverseRelated) {
xml.writeStartElement("reverse-related");
if (i->getDoesAttach()) {
xml.writeAttribute("attach", "attach");
}
if (i->getIsCreateAllExclusion()) {
xml.writeAttribute("exclude", "exclude");
}
if (i->getIsVariable()) {
if (1 == i->getDefaultCount()) {
xml.writeAttribute("count", "x");
} else {
xml.writeAttribute("count", "x=" + QString::number(i->getDefaultCount()));
}
} else if (1 != i->getDefaultCount()) {
xml.writeAttribute("count", QString::number(i->getDefaultCount()));
}
xml.writeCharacters(i->getName());
xml.writeEndElement();
}
// positioning
xml.writeTextElement("tablerow", QString::number(info->getTableRow()));
if (info->getCipt()) {
xml.writeTextElement("cipt", "1");
}
if (info->getUpsideDownArt()) {
xml.writeTextElement("upsidedown", "1");
}
xml.writeEndElement(); // card
return xml;
}
bool CockatriceXml3Parser::saveToFile(SetNameMap sets,
CardNameMap cards,
const QString &fileName,
const QString &sourceUrl,
const QString &sourceVersion)
{
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly)) {
return false;
}
QXmlStreamWriter xml(&file);
xml.setAutoFormatting(true);
xml.writeStartDocument();
xml.writeStartElement(COCKATRICE_XML3_TAGNAME);
xml.writeAttribute("version", QString::number(COCKATRICE_XML3_TAGVER));
xml.writeAttribute("xmlns:xsi", COCKATRICE_XML_XSI_NAMESPACE);
xml.writeAttribute("xsi:schemaLocation", COCKATRICE_XML3_SCHEMALOCATION);
xml.writeStartElement("info");
xml.writeTextElement("author", QCoreApplication::applicationName() + QString(" %1").arg(VERSION_STRING));
xml.writeTextElement("createdAt", QDateTime::currentDateTimeUtc().toString(Qt::ISODate));
xml.writeTextElement("sourceUrl", sourceUrl);
xml.writeTextElement("sourceVersion", sourceVersion);
xml.writeEndElement();
if (sets.count() > 0) {
xml.writeStartElement("sets");
for (CardSetPtr set : sets) {
xml << set;
}
xml.writeEndElement();
}
if (cards.count() > 0) {
xml.writeStartElement("cards");
for (CardInfoPtr card : cards) {
xml << card;
}
xml.writeEndElement();
}
xml.writeEndElement(); // cockatrice_carddatabase
xml.writeEndDocument();
return true;
}

Some files were not shown because too many files have changed in this diff Show More