mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-18 12:53:54 -07:00
Compare commits
No commits in common. "master" and "@cockatrice/sockatrice@4.0.1" have entirely different histories.
master
...
@cockatric
224 changed files with 1957 additions and 3151 deletions
|
|
@ -13,9 +13,17 @@ fi
|
||||||
# Check formatting using format.sh
|
# Check formatting using format.sh
|
||||||
echo "Checking your code using format.sh..."
|
echo "Checking your code using format.sh..."
|
||||||
|
|
||||||
./format.sh --color-diff --cmake --shell --print-version --branch origin/master
|
diff="$(./format.sh --diff --cmake --shell --print-version --branch origin/master)"
|
||||||
err=$?
|
err=$?
|
||||||
|
|
||||||
|
sep="
|
||||||
|
----------
|
||||||
|
"
|
||||||
|
used_version="${diff%%"$sep"*}"
|
||||||
|
diff="${diff#*"$sep"}"
|
||||||
|
changes_to_make="${diff%%"$sep"*}"
|
||||||
|
files_to_edit="${diff#*"$sep"}"
|
||||||
|
|
||||||
case $err in
|
case $err in
|
||||||
1)
|
1)
|
||||||
cat <<EOM
|
cat <<EOM
|
||||||
|
|
@ -28,10 +36,19 @@ case $err in
|
||||||
*** Then commit and push those changes to this branch. ***
|
*** Then commit and push those changes to this branch. ***
|
||||||
*** Check our CONTRIBUTING.md file for more details. ***
|
*** Check our CONTRIBUTING.md file for more details. ***
|
||||||
*** ***
|
*** ***
|
||||||
*** Thank you ❤️ ***
|
*** Thank you ❤️ ***
|
||||||
*** ***
|
*** ***
|
||||||
***********************************************************
|
***********************************************************
|
||||||
|
|
||||||
|
Used version:
|
||||||
|
$used_version
|
||||||
|
|
||||||
|
Affected files:
|
||||||
|
$files_to_edit
|
||||||
|
|
||||||
|
The following changes should be made:
|
||||||
|
$changes_to_make
|
||||||
|
|
||||||
Exiting...
|
Exiting...
|
||||||
EOM
|
EOM
|
||||||
exit 2
|
exit 2
|
||||||
|
|
@ -48,6 +65,9 @@ EOM
|
||||||
*** ***
|
*** ***
|
||||||
***********************************************************
|
***********************************************************
|
||||||
|
|
||||||
|
Used version:
|
||||||
|
$used_version
|
||||||
|
|
||||||
Exiting...
|
Exiting...
|
||||||
EOM
|
EOM
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
350
.github/workflows/desktop-build.yml
vendored
350
.github/workflows/desktop-build.yml
vendored
|
|
@ -1,10 +1,10 @@
|
||||||
name: Build Desktop
|
name: Build Desktop
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
actions: write # needed to delete entries in GHA cache (update ccache)
|
|
||||||
attestations: write # needed to persist the attestation.
|
|
||||||
contents: write
|
contents: write
|
||||||
id-token: write # needed for signing certificate in attestation
|
id-token: write
|
||||||
|
attestations: write
|
||||||
|
actions: write # needed for ccache action to be able to delete gha caches
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
@ -19,7 +19,7 @@ on:
|
||||||
- '.github/workflows/desktop-build.yml'
|
- '.github/workflows/desktop-build.yml'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- 'vcpkg.json'
|
- 'vcpkg.json'
|
||||||
- 'vcpkg' # needed to match submodule bumps (gitlink)
|
- 'vcpkg'
|
||||||
tags:
|
tags:
|
||||||
- '*'
|
- '*'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
@ -32,7 +32,7 @@ on:
|
||||||
- '.github/workflows/desktop-build.yml'
|
- '.github/workflows/desktop-build.yml'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- 'vcpkg.json'
|
- 'vcpkg.json'
|
||||||
- 'vcpkg' # needed to match submodule bumps (gitlink)
|
- 'vcpkg'
|
||||||
|
|
||||||
# Cancel earlier, unfinished runs of this workflow on the same branch (unless on release)
|
# Cancel earlier, unfinished runs of this workflow on the same branch (unless on release)
|
||||||
concurrency:
|
concurrency:
|
||||||
|
|
@ -44,11 +44,11 @@ jobs:
|
||||||
name: Configure
|
name: Configure
|
||||||
runs-on: ubuntu-slim
|
runs-on: ubuntu-slim
|
||||||
outputs:
|
outputs:
|
||||||
tag: ${{ steps.configure.outputs.tag }}
|
tag: ${{steps.configure.outputs.tag}}
|
||||||
sha: ${{ steps.configure.outputs.sha }}
|
sha: ${{steps.configure.outputs.sha}}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Configure"
|
- name: Configure
|
||||||
id: configure
|
id: configure
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -64,150 +64,146 @@ jobs:
|
||||||
fi
|
fi
|
||||||
echo "sha=$sha" >>"$GITHUB_OUTPUT"
|
echo "sha=$sha" >>"$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: "Checkout"
|
- name: Checkout
|
||||||
if: steps.configure.outputs.tag != null
|
if: steps.configure.outputs.tag != null
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # fetch all history for all branches and tags
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: "Prepare release parameters"
|
- name: Prepare release parameters
|
||||||
id: prepare
|
id: prepare
|
||||||
if: steps.configure.outputs.tag != null
|
if: steps.configure.outputs.tag != null
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
TAG: ${{ steps.configure.outputs.tag }}
|
TAG: ${{steps.configure.outputs.tag}}
|
||||||
run: .ci/prep_release.sh
|
run: .ci/prep_release.sh
|
||||||
|
|
||||||
- name: "Create release"
|
- name: Create release
|
||||||
if: steps.configure.outputs.tag != null
|
if: steps.configure.outputs.tag != null
|
||||||
id: create_release
|
id: create_release
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{github.token}}
|
||||||
tag_name: ${{ steps.configure.outputs.tag }}
|
tag_name: ${{steps.configure.outputs.tag}}
|
||||||
target: ${{ steps.configure.outputs.sha }}
|
target: ${{steps.configure.outputs.sha}}
|
||||||
release_name: ${{ steps.prepare.outputs.title }}
|
release_name: ${{steps.prepare.outputs.title}}
|
||||||
body_path: ${{ steps.prepare.outputs.body_path }}
|
body_path: ${{steps.prepare.outputs.body_path}}
|
||||||
prerelease: ${{ steps.prepare.outputs.is_beta }}
|
prerelease: ${{steps.prepare.outputs.is_beta}}
|
||||||
run: |
|
run: |
|
||||||
args=()
|
if [[ $prerelease == yes ]]; then
|
||||||
[[ $prerelease == yes ]] && args+=(--prerelease)
|
args="--prerelease"
|
||||||
|
fi
|
||||||
gh release create "$tag_name" --verify-tag --draft "${args[@]}" \
|
gh release create "$tag_name" --draft --verify-tag $args \
|
||||||
--target "$target" \
|
--target "$target" --title "$release_name" \
|
||||||
--title "$release_name" \
|
--notes-file "$body_path"
|
||||||
--notes-file "$body_path"
|
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
# The files in ".ci/$distro$version" correspond to the values given here
|
# These names correspond to the files in ".ci/$distro$version"
|
||||||
include:
|
include:
|
||||||
- distro: Arch
|
- distro: Arch
|
||||||
|
|
||||||
allow-failure: yes
|
|
||||||
package: skip # We are packaged in Arch already
|
package: skip # We are packaged in Arch already
|
||||||
|
allow-failure: yes
|
||||||
|
|
||||||
- distro: Servatrice_Debian
|
- distro: Servatrice_Debian
|
||||||
version: 12
|
version: 12
|
||||||
|
|
||||||
package: DEB
|
package: DEB
|
||||||
server_only: yes
|
|
||||||
test: skip
|
test: skip
|
||||||
|
server_only: yes
|
||||||
|
|
||||||
- distro: Debian
|
- distro: Debian
|
||||||
version: 12
|
version: 12
|
||||||
|
|
||||||
package: DEB
|
package: DEB
|
||||||
test: skip # Running tests on all distros is superfluous
|
test: skip # Running tests on all distros is superfluous
|
||||||
|
|
||||||
- distro: Debian
|
- distro: Debian
|
||||||
version: 13
|
version: 13
|
||||||
|
|
||||||
package: DEB
|
package: DEB
|
||||||
|
|
||||||
- distro: Fedora
|
- distro: Fedora
|
||||||
version: 43
|
version: 43
|
||||||
|
|
||||||
package: RPM
|
package: RPM
|
||||||
test: skip # Running tests on all distros is superfluous
|
test: skip # Running tests on all distros is superfluous
|
||||||
|
|
||||||
- distro: Fedora
|
- distro: Fedora
|
||||||
version: 44
|
version: 44
|
||||||
|
|
||||||
package: RPM
|
package: RPM
|
||||||
|
|
||||||
- distro: Ubuntu
|
- distro: Ubuntu
|
||||||
version: 24.04
|
version: 24.04
|
||||||
|
|
||||||
package: DEB
|
package: DEB
|
||||||
test: skip # Running tests on all distros is superfluous
|
test: skip # Running tests on all distros is superfluous
|
||||||
|
|
||||||
- distro: Ubuntu
|
- distro: Ubuntu
|
||||||
version: 26.04
|
version: 26.04
|
||||||
|
|
||||||
package: DEB
|
package: DEB
|
||||||
|
|
||||||
name: ${{ matrix.distro }} ${{ matrix.version }}
|
name: ${{matrix.distro}} ${{matrix.version}}
|
||||||
needs: configure
|
needs: configure
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
continue-on-error: ${{ matrix.allow-failure == 'yes' }}
|
continue-on-error: ${{matrix.allow-failure == 'yes'}}
|
||||||
timeout-minutes: 70
|
timeout-minutes: 70
|
||||||
env:
|
env:
|
||||||
CACHE: ${{ github.workspace }}/.cache/${{ matrix.distro }}${{ matrix.version }} # directory for caching docker image and ccache
|
NAME: ${{matrix.distro}}${{matrix.version}}
|
||||||
|
CACHE: ${{github.workspace}}/.cache/${{matrix.distro}}${{matrix.version}} # directory for caching docker image and ccache
|
||||||
|
# Cache size over the entire repo is 10Gi:
|
||||||
|
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
|
||||||
|
CCACHE_SIZE: 550M
|
||||||
CCACHE_EVICTION_AGE: 7d
|
CCACHE_EVICTION_AGE: 7d
|
||||||
CCACHE_SIZE: 550M # space of all repo is 10Gi: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
|
|
||||||
CMAKE_GENERATOR: 'Ninja'
|
CMAKE_GENERATOR: 'Ninja'
|
||||||
NAME: ${{ matrix.distro }}${{ matrix.version }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout"
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Restore compiler cache (ccache)"
|
- name: Restore compiler cache (ccache)
|
||||||
id: ccache_restore
|
id: ccache_restore
|
||||||
uses: actions/cache/restore@v5
|
uses: actions/cache/restore@v5
|
||||||
env:
|
env:
|
||||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||||
with:
|
with:
|
||||||
key: ccache-${{ matrix.distro }}${{ matrix.version }}-${{ env.BRANCH_NAME }}
|
path: ${{env.CACHE}}
|
||||||
path: ${{ env.CACHE }}
|
key: ccache-${{matrix.distro}}${{matrix.version}}-${{env.BRANCH_NAME}}
|
||||||
restore-keys: ccache-${{ matrix.distro }}${{ matrix.version }}-
|
restore-keys: ccache-${{matrix.distro}}${{matrix.version}}-
|
||||||
|
|
||||||
- name: "Build ${{ matrix.distro }} ${{ matrix.version }} Docker image"
|
- name: Build ${{matrix.distro}} ${{matrix.version}} Docker image
|
||||||
shell: bash
|
shell: bash
|
||||||
run: source .ci/docker.sh --build
|
run: source .ci/docker.sh --build
|
||||||
|
|
||||||
- name: "Build debug and test"
|
- name: Build debug and test
|
||||||
if: matrix.test != 'skip'
|
if: matrix.test != 'skip'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
source .ci/docker.sh
|
source .ci/docker.sh
|
||||||
RUN --server --debug --test --ccache "$CCACHE_SIZE" \
|
RUN --server --debug --test --ccache "$CCACHE_SIZE" \
|
||||||
--cmake-generator "$CMAKE_GENERATOR"
|
--cmake-generator "$CMAKE_GENERATOR"
|
||||||
|
|
||||||
- name: "Build release package"
|
- name: Build release package
|
||||||
id: build
|
id: build
|
||||||
if: matrix.package != 'skip'
|
if: matrix.package != 'skip'
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
SUFFIX: '-${{ matrix.distro }}${{ matrix.version }}'
|
SUFFIX: '-${{matrix.distro}}${{matrix.version}}'
|
||||||
package: '${{ matrix.package }}'
|
package: '${{matrix.package}}'
|
||||||
server_only: '${{ matrix.server_only }}'
|
server_only: '${{matrix.server_only}}'
|
||||||
run: |
|
run: |
|
||||||
source .ci/docker.sh
|
source .ci/docker.sh
|
||||||
args=()
|
args=()
|
||||||
[[ $server_only == yes ]] && args+=(--no-client)
|
if [[ $server_only == yes ]]; then
|
||||||
[[ $GITHUB_REF == "refs/heads/master" ]] && args+=(--evict-ccache "$CCACHE_EVICTION_AGE")
|
args+=(--no-client)
|
||||||
|
fi
|
||||||
|
if [[ $GITHUB_REF == "refs/heads/master" ]]; then
|
||||||
|
args+=(--evict-ccache "$CCACHE_EVICTION_AGE")
|
||||||
|
fi
|
||||||
args+=(--ccache "$CCACHE_SIZE")
|
args+=(--ccache "$CCACHE_SIZE")
|
||||||
args+=(--cmake-generator "$CMAKE_GENERATOR")
|
args+=(--cmake-generator "$CMAKE_GENERATOR")
|
||||||
args+=(--suffix "$SUFFIX")
|
args+=(--suffix "$SUFFIX")
|
||||||
|
|
||||||
RUN --server --release --package "$package" "${args[@]}"
|
RUN --server --release --package "$package" "${args[@]}"
|
||||||
|
|
||||||
# Delete used cache to emulate a ccache update. See https://github.com/actions/cache/issues/342
|
# Delete used cache to emulate a ccache update. See https://github.com/actions/cache/issues/342
|
||||||
- name: "Delete remote compiler cache (ccache)"
|
- name: Delete remote compiler cache (ccache)
|
||||||
if: github.ref == 'refs/heads/master' && steps.ccache_restore.outputs.cache-hit
|
if: github.ref == 'refs/heads/master' && steps.ccache_restore.outputs.cache-hit
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
env:
|
env:
|
||||||
|
|
@ -217,47 +213,47 @@ jobs:
|
||||||
echo "Cache deleted successfully"
|
echo "Cache deleted successfully"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: "Save updated compiler cache (ccache)"
|
- name: Save updated compiler cache (ccache)
|
||||||
if: github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master'
|
||||||
uses: actions/cache/save@v5
|
uses: actions/cache/save@v5
|
||||||
with:
|
with:
|
||||||
|
path: ${{env.CACHE}}
|
||||||
key: ${{ steps.ccache_restore.outputs.cache-primary-key }}
|
key: ${{ steps.ccache_restore.outputs.cache-primary-key }}
|
||||||
path: ${{ env.CACHE }}
|
|
||||||
|
|
||||||
- name: "Upload artifact"
|
- name: Upload artifact
|
||||||
id: upload_artifact
|
id: upload_artifact
|
||||||
if: matrix.package != 'skip'
|
if: matrix.package != 'skip'
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
|
path: ${{steps.build.outputs.path}}
|
||||||
archive: false
|
archive: false
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
path: ${{ steps.build.outputs.path }}
|
|
||||||
|
|
||||||
- name: "Upload to release"
|
- name: Upload to release
|
||||||
id: upload_release
|
id: upload_release
|
||||||
if: matrix.package != 'skip' && needs.configure.outputs.tag != null
|
if: matrix.package != 'skip' && needs.configure.outputs.tag != null
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
asset_name: ${{ steps.build.outputs.fullname }}
|
GH_TOKEN: ${{github.token}}
|
||||||
asset_path: ${{ steps.build.outputs.path }}
|
tag_name: ${{needs.configure.outputs.tag}}
|
||||||
GH_TOKEN: ${{ github.token }}
|
asset_name: ${{steps.build.outputs.fullname}}
|
||||||
tag_name: ${{ needs.configure.outputs.tag }}
|
asset_path: ${{steps.build.outputs.path}}
|
||||||
run: gh release upload "$tag_name" "$asset_path#$asset_name"
|
run: gh release upload "$tag_name" "$asset_path#$asset_name"
|
||||||
|
|
||||||
- name: "Attest binary provenance"
|
- name: Attest binary provenance
|
||||||
id: attestation
|
id: attestation
|
||||||
if: steps.upload_release.outcome == 'success'
|
if: steps.upload_release.outcome == 'success'
|
||||||
uses: actions/attest@v4
|
uses: actions/attest@v4
|
||||||
with:
|
with:
|
||||||
|
subject-path: ${{steps.build.outputs.path}}
|
||||||
show-summary: false
|
show-summary: false
|
||||||
subject-path: ${{ steps.build.outputs.path }}
|
|
||||||
|
|
||||||
- name: "Verify binary attestation"
|
- name: Verify binary attestation
|
||||||
if: steps.attestation.outcome == 'success'
|
if: steps.attestation.outcome == 'success'
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{github.token}}
|
||||||
run: gh attestation verify "${{ steps.build.outputs.path }}" --repo Cockatrice/Cockatrice
|
run: gh attestation verify "${{steps.build.outputs.path}}" --repo Cockatrice/Cockatrice
|
||||||
|
|
||||||
build-vcpkg:
|
build-vcpkg:
|
||||||
strategy:
|
strategy:
|
||||||
|
|
@ -267,202 +263,200 @@ jobs:
|
||||||
- os: macOS
|
- os: macOS
|
||||||
target: 13
|
target: 13
|
||||||
runner: macos-15-intel
|
runner: macos-15-intel
|
||||||
|
soc: Intel
|
||||||
ccache_eviction_age: 7d
|
xcode: "16.4"
|
||||||
cmake_generator: Ninja
|
type: Release
|
||||||
make_package: 1
|
|
||||||
override_target: 13
|
override_target: 13
|
||||||
|
make_package: 1
|
||||||
package_suffix: "-macOS13_Intel"
|
package_suffix: "-macOS13_Intel"
|
||||||
qt_version: 6.11.0
|
qt_version: 6.11.0
|
||||||
qt_arch: clang_64
|
qt_arch: clang_64
|
||||||
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
||||||
soc: Intel
|
cmake_generator: Ninja
|
||||||
type: Release
|
|
||||||
use_ccache: 1
|
use_ccache: 1
|
||||||
xcode: "16.4"
|
ccache_eviction_age: 7d
|
||||||
|
|
||||||
- os: macOS
|
- os: macOS
|
||||||
target: 14
|
target: 14
|
||||||
runner: macos-14
|
runner: macos-14
|
||||||
|
soc: Apple
|
||||||
ccache_eviction_age: 7d
|
xcode: "15.4"
|
||||||
cmake_generator: Ninja
|
type: Release
|
||||||
make_package: 1
|
make_package: 1
|
||||||
package_suffix: "-macOS14"
|
package_suffix: "-macOS14"
|
||||||
qt_version: 6.11.0
|
qt_version: 6.11.0
|
||||||
qt_arch: clang_64
|
qt_arch: clang_64
|
||||||
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
||||||
soc: Apple
|
cmake_generator: Ninja
|
||||||
type: Release
|
|
||||||
use_ccache: 1
|
use_ccache: 1
|
||||||
xcode: "15.4"
|
ccache_eviction_age: 7d
|
||||||
|
|
||||||
- os: macOS
|
- os: macOS
|
||||||
target: 15
|
target: 15
|
||||||
runner: macos-15
|
runner: macos-15
|
||||||
|
soc: Apple
|
||||||
ccache_eviction_age: 7d
|
xcode: "16.4"
|
||||||
cmake_generator: Ninja
|
type: Release
|
||||||
make_package: 1
|
make_package: 1
|
||||||
package_suffix: "-macOS15"
|
package_suffix: "-macOS15"
|
||||||
qt_version: 6.11.0
|
qt_version: 6.11.0
|
||||||
qt_arch: clang_64
|
qt_arch: clang_64
|
||||||
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
||||||
soc: Apple
|
cmake_generator: Ninja
|
||||||
type: Release
|
|
||||||
use_ccache: 1
|
use_ccache: 1
|
||||||
xcode: "16.4"
|
ccache_eviction_age: 7d
|
||||||
|
|
||||||
- os: macOS
|
- os: macOS
|
||||||
target: 15
|
target: 15
|
||||||
runner: macos-15
|
runner: macos-15
|
||||||
|
soc: Apple
|
||||||
ccache_eviction_age: 7d
|
xcode: "16.4"
|
||||||
cmake_generator: Ninja
|
type: Debug
|
||||||
qt_version: 6.11.0
|
qt_version: 6.11.0
|
||||||
qt_arch: clang_64
|
qt_arch: clang_64
|
||||||
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
||||||
soc: Apple
|
cmake_generator: Ninja
|
||||||
type: Debug
|
|
||||||
use_ccache: 1
|
use_ccache: 1
|
||||||
xcode: "16.4"
|
ccache_eviction_age: 7d
|
||||||
|
|
||||||
- os: Windows
|
- os: Windows
|
||||||
target: 10
|
target: 10
|
||||||
runner: windows-2025
|
runner: windows-2025
|
||||||
|
type: Release
|
||||||
cmake_generator: "Visual Studio 18 2026"
|
|
||||||
cmake_generator_platform: x64
|
|
||||||
make_package: 1
|
make_package: 1
|
||||||
package_suffix: "-Win10"
|
package_suffix: "-Win10"
|
||||||
qt_version: 6.11.0
|
qt_version: 6.11.0
|
||||||
qt_arch: win64_msvc2022_64
|
qt_arch: win64_msvc2022_64
|
||||||
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
||||||
type: Release
|
cmake_generator: "Visual Studio 17 2022"
|
||||||
|
cmake_generator_platform: x64
|
||||||
|
|
||||||
name: ${{ matrix.os }} ${{ matrix.target }}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }}
|
name: ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }}
|
||||||
needs: configure
|
needs: configure
|
||||||
runs-on: ${{ matrix.runner }}
|
runs-on: ${{matrix.runner}}
|
||||||
timeout-minutes: 100
|
timeout-minutes: 100
|
||||||
env:
|
env:
|
||||||
CCACHE_DIR: ${{ github.workspace }}/.cache/
|
CCACHE_DIR: ${{github.workspace}}/.cache/
|
||||||
CCACHE_SIZE: 550M # space of all repo is 10Gi: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
|
# Cache size over the entire repo is 10Gi:
|
||||||
|
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
|
||||||
|
CCACHE_SIZE: 550M
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout"
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: "[Windows] Add msbuild to PATH"
|
- name: Add msbuild to PATH
|
||||||
if: matrix.os == 'Windows'
|
if: matrix.os == 'Windows'
|
||||||
id: add-msbuild
|
id: add-msbuild
|
||||||
uses: microsoft/setup-msbuild@v3
|
uses: microsoft/setup-msbuild@v3
|
||||||
with:
|
with:
|
||||||
msbuild-architecture: x64
|
msbuild-architecture: x64
|
||||||
|
|
||||||
- name: "[macOS] Setup ccache"
|
- name: Setup ccache
|
||||||
if: matrix.os == 'macOS' && matrix.use_ccache == 1
|
if: matrix.use_ccache == 1 && matrix.os == 'macOS'
|
||||||
run: brew install ccache
|
run: brew install ccache
|
||||||
|
|
||||||
- name: "[macOS] Restore compiler cache (ccache)"
|
- name: Restore compiler cache (ccache)
|
||||||
if: matrix.os == 'macOS' && matrix.use_ccache == 1
|
if: matrix.use_ccache == 1
|
||||||
id: ccache_restore
|
id: ccache_restore
|
||||||
uses: actions/cache/restore@v5
|
uses: actions/cache/restore@v5
|
||||||
env:
|
env:
|
||||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||||
with:
|
with:
|
||||||
key: ccache-${{ matrix.runner }}-${{ matrix.soc }}-${{ matrix.type }}-${{ env.BRANCH_NAME }}
|
path: ${{env.CCACHE_DIR}}
|
||||||
path: ${{ env.CCACHE_DIR }}
|
key: ccache-${{matrix.runner}}-${{matrix.soc}}-${{matrix.type}}-${{env.BRANCH_NAME}}
|
||||||
restore-keys: ccache-${{ matrix.runner }}-${{ matrix.soc }}-${{ matrix.type }}-
|
restore-keys: ccache-${{matrix.runner}}-${{matrix.soc}}-${{matrix.type}}-
|
||||||
|
|
||||||
- name: "Install aqtinstall"
|
- name: Install aqtinstall
|
||||||
run: pipx install aqtinstall
|
run: pipx install aqtinstall
|
||||||
|
|
||||||
# Resolve given wildcard versions (e.g. Qt 6.6.*) to latest version via aqtinstall to avoid stale caches on new releases
|
# Resolve given wildcard versions (e.g. Qt 6.6.*) to latest version via aqtinstall to avoid stale caches on new releases
|
||||||
- name: "Resolve latest Qt patch version"
|
- name: Resolve latest Qt patch version
|
||||||
id: resolve_qt_version
|
id: resolve_qt_version
|
||||||
shell: bash
|
shell: bash
|
||||||
run: .ci/resolve_latest_aqt_qt_version.sh "${{ matrix.qt_version }}"
|
run: .ci/resolve_latest_aqt_qt_version.sh "${{matrix.qt_version}}"
|
||||||
|
|
||||||
- name: "[macOS] Restore thin Qt ${{ steps.resolve_qt_version.outputs.version }} libraries"
|
- name: Restore thin Qt ${{ steps.resolve_qt_version.outputs.version }} libraries (${{ matrix.soc }} macOS)
|
||||||
if: matrix.os == 'macOS'
|
if: matrix.os == 'macOS'
|
||||||
id: restore_qt
|
id: restore_qt
|
||||||
uses: actions/cache/restore@v5
|
uses: actions/cache/restore@v5
|
||||||
with:
|
with:
|
||||||
key: thin-qt-macos-${{ matrix.soc }}-${{ steps.resolve_qt_version.outputs.version }}
|
|
||||||
path: ${{ github.workspace }}/Qt
|
path: ${{ github.workspace }}/Qt
|
||||||
|
key: thin-qt-macos-${{ matrix.soc }}-${{ steps.resolve_qt_version.outputs.version }}
|
||||||
|
|
||||||
# Using jurplel/install-qt-action to install Qt without using brew
|
# Using jurplel/install-qt-action to install Qt without using brew
|
||||||
# Qt build using vcpkg either just fails or takes too long to build
|
# qt build using vcpkg either just fails or takes too long to build
|
||||||
- name: "[macOS] Install fat Qt ${{ steps.resolve_qt_version.outputs.version }}"
|
- name: Install fat Qt ${{ steps.resolve_qt_version.outputs.version }} (${{ matrix.soc }} macOS)
|
||||||
if: matrix.os == 'macOS' && steps.restore_qt.outputs.cache-hit != 'true'
|
if: matrix.os == 'macOS' && steps.restore_qt.outputs.cache-hit != 'true'
|
||||||
uses: jurplel/install-qt-action@v4
|
uses: jurplel/install-qt-action@v4
|
||||||
with:
|
with:
|
||||||
arch: ${{ matrix.qt_arch }}
|
|
||||||
cache: false
|
|
||||||
dir: ${{ github.workspace }}
|
|
||||||
modules: ${{ matrix.qt_modules }}
|
|
||||||
version: ${{ steps.resolve_qt_version.outputs.version }}
|
version: ${{ steps.resolve_qt_version.outputs.version }}
|
||||||
|
arch: ${{matrix.qt_arch}}
|
||||||
|
modules: ${{matrix.qt_modules}}
|
||||||
|
cache: false
|
||||||
|
dir: ${{github.workspace}}
|
||||||
|
|
||||||
- name: "[macOS] Create thin Qt libraries"
|
- name: Thin Qt libraries (${{ matrix.soc }} macOS)
|
||||||
if: matrix.os == 'macOS' && steps.restore_qt.outputs.cache-hit != 'true'
|
if: matrix.os == 'macOS' && steps.restore_qt.outputs.cache-hit != 'true'
|
||||||
run: .ci/thin_macos_qtlib.sh
|
run: .ci/thin_macos_qtlib.sh
|
||||||
|
|
||||||
- name: "[macOS] Cache thin Qt libraries"
|
- name: Cache thin Qt libraries (${{ matrix.soc }} macOS)
|
||||||
if: matrix.os == 'macOS' && steps.restore_qt.outputs.cache-hit != 'true'
|
if: matrix.os == 'macOS' && steps.restore_qt.outputs.cache-hit != 'true'
|
||||||
uses: actions/cache/save@v5
|
uses: actions/cache/save@v5
|
||||||
with:
|
with:
|
||||||
key: thin-qt-macos-${{ matrix.soc }}-${{ steps.resolve_qt_version.outputs.version }}
|
|
||||||
path: ${{ github.workspace }}/Qt
|
path: ${{ github.workspace }}/Qt
|
||||||
|
key: thin-qt-macos-${{ matrix.soc }}-${{ steps.resolve_qt_version.outputs.version }}
|
||||||
|
|
||||||
- name: "[Windows] Install Qt ${{ matrix.qt_version }}"
|
- name: Install Qt ${{matrix.qt_version}} (Windows)
|
||||||
if: matrix.os == 'Windows'
|
if: matrix.os == 'Windows'
|
||||||
uses: jurplel/install-qt-action@v4
|
uses: jurplel/install-qt-action@v4
|
||||||
with:
|
with:
|
||||||
# Qt 6.11.0 only works with aqtinstall directly from git until aqtinstall 3.4 is released
|
# qt 6.11.0 only works with aqtinstall directly from git until aqtinstall 3.4 is released
|
||||||
aqtsource: git+https://github.com/miurahr/aqtinstall.git
|
aqtsource: git+https://github.com/miurahr/aqtinstall.git
|
||||||
arch: ${{ matrix.qt_arch }}
|
|
||||||
cache: true
|
|
||||||
modules: ${{ matrix.qt_modules }}
|
|
||||||
version: ${{ steps.resolve_qt_version.outputs.version }}
|
version: ${{ steps.resolve_qt_version.outputs.version }}
|
||||||
|
arch: ${{matrix.qt_arch}}
|
||||||
|
modules: ${{matrix.qt_modules}}
|
||||||
|
cache: true
|
||||||
|
|
||||||
- name: "[Windows] Install NSIS"
|
- name: Install NSIS
|
||||||
if: matrix.os == 'Windows'
|
if: matrix.os == 'Windows'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: choco install nsis
|
run: choco install nsis
|
||||||
|
|
||||||
- name: "Setup vcpkg cache"
|
- name: Setup vcpkg cache
|
||||||
id: vcpkg-cache
|
id: vcpkg-cache
|
||||||
uses: TAServers/vcpkg-cache@v3
|
uses: TAServers/vcpkg-cache@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
# Uses environment variables, see compile.sh for more details
|
# uses environment variables, see compile.sh for more details
|
||||||
- name: "Build Cockatrice"
|
- name: Build Cockatrice
|
||||||
id: build
|
id: build
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
BUILDTYPE: '${{ matrix.type }}'
|
BUILDTYPE: '${{matrix.type}}'
|
||||||
CCACHE_EVICTION_AGE: ${{ matrix.ccache_eviction_age }}
|
MAKE_PACKAGE: '${{matrix.make_package}}'
|
||||||
CMAKE_GENERATOR: ${{ matrix.cmake_generator }}
|
PACKAGE_SUFFIX: '${{matrix.package_suffix}}'
|
||||||
CMAKE_GENERATOR_PLATFORM: ${{ matrix.cmake_generator_platform }}
|
CMAKE_GENERATOR: ${{matrix.cmake_generator}}
|
||||||
DEVELOPER_DIR: '/Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer'
|
CMAKE_GENERATOR_PLATFORM: ${{matrix.cmake_generator_platform}}
|
||||||
MACOS_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }}
|
USE_CCACHE: ${{matrix.use_ccache}}
|
||||||
MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
|
|
||||||
MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
|
|
||||||
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
|
|
||||||
MAKE_PACKAGE: '${{ matrix.make_package }}'
|
|
||||||
PACKAGE_SUFFIX: '${{ matrix.package_suffix }}'
|
|
||||||
TARGET_MACOS_VERSION: ${{ matrix.override_target }}
|
|
||||||
USE_CCACHE: ${{ matrix.use_ccache }}
|
|
||||||
VCPKG_BINARY_SOURCES: 'clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite'
|
|
||||||
VCPKG_DISABLE_METRICS: 1
|
VCPKG_DISABLE_METRICS: 1
|
||||||
|
VCPKG_BINARY_SOURCES: 'clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite'
|
||||||
|
# macOS-specific environment variables, will be ignored on Windows
|
||||||
|
MACOS_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }}
|
||||||
|
MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
|
||||||
|
MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
|
||||||
|
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
|
||||||
|
DEVELOPER_DIR: '/Applications/Xcode_${{matrix.xcode}}.app/Contents/Developer'
|
||||||
|
TARGET_MACOS_VERSION: ${{ matrix.override_target }}
|
||||||
|
CCACHE_EVICTION_AGE: ${{ matrix.ccache_eviction_age }}
|
||||||
run: .ci/compile.sh --server --test --vcpkg
|
run: .ci/compile.sh --server --test --vcpkg
|
||||||
|
|
||||||
# Delete used cache to emulate a ccache update. See https://github.com/actions/cache/issues/342
|
# Delete used cache to emulate a ccache update. See https://github.com/actions/cache/issues/342
|
||||||
- name: "[macOS] Delete remote compiler cache (ccache)"
|
- name: Delete remote compiler cache (ccache)
|
||||||
if: matrix.os == 'macOS' && matrix.use_ccache == 1 && github.ref == 'refs/heads/master' && steps.ccache_restore.outputs.cache-hit
|
if: github.ref == 'refs/heads/master' && matrix.use_ccache == 1 && steps.ccache_restore.outputs.cache-hit
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
|
@ -471,14 +465,14 @@ jobs:
|
||||||
echo "Cache deleted successfully"
|
echo "Cache deleted successfully"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: "[macOS] Save updated compiler cache (ccache)"
|
- name: Save updated compiler cache (ccache)
|
||||||
if: matrix.os == 'macOS' && matrix.use_ccache == 1 && github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master' && matrix.use_ccache == 1
|
||||||
uses: actions/cache/save@v5
|
uses: actions/cache/save@v5
|
||||||
with:
|
with:
|
||||||
|
path: ${{env.CCACHE_DIR}}
|
||||||
key: ${{ steps.ccache_restore.outputs.cache-primary-key }}
|
key: ${{ steps.ccache_restore.outputs.cache-primary-key }}
|
||||||
path: ${{ env.CCACHE_DIR }}
|
|
||||||
|
|
||||||
- name: "[macOS] Sign app bundle"
|
- name: Sign app bundle
|
||||||
if: matrix.os == 'macOS' && matrix.make_package && needs.configure.outputs.tag != null
|
if: matrix.os == 'macOS' && matrix.make_package && needs.configure.outputs.tag != null
|
||||||
id: sign_macos
|
id: sign_macos
|
||||||
env:
|
env:
|
||||||
|
|
@ -488,15 +482,15 @@ jobs:
|
||||||
if [[ -n "$MACOS_CERTIFICATE_NAME" ]]
|
if [[ -n "$MACOS_CERTIFICATE_NAME" ]]
|
||||||
then
|
then
|
||||||
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
|
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
|
||||||
/usr/bin/codesign --sign="$MACOS_CERTIFICATE_NAME" --entitlements=".ci/macos.entitlements" --options=runtime --force --deep --timestamp --verbose "${{ steps.build.outputs.path }}"
|
/usr/bin/codesign --sign="$MACOS_CERTIFICATE_NAME" --entitlements=".ci/macos.entitlements" --options=runtime --force --deep --timestamp --verbose "${{steps.build.outputs.path}}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: "[macOS] Notarize app bundle"
|
- name: Notarize app bundle
|
||||||
if: matrix.os == 'macOS' && steps.sign_macos.outcome == 'success'
|
if: steps.sign_macos.outcome == 'success'
|
||||||
env:
|
env:
|
||||||
MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
|
MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
|
||||||
MACOS_NOTARIZATION_PWD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
|
|
||||||
MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
|
MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
|
||||||
|
MACOS_NOTARIZATION_PWD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
|
||||||
run: |
|
run: |
|
||||||
if [[ -n "$MACOS_NOTARIZATION_APPLE_ID" ]]
|
if [[ -n "$MACOS_NOTARIZATION_APPLE_ID" ]]
|
||||||
then
|
then
|
||||||
|
|
@ -508,7 +502,7 @@ jobs:
|
||||||
# Therefore, we create a zip file containing our app bundle, so that we can send it to the
|
# Therefore, we create a zip file containing our app bundle, so that we can send it to the
|
||||||
# notarization service
|
# notarization service
|
||||||
echo "Creating temp notarization archive"
|
echo "Creating temp notarization archive"
|
||||||
ditto -c -k --keepParent "${{ steps.build.outputs.path }}" "notarization.zip"
|
ditto -c -k --keepParent "${{steps.build.outputs.path}}" "notarization.zip"
|
||||||
|
|
||||||
# Here we send the notarization request to the Apple's Notarization service, waiting for the result.
|
# Here we send the notarization request to the Apple's Notarization service, waiting for the result.
|
||||||
# This typically takes a few seconds inside a CI environment, but it might take more depending on the App
|
# This typically takes a few seconds inside a CI environment, but it might take more depending on the App
|
||||||
|
|
@ -520,51 +514,51 @@ jobs:
|
||||||
# Finally, we need to "attach the staple" to our executable, which will allow our app to be
|
# Finally, we need to "attach the staple" to our executable, which will allow our app to be
|
||||||
# validated by macOS even when an internet connection is not available.
|
# validated by macOS even when an internet connection is not available.
|
||||||
echo "Attach staple"
|
echo "Attach staple"
|
||||||
xcrun stapler staple "${{ steps.build.outputs.path }}"
|
xcrun stapler staple "${{steps.build.outputs.path}}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: "Upload artifact"
|
- name: Upload artifact
|
||||||
if: matrix.make_package
|
if: matrix.make_package
|
||||||
id: upload_artifact
|
id: upload_artifact
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
|
path: ${{steps.build.outputs.path}}
|
||||||
archive: false
|
archive: false
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
path: ${{ steps.build.outputs.path }}
|
|
||||||
|
|
||||||
- name: "[Windows] Upload PDBs (Program Databases)"
|
- name: Upload PDBs (Program Databases)
|
||||||
if: matrix.os == 'Windows' && github.ref_type != 'tag'
|
if: matrix.os == 'Windows' && github.ref_type != 'tag'
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
if-no-files-found: error
|
name: ${{steps.build.outputs.name}}-PDBs
|
||||||
name: ${{ steps.build.outputs.name }}-PDBs
|
|
||||||
path: |
|
path: |
|
||||||
build/cockatrice/Release/*.pdb
|
build/cockatrice/Release/*.pdb
|
||||||
build/oracle/Release/*.pdb
|
build/oracle/Release/*.pdb
|
||||||
build/servatrice/Release/*.pdb
|
build/servatrice/Release/*.pdb
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: "Upload to release"
|
- name: Upload to release
|
||||||
if: needs.configure.outputs.tag != null && matrix.make_package == '1'
|
if: needs.configure.outputs.tag != null && matrix.make_package == '1'
|
||||||
id: upload_release
|
id: upload_release
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
asset_name: ${{ steps.build.outputs.fullname }}
|
GH_TOKEN: ${{github.token}}
|
||||||
asset_path: ${{ steps.build.outputs.path }}
|
tag_name: ${{needs.configure.outputs.tag}}
|
||||||
GH_TOKEN: ${{ github.token }}
|
asset_name: ${{steps.build.outputs.fullname}}
|
||||||
tag_name: ${{ needs.configure.outputs.tag }}
|
asset_path: ${{steps.build.outputs.path}}
|
||||||
run: gh release upload "$tag_name" "$asset_path#$asset_name"
|
run: gh release upload "$tag_name" "$asset_path#$asset_name"
|
||||||
|
|
||||||
- name: "Attest binary provenance"
|
- name: Attest binary provenance
|
||||||
if: steps.upload_release.outcome == 'success'
|
if: steps.upload_release.outcome == 'success'
|
||||||
id: attestation
|
id: attestation
|
||||||
uses: actions/attest@v4
|
uses: actions/attest@v4
|
||||||
with:
|
with:
|
||||||
|
subject-path: ${{steps.build.outputs.path}}
|
||||||
show-summary: false
|
show-summary: false
|
||||||
subject-path: ${{ steps.build.outputs.path }}
|
|
||||||
|
|
||||||
- name: "Verify binary attestation"
|
- name: Verify binary attestation
|
||||||
if: steps.attestation.outcome == 'success'
|
if: steps.attestation.outcome == 'success'
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{github.token}}
|
||||||
run: gh attestation verify "${{ steps.build.outputs.path }}" --repo Cockatrice/Cockatrice
|
run: gh attestation verify "${{steps.build.outputs.path}}" --repo Cockatrice/Cockatrice
|
||||||
|
|
|
||||||
13
.github/workflows/desktop-lint.yml
vendored
13
.github/workflows/desktop-lint.yml
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
name: Code Style (C++)
|
name: Code Style (C++)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# Push trigger not needed for linting, we do not allow direct pushes to master
|
# push trigger not needed for linting, we do not allow direct pushes to master
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- '*/**' # matches all files not in root
|
- '*/**' # matches all files not in root
|
||||||
|
|
@ -21,20 +21,17 @@ jobs:
|
||||||
runs-on: ubuntu-slim
|
runs-on: ubuntu-slim
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout"
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 20 # should be enough to find merge base
|
fetch-depth: 20 # should be enough to find merge base
|
||||||
|
|
||||||
- name: "Install dependencies"
|
- name: Install dependencies
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y --no-install-recommends \
|
sudo apt-get install -y --no-install-recommends clang-format cmake-format shellcheck
|
||||||
clang-format \
|
|
||||||
cmake-format \
|
|
||||||
shellcheck
|
|
||||||
|
|
||||||
- name: "Check code formatting"
|
- name: Check code formatting
|
||||||
shell: bash
|
shell: bash
|
||||||
run: ./.ci/lint_cpp.sh
|
run: ./.ci/lint_cpp.sh
|
||||||
|
|
|
||||||
44
.github/workflows/docker-release.yml
vendored
44
.github/workflows/docker-release.yml
vendored
|
|
@ -1,10 +1,9 @@
|
||||||
name: Build Docker Image
|
name: Build Docker Image
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- released # publishing of stable releases
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
|
@ -14,9 +13,6 @@ on:
|
||||||
paths:
|
paths:
|
||||||
- '.github/workflows/docker-release.yml'
|
- '.github/workflows/docker-release.yml'
|
||||||
- 'Dockerfile'
|
- 'Dockerfile'
|
||||||
release:
|
|
||||||
types:
|
|
||||||
- released # publishing of stable releases
|
|
||||||
|
|
||||||
# Cancel earlier, unfinished runs of this workflow on the same branch (unless on release)
|
# Cancel earlier, unfinished runs of this workflow on the same branch (unless on release)
|
||||||
concurrency:
|
concurrency:
|
||||||
|
|
@ -29,49 +25,53 @@ jobs:
|
||||||
if: ${{ github.repository_owner == 'Cockatrice' }}
|
if: ${{ github.repository_owner == 'Cockatrice' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout"
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Docker metadata"
|
- name: Docker metadata
|
||||||
id: metadata
|
id: metadata
|
||||||
uses: docker/metadata-action@v6
|
uses: docker/metadata-action@v6
|
||||||
env:
|
env:
|
||||||
DOCKER_METADATA_ANNOTATIONS_LEVELS: index # needed for GHCR
|
DOCKER_METADATA_ANNOTATIONS_LEVELS: index # needed for GHCR
|
||||||
with:
|
with:
|
||||||
annotations: |
|
|
||||||
org.opencontainers.image.title=Servatrice
|
|
||||||
org.opencontainers.image.url=https://cockatrice.github.io/
|
|
||||||
org.opencontainers.image.description=Server for Cockatrice, a cross-platform virtual tabletop for multiplayer card games
|
|
||||||
images: |
|
images: |
|
||||||
ghcr.io/cockatrice/servatrice
|
ghcr.io/cockatrice/servatrice
|
||||||
labels: |
|
labels: |
|
||||||
org.opencontainers.image.title=Servatrice
|
org.opencontainers.image.title=Servatrice
|
||||||
org.opencontainers.image.url=https://cockatrice.github.io/
|
org.opencontainers.image.url=https://cockatrice.github.io/
|
||||||
org.opencontainers.image.description=Server for Cockatrice, a cross-platform virtual tabletop for multiplayer card games
|
org.opencontainers.image.description=Server for Cockatrice, a cross-platform virtual tabletop for multiplayer card games
|
||||||
|
annotations: |
|
||||||
|
org.opencontainers.image.title=Servatrice
|
||||||
|
org.opencontainers.image.url=https://cockatrice.github.io/
|
||||||
|
org.opencontainers.image.description=Server for Cockatrice, a cross-platform virtual tabletop for multiplayer card games
|
||||||
|
|
||||||
- name: "Set up QEMU"
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v4
|
uses: docker/setup-qemu-action@v4
|
||||||
|
|
||||||
- name: "Set up Docker buildx"
|
- name: Set up Docker buildx
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
- name: "Login to GitHub Container Registry"
|
- name: Login to GitHub Container Registry
|
||||||
if: contains(github.event.release.tag_name, 'Release') && github.event.release.target_commitish == 'master'
|
if: contains(github.event.release.tag_name, 'Release') && github.event.release.target_commitish == 'master'
|
||||||
uses: docker/login-action@v4
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
password: ${{ github.token }}
|
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ github.token }}
|
||||||
|
|
||||||
- name: "Build and push Docker image"
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v7
|
uses: docker/build-push-action@v7
|
||||||
with:
|
with:
|
||||||
annotations: ${{ steps.metadata.outputs.annotations }}
|
|
||||||
cache-from: type=gha,scope=servatrice
|
|
||||||
cache-to: type=gha,mode=max,scope=servatrice
|
|
||||||
context: .
|
context: .
|
||||||
labels: ${{ steps.metadata.outputs.labels }}
|
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: ${{ github.ref_type == 'tag' }}
|
push: ${{ github.ref_type == 'tag' }}
|
||||||
tags: ${{ steps.metadata.outputs.tags }}
|
tags: ${{ steps.metadata.outputs.tags }}
|
||||||
|
labels: ${{ steps.metadata.outputs.labels }}
|
||||||
|
annotations: ${{ steps.metadata.outputs.annotations }}
|
||||||
|
cache-from: type=gha,scope=servatrice
|
||||||
|
cache-to: type=gha,mode=max,scope=servatrice
|
||||||
|
|
|
||||||
22
.github/workflows/documentation-build.yml
vendored
22
.github/workflows/documentation-build.yml
vendored
|
|
@ -1,18 +1,18 @@
|
||||||
name: Generate Docs
|
name: Generate Docs
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published # publishing of stable releases and pre-releases
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- 'doc/doxygen/**'
|
- 'doc/doxygen/**'
|
||||||
- '.github/workflows/documentation-build.yml'
|
- '.github/workflows/documentation-build.yml'
|
||||||
- 'Doxyfile'
|
- 'Doxyfile'
|
||||||
release:
|
|
||||||
types:
|
|
||||||
- published # publishing of stable releases and pre-releases
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
COCKATRICE_REF: ${{ github.ref_name }} # tag name if the commit is tagged, otherwise branch name
|
COCKATRICE_REF: ${{ github.ref_name }} # Tag name if the commit is tagged, otherwise branch name
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docs:
|
docs:
|
||||||
|
|
@ -20,22 +20,22 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: Checkout code
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: "Install Graphviz"
|
- name: Install Graphviz
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install -y graphviz
|
sudo apt-get install -y graphviz
|
||||||
dot -V
|
dot -V
|
||||||
|
|
||||||
- name: "Install Doxygen"
|
- name: Install Doxygen
|
||||||
uses: ssciwr/doxygen-install@v2
|
uses: ssciwr/doxygen-install@v2
|
||||||
with:
|
with:
|
||||||
version: "1.16.1"
|
version: "1.16.1"
|
||||||
|
|
||||||
- name: "Update Doxygen Configuration"
|
- name: Update Doxygen Configuration
|
||||||
run: |
|
run: |
|
||||||
git diff Doxyfile
|
git diff Doxyfile
|
||||||
doxygen -u Doxyfile
|
doxygen -u Doxyfile
|
||||||
|
|
@ -48,16 +48,16 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: "Generate Documentation"
|
- name: Generate Documentation
|
||||||
if: always()
|
if: always()
|
||||||
run: doxygen Doxyfile
|
run: doxygen Doxyfile
|
||||||
|
|
||||||
- name: "Deploy to cockatrice.github.io"
|
- name: Deploy to cockatrice.github.io
|
||||||
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
|
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
|
||||||
uses: peaceiris/actions-gh-pages@v4
|
uses: peaceiris/actions-gh-pages@v4
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }}
|
deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }}
|
||||||
destination_dir: docs # docs will be available at https://cockatrice.github.io/docs/
|
|
||||||
external_repository: Cockatrice/cockatrice.github.io
|
external_repository: Cockatrice/cockatrice.github.io
|
||||||
publish_branch: master
|
publish_branch: master
|
||||||
publish_dir: ./docs/html
|
publish_dir: ./docs/html
|
||||||
|
destination_dir: docs # Docs will live under https://cockatrice.github.io/docs/
|
||||||
|
|
|
||||||
35
.github/workflows/translations-pull.yml
vendored
35
.github/workflows/translations-pull.yml
vendored
|
|
@ -1,14 +1,14 @@
|
||||||
name: Update Translations
|
name: Update Translations
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
# runs in the middle of each month starting a quarter (UTC) = two weeks after new strings are built
|
||||||
|
- cron: '0 0 15 1,4,7,10 *'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- '.tx/**'
|
- '.tx/**'
|
||||||
- '.github/workflows/translations-pull.yml'
|
- '.github/workflows/translations-pull.yml'
|
||||||
schedule:
|
|
||||||
# Runs in the middle of each month starting a quarter (UTC) = two weeks after new strings are built
|
|
||||||
- cron: '0 0 15 1,4,7,10 *'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
translations:
|
translations:
|
||||||
|
|
@ -19,18 +19,18 @@ jobs:
|
||||||
runs-on: ubuntu-slim
|
runs-on: ubuntu-slim
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout repo"
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Pull translated strings from Transifex"
|
- name: Pull translated strings from Transifex
|
||||||
uses: transifex/cli-action@v2
|
uses: transifex/cli-action@v2
|
||||||
with:
|
with:
|
||||||
# Used config file: https://github.com/Cockatrice/Cockatrice/blob/master/.tx/config
|
# used config file: https://github.com/Cockatrice/Cockatrice/blob/master/.tx/config
|
||||||
# Docs: https://github.com/transifex/cli#pulling-files-from-transifex
|
# https://github.com/transifex/cli#pulling-files-from-transifex
|
||||||
args: pull --force --all
|
|
||||||
token: ${{ secrets.TX_TOKEN }}
|
token: ${{ secrets.TX_TOKEN }}
|
||||||
|
args: pull --force --all
|
||||||
|
|
||||||
- name: "Create pull request"
|
- name: Create pull request
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
id: create_pr
|
id: create_pr
|
||||||
uses: peter-evans/create-pull-request@v8
|
uses: peter-evans/create-pull-request@v8
|
||||||
|
|
@ -38,7 +38,12 @@ jobs:
|
||||||
add-paths: |
|
add-paths: |
|
||||||
cockatrice/translations/*.ts
|
cockatrice/translations/*.ts
|
||||||
oracle/translations/*.ts
|
oracle/translations/*.ts
|
||||||
author: github-actions <github-actions@github.com> # owner of the commit
|
commit-message: Update translation files
|
||||||
|
# author is the owner of the commit
|
||||||
|
author: github-actions <github-actions@github.com>
|
||||||
|
branch: ci-update_translations
|
||||||
|
delete-branch: true
|
||||||
|
title: 'Update translations'
|
||||||
body: |
|
body: |
|
||||||
Pulled all translated strings from [Transifex][1].
|
Pulled all translated strings from [Transifex][1].
|
||||||
|
|
||||||
|
|
@ -48,16 +53,12 @@ jobs:
|
||||||
|
|
||||||
[1]: https://explore.transifex.com/cockatrice/cockatrice/
|
[1]: https://explore.transifex.com/cockatrice/cockatrice/
|
||||||
[2]: https://github.com/Cockatrice/Cockatrice/actions/workflows/translations-pull.yml?query=branch%3Amaster
|
[2]: https://github.com/Cockatrice/Cockatrice/actions/workflows/translations-pull.yml?query=branch%3Amaster
|
||||||
branch: ci-update_translations
|
|
||||||
commit-message: Update translation files
|
|
||||||
delete-branch: true
|
|
||||||
draft: false
|
|
||||||
labels: |
|
labels: |
|
||||||
CI
|
CI
|
||||||
Translation
|
Translation
|
||||||
title: 'Update translations'
|
draft: false
|
||||||
|
|
||||||
- name: "PR Status"
|
- name: PR Status
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
35
.github/workflows/translations-push.yml
vendored
35
.github/workflows/translations-push.yml
vendored
|
|
@ -1,14 +1,14 @@
|
||||||
name: Update Translation Source
|
name: Update Translation Source
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
# runs at the start of each quarter (UTC)
|
||||||
|
- cron: '0 0 1 1,4,7,10 *'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- '.ci/update_translation_source_strings.sh'
|
- '.ci/update_translation_source_strings.sh'
|
||||||
- '.github/workflows/translations-push.yml'
|
- '.github/workflows/translations-push.yml'
|
||||||
schedule:
|
|
||||||
# Runs at the start of each quarter (UTC)
|
|
||||||
- cron: '0 0 1 1,4,7,10 *'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
translations:
|
translations:
|
||||||
|
|
@ -19,16 +19,16 @@ jobs:
|
||||||
runs-on: ubuntu-slim
|
runs-on: ubuntu-slim
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout repo"
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Install lupdate"
|
- name: Install lupdate
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y --no-install-recommends qttools5-dev-tools
|
sudo apt-get install -y --no-install-recommends qttools5-dev-tools
|
||||||
|
|
||||||
- name: "Update Cockatrice translation source"
|
- name: Update Cockatrice translation source
|
||||||
id: cockatrice
|
id: cockatrice
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -36,15 +36,15 @@ jobs:
|
||||||
export DIRS="cockatrice/src $(find . -maxdepth 1 -type d -name 'libcockatrice_*')"
|
export DIRS="cockatrice/src $(find . -maxdepth 1 -type d -name 'libcockatrice_*')"
|
||||||
FILE="$FILE" DIRS="$DIRS" .ci/update_translation_source_strings.sh
|
FILE="$FILE" DIRS="$DIRS" .ci/update_translation_source_strings.sh
|
||||||
|
|
||||||
- name: "Update Oracle translation source"
|
- name: Update Oracle translation source
|
||||||
id: oracle
|
id: oracle
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
DIRS: 'oracle/src'
|
|
||||||
FILE: 'oracle/oracle_en@source.ts'
|
FILE: 'oracle/oracle_en@source.ts'
|
||||||
|
DIRS: 'oracle/src'
|
||||||
run: .ci/update_translation_source_strings.sh
|
run: .ci/update_translation_source_strings.sh
|
||||||
|
|
||||||
- name: "Render template"
|
- name: Render template
|
||||||
id: template
|
id: template
|
||||||
uses: chuhlomin/render-template/binary@v1
|
uses: chuhlomin/render-template/binary@v1
|
||||||
with:
|
with:
|
||||||
|
|
@ -54,7 +54,7 @@ jobs:
|
||||||
oracle_output: ${{ steps.oracle.outputs.output }}
|
oracle_output: ${{ steps.oracle.outputs.output }}
|
||||||
commit: ${{ github.sha }}
|
commit: ${{ github.sha }}
|
||||||
|
|
||||||
- name: "Create pull request"
|
- name: Create pull request
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
id: create_pr
|
id: create_pr
|
||||||
uses: peter-evans/create-pull-request@v8
|
uses: peter-evans/create-pull-request@v8
|
||||||
|
|
@ -62,18 +62,19 @@ jobs:
|
||||||
add-paths: |
|
add-paths: |
|
||||||
cockatrice/cockatrice_en@source.ts
|
cockatrice/cockatrice_en@source.ts
|
||||||
oracle/oracle_en@source.ts
|
oracle/oracle_en@source.ts
|
||||||
author: github-actions <github-actions@github.com> # owner of the commit
|
|
||||||
body: ${{ steps.template.outputs.result }}
|
|
||||||
branch: ci-update_translation_source
|
|
||||||
commit-message: Update translation source strings
|
commit-message: Update translation source strings
|
||||||
|
# author is the owner of the commit
|
||||||
|
author: github-actions <github-actions@github.com>
|
||||||
|
branch: ci-update_translation_source
|
||||||
delete-branch: true
|
delete-branch: true
|
||||||
draft: false
|
title: 'Update source strings'
|
||||||
|
body: ${{ steps.template.outputs.result }}
|
||||||
labels: |
|
labels: |
|
||||||
CI
|
CI
|
||||||
Translation
|
Translation
|
||||||
title: 'Update source strings'
|
draft: false
|
||||||
|
|
||||||
- name: "PR Status"
|
- name: PR Status
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
|
|
@ -117,22 +117,21 @@ ${If} $InstDir == ""
|
||||||
; we need to set a default based on the install mode
|
; we need to set a default based on the install mode
|
||||||
StrCpy $InstDir $0
|
StrCpy $InstDir $0
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
Call SetModeDestinationFromInstdir
|
||||||
|
|
||||||
; --- Detect portable install when using /R (must come BEFORE SetModeDestinationFromInstdir) ---
|
; --- Detect portable install when using /R ---
|
||||||
${If} $ReinstallMode = 1
|
${If} $ReinstallMode = 1
|
||||||
IfFileExists "$InstDir\portable.dat" 0 not_portable
|
IfFileExists "$InstDir\portable.dat" 0 not_portable
|
||||||
StrCpy $PortableMode 1
|
StrCpy $PortableMode 1
|
||||||
Goto portable_done
|
Goto portable_done
|
||||||
|
|
||||||
not_portable:
|
not_portable:
|
||||||
StrCpy $PortableMode 0
|
StrCpy $PortableMode 0
|
||||||
|
|
||||||
portable_done:
|
portable_done:
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
; Now that $PortableMode reflects reality, commit InstDir into the correct slot
|
|
||||||
Call SetModeDestinationFromInstdir
|
|
||||||
|
|
||||||
${If} $ReinstallMode = 1
|
${If} $ReinstallMode = 1
|
||||||
${AndIf} $PortableMode = 0
|
|
||||||
Call AutoUninstallIfNeeded
|
Call AutoUninstallIfNeeded
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,58 +56,56 @@ set(cockatrice_SOURCES
|
||||||
src/filters/filter_tree_model.cpp
|
src/filters/filter_tree_model.cpp
|
||||||
src/filters/syntax_help.cpp
|
src/filters/syntax_help.cpp
|
||||||
src/game/abstract_game.cpp
|
src/game/abstract_game.cpp
|
||||||
src/game/arrow_registry.cpp
|
src/game/board/abstract_card_drag_item.cpp
|
||||||
src/game_graphics/board/abstract_card_drag_item.cpp
|
src/game/board/abstract_card_item.cpp
|
||||||
src/game_graphics/board/abstract_card_item.cpp
|
src/game/board/abstract_counter.cpp
|
||||||
src/game_graphics/board/abstract_counter.cpp
|
|
||||||
src/game/board/arrow_data.cpp
|
src/game/board/arrow_data.cpp
|
||||||
src/game_graphics/board/arrow_item.cpp
|
src/game/board/arrow_item.cpp
|
||||||
src/game_graphics/board/arrow_target.cpp
|
src/game/board/arrow_target.cpp
|
||||||
src/game_graphics/board/card_drag_item.cpp
|
src/game/board/card_drag_item.cpp
|
||||||
src/game_graphics/board/card_item.cpp
|
src/game/board/card_item.cpp
|
||||||
src/game/board/card_list.cpp
|
src/game/board/card_list.cpp
|
||||||
src/game/board/card_state.cpp
|
src/game/board/card_state.cpp
|
||||||
src/game_graphics/board/counter_general.cpp
|
src/game/board/counter_general.cpp
|
||||||
src/game/board/counter_state.cpp
|
src/game/board/counter_state.cpp
|
||||||
src/game_graphics/board/translate_counter_name.cpp
|
src/game/board/translate_counter_name.cpp
|
||||||
src/game_graphics/deckview/deck_view.cpp
|
src/game/deckview/deck_view.cpp
|
||||||
src/game_graphics/deckview/deck_view_container.cpp
|
src/game/deckview/deck_view_container.cpp
|
||||||
src/game_graphics/deckview/tabbed_deck_view_container.cpp
|
src/game/deckview/tabbed_deck_view_container.cpp
|
||||||
src/game_graphics/dialogs/dlg_create_token.cpp
|
src/game/dialogs/dlg_create_token.cpp
|
||||||
src/game_graphics/dialogs/dlg_move_top_cards_until.cpp
|
src/game/dialogs/dlg_move_top_cards_until.cpp
|
||||||
src/game_graphics/dialogs/dlg_roll_dice.cpp
|
src/game/dialogs/dlg_roll_dice.cpp
|
||||||
src/game/game.cpp
|
src/game/game.cpp
|
||||||
src/game/game_event_handler.cpp
|
src/game/game_event_handler.cpp
|
||||||
src/game/game_meta_info.cpp
|
src/game/game_meta_info.cpp
|
||||||
src/game_graphics/game_scene.cpp
|
src/game/game_scene.cpp
|
||||||
src/game/game_state.cpp
|
src/game/game_state.cpp
|
||||||
src/game_graphics/game_view.cpp
|
src/game/game_view.cpp
|
||||||
src/game_graphics/hand_counter.cpp
|
src/game/hand_counter.cpp
|
||||||
src/game_graphics/log/message_log_widget.cpp
|
src/game/log/message_log_widget.cpp
|
||||||
src/game/phase.cpp
|
src/game/phase.cpp
|
||||||
src/game_graphics/phases_toolbar.cpp
|
src/game/phases_toolbar.cpp
|
||||||
src/game_graphics/player/menu/card_menu.cpp
|
src/game/player/menu/card_menu.cpp
|
||||||
src/game_graphics/player/menu/custom_zone_menu.cpp
|
src/game/player/menu/custom_zone_menu.cpp
|
||||||
src/game_graphics/player/menu/grave_menu.cpp
|
src/game/player/menu/grave_menu.cpp
|
||||||
src/game_graphics/player/menu/hand_menu.cpp
|
src/game/player/menu/hand_menu.cpp
|
||||||
src/game_graphics/player/menu/library_menu.cpp
|
src/game/player/menu/library_menu.cpp
|
||||||
src/game_graphics/player/menu/move_menu.cpp
|
src/game/player/menu/move_menu.cpp
|
||||||
src/game_graphics/player/menu/player_menu.cpp
|
src/game/player/menu/player_menu.cpp
|
||||||
src/game_graphics/player/menu/pt_menu.cpp
|
src/game/player/menu/pt_menu.cpp
|
||||||
src/game_graphics/player/menu/rfg_menu.cpp
|
src/game/player/menu/rfg_menu.cpp
|
||||||
src/game_graphics/player/menu/say_menu.cpp
|
src/game/player/menu/say_menu.cpp
|
||||||
src/game_graphics/player/menu/sideboard_menu.cpp
|
src/game/player/menu/sideboard_menu.cpp
|
||||||
src/game_graphics/player/menu/utility_menu.cpp
|
src/game/player/menu/utility_menu.cpp
|
||||||
src/game/player/player_actions.cpp
|
src/game/player/player_actions.cpp
|
||||||
src/game_graphics/player/player_area.cpp
|
src/game/player/player_area.cpp
|
||||||
src/game_graphics/player/player_dialogs.cpp
|
|
||||||
src/game/player/player_event_handler.cpp
|
src/game/player/player_event_handler.cpp
|
||||||
src/game_graphics/player/player_graphics_item.cpp
|
src/game/player/player_graphics_item.cpp
|
||||||
src/game/player/player_info.cpp
|
src/game/player/player_info.cpp
|
||||||
src/game_graphics/player/player_list_widget.cpp
|
src/game/player/player_list_widget.cpp
|
||||||
src/game/player/player_logic.cpp
|
src/game/player/player_logic.cpp
|
||||||
src/game/player/player_manager.cpp
|
src/game/player/player_manager.cpp
|
||||||
src/game_graphics/player/player_target.cpp
|
src/game/player/player_target.cpp
|
||||||
src/game/replay.cpp
|
src/game/replay.cpp
|
||||||
src/game/zones/card_zone_logic.cpp
|
src/game/zones/card_zone_logic.cpp
|
||||||
src/game/zones/hand_zone_logic.cpp
|
src/game/zones/hand_zone_logic.cpp
|
||||||
|
|
@ -183,7 +181,6 @@ set(cockatrice_SOURCES
|
||||||
src/interface/widgets/deck_analytics/analyzer_modules/mana_distribution/mana_distribution_single_display_widget.cpp
|
src/interface/widgets/deck_analytics/analyzer_modules/mana_distribution/mana_distribution_single_display_widget.cpp
|
||||||
src/interface/widgets/deck_analytics/analyzer_modules/mana_curve/mana_curve_total_widget.cpp
|
src/interface/widgets/deck_analytics/analyzer_modules/mana_curve/mana_curve_total_widget.cpp
|
||||||
src/interface/widgets/deck_analytics/analyzer_modules/mana_curve/mana_curve_category_widget.cpp
|
src/interface/widgets/deck_analytics/analyzer_modules/mana_curve/mana_curve_category_widget.cpp
|
||||||
src/interface/widgets/deck_editor/card_database_view.cpp
|
|
||||||
src/interface/widgets/deck_editor/deck_list_history_manager_widget.cpp
|
src/interface/widgets/deck_editor/deck_list_history_manager_widget.cpp
|
||||||
src/interface/widgets/deck_editor/deck_editor_card_database_dock_widget.cpp
|
src/interface/widgets/deck_editor/deck_editor_card_database_dock_widget.cpp
|
||||||
src/interface/widgets/deck_editor/deck_editor_card_info_dock_widget.cpp
|
src/interface/widgets/deck_editor/deck_editor_card_info_dock_widget.cpp
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <libcockatrice/card/database/card_database_manager.h>
|
|
||||||
#include <libcockatrice/deck_list/deck_list.h>
|
#include <libcockatrice/deck_list/deck_list.h>
|
||||||
#include <libcockatrice/deck_list/tree/deck_list_card_node.h>
|
#include <libcockatrice/deck_list/tree/deck_list_card_node.h>
|
||||||
#include <version_string.h>
|
#include <version_string.h>
|
||||||
|
|
||||||
DeckStatsInterface::DeckStatsInterface(QObject *parent) : QObject(parent)
|
DeckStatsInterface::DeckStatsInterface(CardDatabase &_cardDatabase, QObject *parent)
|
||||||
|
: QObject(parent), cardDatabase(_cardDatabase)
|
||||||
{
|
{
|
||||||
manager = new QNetworkAccessManager(this);
|
manager = new QNetworkAccessManager(this);
|
||||||
connect(manager, &QNetworkAccessManager::finished, this, &DeckStatsInterface::queryFinished);
|
connect(manager, &QNetworkAccessManager::finished, this, &DeckStatsInterface::queryFinished);
|
||||||
|
|
@ -70,8 +70,8 @@ void DeckStatsInterface::analyzeDeck(const DeckList &deck)
|
||||||
|
|
||||||
void DeckStatsInterface::copyDeckWithoutTokens(const DeckList &source, DeckList &destination)
|
void DeckStatsInterface::copyDeckWithoutTokens(const DeckList &source, DeckList &destination)
|
||||||
{
|
{
|
||||||
auto copyIfNotAToken = [&destination](const auto node, const auto card) {
|
auto copyIfNotAToken = [this, &destination](const auto node, const auto card) {
|
||||||
CardInfoPtr dbCard = CardDatabaseManager::query()->getCardInfo(card->getName());
|
CardInfoPtr dbCard = cardDatabase.query()->getCardInfo(card->getName());
|
||||||
if (dbCard && !dbCard->getIsToken()) {
|
if (dbCard && !dbCard->getIsToken()) {
|
||||||
DecklistCardNode *addedCard = destination.addCard(card->getName(), node->getName(), -1);
|
DecklistCardNode *addedCard = destination.addCard(card->getName(), node->getName(), -1);
|
||||||
addedCard->setNumber(card->getNumber());
|
addedCard->setNumber(card->getNumber());
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#ifndef DECKSTATS_INTERFACE_H
|
#ifndef DECKSTATS_INTERFACE_H
|
||||||
#define DECKSTATS_INTERFACE_H
|
#define DECKSTATS_INTERFACE_H
|
||||||
|
|
||||||
|
#include <libcockatrice/card/database/card_database.h>
|
||||||
#include <libcockatrice/deck_list/deck_list.h>
|
#include <libcockatrice/deck_list/deck_list.h>
|
||||||
|
|
||||||
class QByteArray;
|
class QByteArray;
|
||||||
|
|
@ -20,6 +21,8 @@ class DeckStatsInterface : public QObject
|
||||||
private:
|
private:
|
||||||
QNetworkAccessManager *manager;
|
QNetworkAccessManager *manager;
|
||||||
|
|
||||||
|
CardDatabase &cardDatabase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deckstats doesn't recognize token cards, and instead tries to find the
|
* Deckstats doesn't recognize token cards, and instead tries to find the
|
||||||
* closest non-token card instead. So we construct a new deck which has no
|
* closest non-token card instead. So we construct a new deck which has no
|
||||||
|
|
@ -32,7 +35,7 @@ private slots:
|
||||||
void getAnalyzeRequestData(const DeckList &deck, QByteArray &data);
|
void getAnalyzeRequestData(const DeckList &deck, QByteArray &data);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DeckStatsInterface(QObject *parent = nullptr);
|
explicit DeckStatsInterface(CardDatabase &_cardDatabase, QObject *parent = nullptr);
|
||||||
void analyzeDeck(const DeckList &deck);
|
void analyzeDeck(const DeckList &deck);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <libcockatrice/card/database/card_database_manager.h>
|
|
||||||
#include <libcockatrice/deck_list/deck_list.h>
|
#include <libcockatrice/deck_list/deck_list.h>
|
||||||
#include <libcockatrice/deck_list/tree/deck_list_card_node.h>
|
#include <libcockatrice/deck_list/tree/deck_list_card_node.h>
|
||||||
#include <version_string.h>
|
#include <version_string.h>
|
||||||
|
|
||||||
TappedOutInterface::TappedOutInterface(QObject *parent) : QObject(parent)
|
TappedOutInterface::TappedOutInterface(CardDatabase &_cardDatabase, QObject *parent)
|
||||||
|
: QObject(parent), cardDatabase(_cardDatabase)
|
||||||
{
|
{
|
||||||
manager = new QNetworkAccessManager(this);
|
manager = new QNetworkAccessManager(this);
|
||||||
connect(manager, &QNetworkAccessManager::finished, this, &TappedOutInterface::queryFinished);
|
connect(manager, &QNetworkAccessManager::finished, this, &TappedOutInterface::queryFinished);
|
||||||
|
|
@ -97,8 +97,8 @@ void TappedOutInterface::analyzeDeck(const DeckList &deck)
|
||||||
|
|
||||||
void TappedOutInterface::copyDeckSplitMainAndSide(const DeckList &source, DeckList &mainboard, DeckList &sideboard)
|
void TappedOutInterface::copyDeckSplitMainAndSide(const DeckList &source, DeckList &mainboard, DeckList &sideboard)
|
||||||
{
|
{
|
||||||
auto copyMainOrSide = [&mainboard, &sideboard](const auto node, const auto card) {
|
auto copyMainOrSide = [this, &mainboard, &sideboard](const auto node, const auto card) {
|
||||||
CardInfoPtr dbCard = CardDatabaseManager::query()->getCardInfo(card->getName());
|
CardInfoPtr dbCard = cardDatabase.query()->getCardInfo(card->getName());
|
||||||
if (!dbCard || dbCard->getIsToken()) {
|
if (!dbCard || dbCard->getIsToken()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
#ifndef TAPPEDOUT_INTERFACE_H
|
#ifndef TAPPEDOUT_INTERFACE_H
|
||||||
#define TAPPEDOUT_INTERFACE_H
|
#define TAPPEDOUT_INTERFACE_H
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <libcockatrice/card/database/card_database.h>
|
||||||
#include <QObject>
|
#include <libcockatrice/deck_list/deck_list.h>
|
||||||
|
|
||||||
inline Q_LOGGING_CATEGORY(TappedOutInterfaceLog, "tapped_out_interface");
|
inline Q_LOGGING_CATEGORY(TappedOutInterfaceLog, "tapped_out_interface");
|
||||||
|
|
||||||
|
|
@ -29,13 +29,14 @@ class TappedOutInterface : public QObject
|
||||||
private:
|
private:
|
||||||
QNetworkAccessManager *manager;
|
QNetworkAccessManager *manager;
|
||||||
|
|
||||||
|
CardDatabase &cardDatabase;
|
||||||
void copyDeckSplitMainAndSide(const DeckList &source, DeckList &mainboard, DeckList &sideboard);
|
void copyDeckSplitMainAndSide(const DeckList &source, DeckList &mainboard, DeckList &sideboard);
|
||||||
private slots:
|
private slots:
|
||||||
void queryFinished(QNetworkReply *reply);
|
void queryFinished(QNetworkReply *reply);
|
||||||
void getAnalyzeRequestData(const DeckList &deck, QByteArray &data);
|
void getAnalyzeRequestData(const DeckList &deck, QByteArray &data);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TappedOutInterface(QObject *parent = nullptr);
|
explicit TappedOutInterface(CardDatabase &_cardDatabase, QObject *parent = nullptr);
|
||||||
void analyzeDeck(const DeckList &deck);
|
void analyzeDeck(const DeckList &deck);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,6 @@ SettingsCache::SettingsCache()
|
||||||
cardViewExpandedRowsMax = settings->value("interface/cardViewExpandedRowsMax", 20).toInt();
|
cardViewExpandedRowsMax = settings->value("interface/cardViewExpandedRowsMax", 20).toInt();
|
||||||
closeEmptyCardView = settings->value("interface/closeEmptyCardView", true).toBool();
|
closeEmptyCardView = settings->value("interface/closeEmptyCardView", true).toBool();
|
||||||
focusCardViewSearchBar = settings->value("interface/focusCardViewSearchBar", true).toBool();
|
focusCardViewSearchBar = settings->value("interface/focusCardViewSearchBar", true).toBool();
|
||||||
keepGameChatFocus = settings->value("interface/keepGameChatFocus", false).toBool();
|
|
||||||
|
|
||||||
showDragSelectionCount = settings->value("interface/showlassoselectioncount", true).toBool();
|
showDragSelectionCount = settings->value("interface/showlassoselectioncount", true).toBool();
|
||||||
showTotalSelectionCount = settings->value("interface/showpersistentselectioncount", true).toBool();
|
showTotalSelectionCount = settings->value("interface/showpersistentselectioncount", true).toBool();
|
||||||
|
|
@ -389,7 +388,6 @@ SettingsCache::SettingsCache()
|
||||||
|
|
||||||
ignoreUnregisteredUsers = settings->value("chat/ignore_unregistered", false).toBool();
|
ignoreUnregisteredUsers = settings->value("chat/ignore_unregistered", false).toBool();
|
||||||
ignoreUnregisteredUserMessages = settings->value("chat/ignore_unregistered_messages", false).toBool();
|
ignoreUnregisteredUserMessages = settings->value("chat/ignore_unregistered_messages", false).toBool();
|
||||||
ignoreNonBuddyUserMessages = settings->value("chat/ignore_nonbuddy_messages", false).toBool();
|
|
||||||
|
|
||||||
scaleCards = settings->value("cards/scaleCards", true).toBool();
|
scaleCards = settings->value("cards/scaleCards", true).toBool();
|
||||||
verticalCardOverlapPercent = settings->value("cards/verticalCardOverlapPercent", 33).toInt();
|
verticalCardOverlapPercent = settings->value("cards/verticalCardOverlapPercent", 33).toInt();
|
||||||
|
|
@ -458,13 +456,6 @@ void SettingsCache::setFocusCardViewSearchBar(QT_STATE_CHANGED_T value)
|
||||||
settings->setValue("interface/focusCardViewSearchBar", focusCardViewSearchBar);
|
settings->setValue("interface/focusCardViewSearchBar", focusCardViewSearchBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsCache::setKeepGameChatFocus(QT_STATE_CHANGED_T value)
|
|
||||||
{
|
|
||||||
keepGameChatFocus = value;
|
|
||||||
settings->setValue("interface/keepGameChatFocus", keepGameChatFocus);
|
|
||||||
emit keepGameChatFocusChanged(keepGameChatFocus);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsCache::setKnownMissingFeatures(const QString &_knownMissingFeatures)
|
void SettingsCache::setKnownMissingFeatures(const QString &_knownMissingFeatures)
|
||||||
{
|
{
|
||||||
knownMissingFeatures = _knownMissingFeatures;
|
knownMissingFeatures = _knownMissingFeatures;
|
||||||
|
|
@ -1126,12 +1117,6 @@ void SettingsCache::setIgnoreUnregisteredUserMessages(QT_STATE_CHANGED_T _ignore
|
||||||
settings->setValue("chat/ignore_unregistered_messages", ignoreUnregisteredUserMessages);
|
settings->setValue("chat/ignore_unregistered_messages", ignoreUnregisteredUserMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsCache::setIgnoreNonBuddyUserMessages(QT_STATE_CHANGED_T _ignoreNonBuddyUserMessages)
|
|
||||||
{
|
|
||||||
ignoreNonBuddyUserMessages = static_cast<bool>(_ignoreNonBuddyUserMessages);
|
|
||||||
settings->setValue("chat/ignore_nonbuddy_messages", ignoreNonBuddyUserMessages);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsCache::setPixmapCacheSize(const int _pixmapCacheSize)
|
void SettingsCache::setPixmapCacheSize(const int _pixmapCacheSize)
|
||||||
{
|
{
|
||||||
pixmapCacheSize = _pixmapCacheSize;
|
pixmapCacheSize = _pixmapCacheSize;
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,6 @@ signals:
|
||||||
void soundThemeChanged();
|
void soundThemeChanged();
|
||||||
void ignoreUnregisteredUsersChanged();
|
void ignoreUnregisteredUsersChanged();
|
||||||
void ignoreUnregisteredUserMessagesChanged();
|
void ignoreUnregisteredUserMessagesChanged();
|
||||||
void ignoreNonBuddyUserMessagesChanged();
|
|
||||||
void pixmapCacheSizeChanged(int newSizeInMBs);
|
void pixmapCacheSizeChanged(int newSizeInMBs);
|
||||||
void networkCacheSizeChanged(int newSizeInMBs);
|
void networkCacheSizeChanged(int newSizeInMBs);
|
||||||
void redirectCacheTtlChanged(int newTtl);
|
void redirectCacheTtlChanged(int newTtl);
|
||||||
|
|
@ -195,7 +194,6 @@ signals:
|
||||||
void downloadSpoilerStatusChanged();
|
void downloadSpoilerStatusChanged();
|
||||||
void useTearOffMenusChanged(bool state);
|
void useTearOffMenusChanged(bool state);
|
||||||
void roundCardCornersChanged(bool roundCardCorners);
|
void roundCardCornersChanged(bool roundCardCorners);
|
||||||
void keepGameChatFocusChanged(bool value);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSettings *settings;
|
QSettings *settings;
|
||||||
|
|
@ -296,7 +294,6 @@ private:
|
||||||
QString soundThemeName;
|
QString soundThemeName;
|
||||||
bool ignoreUnregisteredUsers;
|
bool ignoreUnregisteredUsers;
|
||||||
bool ignoreUnregisteredUserMessages;
|
bool ignoreUnregisteredUserMessages;
|
||||||
bool ignoreNonBuddyUserMessages;
|
|
||||||
QString picUrl;
|
QString picUrl;
|
||||||
QString picUrlFallback;
|
QString picUrlFallback;
|
||||||
QString clientID;
|
QString clientID;
|
||||||
|
|
@ -307,7 +304,6 @@ private:
|
||||||
int cardViewExpandedRowsMax;
|
int cardViewExpandedRowsMax;
|
||||||
bool closeEmptyCardView;
|
bool closeEmptyCardView;
|
||||||
bool focusCardViewSearchBar;
|
bool focusCardViewSearchBar;
|
||||||
bool keepGameChatFocus;
|
|
||||||
int pixmapCacheSize;
|
int pixmapCacheSize;
|
||||||
int networkCacheSize;
|
int networkCacheSize;
|
||||||
int redirectCacheTtl;
|
int redirectCacheTtl;
|
||||||
|
|
@ -792,10 +788,6 @@ public:
|
||||||
{
|
{
|
||||||
return ignoreUnregisteredUserMessages;
|
return ignoreUnregisteredUserMessages;
|
||||||
}
|
}
|
||||||
[[nodiscard]] bool getIgnoreNonBuddyUserMessages() const
|
|
||||||
{
|
|
||||||
return ignoreNonBuddyUserMessages;
|
|
||||||
}
|
|
||||||
[[nodiscard]] int getPixmapCacheSize() const
|
[[nodiscard]] int getPixmapCacheSize() const
|
||||||
{
|
{
|
||||||
return pixmapCacheSize;
|
return pixmapCacheSize;
|
||||||
|
|
@ -937,7 +929,6 @@ public:
|
||||||
void setCardViewExpandedRowsMax(int value);
|
void setCardViewExpandedRowsMax(int value);
|
||||||
void setCloseEmptyCardView(QT_STATE_CHANGED_T value);
|
void setCloseEmptyCardView(QT_STATE_CHANGED_T value);
|
||||||
void setFocusCardViewSearchBar(QT_STATE_CHANGED_T value);
|
void setFocusCardViewSearchBar(QT_STATE_CHANGED_T value);
|
||||||
void setKeepGameChatFocus(QT_STATE_CHANGED_T value);
|
|
||||||
QString getClientID() override
|
QString getClientID() override
|
||||||
{
|
{
|
||||||
return clientID;
|
return clientID;
|
||||||
|
|
@ -970,10 +961,6 @@ public:
|
||||||
{
|
{
|
||||||
return focusCardViewSearchBar;
|
return focusCardViewSearchBar;
|
||||||
}
|
}
|
||||||
[[nodiscard]] bool getKeepGameChatFocus() const
|
|
||||||
{
|
|
||||||
return keepGameChatFocus;
|
|
||||||
}
|
|
||||||
[[nodiscard]] ShortcutsSettings &shortcuts() const
|
[[nodiscard]] ShortcutsSettings &shortcuts() const
|
||||||
{
|
{
|
||||||
return *shortcutsSettings;
|
return *shortcutsSettings;
|
||||||
|
|
@ -1124,7 +1111,6 @@ public slots:
|
||||||
void setSoundThemeName(const QString &_soundThemeName);
|
void setSoundThemeName(const QString &_soundThemeName);
|
||||||
void setIgnoreUnregisteredUsers(QT_STATE_CHANGED_T _ignoreUnregisteredUsers);
|
void setIgnoreUnregisteredUsers(QT_STATE_CHANGED_T _ignoreUnregisteredUsers);
|
||||||
void setIgnoreUnregisteredUserMessages(QT_STATE_CHANGED_T _ignoreUnregisteredUserMessages);
|
void setIgnoreUnregisteredUserMessages(QT_STATE_CHANGED_T _ignoreUnregisteredUserMessages);
|
||||||
void setIgnoreNonBuddyUserMessages(QT_STATE_CHANGED_T _ignoreNonBuddyUserMessages);
|
|
||||||
void setPixmapCacheSize(const int _pixmapCacheSize);
|
void setPixmapCacheSize(const int _pixmapCacheSize);
|
||||||
void setCardImageCacheMethod(CardPictureLoaderCacheMethod::CacheMethod _cardImageCachingMethod);
|
void setCardImageCacheMethod(CardPictureLoaderCacheMethod::CacheMethod _cardImageCachingMethod);
|
||||||
void setNetworkCacheSizeInMB(const int _networkCacheSize);
|
void setNetworkCacheSizeInMB(const int _networkCacheSize);
|
||||||
|
|
|
||||||
|
|
@ -223,10 +223,6 @@ private:
|
||||||
{"TabDeckEditor/aLoadDeck", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Load Deck..."),
|
{"TabDeckEditor/aLoadDeck", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Load Deck..."),
|
||||||
parseSequenceString("Ctrl+O"),
|
parseSequenceString("Ctrl+O"),
|
||||||
ShortcutGroup::Deck_Editor)},
|
ShortcutGroup::Deck_Editor)},
|
||||||
{"TabDeckEditor/aLoadDeckFromWebsite",
|
|
||||||
ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Load deck from online service..."),
|
|
||||||
parseSequenceString("Ctrl+Shift+O"),
|
|
||||||
ShortcutGroup::Deck_Editor)},
|
|
||||||
{"TabDeckEditor/aLoadDeckFromClipboard",
|
{"TabDeckEditor/aLoadDeckFromClipboard",
|
||||||
ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Load Deck from Clipboard..."),
|
ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Load Deck from Clipboard..."),
|
||||||
parseSequenceString("Ctrl+Shift+V"),
|
parseSequenceString("Ctrl+Shift+V"),
|
||||||
|
|
@ -287,10 +283,6 @@ private:
|
||||||
ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Load Deck from Clipboard..."),
|
ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Load Deck from Clipboard..."),
|
||||||
parseSequenceString("Ctrl+Shift+V"),
|
parseSequenceString("Ctrl+Shift+V"),
|
||||||
ShortcutGroup::Game_Lobby)},
|
ShortcutGroup::Game_Lobby)},
|
||||||
{"DeckViewContainer/loadFromWebsiteButton",
|
|
||||||
ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Load from website..."),
|
|
||||||
parseSequenceString("Ctrl+Shift+O"),
|
|
||||||
ShortcutGroup::Game_Lobby)},
|
|
||||||
{"DeckViewContainer/unloadDeckButton", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Unload Deck"),
|
{"DeckViewContainer/unloadDeckButton", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Unload Deck"),
|
||||||
parseSequenceString("Ctrl+Alt+U"),
|
parseSequenceString("Ctrl+Alt+U"),
|
||||||
ShortcutGroup::Game_Lobby)},
|
ShortcutGroup::Game_Lobby)},
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include "../interface/widgets/tabs/tab_game.h"
|
#include "../interface/widgets/tabs/tab_game.h"
|
||||||
#include "player/player_logic.h"
|
#include "player/player_logic.h"
|
||||||
|
|
||||||
AbstractGame::AbstractGame(QObject *_parent) : QObject(_parent)
|
AbstractGame::AbstractGame(TabGame *_tab) : QObject(_tab), tab(_tab)
|
||||||
{
|
{
|
||||||
gameMetaInfo = new GameMetaInfo(this);
|
gameMetaInfo = new GameMetaInfo(this);
|
||||||
gameEventHandler = new GameEventHandler(this);
|
gameEventHandler = new GameEventHandler(this);
|
||||||
|
|
|
||||||
|
|
@ -16,19 +16,26 @@
|
||||||
#include <libcockatrice/protocol/pb/game_replay.pb.h>
|
#include <libcockatrice/protocol/pb/game_replay.pb.h>
|
||||||
|
|
||||||
class CardItem;
|
class CardItem;
|
||||||
|
class TabGame;
|
||||||
class AbstractGame : public QObject
|
class AbstractGame : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AbstractGame(QObject *parent);
|
explicit AbstractGame(TabGame *tab);
|
||||||
|
|
||||||
|
TabGame *tab;
|
||||||
GameMetaInfo *gameMetaInfo;
|
GameMetaInfo *gameMetaInfo;
|
||||||
GameState *gameState;
|
GameState *gameState;
|
||||||
GameEventHandler *gameEventHandler;
|
GameEventHandler *gameEventHandler;
|
||||||
PlayerManager *playerManager;
|
PlayerManager *playerManager;
|
||||||
CardItem *activeCard;
|
CardItem *activeCard;
|
||||||
|
|
||||||
|
TabGame *getTab() const
|
||||||
|
{
|
||||||
|
return tab;
|
||||||
|
}
|
||||||
|
|
||||||
GameMetaInfo *getGameMetaInfo()
|
GameMetaInfo *getGameMetaInfo()
|
||||||
{
|
{
|
||||||
return gameMetaInfo;
|
return gameMetaInfo;
|
||||||
|
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
#include "arrow_registry.h"
|
|
||||||
|
|
||||||
#include "../game_graphics/board/arrow_item.h"
|
|
||||||
|
|
||||||
void ArrowRegistry::insert(QSharedPointer<ArrowData> data, ArrowItem *arrow)
|
|
||||||
{
|
|
||||||
const ArrowKey key{data->creatorId, data->id};
|
|
||||||
|
|
||||||
if (auto *existing = take(data->creatorId, data->id)) {
|
|
||||||
existing->delArrow();
|
|
||||||
}
|
|
||||||
|
|
||||||
dataStore.insert(key, data);
|
|
||||||
items.insert(key, arrow);
|
|
||||||
byPlayer[data->creatorId].insert(data->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrowItem *ArrowRegistry::take(int creatorId, int arrowId)
|
|
||||||
{
|
|
||||||
const ArrowKey key{creatorId, arrowId};
|
|
||||||
dataStore.remove(key);
|
|
||||||
auto &playerSet = byPlayer[creatorId];
|
|
||||||
playerSet.remove(arrowId);
|
|
||||||
if (playerSet.isEmpty()) {
|
|
||||||
byPlayer.remove(creatorId);
|
|
||||||
}
|
|
||||||
return items.take(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrowItem *ArrowRegistry::get(int creatorId, int arrowId) const
|
|
||||||
{
|
|
||||||
return items.value(ArrowKey{creatorId, arrowId}, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ArrowRegistry::contains(int creatorId, int arrowId) const
|
|
||||||
{
|
|
||||||
return items.contains(ArrowKey{creatorId, arrowId});
|
|
||||||
}
|
|
||||||
|
|
||||||
QSet<int> ArrowRegistry::idsForPlayer(int playerId) const
|
|
||||||
{
|
|
||||||
return byPlayer.value(playerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<ArrowItem *> ArrowRegistry::all() const
|
|
||||||
{
|
|
||||||
return items.values();
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
#ifndef COCKATRICE_ARROW_REGISTRY_H
|
|
||||||
#define COCKATRICE_ARROW_REGISTRY_H
|
|
||||||
|
|
||||||
#include "board/arrow_data.h"
|
|
||||||
|
|
||||||
#include <QMap>
|
|
||||||
#include <QSet>
|
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
class ArrowItem;
|
|
||||||
|
|
||||||
struct ArrowKey
|
|
||||||
{
|
|
||||||
int creatorId;
|
|
||||||
int arrowId;
|
|
||||||
|
|
||||||
bool operator<(const ArrowKey &other) const
|
|
||||||
{
|
|
||||||
if (creatorId != other.creatorId) {
|
|
||||||
return creatorId < other.creatorId;
|
|
||||||
}
|
|
||||||
return arrowId < other.arrowId;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class ArrowRegistry
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void insert(QSharedPointer<ArrowData> data, ArrowItem *arrow);
|
|
||||||
ArrowItem *take(int creatorId, int arrowId);
|
|
||||||
|
|
||||||
[[nodiscard]] ArrowItem *get(int creatorId, int arrowId) const;
|
|
||||||
[[nodiscard]] bool contains(int creatorId, int arrowId) const;
|
|
||||||
[[nodiscard]] QSet<int> idsForPlayer(int playerId) const;
|
|
||||||
[[nodiscard]] QList<ArrowItem *> all() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QMap<ArrowKey, QSharedPointer<ArrowData>> dataStore;
|
|
||||||
QMap<ArrowKey, ArrowItem *> items;
|
|
||||||
QMap<int, QSet<int>> byPlayer;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
#ifndef ABSTRACTCARDITEM_H
|
#ifndef ABSTRACTCARDITEM_H
|
||||||
#define ABSTRACTCARDITEM_H
|
#define ABSTRACTCARDITEM_H
|
||||||
|
|
||||||
|
#include "../../game_graphics/board/graphics_item_type.h"
|
||||||
#include "../card_dimensions.h"
|
#include "../card_dimensions.h"
|
||||||
#include "arrow_target.h"
|
#include "arrow_target.h"
|
||||||
#include "graphics_item_type.h"
|
|
||||||
|
|
||||||
#include <libcockatrice/card/printing/exact_card.h>
|
#include <libcockatrice/card/printing/exact_card.h>
|
||||||
#include <libcockatrice/utility/card_ref.h>
|
#include <libcockatrice/utility/card_ref.h>
|
||||||
|
|
@ -44,11 +44,6 @@ signals:
|
||||||
void deleteCardInfoPopup(QString cardName);
|
void deleteCardInfoPopup(QString cardName);
|
||||||
void sigPixmapUpdated();
|
void sigPixmapUpdated();
|
||||||
void cardShiftClicked(QString cardName);
|
void cardShiftClicked(QString cardName);
|
||||||
void rightClicked(AbstractCardItem *card, QPoint screenPos);
|
|
||||||
void playSelected(AbstractCardItem *card);
|
|
||||||
void playSelectedFaceDown(AbstractCardItem *card);
|
|
||||||
void hideSelected(AbstractCardItem *card);
|
|
||||||
void selectionChanged(AbstractCardItem *card, bool selected);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#include "abstract_counter.h"
|
#include "abstract_counter.h"
|
||||||
|
|
||||||
#include "../../client/settings/cache_settings.h"
|
#include "../../client/settings/cache_settings.h"
|
||||||
#include "../../game/player/player_actions.h"
|
|
||||||
#include "../../game/player/player_logic.h"
|
|
||||||
#include "../../game_graphics/board/translate_counter_name.h"
|
|
||||||
#include "../../interface/widgets/tabs/tab_game.h"
|
#include "../../interface/widgets/tabs/tab_game.h"
|
||||||
|
#include "../player/player_actions.h"
|
||||||
|
#include "../player/player_logic.h"
|
||||||
|
#include "translate_counter_name.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
#ifndef COUNTER_H
|
#ifndef COUNTER_H
|
||||||
#define COUNTER_H
|
#define COUNTER_H
|
||||||
|
|
||||||
#include "../../game/board/counter_state.h"
|
|
||||||
#include "../../interface/widgets/menus/tearoff_menu.h"
|
#include "../../interface/widgets/menus/tearoff_menu.h"
|
||||||
#include "../player/menu/abstract_player_component.h"
|
#include "../player/menu/abstract_player_component.h"
|
||||||
|
#include "counter_state.h"
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
#include "arrow_data.h"
|
#include "arrow_data.h"
|
||||||
|
|
||||||
ArrowData ArrowData::fromProto(const ServerInfo_Arrow &arrow, int creatorId, bool isLocalCreator)
|
ArrowData ArrowData::fromProto(const ServerInfo_Arrow &arrow)
|
||||||
{
|
{
|
||||||
ArrowData data;
|
ArrowData data;
|
||||||
data.creatorId = creatorId;
|
|
||||||
data.isLocalCreator = isLocalCreator;
|
|
||||||
data.id = arrow.id();
|
data.id = arrow.id();
|
||||||
data.startPlayerId = arrow.start_player_id();
|
data.startPlayerId = arrow.start_player_id();
|
||||||
data.startZone = QString::fromStdString(arrow.start_zone());
|
data.startZone = QString::fromStdString(arrow.start_zone());
|
||||||
|
|
|
||||||
|
|
@ -8,18 +8,16 @@
|
||||||
|
|
||||||
struct ArrowData
|
struct ArrowData
|
||||||
{
|
{
|
||||||
int creatorId = -1;
|
int id;
|
||||||
bool isLocalCreator = false;
|
int startPlayerId;
|
||||||
int id = -1;
|
QString startZone;
|
||||||
int startPlayerId = -1;
|
int startCardId;
|
||||||
QString startZone = "";
|
int targetPlayerId;
|
||||||
int startCardId = -1;
|
QString targetZone; // empty = targeting a player
|
||||||
int targetPlayerId = -1;
|
int targetCardId = -1; // -1 = targeting a player
|
||||||
QString targetZone = "";
|
QColor color;
|
||||||
int targetCardId = -1;
|
|
||||||
QColor color = "";
|
|
||||||
|
|
||||||
static ArrowData fromProto(const ServerInfo_Arrow &arrow, int creatorId, bool isLocalCreator);
|
static ArrowData fromProto(const ServerInfo_Arrow &arrow);
|
||||||
|
|
||||||
bool isPlayerTargeted() const
|
bool isPlayerTargeted() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
#include "arrow_item.h"
|
#include "arrow_item.h"
|
||||||
|
|
||||||
#include "../../client/settings/cache_settings.h"
|
#include "../../client/settings/cache_settings.h"
|
||||||
#include "../../game/player/player_actions.h"
|
#include "../../game_graphics/zones/card_zone.h"
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../player/player_actions.h"
|
||||||
|
#include "../player/player_logic.h"
|
||||||
#include "../player/player_target.h"
|
#include "../player/player_target.h"
|
||||||
#include "../z_values.h"
|
#include "../z_values.h"
|
||||||
#include "../zones/card_zone.h"
|
|
||||||
#include "card_item.h"
|
#include "card_item.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
@ -21,8 +21,12 @@
|
||||||
#include <libcockatrice/utility/color.h>
|
#include <libcockatrice/utility/color.h>
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
ArrowItem::ArrowItem(QSharedPointer<const ArrowData> _data, ArrowTarget *_startItem, ArrowTarget *_targetItem)
|
ArrowItem::ArrowItem(PlayerLogic *_player,
|
||||||
: data(std::move(_data)), startItem(_startItem), targetItem(_targetItem)
|
int _id,
|
||||||
|
ArrowTarget *_startItem,
|
||||||
|
ArrowTarget *_targetItem,
|
||||||
|
const QColor &_color)
|
||||||
|
: player(_player), id(_id), startItem(_startItem), targetItem(_targetItem), color(_color)
|
||||||
{
|
{
|
||||||
setZValue(ZValues::ARROWS);
|
setZValue(ZValues::ARROWS);
|
||||||
|
|
||||||
|
|
@ -48,7 +52,7 @@ ArrowItem::ArrowItem(QSharedPointer<const ArrowData> _data, ArrowTarget *_startI
|
||||||
|
|
||||||
void ArrowItem::onTargetDestroyed()
|
void ArrowItem::onTargetDestroyed()
|
||||||
{
|
{
|
||||||
emit requestDeletion(data->creatorId, data->id);
|
emit requestDeletion(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrowItem::delArrow()
|
void ArrowItem::delArrow()
|
||||||
|
|
@ -126,7 +130,7 @@ void ArrowItem::updatePath(const QPointF &endPoint)
|
||||||
|
|
||||||
void ArrowItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
void ArrowItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||||
{
|
{
|
||||||
QColor paintColor(data->color);
|
QColor paintColor(color);
|
||||||
if (fullColor) {
|
if (fullColor) {
|
||||||
paintColor.setAlpha(200);
|
paintColor.setAlpha(200);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -138,7 +142,7 @@ void ArrowItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*opti
|
||||||
|
|
||||||
void ArrowItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void ArrowItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (!data->isLocalCreator) {
|
if (!player->getPlayerInfo()->getLocal()) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -152,20 +156,14 @@ void ArrowItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
if (event->button() == Qt::RightButton) {
|
if (event->button() == Qt::RightButton) {
|
||||||
emit requestDeletion(data->creatorId, data->id);
|
emit requestDeletion(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ArrowDragItem
|
// ArrowDragItem
|
||||||
|
|
||||||
ArrowDragItem::ArrowDragItem(PlayerLogic *_owner, ArrowTarget *_startItem, const QColor &_color, int _deleteInPhase)
|
ArrowDragItem::ArrowDragItem(PlayerLogic *_owner, ArrowTarget *_startItem, const QColor &_color, int _deleteInPhase)
|
||||||
: ArrowItem(QSharedPointer<ArrowData>::create(ArrowData{.creatorId = _owner->getPlayerInfo()->getId(),
|
: ArrowItem(_owner, -1, _startItem, nullptr, _color), deleteInPhase(_deleteInPhase)
|
||||||
.isLocalCreator = true,
|
|
||||||
.id = -1,
|
|
||||||
.color = _color}),
|
|
||||||
_startItem,
|
|
||||||
nullptr),
|
|
||||||
player(_owner), deleteInPhase(_deleteInPhase)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -240,7 +238,7 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
CardZoneLogic *startZone = startCard->getZone();
|
CardZoneLogic *startZone = startCard->getZone();
|
||||||
|
|
||||||
Command_CreateArrow cmd;
|
Command_CreateArrow cmd;
|
||||||
cmd.mutable_arrow_color()->CopyFrom(convertQColorToColor(data->color));
|
cmd.mutable_arrow_color()->CopyFrom(convertQColorToColor(color));
|
||||||
cmd.set_start_player_id(startZone->getPlayer()->getPlayerInfo()->getId());
|
cmd.set_start_player_id(startZone->getPlayer()->getPlayerInfo()->getId());
|
||||||
cmd.set_start_zone(startZone->getName().toStdString());
|
cmd.set_start_zone(startZone->getName().toStdString());
|
||||||
cmd.set_start_card_id(startCard->getId());
|
cmd.set_start_card_id(startCard->getId());
|
||||||
|
|
@ -286,14 +284,7 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
|
||||||
// ArrowAttachItem
|
// ArrowAttachItem
|
||||||
ArrowAttachItem::ArrowAttachItem(ArrowTarget *_startItem)
|
ArrowAttachItem::ArrowAttachItem(ArrowTarget *_startItem)
|
||||||
: ArrowItem(
|
: ArrowItem(_startItem->getOwner(), -1, _startItem, nullptr, Qt::green)
|
||||||
QSharedPointer<ArrowData>::create(ArrowData{.creatorId = _startItem->getOwner()->getPlayerInfo()->getId(),
|
|
||||||
.isLocalCreator = true,
|
|
||||||
.id = -1,
|
|
||||||
.color = Qt::green}),
|
|
||||||
_startItem,
|
|
||||||
nullptr),
|
|
||||||
player(_startItem->getOwner())
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,15 +1,20 @@
|
||||||
|
/**
|
||||||
|
* @file arrow_item.h
|
||||||
|
* @ingroup GameGraphics
|
||||||
|
*/
|
||||||
|
//! \todo Document this file.
|
||||||
|
|
||||||
#ifndef ARROWITEM_H
|
#ifndef ARROWITEM_H
|
||||||
#define ARROWITEM_H
|
#define ARROWITEM_H
|
||||||
|
|
||||||
#include "../../game/board/arrow_data.h"
|
|
||||||
#include "arrow_target.h"
|
#include "arrow_target.h"
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
class CardItem;
|
class CardItem;
|
||||||
class QGraphicsSceneMouseEvent;
|
class QGraphicsSceneMouseEvent;
|
||||||
|
class QMenu;
|
||||||
class PlayerLogic;
|
class PlayerLogic;
|
||||||
|
|
||||||
class ArrowItem : public QObject, public QGraphicsItem
|
class ArrowItem : public QObject, public QGraphicsItem
|
||||||
|
|
@ -17,27 +22,25 @@ class ArrowItem : public QObject, public QGraphicsItem
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(QGraphicsItem)
|
Q_INTERFACES(QGraphicsItem)
|
||||||
signals:
|
signals:
|
||||||
void requestDeletion(int creatorId, int id);
|
void requestDeletion(int id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QSharedPointer<const ArrowData> data;
|
PlayerLogic *player;
|
||||||
|
int id;
|
||||||
QPointer<ArrowTarget> startItem;
|
QPointer<ArrowTarget> startItem;
|
||||||
QPointer<ArrowTarget> targetItem;
|
QPointer<ArrowTarget> targetItem;
|
||||||
bool targetLocked = false;
|
bool targetLocked = false;
|
||||||
|
QColor color;
|
||||||
bool fullColor = true;
|
bool fullColor = true;
|
||||||
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ArrowItem(QSharedPointer<const ArrowData> _data, ArrowTarget *_startItem, ArrowTarget *_targetItem);
|
ArrowItem(PlayerLogic *_player, int _id, ArrowTarget *_startItem, ArrowTarget *_targetItem, const QColor &_color);
|
||||||
|
|
||||||
void onTargetDestroyed();
|
void onTargetDestroyed();
|
||||||
void delArrow();
|
|
||||||
void updatePath();
|
|
||||||
void updatePath(const QPointF &endPoint);
|
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
[[nodiscard]] QRectF boundingRect() const override
|
[[nodiscard]] QRectF boundingRect() const override
|
||||||
|
|
@ -48,13 +51,17 @@ public:
|
||||||
{
|
{
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updatePath();
|
||||||
|
void updatePath(const QPointF &endPoint);
|
||||||
|
|
||||||
[[nodiscard]] int getId() const
|
[[nodiscard]] int getId() const
|
||||||
{
|
{
|
||||||
return data->id;
|
return id;
|
||||||
}
|
}
|
||||||
[[nodiscard]] int getCreatorId() const
|
[[nodiscard]] PlayerLogic *getPlayer() const
|
||||||
{
|
{
|
||||||
return data->creatorId;
|
return player;
|
||||||
}
|
}
|
||||||
[[nodiscard]] ArrowTarget *getStartItem() const
|
[[nodiscard]] ArrowTarget *getStartItem() const
|
||||||
{
|
{
|
||||||
|
|
@ -68,13 +75,14 @@ public:
|
||||||
{
|
{
|
||||||
targetLocked = _targetLocked;
|
targetLocked = _targetLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void delArrow();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ArrowDragItem : public ArrowItem
|
class ArrowDragItem : public ArrowItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
PlayerLogic *player;
|
|
||||||
int deleteInPhase;
|
int deleteInPhase;
|
||||||
QList<ArrowDragItem *> childArrows;
|
QList<ArrowDragItem *> childArrows;
|
||||||
QMetaObject::Connection positionConnection;
|
QMetaObject::Connection positionConnection;
|
||||||
|
|
@ -92,7 +100,6 @@ class ArrowAttachItem : public ArrowItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
PlayerLogic *player;
|
|
||||||
QList<ArrowAttachItem *> childArrows;
|
QList<ArrowAttachItem *> childArrows;
|
||||||
QMetaObject::Connection positionConnection;
|
QMetaObject::Connection positionConnection;
|
||||||
void attachCards(CardItem *startCard, const CardItem *targetCard);
|
void attachCards(CardItem *startCard, const CardItem *targetCard);
|
||||||
|
|
@ -106,4 +113,4 @@ protected:
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // ARROWITEM_H
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include "arrow_target.h"
|
#include "arrow_target.h"
|
||||||
|
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../player/player_logic.h"
|
||||||
#include "arrow_item.h"
|
#include "arrow_item.h"
|
||||||
|
|
||||||
ArrowTarget::ArrowTarget(PlayerLogic *_owner, QGraphicsItem *parent) : AbstractGraphicsItem(parent), owner(_owner)
|
ArrowTarget::ArrowTarget(PlayerLogic *_owner, QGraphicsItem *parent) : AbstractGraphicsItem(parent), owner(_owner)
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef ARROWTARGET_H
|
#ifndef ARROWTARGET_H
|
||||||
#define ARROWTARGET_H
|
#define ARROWTARGET_H
|
||||||
|
|
||||||
#include "abstract_graphics_item.h"
|
#include "../../game_graphics/board/abstract_graphics_item.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#include "card_drag_item.h"
|
#include "card_drag_item.h"
|
||||||
|
|
||||||
|
#include "../../game_graphics/zones/card_zone.h"
|
||||||
|
#include "../../game_graphics/zones/table_zone.h"
|
||||||
|
#include "../../game_graphics/zones/view_zone.h"
|
||||||
#include "../game_scene.h"
|
#include "../game_scene.h"
|
||||||
#include "../zones/card_zone.h"
|
|
||||||
#include "../zones/table_zone.h"
|
|
||||||
#include "../zones/view_zone.h"
|
|
||||||
#include "card_item.h"
|
#include "card_item.h"
|
||||||
|
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
#include "card_item.h"
|
#include "card_item.h"
|
||||||
|
|
||||||
#include "../../client/settings/cache_settings.h"
|
#include "../../client/settings/cache_settings.h"
|
||||||
#include "../../game/phase.h"
|
#include "../../game_graphics/zones/table_zone.h"
|
||||||
#include "../../game/player/player_actions.h"
|
#include "../../game_graphics/zones/view_zone.h"
|
||||||
#include "../../game/player/player_logic.h"
|
|
||||||
#include "../../game/zones/view_zone_logic.h"
|
|
||||||
#include "../../interface/widgets/tabs/tab_game.h"
|
#include "../../interface/widgets/tabs/tab_game.h"
|
||||||
#include "../game_scene.h"
|
#include "../game_scene.h"
|
||||||
#include "../zones/table_zone.h"
|
#include "../phase.h"
|
||||||
#include "../zones/view_zone.h"
|
#include "../player/player_actions.h"
|
||||||
|
#include "../player/player_logic.h"
|
||||||
|
#include "../zones/view_zone_logic.h"
|
||||||
#include "arrow_item.h"
|
#include "arrow_item.h"
|
||||||
#include "card_drag_item.h"
|
#include "card_drag_item.h"
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ void CardItem::prepareDelete()
|
||||||
{
|
{
|
||||||
if (owner != nullptr) {
|
if (owner != nullptr) {
|
||||||
if (owner->getGame()->getActiveCard() == this) {
|
if (owner->getGame()->getActiveCard() == this) {
|
||||||
emit owner->requestCardMenuUpdate(nullptr);
|
owner->getPlayerMenu()->updateCardMenu(nullptr);
|
||||||
owner->getGame()->setActiveCard(nullptr);
|
owner->getGame()->setActiveCard(nullptr);
|
||||||
}
|
}
|
||||||
owner = nullptr;
|
owner = nullptr;
|
||||||
|
|
@ -399,11 +399,8 @@ void CardItem::playCard(bool faceDown)
|
||||||
emit tz->toggleTapped();
|
emit tz->toggleTapped();
|
||||||
} else {
|
} else {
|
||||||
if (SettingsCache::instance().getClickPlaysAllSelected()) {
|
if (SettingsCache::instance().getClickPlaysAllSelected()) {
|
||||||
if (faceDown) {
|
faceDown ? state->getZone()->getPlayer()->getPlayerActions()->actPlayFacedown()
|
||||||
emit playSelectedFaceDown(this);
|
: state->getZone()->getPlayer()->getPlayerActions()->actPlay();
|
||||||
} else {
|
|
||||||
emit playSelected(this);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
state->getZone()->getPlayer()->getPlayerActions()->playCard(this, faceDown);
|
state->getZone()->getPlayer()->getPlayerActions()->playCard(this, faceDown);
|
||||||
}
|
}
|
||||||
|
|
@ -463,7 +460,7 @@ void CardItem::handleClickedToPlay(bool shiftHeld)
|
||||||
{
|
{
|
||||||
if (isUnwritableRevealZone(state->getZone())) {
|
if (isUnwritableRevealZone(state->getZone())) {
|
||||||
if (SettingsCache::instance().getClickPlaysAllSelected()) {
|
if (SettingsCache::instance().getClickPlaysAllSelected()) {
|
||||||
emit hideSelected(this);
|
state->getZone()->getPlayer()->getPlayerActions()->actHide();
|
||||||
} else {
|
} else {
|
||||||
state->getZone()->removeCard(this);
|
state->getZone()->removeCard(this);
|
||||||
}
|
}
|
||||||
|
|
@ -474,15 +471,21 @@ void CardItem::handleClickedToPlay(bool shiftHeld)
|
||||||
|
|
||||||
void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::RightButton && owner != nullptr) {
|
if (event->button() == Qt::RightButton) {
|
||||||
emit rightClicked(this, event->screenPos());
|
|
||||||
return;
|
if (owner != nullptr) {
|
||||||
}
|
owner->getGame()->setActiveCard(this);
|
||||||
if ((event->modifiers() != Qt::AltModifier) && (event->button() == Qt::LeftButton) &&
|
if (QMenu *cardMenu = owner->getPlayerMenu()->updateCardMenu(this)) {
|
||||||
(!SettingsCache::instance().getDoubleClickToPlay())) {
|
cardMenu->popup(event->screenPos());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ((event->modifiers() != Qt::AltModifier) && (event->button() == Qt::LeftButton) &&
|
||||||
|
(!SettingsCache::instance().getDoubleClickToPlay())) {
|
||||||
handleClickedToPlay(event->modifiers().testFlag(Qt::ShiftModifier));
|
handleClickedToPlay(event->modifiers().testFlag(Qt::ShiftModifier));
|
||||||
}
|
}
|
||||||
if (owner != nullptr) {
|
|
||||||
|
if (owner != nullptr) { // cards without owner will be deleted
|
||||||
setCursor(Qt::OpenHandCursor);
|
setCursor(Qt::OpenHandCursor);
|
||||||
}
|
}
|
||||||
AbstractCardItem::mouseReleaseEvent(event);
|
AbstractCardItem::mouseReleaseEvent(event);
|
||||||
|
|
@ -528,14 +531,14 @@ bool CardItem::animationEvent()
|
||||||
QVariant CardItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
QVariant CardItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||||
{
|
{
|
||||||
if ((change == ItemSelectedHasChanged) && owner != nullptr) {
|
if ((change == ItemSelectedHasChanged) && owner != nullptr) {
|
||||||
bool selected = value.toBool();
|
if (value == true) {
|
||||||
|
|
||||||
if (selected) {
|
|
||||||
owner->getGame()->setActiveCard(this);
|
owner->getGame()->setActiveCard(this);
|
||||||
|
owner->getPlayerMenu()->updateCardMenu(this);
|
||||||
|
} else if (owner->getGameScene()->selectedItems().isEmpty()) {
|
||||||
|
|
||||||
|
owner->getGame()->setActiveCard(nullptr);
|
||||||
|
owner->getPlayerMenu()->updateCardMenu(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit selectionChanged(this, selected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return AbstractCardItem::itemChange(change, value);
|
return AbstractCardItem::itemChange(change, value);
|
||||||
}
|
}
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
#ifndef CARDITEM_H
|
#ifndef CARDITEM_H
|
||||||
#define CARDITEM_H
|
#define CARDITEM_H
|
||||||
|
|
||||||
#include "../../game/board/card_state.h"
|
#include "../zones/card_zone_logic.h"
|
||||||
#include "../../game/zones/card_zone_logic.h"
|
|
||||||
#include "abstract_card_item.h"
|
#include "abstract_card_item.h"
|
||||||
|
#include "card_state.h"
|
||||||
|
|
||||||
#include <libcockatrice/network/server/remote/game/server_card.h>
|
#include <libcockatrice/network/server/remote/game/server_card.h>
|
||||||
#include <libcockatrice/utility/trice_limits.h>
|
#include <libcockatrice/utility/trice_limits.h>
|
||||||
|
|
@ -55,10 +55,6 @@ public:
|
||||||
CardZoneLogic *_zone = nullptr);
|
CardZoneLogic *_zone = nullptr);
|
||||||
|
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
[[nodiscard]] CardState *getState() const
|
|
||||||
{
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
[[nodiscard]] CardZoneLogic *getZone() const
|
[[nodiscard]] CardZoneLogic *getZone() const
|
||||||
{
|
{
|
||||||
return state->getZone();
|
return state->getZone();
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include "card_list.h"
|
#include "card_list.h"
|
||||||
|
|
||||||
#include "../../game_graphics/board/card_item.h"
|
#include "card_item.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ void CardState::setZone(CardZoneLogic *_zone)
|
||||||
}
|
}
|
||||||
|
|
||||||
zone = _zone;
|
zone = _zone;
|
||||||
emit zoneChanged(this, zone);
|
emit zoneChanged(zone);
|
||||||
emit stateChanged();
|
emit stateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ signals:
|
||||||
void doesntUntapChanged(bool newValue);
|
void doesntUntapChanged(bool newValue);
|
||||||
void destroyOnZoneChangeChanged(bool newValue);
|
void destroyOnZoneChangeChanged(bool newValue);
|
||||||
void attachedToChanged(CardItem *newAttachedTo);
|
void attachedToChanged(CardItem *newAttachedTo);
|
||||||
void zoneChanged(CardState *changedCard, CardZoneLogic *newZone);
|
void zoneChanged(CardZoneLogic *newZone);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CardState(QObject *parent, CardZoneLogic *_zone) : QObject(parent), zone(_zone)
|
explicit CardState(QObject *parent, CardZoneLogic *_zone) : QObject(parent), zone(_zone)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "counter_general.h"
|
#include "counter_general.h"
|
||||||
|
|
||||||
|
#include "../../game_graphics/board/abstract_graphics_item.h"
|
||||||
#include "../../interface/pixel_map_generator.h"
|
#include "../../interface/pixel_map_generator.h"
|
||||||
#include "abstract_graphics_item.h"
|
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
@ -360,16 +360,6 @@ void DeckViewScene::rebuildTree()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList requiredZones = {DECK_ZONE_MAIN, DECK_ZONE_SIDE};
|
|
||||||
|
|
||||||
for (const QString &zoneName : requiredZones) {
|
|
||||||
if (!cardContainers.contains(zoneName)) {
|
|
||||||
auto *container = new DeckViewCardContainer(zoneName);
|
|
||||||
cardContainers.insert(zoneName, container);
|
|
||||||
addItem(container);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto *currentZone : deck->getZoneNodes()) {
|
for (auto *currentZone : deck->getZoneNodes()) {
|
||||||
DeckViewCardContainer *container = cardContainers.value(currentZone->getName(), 0);
|
DeckViewCardContainer *container = cardContainers.value(currentZone->getName(), 0);
|
||||||
if (!container) {
|
if (!container) {
|
||||||
|
|
@ -209,7 +209,6 @@ void DeckViewContainer::refreshShortcuts()
|
||||||
loadLocalButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadLocalButton"));
|
loadLocalButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadLocalButton"));
|
||||||
loadRemoteButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadRemoteButton"));
|
loadRemoteButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadRemoteButton"));
|
||||||
loadFromClipboardButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadFromClipboardButton"));
|
loadFromClipboardButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadFromClipboardButton"));
|
||||||
loadFromWebsiteButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/loadFromWebsiteButton"));
|
|
||||||
unloadDeckButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/unloadDeckButton"));
|
unloadDeckButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/unloadDeckButton"));
|
||||||
readyStartButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/readyStartButton"));
|
readyStartButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/readyStartButton"));
|
||||||
sideboardLockButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/sideboardLockButton"));
|
sideboardLockButton->setShortcut(shortcuts.getSingleShortcut("DeckViewContainer/sideboardLockButton"));
|
||||||
|
|
@ -4,16 +4,16 @@
|
||||||
|
|
||||||
#include <libcockatrice/protocol/pb/event_game_joined.pb.h>
|
#include <libcockatrice/protocol/pb/event_game_joined.pb.h>
|
||||||
|
|
||||||
Game::Game(QObject *_parent,
|
Game::Game(TabGame *_tab,
|
||||||
bool isLocalGame,
|
|
||||||
QList<AbstractClient *> &_clients,
|
QList<AbstractClient *> &_clients,
|
||||||
const Event_GameJoined &event,
|
const Event_GameJoined &event,
|
||||||
const QMap<int, QString> &_roomGameTypes)
|
const QMap<int, QString> &_roomGameTypes)
|
||||||
: AbstractGame(_parent)
|
: AbstractGame(_tab)
|
||||||
{
|
{
|
||||||
gameMetaInfo->setFromProto(event.game_info());
|
gameMetaInfo->setFromProto(event.game_info());
|
||||||
gameMetaInfo->setRoomGameTypes(_roomGameTypes);
|
gameMetaInfo->setRoomGameTypes(_roomGameTypes);
|
||||||
gameState = new GameState(this, 0, event.host_id(), isLocalGame, _clients, false, event.resuming(), -1, false);
|
gameState = new GameState(this, 0, event.host_id(), tab->getTabSupervisor()->getIsLocalGame(), _clients, false,
|
||||||
|
event.resuming(), -1, false);
|
||||||
connect(gameMetaInfo, &GameMetaInfo::startedChanged, gameState, &GameState::onStartedChanged);
|
connect(gameMetaInfo, &GameMetaInfo::startedChanged, gameState, &GameState::onStartedChanged);
|
||||||
playerManager = new PlayerManager(this, event.player_id(), event.judge(), event.spectator());
|
playerManager = new PlayerManager(this, event.player_id(), event.judge(), event.spectator());
|
||||||
gameMetaInfo->setStarted(false);
|
gameMetaInfo->setStarted(false);
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,7 @@ class Game : public AbstractGame
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Game(QObject *parent,
|
Game(TabGame *tab,
|
||||||
bool isLocalGame,
|
|
||||||
QList<AbstractClient *> &_clients,
|
QList<AbstractClient *> &_clients,
|
||||||
const Event_GameJoined &event,
|
const Event_GameJoined &event,
|
||||||
const QMap<int, QString> &_roomGameTypes);
|
const QMap<int, QString> &_roomGameTypes);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#include "game_event_handler.h"
|
#include "game_event_handler.h"
|
||||||
|
|
||||||
#include "../game_graphics/log/message_log_widget.h"
|
|
||||||
#include "../interface/widgets/tabs/tab_game.h"
|
#include "../interface/widgets/tabs/tab_game.h"
|
||||||
#include "abstract_game.h"
|
#include "abstract_game.h"
|
||||||
|
#include "log/message_log_widget.h"
|
||||||
|
|
||||||
#include <libcockatrice/network/client/abstract/abstract_client.h>
|
#include <libcockatrice/network/client/abstract/abstract_client.h>
|
||||||
#include <libcockatrice/protocol/get_pb_extension.h>
|
#include <libcockatrice/protocol/get_pb_extension.h>
|
||||||
|
|
@ -213,25 +213,11 @@ void GameEventHandler::handleChatMessageSent(const QString &chatMessage)
|
||||||
sendGameCommand(cmd);
|
sendGameCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameEventHandler::handleArrowDeletion(int creatorId, int arrowId)
|
void GameEventHandler::handleArrowDeletion(int arrowId)
|
||||||
{
|
{
|
||||||
Command_DeleteArrow cmd;
|
Command_DeleteArrow cmd;
|
||||||
cmd.set_arrow_id(arrowId);
|
cmd.set_arrow_id(arrowId);
|
||||||
|
sendGameCommand(cmd);
|
||||||
auto preparedCommand = prepareGameCommand(cmd);
|
|
||||||
|
|
||||||
connect(preparedCommand, &PendingCommand::finished, this, [creatorId, arrowId, this](const Response &response) {
|
|
||||||
handleArrowDeletionFinished(response, creatorId, arrowId);
|
|
||||||
});
|
|
||||||
|
|
||||||
sendGameCommand(preparedCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameEventHandler::handleArrowDeletionFinished(const Response &response, int creatorId, int arrowId)
|
|
||||||
{
|
|
||||||
if (response.response_code() == Response::RespNameNotFound) {
|
|
||||||
emit arrowDeleted(creatorId, arrowId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameEventHandler::eventSpectatorSay(const Event_GameSay &event,
|
void GameEventHandler::eventSpectatorSay(const Event_GameSay &event,
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,7 @@ public:
|
||||||
void handleActivePhaseChanged(int phase);
|
void handleActivePhaseChanged(int phase);
|
||||||
void handleGameLeft();
|
void handleGameLeft();
|
||||||
void handleChatMessageSent(const QString &chatMessage);
|
void handleChatMessageSent(const QString &chatMessage);
|
||||||
void handleArrowDeletion(int creatorId, int arrowId);
|
void handleArrowDeletion(int arrowId);
|
||||||
void handleArrowDeletionFinished(const Response &response, int creatorId, int arrowId);
|
|
||||||
|
|
||||||
void eventSpectatorSay(const Event_GameSay &event, int eventPlayerId, const GameEventContext &context);
|
void eventSpectatorSay(const Event_GameSay &event, int eventPlayerId, const GameEventContext &context);
|
||||||
void eventSpectatorLeave(const Event_Leave &event, int eventPlayerId, const GameEventContext &context);
|
void eventSpectatorLeave(const Event_Leave &event, int eventPlayerId, const GameEventContext &context);
|
||||||
|
|
@ -113,7 +112,6 @@ signals:
|
||||||
void containerProcessingStarted(GameEventContext context);
|
void containerProcessingStarted(GameEventContext context);
|
||||||
void setContextJudgeName(QString judgeName);
|
void setContextJudgeName(QString judgeName);
|
||||||
void containerProcessingDone();
|
void containerProcessingDone();
|
||||||
void arrowDeleted(int creatorId, int arrowId);
|
|
||||||
void logSpectatorSay(ServerInfo_User userInfo, QString message);
|
void logSpectatorSay(ServerInfo_User userInfo, QString message);
|
||||||
void logSpectatorLeave(QString name, QString reason);
|
void logSpectatorLeave(QString name, QString reason);
|
||||||
void logGameStart();
|
void logGameStart();
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
#include "game_scene.h"
|
#include "game_scene.h"
|
||||||
|
|
||||||
#include "../client/settings/cache_settings.h"
|
#include "../client/settings/cache_settings.h"
|
||||||
#include "../game/abstract_game.h"
|
#include "../game_graphics/zones/select_zone.h"
|
||||||
#include "../game/player/player_actions.h"
|
#include "../game_graphics/zones/view_zone.h"
|
||||||
#include "../game/player/player_logic.h"
|
#include "../game_graphics/zones/view_zone_widget.h"
|
||||||
#include "../game_graphics/player/player_graphics_item.h"
|
|
||||||
#include "board/card_item.h"
|
#include "board/card_item.h"
|
||||||
#include "phases_toolbar.h"
|
#include "phases_toolbar.h"
|
||||||
#include "player/menu/player_menu.h"
|
|
||||||
#include "player/player_graphics_item.h"
|
#include "player/player_graphics_item.h"
|
||||||
#include "zones/select_zone.h"
|
#include "player/player_logic.h"
|
||||||
#include "zones/view_zone.h"
|
|
||||||
#include "zones/view_zone_widget.h"
|
|
||||||
|
|
||||||
#include <QBasicTimer>
|
#include <QBasicTimer>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
@ -76,80 +72,6 @@ QList<CardItem *> GameScene::selectedCards() const
|
||||||
return selectedCards;
|
return selectedCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::onCardSelectionChanged(AbstractCardItem *abstractCard, bool selected)
|
|
||||||
{
|
|
||||||
CardItem *card = qobject_cast<CardItem *>(abstractCard);
|
|
||||||
if (!card || !card->getOwner()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto *owner = card->getOwner();
|
|
||||||
|
|
||||||
if (selected) {
|
|
||||||
owner->requestCardMenuUpdate(card);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedItems().isEmpty()) {
|
|
||||||
owner->getGame()->setActiveCard(nullptr);
|
|
||||||
owner->requestCardMenuUpdate(nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameScene::onCardRightClicked(AbstractCardItem *abstractCard, QPoint screenPos)
|
|
||||||
{
|
|
||||||
auto *card = qobject_cast<CardItem *>(abstractCard);
|
|
||||||
if (!card) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!card->getOwner()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto *view = playerViews.value(card->getOwner()->getPlayerInfo()->getId());
|
|
||||||
if (!view) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
card->getOwner()->getGame()->setActiveCard(card);
|
|
||||||
|
|
||||||
if (auto *menu = view->getPlayerMenu()->updateCardMenu(card)) {
|
|
||||||
menu->popup(screenPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameScene::playSelected(AbstractCardItem *card)
|
|
||||||
{
|
|
||||||
if (!card) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!card->getOwner()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
card->getOwner()->getPlayerActions()->actPlay(selectedCards());
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameScene::playSelectedFaceDown(AbstractCardItem *card)
|
|
||||||
{
|
|
||||||
if (!card) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!card->getOwner()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
card->getOwner()->getPlayerActions()->actPlayFacedown(selectedCards());
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameScene::hideSelected(AbstractCardItem *card)
|
|
||||||
{
|
|
||||||
if (!card) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!card->getOwner()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
card->getOwner()->getPlayerActions()->actHide(selectedCards());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Adds a player to the scene and stores their graphics item.
|
* @brief Adds a player to the scene and stores their graphics item.
|
||||||
* @param player Player to add.
|
* @param player Player to add.
|
||||||
|
|
@ -160,11 +82,9 @@ void GameScene::addPlayer(PlayerLogic *player)
|
||||||
{
|
{
|
||||||
qCInfo(GameScenePlayerAdditionRemovalLog) << "GameScene::addPlayer name=" << player->getPlayerInfo()->getName();
|
qCInfo(GameScenePlayerAdditionRemovalLog) << "GameScene::addPlayer name=" << player->getPlayerInfo()->getName();
|
||||||
|
|
||||||
auto *view = new PlayerGraphicsItem(player);
|
playerViews.insert(player->getPlayerInfo()->getId(), player->getGraphicsItem());
|
||||||
|
addItem(player->getGraphicsItem());
|
||||||
playerViews.insert(player->getPlayerInfo()->getId(), view);
|
connect(player->getGraphicsItem(), &PlayerGraphicsItem::sizeChanged, this, &GameScene::rearrange);
|
||||||
addItem(view);
|
|
||||||
connect(view, &PlayerGraphicsItem::sizeChanged, this, &GameScene::rearrange);
|
|
||||||
|
|
||||||
connect(player, &PlayerLogic::concededChanged, this, [this](int id, bool conceded) {
|
connect(player, &PlayerLogic::concededChanged, this, [this](int id, bool conceded) {
|
||||||
if (conceded) {
|
if (conceded) {
|
||||||
|
|
@ -173,13 +93,11 @@ void GameScene::addPlayer(PlayerLogic *player)
|
||||||
rearrange();
|
rearrange();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(player, &PlayerLogic::requestZoneViewToggle, this, &GameScene::toggleZoneView);
|
connect(player, &PlayerLogic::arrowDeleted, this, &GameScene::onArrowDeleted);
|
||||||
connect(player, &PlayerLogic::requestRevealedZoneView, this, &GameScene::addRevealedZoneView);
|
connect(player, &PlayerLogic::arrowCreateRequested, this, &GameScene::onArrowCreateRequested);
|
||||||
connect(player, &PlayerLogic::arrowDeleted, this, &GameScene::deleteArrow);
|
connect(player, &PlayerLogic::arrowDeleteRequested, this, &GameScene::onArrowDeleteRequested);
|
||||||
connect(player, &PlayerLogic::arrowCreateRequested, this, &GameScene::addArrow);
|
connect(player, &PlayerLogic::arrowsCleared, this,
|
||||||
connect(player, &PlayerLogic::arrowDeleteRequested, this, &GameScene::requestArrowDeletion);
|
[this, id = player->getPlayerInfo()->getId()]() { clearArrowsForPlayer(id); });
|
||||||
connect(player, &PlayerLogic::arrowsClearedLocally, this,
|
|
||||||
[this, id = player->getPlayerInfo()->getId()]() { clearArrowsForPlayerLocally(id); });
|
|
||||||
|
|
||||||
connect(player->getPlayerEventHandler(), &PlayerEventHandler::cardZoneChanged, this, &GameScene::onCardZoneChanged);
|
connect(player->getPlayerEventHandler(), &PlayerEventHandler::cardZoneChanged, this, &GameScene::onCardZoneChanged);
|
||||||
|
|
||||||
|
|
@ -205,7 +123,6 @@ void GameScene::removePlayer(PlayerLogic *player)
|
||||||
}
|
}
|
||||||
auto *view = playerViews.take(player->getPlayerInfo()->getId());
|
auto *view = playerViews.take(player->getPlayerInfo()->getId());
|
||||||
removeItem(view);
|
removeItem(view);
|
||||||
view->deleteLater();
|
|
||||||
rearrange();
|
rearrange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -287,7 +204,7 @@ QList<PlayerLogic *> GameScene::collectActivePlayers(int &firstPlayerIndex) cons
|
||||||
bool firstPlayerFound = false;
|
bool firstPlayerFound = false;
|
||||||
|
|
||||||
for (auto *pgItem : playerViews.values()) {
|
for (auto *pgItem : playerViews.values()) {
|
||||||
PlayerLogic *p = pgItem->getLogic();
|
PlayerLogic *p = pgItem->getPlayer();
|
||||||
if (p && !p->getConceded()) {
|
if (p && !p->getConceded()) {
|
||||||
activePlayers.append(p);
|
activePlayers.append(p);
|
||||||
if (!firstPlayerFound && p->getPlayerInfo()->getLocal()) {
|
if (!firstPlayerFound && p->getPlayerInfo()->getLocal()) {
|
||||||
|
|
@ -358,12 +275,12 @@ QSizeF GameScene::computeSceneSizeAndPlayerLayout(const QList<PlayerLogic *> &pl
|
||||||
for (int j = 0; j < rowsInColumn; ++j) {
|
for (int j = 0; j < rowsInColumn; ++j) {
|
||||||
PlayerLogic *player = playersIter.next();
|
PlayerLogic *player = playersIter.next();
|
||||||
if (col == 0) {
|
if (col == 0) {
|
||||||
playersByColumn[col].prepend(playerViews.value(player->getPlayerInfo()->getId()));
|
playersByColumn[col].prepend(player->getGraphicsItem());
|
||||||
} else {
|
} else {
|
||||||
playersByColumn[col].append(playerViews.value(player->getPlayerInfo()->getId()));
|
playersByColumn[col].append(player->getGraphicsItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *pgItem = playerViews.value(player->getPlayerInfo()->getId());
|
auto *pgItem = player->getGraphicsItem();
|
||||||
thisColumnHeight += pgItem->boundingRect().height() + playerAreaSpacing;
|
thisColumnHeight += pgItem->boundingRect().height() + playerAreaSpacing;
|
||||||
columnWidth[col] = std::max(columnWidth[col], (int)pgItem->boundingRect().width());
|
columnWidth[col] = std::max(columnWidth[col], (int)pgItem->boundingRect().width());
|
||||||
}
|
}
|
||||||
|
|
@ -450,62 +367,62 @@ void GameScene::resizeColumnsAndPlayers(const QList<qreal> &minWidthByColumn, qr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::addArrow(QSharedPointer<ArrowData> data)
|
void GameScene::onArrowCreateRequested(const ArrowData &data)
|
||||||
{
|
{
|
||||||
auto *startView = playerViews.value(data->startPlayerId);
|
auto *startView = playerViews.value(data.startPlayerId);
|
||||||
auto *targetView = playerViews.value(data->targetPlayerId);
|
auto *targetView = playerViews.value(data.targetPlayerId);
|
||||||
if (!startView || !targetView) {
|
if (!startView || !targetView) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerLogic *startLogic = startView->getLogic();
|
PlayerLogic *startLogic = startView->getPlayer();
|
||||||
auto *startZone = startLogic->getZones().value(data->startZone);
|
auto *startZone = startLogic->getZones().value(data.startZone);
|
||||||
if (!startZone) {
|
if (!startZone) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardItem *startCard = startZone->getCard(data->startCardId);
|
CardItem *startCard = startZone->getCard(data.startCardId);
|
||||||
if (!startCard) {
|
if (!startCard) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrowTarget *targetItem = nullptr;
|
ArrowTarget *targetItem = nullptr;
|
||||||
if (data->isPlayerTargeted()) {
|
if (data.isPlayerTargeted()) {
|
||||||
targetItem = targetView->getPlayerTarget();
|
targetItem = targetView->getPlayerTarget();
|
||||||
} else {
|
} else {
|
||||||
auto *zone = targetView->getLogic()->getZones().value(data->targetZone);
|
auto *zone = targetView->getPlayer()->getZones().value(data.targetZone);
|
||||||
if (zone) {
|
if (zone) {
|
||||||
targetItem = zone->getCard(data->targetCardId);
|
targetItem = zone->getCard(data.targetCardId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!targetItem) {
|
if (!targetItem) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *arrow = new ArrowItem(data, startCard, targetItem);
|
auto *arrow = new ArrowItem(startView->getPlayer(), data.id, startCard, targetItem, data.color);
|
||||||
addItem(arrow);
|
addItem(arrow);
|
||||||
arrowRegistry.insert(data, arrow);
|
arrowRegistry.insert(data.id, arrow);
|
||||||
connect(arrow, &ArrowItem::requestDeletion, this, &GameScene::requestArrowDeletion);
|
connect(arrow, &ArrowItem::requestDeletion, this, &GameScene::onArrowDeleteRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::deleteArrow(int playerId, int arrowId)
|
void GameScene::onArrowDeleted(int arrowId)
|
||||||
{
|
{
|
||||||
if (auto *arrow = arrowRegistry.take(playerId, arrowId)) {
|
if (arrowRegistry.contains(arrowId)) {
|
||||||
arrow->delArrow();
|
arrowRegistry.take(arrowId)->delArrow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::requestArrowDeletion(int playerId, int arrowId)
|
void GameScene::onArrowDeleteRequested(int arrowId)
|
||||||
{
|
{
|
||||||
if (arrowRegistry.contains(playerId, arrowId)) {
|
if (arrowRegistry.contains(arrowId)) {
|
||||||
emit arrowDeletionRequested(playerId, arrowId);
|
emit requestArrowDeletion(arrowId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::onCardZoneChanged(CardItem *card, bool sameZone)
|
void GameScene::onCardZoneChanged(CardItem *card, bool sameZone)
|
||||||
{
|
{
|
||||||
QList<ArrowItem *> toDelete;
|
QList<ArrowItem *> toDelete;
|
||||||
for (auto *arrow : arrowRegistry.all()) {
|
for (auto *arrow : arrowRegistry.values()) {
|
||||||
if (arrow->getStartItem() == card || arrow->getTargetItem() == card) {
|
if (arrow->getStartItem() == card || arrow->getTargetItem() == card) {
|
||||||
if (sameZone) {
|
if (sameZone) {
|
||||||
arrow->updatePath();
|
arrow->updatePath();
|
||||||
|
|
@ -515,21 +432,16 @@ void GameScene::onCardZoneChanged(CardItem *card, bool sameZone)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto *arrow : toDelete) {
|
for (auto *arrow : toDelete) {
|
||||||
deleteArrow(arrow->getCreatorId(), arrow->getId());
|
emit requestArrowDeletion(arrow->getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::clearArrowsForPlayer(int playerId)
|
void GameScene::clearArrowsForPlayer(int playerId)
|
||||||
{
|
{
|
||||||
for (int arrowId : arrowRegistry.idsForPlayer(playerId)) {
|
for (auto *arrow : arrowRegistry.values()) {
|
||||||
emit requestArrowDeletion(playerId, arrowId);
|
if (arrow->getPlayer()->getPlayerInfo()->getId() == playerId) {
|
||||||
}
|
emit requestArrowDeletion(arrow->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::clearArrowsForPlayerLocally(int playerId)
|
|
||||||
{
|
|
||||||
for (int arrowId : arrowRegistry.idsForPlayer(playerId)) {
|
|
||||||
arrowRegistry.take(playerId, arrowId)->delArrow();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
#ifndef GAMESCENE_H
|
#ifndef GAMESCENE_H
|
||||||
#define GAMESCENE_H
|
#define GAMESCENE_H
|
||||||
|
|
||||||
#include "../game/arrow_registry.h"
|
#include "board/arrow_data.h"
|
||||||
#include "../game/board/arrow_data.h"
|
|
||||||
#include "../game/zones/card_zone_logic.h"
|
|
||||||
#include "board/arrow_item.h"
|
#include "board/arrow_item.h"
|
||||||
|
#include "zones/card_zone_logic.h"
|
||||||
|
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
@ -46,7 +45,7 @@ private:
|
||||||
PhasesToolbar *phasesToolbar; ///< Toolbar showing game phases
|
PhasesToolbar *phasesToolbar; ///< Toolbar showing game phases
|
||||||
QMap<int, PlayerGraphicsItem *> playerViews; ///< ID lookup for player graphics items
|
QMap<int, PlayerGraphicsItem *> playerViews; ///< ID lookup for player graphics items
|
||||||
QList<QList<PlayerGraphicsItem *>> playersByColumn; ///< Players organized by column
|
QList<QList<PlayerGraphicsItem *>> playersByColumn; ///< Players organized by column
|
||||||
ArrowRegistry arrowRegistry; ///< ID registry for arrow graphics items
|
QMap<int, ArrowItem *> arrowRegistry; ///< ID registry for arrow graphics items
|
||||||
QList<ZoneViewWidget *> zoneViews; ///< Active zone view widgets
|
QList<ZoneViewWidget *> zoneViews; ///< Active zone view widgets
|
||||||
QSize viewSize; ///< Current view size
|
QSize viewSize; ///< Current view size
|
||||||
QPointer<CardItem> hoveredCard; ///< Currently hovered card
|
QPointer<CardItem> hoveredCard; ///< Currently hovered card
|
||||||
|
|
@ -97,16 +96,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void removePlayer(PlayerLogic *player);
|
void removePlayer(PlayerLogic *player);
|
||||||
|
|
||||||
QMap<int, PlayerGraphicsItem *> getPlayers() const
|
|
||||||
{
|
|
||||||
return playerViews;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerGraphicsItem *viewForPlayer(int playerId)
|
|
||||||
{
|
|
||||||
return playerViews.value(playerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Adjusts the global rotation offset for player layout.
|
* @brief Adjusts the global rotation offset for player layout.
|
||||||
* @param rotationAdjustment Number of positions to rotate.
|
* @param rotationAdjustment Number of positions to rotate.
|
||||||
|
|
@ -192,11 +181,6 @@ public:
|
||||||
void stopRubberBand();
|
void stopRubberBand();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onCardSelectionChanged(AbstractCardItem *card, bool selected);
|
|
||||||
void onCardRightClicked(AbstractCardItem *card, QPoint screenPos);
|
|
||||||
void playSelected(AbstractCardItem *card);
|
|
||||||
void playSelectedFaceDown(AbstractCardItem *card);
|
|
||||||
void hideSelected(AbstractCardItem *card);
|
|
||||||
/** @brief Toggles a zone view for a player. */
|
/** @brief Toggles a zone view for a player. */
|
||||||
void toggleZoneView(PlayerLogic *player, const QString &zoneName, int numberCards, bool isReversed = false);
|
void toggleZoneView(PlayerLogic *player, const QString &zoneName, int numberCards, bool isReversed = false);
|
||||||
|
|
||||||
|
|
@ -217,16 +201,11 @@ public slots:
|
||||||
QTransform getViewTransform() const;
|
QTransform getViewTransform() const;
|
||||||
QTransform getViewportTransform() const;
|
QTransform getViewportTransform() const;
|
||||||
|
|
||||||
/// Directly modifies the scene
|
void onArrowCreateRequested(const ArrowData &data);
|
||||||
void addArrow(QSharedPointer<ArrowData> data);
|
void onArrowDeleted(int arrowId);
|
||||||
void deleteArrow(int playerId, int arrowId);
|
void onArrowDeleteRequested(int arrowId);
|
||||||
void clearArrowsForPlayer(int playerId);
|
|
||||||
void clearArrowsForPlayerLocally(int playerId);
|
|
||||||
|
|
||||||
/// Queues up arrow deletion but doesn't directly modify the scene
|
|
||||||
void requestArrowDeletion(int playerId, int arrowId);
|
|
||||||
|
|
||||||
void onCardZoneChanged(CardItem *card, bool sameZone);
|
void onCardZoneChanged(CardItem *card, bool sameZone);
|
||||||
|
void clearArrowsForPlayer(int playerId);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** @brief Handles hover updates. */
|
/** @brief Handles hover updates. */
|
||||||
|
|
@ -239,7 +218,7 @@ signals:
|
||||||
void sigStartRubberBand(const QPointF &selectionOrigin);
|
void sigStartRubberBand(const QPointF &selectionOrigin);
|
||||||
void sigResizeRubberBand(const QPointF &cursorPoint, int selectedCount);
|
void sigResizeRubberBand(const QPointF &cursorPoint, int selectedCount);
|
||||||
void sigStopRubberBand();
|
void sigStopRubberBand();
|
||||||
void arrowDeletionRequested(int creatorId, int arrowId);
|
void requestArrowDeletion(int arrowId);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -34,6 +34,7 @@ GameView::GameView(GameScene *scene, QWidget *parent) : QGraphicsView(scene, par
|
||||||
{
|
{
|
||||||
setBackgroundBrush(QBrush(QColor(0, 0, 0)));
|
setBackgroundBrush(QBrush(QColor(0, 0, 0)));
|
||||||
setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing);
|
setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing);
|
||||||
|
setFocusPolicy(Qt::ClickFocus);
|
||||||
setViewportUpdateMode(BoundingRectViewportUpdate);
|
setViewportUpdateMode(BoundingRectViewportUpdate);
|
||||||
|
|
||||||
connect(scene, &GameScene::sceneRectChanged, this, &GameView::updateSceneRect);
|
connect(scene, &GameScene::sceneRectChanged, this, &GameView::updateSceneRect);
|
||||||
|
|
@ -43,9 +44,6 @@ GameView::GameView(GameScene *scene, QWidget *parent) : QGraphicsView(scene, par
|
||||||
connect(scene, &GameScene::sigStopRubberBand, this, &GameView::stopRubberBand);
|
connect(scene, &GameScene::sigStopRubberBand, this, &GameView::stopRubberBand);
|
||||||
connect(scene, &QGraphicsScene::selectionChanged, this, [this]() { updateTotalSelectionCount(); });
|
connect(scene, &QGraphicsScene::selectionChanged, this, [this]() { updateTotalSelectionCount(); });
|
||||||
|
|
||||||
setFocusDisabled(SettingsCache::instance().getKeepGameChatFocus());
|
|
||||||
connect(&SettingsCache::instance(), &SettingsCache::keepGameChatFocusChanged, this, &GameView::setFocusDisabled);
|
|
||||||
|
|
||||||
aCloseMostRecentZoneView = new QAction(this);
|
aCloseMostRecentZoneView = new QAction(this);
|
||||||
|
|
||||||
connect(aCloseMostRecentZoneView, &QAction::triggered, scene, &GameScene::closeMostRecentZoneView);
|
connect(aCloseMostRecentZoneView, &QAction::triggered, scene, &GameScene::closeMostRecentZoneView);
|
||||||
|
|
@ -188,12 +186,3 @@ void GameView::updateTotalSelectionCount(const QSize &viewSize)
|
||||||
totalCountLabel->hide();
|
totalCountLabel->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Disabling focus on the game view will allow chat to maintain the autofocusing behavior of pre 2.10.3,
|
|
||||||
* at the cost of disabling the zone view search bar.
|
|
||||||
*/
|
|
||||||
void GameView::setFocusDisabled(bool disabled)
|
|
||||||
{
|
|
||||||
setFocusPolicy(disabled ? Qt::NoFocus : Qt::ClickFocus);
|
|
||||||
}
|
|
||||||
|
|
@ -31,7 +31,6 @@ private slots:
|
||||||
void stopRubberBand();
|
void stopRubberBand();
|
||||||
void refreshShortcuts();
|
void refreshShortcuts();
|
||||||
void updateTotalSelectionCount(const QSize &viewSize = QSize());
|
void updateTotalSelectionCount(const QSize &viewSize = QSize());
|
||||||
void setFocusDisabled(bool disabled);
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateSceneRect(const QRectF &rect);
|
void updateSceneRect(const QRectF &rect);
|
||||||
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include "hand_counter.h"
|
#include "hand_counter.h"
|
||||||
|
|
||||||
#include "zones/card_zone.h"
|
#include "../game_graphics/zones/card_zone.h"
|
||||||
|
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
#ifndef HANDCOUNTER_H
|
#ifndef HANDCOUNTER_H
|
||||||
#define HANDCOUNTER_H
|
#define HANDCOUNTER_H
|
||||||
|
|
||||||
#include "board/abstract_graphics_item.h"
|
#include "../game_graphics/board/abstract_graphics_item.h"
|
||||||
#include "board/graphics_item_type.h"
|
#include "../game_graphics/board/graphics_item_type.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
#include "message_log_widget.h"
|
#include "message_log_widget.h"
|
||||||
|
|
||||||
#include "../../client/settings/card_counter_settings.h"
|
|
||||||
#include "../../client/sound_engine.h"
|
#include "../../client/sound_engine.h"
|
||||||
#include "../../game/phase.h"
|
|
||||||
#include "../../game/player/player_logic.h"
|
|
||||||
#include "../../interface/widgets/tabs/tab_game.h"
|
#include "../../interface/widgets/tabs/tab_game.h"
|
||||||
#include "../board/card_item.h"
|
#include "../board/card_item.h"
|
||||||
#include "../board/translate_counter_name.h"
|
#include "../board/translate_counter_name.h"
|
||||||
|
#include "../phase.h"
|
||||||
|
#include "../player/player_logic.h"
|
||||||
|
|
||||||
|
#include <../../client/settings/card_counter_settings.h>
|
||||||
#include <libcockatrice/protocol/pb/context_move_card.pb.h>
|
#include <libcockatrice/protocol/pb/context_move_card.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/context_mulligan.pb.h>
|
#include <libcockatrice/protocol/pb/context_mulligan.pb.h>
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
@ -650,16 +650,14 @@ void MessageLogWidget::logSetCardCounter(PlayerLogic *player, QString cardName,
|
||||||
QString finalStr;
|
QString finalStr;
|
||||||
int delta = abs(oldValue - value);
|
int delta = abs(oldValue - value);
|
||||||
if (value > oldValue) {
|
if (value > oldValue) {
|
||||||
finalStr = tr("%1 places %2 %3%4 counter(s) on %5 (now %6).", "", delta);
|
finalStr = tr("%1 places %2 \"%3\" counter(s) on %4 (now %5).", "", delta);
|
||||||
} else {
|
} else {
|
||||||
finalStr = tr("%1 removes %2 %3%4 counter(s) from %5 (now %6).", "", delta);
|
finalStr = tr("%1 removes %2 \"%3\" counter(s) from %4 (now %5).", "", delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &cardCounterSettings = SettingsCache::instance().cardCounters();
|
auto &cardCounterSettings = SettingsCache::instance().cardCounters();
|
||||||
QString hex = cardCounterSettings.color(counterId).name();
|
|
||||||
appendHtmlServerMessage(finalStr.arg(sanitizeHtml(player->getPlayerInfo()->getName()))
|
appendHtmlServerMessage(finalStr.arg(sanitizeHtml(player->getPlayerInfo()->getName()))
|
||||||
.arg("<font class=\"blue\">" + QString::number(delta) + "</font>")
|
.arg("<font class=\"blue\">" + QString::number(delta) + "</font>")
|
||||||
.arg("<font color=\"" + hex + "\">●</font>")
|
|
||||||
.arg(cardCounterSettings.displayName(counterId))
|
.arg(cardCounterSettings.displayName(counterId))
|
||||||
.arg(cardLink(std::move(cardName)))
|
.arg(cardLink(std::move(cardName)))
|
||||||
.arg(value));
|
.arg(value));
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
#ifndef MESSAGELOGWIDGET_H
|
#ifndef MESSAGELOGWIDGET_H
|
||||||
#define MESSAGELOGWIDGET_H
|
#define MESSAGELOGWIDGET_H
|
||||||
|
|
||||||
#include "../../game/zones/card_zone_logic.h"
|
|
||||||
#include "../../interface/widgets/server/chat_view/chat_view.h"
|
#include "../../interface/widgets/server/chat_view/chat_view.h"
|
||||||
|
#include "../zones/card_zone_logic.h"
|
||||||
|
|
||||||
class AbstractGame;
|
class AbstractGame;
|
||||||
class CardItem;
|
class CardItem;
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#ifndef PHASESTOOLBAR_H
|
#ifndef PHASESTOOLBAR_H
|
||||||
#define PHASESTOOLBAR_H
|
#define PHASESTOOLBAR_H
|
||||||
|
|
||||||
#include "board/abstract_graphics_item.h"
|
#include "../game_graphics/board/abstract_graphics_item.h"
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QGraphicsObject>
|
#include <QGraphicsObject>
|
||||||
|
|
@ -3,121 +3,92 @@
|
||||||
#include "../../../client/settings/card_counter_settings.h"
|
#include "../../../client/settings/card_counter_settings.h"
|
||||||
#include "../../../interface/widgets/tabs/tab_game.h"
|
#include "../../../interface/widgets/tabs/tab_game.h"
|
||||||
#include "../../board/card_item.h"
|
#include "../../board/card_item.h"
|
||||||
#include "../../game/player/player_actions.h"
|
#include "../../zones/view_zone_logic.h"
|
||||||
#include "../../game/player/player_logic.h"
|
|
||||||
#include "../../game/zones/view_zone_logic.h"
|
|
||||||
#include "../card_menu_action_type.h"
|
#include "../card_menu_action_type.h"
|
||||||
#include "../player_graphics_item.h"
|
#include "../player_actions.h"
|
||||||
|
#include "../player_logic.h"
|
||||||
#include "move_menu.h"
|
#include "move_menu.h"
|
||||||
#include "pt_menu.h"
|
#include "pt_menu.h"
|
||||||
|
|
||||||
#include <QPainter>
|
|
||||||
#include <libcockatrice/card/database/card_database_manager.h>
|
#include <libcockatrice/card/database/card_database_manager.h>
|
||||||
#include <libcockatrice/card/relation/card_relation.h>
|
#include <libcockatrice/card/relation/card_relation.h>
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
/**
|
CardMenu::CardMenu(PlayerLogic *_player, const CardItem *_card, bool _shortcutsActive)
|
||||||
* @brief Creates a circular icon filled with the specified color.
|
|
||||||
*/
|
|
||||||
static QIcon createCircleIcon(const QColor &color)
|
|
||||||
{
|
|
||||||
QPixmap pixmap(32, 32);
|
|
||||||
pixmap.fill(Qt::transparent);
|
|
||||||
QPainter painter(&pixmap);
|
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
|
||||||
painter.setPen(Qt::NoPen);
|
|
||||||
painter.setBrush(color);
|
|
||||||
painter.drawEllipse(pixmap.rect());
|
|
||||||
|
|
||||||
return QIcon(pixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Slot>
|
|
||||||
static QAction *makeAction(QObject *parent, Slot &&slot, bool checkable = false, bool checked = false)
|
|
||||||
{
|
|
||||||
auto *a = new QAction(parent);
|
|
||||||
a->setCheckable(checkable);
|
|
||||||
if (checkable) {
|
|
||||||
a->setChecked(checked);
|
|
||||||
}
|
|
||||||
QObject::connect(a, &QAction::triggered, parent, std::forward<Slot>(slot));
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
CardMenu::CardMenu(PlayerGraphicsItem *_player, const CardItem *_card, bool _shortcutsActive)
|
|
||||||
: player(_player), card(_card), shortcutsActive(_shortcutsActive)
|
: player(_player), card(_card), shortcutsActive(_shortcutsActive)
|
||||||
{
|
{
|
||||||
const QList<PlayerLogic *> &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
auto playerActions = player->getPlayerActions();
|
||||||
|
|
||||||
|
const QList<PlayerLogic *> &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
|
|
||||||
for (auto playerToAdd : players) {
|
for (auto playerToAdd : players) {
|
||||||
if (playerToAdd == player->getLogic()) {
|
if (playerToAdd == player) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
playersInfo.append(qMakePair(playerToAdd->getPlayerInfo()->getName(), playerToAdd->getPlayerInfo()->getId()));
|
playersInfo.append(qMakePair(playerToAdd->getPlayerInfo()->getName(), playerToAdd->getPlayerInfo()->getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(player->getLogic()->getGame()->getPlayerManager(), &PlayerManager::playerRemoved, this,
|
connect(player->getGame()->getPlayerManager(), &PlayerManager::playerRemoved, this, &CardMenu::removePlayer);
|
||||||
&CardMenu::removePlayer);
|
|
||||||
|
|
||||||
auto *actions = player->getLogic()->getPlayerActions();
|
aTap = new QAction(this);
|
||||||
auto *gameScene = player->getGameScene();
|
aTap->setData(cmTap);
|
||||||
|
connect(aTap, &QAction::triggered, playerActions, &PlayerActions::cardMenuAction);
|
||||||
// Single selection resolver used by all lambdas — called at trigger time
|
aDoesntUntap = new QAction(this);
|
||||||
auto sel = [gameScene]() { return gameScene->selectedCards(); };
|
aDoesntUntap->setData(cmDoesntUntap);
|
||||||
|
aDoesntUntap->setCheckable(true);
|
||||||
// Unified dispatcher for card menu actions
|
aDoesntUntap->setChecked(card != nullptr && card->getDoesntUntap());
|
||||||
auto invoke = [actions, sel](CardMenuActionType type) {
|
connect(aDoesntUntap, &QAction::triggered, playerActions, &PlayerActions::cardMenuAction);
|
||||||
return [actions, sel, type]() { actions->cardMenuAction(sel(), type); };
|
|
||||||
};
|
|
||||||
|
|
||||||
// Actions using invoke (type dispatch, need selection)
|
|
||||||
aTap = makeAction(this, invoke(cmTap));
|
|
||||||
aDoesntUntap = makeAction(this, invoke(cmDoesntUntap), /*checkable=*/true, card && card->getDoesntUntap());
|
|
||||||
aFlip = makeAction(this, invoke(cmFlip));
|
|
||||||
aPeek = makeAction(this, invoke(cmPeek));
|
|
||||||
aClone = makeAction(this, invoke(cmClone));
|
|
||||||
|
|
||||||
// Actions using selection directly
|
|
||||||
aUnattach = makeAction(this, [actions, sel]() { actions->actUnattach(sel()); });
|
|
||||||
aSetAnnotation = makeAction(this, [actions, sel]() { actions->actRequestSetAnnotationDialog(sel()); });
|
|
||||||
aPlay = makeAction(this, [actions, sel]() { actions->actPlay(sel()); });
|
|
||||||
aPlayFacedown = makeAction(this, [actions, sel]() { actions->actPlayFacedown(sel()); });
|
|
||||||
aHide = makeAction(this, [actions, sel]() { actions->actHide(sel()); });
|
|
||||||
aReduceLifeByPower = makeAction(this, [actions, sel]() { actions->actReduceLifeByPower(sel()); });
|
|
||||||
|
|
||||||
// Actions that use activeCard, not selection — direct connection
|
|
||||||
aAttach = new QAction(this);
|
aAttach = new QAction(this);
|
||||||
|
connect(aAttach, &QAction::triggered, playerActions, &PlayerActions::actAttach);
|
||||||
|
aUnattach = new QAction(this);
|
||||||
|
connect(aUnattach, &QAction::triggered, playerActions, &PlayerActions::actUnattach);
|
||||||
aDrawArrow = new QAction(this);
|
aDrawArrow = new QAction(this);
|
||||||
|
connect(aDrawArrow, &QAction::triggered, playerActions, &PlayerActions::actDrawArrow);
|
||||||
|
aSetAnnotation = new QAction(this);
|
||||||
|
connect(aSetAnnotation, &QAction::triggered, playerActions, &PlayerActions::actSetAnnotation);
|
||||||
|
aFlip = new QAction(this);
|
||||||
|
aFlip->setData(cmFlip);
|
||||||
|
connect(aFlip, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
|
||||||
|
aPeek = new QAction(this);
|
||||||
|
aPeek->setData(cmPeek);
|
||||||
|
connect(aPeek, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
|
||||||
|
aClone = new QAction(this);
|
||||||
|
aClone->setData(cmClone);
|
||||||
|
connect(aClone, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
|
||||||
aSelectAll = new QAction(this);
|
aSelectAll = new QAction(this);
|
||||||
|
connect(aSelectAll, &QAction::triggered, playerActions, &PlayerActions::actSelectAll);
|
||||||
aSelectRow = new QAction(this);
|
aSelectRow = new QAction(this);
|
||||||
|
connect(aSelectRow, &QAction::triggered, playerActions, &PlayerActions::actSelectRow);
|
||||||
aSelectColumn = new QAction(this);
|
aSelectColumn = new QAction(this);
|
||||||
|
connect(aSelectColumn, &QAction::triggered, playerActions, &PlayerActions::actSelectColumn);
|
||||||
|
|
||||||
connect(aAttach, &QAction::triggered, actions, &PlayerActions::actAttach);
|
aReduceLifeByPower = new QAction(this);
|
||||||
connect(aDrawArrow, &QAction::triggered, actions, &PlayerActions::actDrawArrow);
|
connect(aReduceLifeByPower, &QAction::triggered, playerActions, &PlayerActions::actReduceLifeByPower);
|
||||||
connect(aSelectAll, &QAction::triggered, actions, &PlayerActions::actSelectAll);
|
|
||||||
connect(aSelectRow, &QAction::triggered, actions, &PlayerActions::actSelectRow);
|
aPlay = new QAction(this);
|
||||||
connect(aSelectColumn, &QAction::triggered, actions, &PlayerActions::actSelectColumn);
|
connect(aPlay, &QAction::triggered, playerActions, &PlayerActions::actPlay);
|
||||||
|
aHide = new QAction(this);
|
||||||
|
connect(aHide, &QAction::triggered, playerActions, &PlayerActions::actHide);
|
||||||
|
aPlayFacedown = new QAction(this);
|
||||||
|
connect(aPlayFacedown, &QAction::triggered, playerActions, &PlayerActions::actPlayFacedown);
|
||||||
|
|
||||||
aRevealToAll = new QAction(this);
|
aRevealToAll = new QAction(this);
|
||||||
|
|
||||||
mCardCounters = new QMenu;
|
mCardCounters = new QMenu;
|
||||||
|
|
||||||
// Card counters
|
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
QColor color = SettingsCache::instance().cardCounters().color(i);
|
auto *tempAddCounter = new QAction(this);
|
||||||
QIcon circleIcon = createCircleIcon(color);
|
auto *tempRemoveCounter = new QAction(this);
|
||||||
|
auto *tempSetCounter = new QAction(this);
|
||||||
auto *addAction = makeAction(this, [actions, sel, i]() { actions->actAddCardCounter(sel(), i); });
|
aAddCounter.append(tempAddCounter);
|
||||||
addAction->setIcon(circleIcon);
|
aRemoveCounter.append(tempRemoveCounter);
|
||||||
aAddCounter.append(addAction);
|
aSetCounter.append(tempSetCounter);
|
||||||
|
connect(tempAddCounter, &QAction::triggered, playerActions,
|
||||||
auto *removeAction = makeAction(this, [actions, sel, i]() { actions->actRemoveCardCounter(sel(), i); });
|
[playerActions, i] { playerActions->actAddCardCounter(i); });
|
||||||
removeAction->setIcon(circleIcon);
|
connect(tempRemoveCounter, &QAction::triggered, playerActions,
|
||||||
aRemoveCounter.append(removeAction);
|
[playerActions, i] { playerActions->actRemoveCardCounter(i); });
|
||||||
|
connect(tempSetCounter, &QAction::triggered, playerActions,
|
||||||
auto *setAction = makeAction(this, [actions, sel, i]() { actions->actRequestSetCardCounterDialog(sel(), i); });
|
[playerActions, i] { playerActions->actSetCardCounter(i); });
|
||||||
setAction->setIcon(circleIcon);
|
|
||||||
aSetCounter.append(setAction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setShortcutsActive();
|
setShortcutsActive();
|
||||||
|
|
@ -129,7 +100,7 @@ CardMenu::CardMenu(PlayerGraphicsItem *_player, const CardItem *_card, bool _sho
|
||||||
}
|
}
|
||||||
|
|
||||||
bool revealedCard = false;
|
bool revealedCard = false;
|
||||||
bool writeableCard = player->getLogic()->getPlayerInfo()->getLocalOrJudge();
|
bool writeableCard = player->getPlayerInfo()->getLocalOrJudge();
|
||||||
if (auto *view = qobject_cast<ZoneViewZoneLogic *>(card->getZone())) {
|
if (auto *view = qobject_cast<ZoneViewZoneLogic *>(card->getZone())) {
|
||||||
if (view->getRevealZone()) {
|
if (view->getRevealZone()) {
|
||||||
if (view->getWriteableRevealZone()) {
|
if (view->getWriteableRevealZone()) {
|
||||||
|
|
@ -313,9 +284,7 @@ void CardMenu::createHandOrCustomZoneMenu(bool canModifyCard)
|
||||||
|
|
||||||
initContextualPlayersMenu(revealMenu, aRevealToAll);
|
initContextualPlayersMenu(revealMenu, aRevealToAll);
|
||||||
|
|
||||||
connect(revealMenu, &QMenu::triggered, this, [this](QAction *action) {
|
connect(revealMenu, &QMenu::triggered, player->getPlayerActions(), &PlayerActions::actReveal);
|
||||||
player->getLogic()->getPlayerActions()->actReveal(player->getGameScene()->selectedCards(), action);
|
|
||||||
});
|
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
addAction(aClone);
|
addAction(aClone);
|
||||||
|
|
@ -400,7 +369,8 @@ void CardMenu::addRelatedCardView()
|
||||||
QAction *viewCard = viewRelatedCards->addAction(relatedCardName);
|
QAction *viewCard = viewRelatedCards->addAction(relatedCardName);
|
||||||
Q_UNUSED(viewCard);
|
Q_UNUSED(viewCard);
|
||||||
|
|
||||||
connect(viewCard, &QAction::triggered, this, [this, cardRef] { emit cardInfoRequested(cardRef); });
|
connect(viewCard, &QAction::triggered, player->getGame(),
|
||||||
|
[this, cardRef] { player->getGame()->getTab()->viewCardInfo(cardRef); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -462,8 +432,7 @@ void CardMenu::addRelatedCardActions()
|
||||||
|
|
||||||
auto *createRelated = new QAction(text, this);
|
auto *createRelated = new QAction(text, this);
|
||||||
createRelated->setData(QVariant(index++));
|
createRelated->setData(QVariant(index++));
|
||||||
connect(createRelated, &QAction::triggered, player->getLogic()->getPlayerActions(),
|
connect(createRelated, &QAction::triggered, player->getPlayerActions(), &PlayerActions::actCreateRelatedCard);
|
||||||
&PlayerActions::actCreateRelatedCard);
|
|
||||||
addAction(createRelated);
|
addAction(createRelated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -472,7 +441,7 @@ void CardMenu::addRelatedCardActions()
|
||||||
createRelatedCards->setShortcuts(
|
createRelatedCards->setShortcuts(
|
||||||
SettingsCache::instance().shortcuts().getShortcut("Player/aCreateRelatedTokens"));
|
SettingsCache::instance().shortcuts().getShortcut("Player/aCreateRelatedTokens"));
|
||||||
}
|
}
|
||||||
connect(createRelatedCards, &QAction::triggered, player->getLogic()->getPlayerActions(),
|
connect(createRelatedCards, &QAction::triggered, player->getPlayerActions(),
|
||||||
&PlayerActions::actCreateAllRelatedCards);
|
&PlayerActions::actCreateAllRelatedCards);
|
||||||
addAction(createRelatedCards);
|
addAction(createRelatedCards);
|
||||||
}
|
}
|
||||||
|
|
@ -8,20 +8,15 @@
|
||||||
#define COCKATRICE_CARD_MENU_H
|
#define COCKATRICE_CARD_MENU_H
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <libcockatrice/utility/card_ref.h>
|
|
||||||
|
|
||||||
class CardItem;
|
class CardItem;
|
||||||
class PlayerGraphicsItem;
|
|
||||||
class PlayerLogic;
|
class PlayerLogic;
|
||||||
class CardMenu : public QMenu
|
class CardMenu : public QMenu
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
signals:
|
|
||||||
void cardInfoRequested(const CardRef &cardRef);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CardMenu(PlayerGraphicsItem *player, const CardItem *card, bool shortcutsActive);
|
explicit CardMenu(PlayerLogic *player, const CardItem *card, bool shortcutsActive);
|
||||||
void removePlayer(PlayerLogic *playerToRemove);
|
void removePlayer(PlayerLogic *playerToRemove);
|
||||||
void createTableMenu(bool canModifyCard);
|
void createTableMenu(bool canModifyCard);
|
||||||
void createStackMenu(bool canModifyCard);
|
void createStackMenu(bool canModifyCard);
|
||||||
|
|
@ -46,7 +41,7 @@ public:
|
||||||
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
|
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerGraphicsItem *player;
|
PlayerLogic *player;
|
||||||
const CardItem *card;
|
const CardItem *card;
|
||||||
QList<QPair<QString, int>> playersInfo;
|
QList<QPair<QString, int>> playersInfo;
|
||||||
bool shortcutsActive;
|
bool shortcutsActive;
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
#include "custom_zone_menu.h"
|
#include "custom_zone_menu.h"
|
||||||
|
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../player_logic.h"
|
||||||
#include "../player_graphics_item.h"
|
|
||||||
|
|
||||||
CustomZoneMenu::CustomZoneMenu(PlayerGraphicsItem *_player) : player(_player)
|
CustomZoneMenu::CustomZoneMenu(PlayerLogic *_player) : player(_player)
|
||||||
{
|
{
|
||||||
menuAction()->setVisible(false);
|
menuAction()->setVisible(false);
|
||||||
|
|
||||||
connect(player->getLogic(), &PlayerLogic::clearCustomZonesMenu, this, &CustomZoneMenu::clearCustomZonesMenu);
|
connect(player, &PlayerLogic::clearCustomZonesMenu, this, &CustomZoneMenu::clearCustomZonesMenu);
|
||||||
connect(player->getLogic(), &PlayerLogic::addViewCustomZoneActionToCustomZoneMenu, this,
|
connect(player, &PlayerLogic::addViewCustomZoneActionToCustomZoneMenu, this,
|
||||||
&CustomZoneMenu::addViewCustomZoneActionToCustomZoneMenu);
|
&CustomZoneMenu::addViewCustomZoneActionToCustomZoneMenu);
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
|
|
@ -18,7 +17,7 @@ void CustomZoneMenu::retranslateUi()
|
||||||
{
|
{
|
||||||
setTitle(tr("C&ustom Zones"));
|
setTitle(tr("C&ustom Zones"));
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
|
|
||||||
for (auto aViewZone : actions()) {
|
for (auto aViewZone : actions()) {
|
||||||
aViewZone->setText(tr("View custom zone '%1'").arg(aViewZone->data().toString()));
|
aViewZone->setText(tr("View custom zone '%1'").arg(aViewZone->data().toString()));
|
||||||
|
|
@ -38,5 +37,5 @@ void CustomZoneMenu::addViewCustomZoneActionToCustomZoneMenu(QString zoneName)
|
||||||
QAction *aViewZone = addAction(tr("View custom zone '%1'").arg(zoneName));
|
QAction *aViewZone = addAction(tr("View custom zone '%1'").arg(zoneName));
|
||||||
aViewZone->setData(zoneName);
|
aViewZone->setData(zoneName);
|
||||||
connect(aViewZone, &QAction::triggered, this,
|
connect(aViewZone, &QAction::triggered, this,
|
||||||
[zoneName, this]() { player->getGameScene()->toggleZoneView(player->getLogic(), zoneName, -1); });
|
[zoneName, this]() { player->getGameScene()->toggleZoneView(player, zoneName, -1); });
|
||||||
}
|
}
|
||||||
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerGraphicsItem;
|
class PlayerLogic;
|
||||||
class CustomZoneMenu : public QMenu, public AbstractPlayerComponent
|
class CustomZoneMenu : public QMenu, public AbstractPlayerComponent
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CustomZoneMenu(PlayerGraphicsItem *player);
|
explicit CustomZoneMenu(PlayerLogic *player);
|
||||||
void retranslateUi() override;
|
void retranslateUi() override;
|
||||||
void setShortcutsActive() override
|
void setShortcutsActive() override
|
||||||
{
|
{
|
||||||
|
|
@ -26,7 +26,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerGraphicsItem *player;
|
PlayerLogic *player;
|
||||||
private slots:
|
private slots:
|
||||||
void clearCustomZonesMenu();
|
void clearCustomZonesMenu();
|
||||||
void addViewCustomZoneActionToCustomZoneMenu(QString zoneName);
|
void addViewCustomZoneActionToCustomZoneMenu(QString zoneName);
|
||||||
|
|
@ -1,22 +1,21 @@
|
||||||
#include "grave_menu.h"
|
#include "grave_menu.h"
|
||||||
|
|
||||||
#include "../../game/abstract_game.h"
|
#include "../../abstract_game.h"
|
||||||
#include "../../game/player/player_actions.h"
|
#include "../player_actions.h"
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../player_logic.h"
|
||||||
#include "../player_graphics_item.h"
|
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
GraveyardMenu::GraveyardMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
GraveyardMenu::GraveyardMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||||
{
|
{
|
||||||
createMoveActions();
|
createMoveActions();
|
||||||
createViewActions();
|
createViewActions();
|
||||||
|
|
||||||
addAction(aViewGraveyard);
|
addAction(aViewGraveyard);
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
||||||
mRevealRandomGraveyardCard = addMenu(QString());
|
mRevealRandomGraveyardCard = addMenu(QString());
|
||||||
connect(mRevealRandomGraveyardCard, &QMenu::aboutToShow, this,
|
connect(mRevealRandomGraveyardCard, &QMenu::aboutToShow, this,
|
||||||
&GraveyardMenu::populateRevealRandomMenuWithActivePlayers);
|
&GraveyardMenu::populateRevealRandomMenuWithActivePlayers);
|
||||||
|
|
@ -37,9 +36,9 @@ GraveyardMenu::GraveyardMenu(PlayerGraphicsItem *_player, QWidget *parent) : Tea
|
||||||
|
|
||||||
void GraveyardMenu::createMoveActions()
|
void GraveyardMenu::createMoveActions()
|
||||||
{
|
{
|
||||||
auto grave = player->getLogic()->getGraveZone();
|
auto grave = player->getGraveZone();
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
||||||
aMoveGraveToTopLibrary = new QAction(this);
|
aMoveGraveToTopLibrary = new QAction(this);
|
||||||
aMoveGraveToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
aMoveGraveToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
||||||
|
|
||||||
|
|
@ -61,7 +60,7 @@ void GraveyardMenu::createMoveActions()
|
||||||
|
|
||||||
void GraveyardMenu::createViewActions()
|
void GraveyardMenu::createViewActions()
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
PlayerActions *playerActions = player->getPlayerActions();
|
||||||
|
|
||||||
aViewGraveyard = new QAction(this);
|
aViewGraveyard = new QAction(this);
|
||||||
connect(aViewGraveyard, &QAction::triggered, playerActions, &PlayerActions::actViewGraveyard);
|
connect(aViewGraveyard, &QAction::triggered, playerActions, &PlayerActions::actViewGraveyard);
|
||||||
|
|
@ -77,9 +76,9 @@ void GraveyardMenu::populateRevealRandomMenuWithActivePlayers()
|
||||||
|
|
||||||
mRevealRandomGraveyardCard->addSeparator();
|
mRevealRandomGraveyardCard->addSeparator();
|
||||||
|
|
||||||
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
for (auto *other : players) {
|
for (auto *other : players) {
|
||||||
if (other == player->getLogic()) {
|
if (other == player) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QAction *a = mRevealRandomGraveyardCard->addAction(other->getPlayerInfo()->getName());
|
QAction *a = mRevealRandomGraveyardCard->addAction(other->getPlayerInfo()->getName());
|
||||||
|
|
@ -91,7 +90,7 @@ void GraveyardMenu::populateRevealRandomMenuWithActivePlayers()
|
||||||
void GraveyardMenu::onRevealRandomTriggered()
|
void GraveyardMenu::onRevealRandomTriggered()
|
||||||
{
|
{
|
||||||
if (auto *a = qobject_cast<QAction *>(sender())) {
|
if (auto *a = qobject_cast<QAction *>(sender())) {
|
||||||
player->getLogic()->getPlayerActions()->actRevealRandomGraveyardCard(a->data().toInt());
|
player->getPlayerActions()->actRevealRandomGraveyardCard(a->data().toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,7 +100,7 @@ void GraveyardMenu::retranslateUi()
|
||||||
|
|
||||||
aViewGraveyard->setText(tr("&View graveyard"));
|
aViewGraveyard->setText(tr("&View graveyard"));
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
moveGraveMenu->setTitle(tr("&Move graveyard to..."));
|
moveGraveMenu->setTitle(tr("&Move graveyard to..."));
|
||||||
aMoveGraveToTopLibrary->setText(tr("&Top of library"));
|
aMoveGraveToTopLibrary->setText(tr("&Top of library"));
|
||||||
aMoveGraveToBottomLibrary->setText(tr("&Bottom of library"));
|
aMoveGraveToBottomLibrary->setText(tr("&Bottom of library"));
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerGraphicsItem;
|
class PlayerLogic;
|
||||||
class GraveyardMenu : public TearOffMenu, public AbstractPlayerComponent
|
class GraveyardMenu : public TearOffMenu, public AbstractPlayerComponent
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -21,7 +21,7 @@ signals:
|
||||||
void newPlayerActionCreated(QAction *action);
|
void newPlayerActionCreated(QAction *action);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GraveyardMenu(PlayerGraphicsItem *player, QWidget *parent = nullptr);
|
explicit GraveyardMenu(PlayerLogic *player, QWidget *parent = nullptr);
|
||||||
void createMoveActions();
|
void createMoveActions();
|
||||||
void createViewActions();
|
void createViewActions();
|
||||||
void populateRevealRandomMenuWithActivePlayers();
|
void populateRevealRandomMenuWithActivePlayers();
|
||||||
|
|
@ -40,7 +40,7 @@ public:
|
||||||
QAction *aMoveGraveToRfg = nullptr;
|
QAction *aMoveGraveToRfg = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerGraphicsItem *player;
|
PlayerLogic *player;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCKATRICE_GRAVE_MENU_H
|
#endif // COCKATRICE_GRAVE_MENU_H
|
||||||
|
|
@ -3,22 +3,18 @@
|
||||||
#include "../../../client/settings/cache_settings.h"
|
#include "../../../client/settings/cache_settings.h"
|
||||||
#include "../../../client/settings/shortcuts_settings.h"
|
#include "../../../client/settings/shortcuts_settings.h"
|
||||||
#include "../../../game_graphics/zones/hand_zone.h"
|
#include "../../../game_graphics/zones/hand_zone.h"
|
||||||
#include "../../game/abstract_game.h"
|
#include "../../abstract_game.h"
|
||||||
#include "../../game/player/player_actions.h"
|
#include "../player_actions.h"
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../player_logic.h"
|
||||||
#include "../player_graphics_item.h"
|
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
HandMenu::HandMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
HandMenu::HandMenu(PlayerLogic *_player, PlayerActions *actions, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||||
{
|
{
|
||||||
auto *actions = player->getLogic()->getPlayerActions();
|
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
|
||||||
aViewHand = new QAction(this);
|
aViewHand = new QAction(this);
|
||||||
|
|
||||||
connect(aViewHand, &QAction::triggered, actions, &PlayerActions::actViewHand);
|
connect(aViewHand, &QAction::triggered, actions, &PlayerActions::actViewHand);
|
||||||
addAction(aViewHand);
|
addAction(aViewHand);
|
||||||
|
|
||||||
|
|
@ -62,7 +58,7 @@ HandMenu::HandMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(p
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
|
||||||
aMulligan = new QAction(this);
|
aMulligan = new QAction(this);
|
||||||
connect(aMulligan, &QAction::triggered, actions, &PlayerActions::actRequestMulliganDialog);
|
connect(aMulligan, &QAction::triggered, actions, &PlayerActions::actMulligan);
|
||||||
addAction(aMulligan);
|
addAction(aMulligan);
|
||||||
|
|
||||||
// Mulligan same size
|
// Mulligan same size
|
||||||
|
|
@ -79,7 +75,7 @@ HandMenu::HandMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(p
|
||||||
|
|
||||||
mMoveHandMenu = addTearOffMenu(QString());
|
mMoveHandMenu = addTearOffMenu(QString());
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
||||||
aMoveHandToTopLibrary = new QAction(this);
|
aMoveHandToTopLibrary = new QAction(this);
|
||||||
aMoveHandToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
aMoveHandToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
||||||
aMoveHandToBottomLibrary = new QAction(this);
|
aMoveHandToBottomLibrary = new QAction(this);
|
||||||
|
|
@ -89,7 +85,7 @@ HandMenu::HandMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(p
|
||||||
aMoveHandToRfg = new QAction(this);
|
aMoveHandToRfg = new QAction(this);
|
||||||
aMoveHandToRfg->setData(QList<QVariant>() << ZoneNames::EXILE << 0);
|
aMoveHandToRfg->setData(QList<QVariant>() << ZoneNames::EXILE << 0);
|
||||||
|
|
||||||
auto hand = player->getLogic()->getHandZone();
|
auto hand = player->getHandZone();
|
||||||
|
|
||||||
connect(aMoveHandToTopLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
|
connect(aMoveHandToTopLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
|
||||||
connect(aMoveHandToBottomLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
|
connect(aMoveHandToBottomLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
|
||||||
|
|
@ -111,7 +107,7 @@ void HandMenu::retranslateUi()
|
||||||
{
|
{
|
||||||
setTitle(tr("&Hand"));
|
setTitle(tr("&Hand"));
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
aViewHand->setText(tr("&View hand"));
|
aViewHand->setText(tr("&View hand"));
|
||||||
|
|
||||||
mSortHand->setTitle(tr("Sort hand by..."));
|
mSortHand->setTitle(tr("Sort hand by..."));
|
||||||
|
|
@ -170,9 +166,9 @@ void HandMenu::populateRevealHandMenuWithActivePlayers()
|
||||||
|
|
||||||
mRevealHand->addSeparator();
|
mRevealHand->addSeparator();
|
||||||
|
|
||||||
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
for (auto *other : players) {
|
for (auto *other : players) {
|
||||||
if (other == player->getLogic()) {
|
if (other == player) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QAction *a = mRevealHand->addAction(other->getPlayerInfo()->getName());
|
QAction *a = mRevealHand->addAction(other->getPlayerInfo()->getName());
|
||||||
|
|
@ -189,9 +185,9 @@ void HandMenu::populateRevealRandomHandCardMenuWithActivePlayers()
|
||||||
|
|
||||||
mRevealRandomHandCard->addSeparator();
|
mRevealRandomHandCard->addSeparator();
|
||||||
|
|
||||||
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
for (auto *other : players) {
|
for (auto *other : players) {
|
||||||
if (other == player->getLogic()) {
|
if (other == player) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QAction *a = mRevealRandomHandCard->addAction(other->getPlayerInfo()->getName());
|
QAction *a = mRevealRandomHandCard->addAction(other->getPlayerInfo()->getName());
|
||||||
|
|
@ -208,7 +204,7 @@ void HandMenu::onRevealHandTriggered()
|
||||||
}
|
}
|
||||||
|
|
||||||
const int targetId = action->data().toInt();
|
const int targetId = action->data().toInt();
|
||||||
player->getLogic()->getPlayerActions()->actRevealHand(targetId);
|
player->getPlayerActions()->actRevealHand(targetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandMenu::onRevealRandomHandCardTriggered()
|
void HandMenu::onRevealRandomHandCardTriggered()
|
||||||
|
|
@ -219,5 +215,5 @@ void HandMenu::onRevealRandomHandCardTriggered()
|
||||||
}
|
}
|
||||||
|
|
||||||
const int targetId = action->data().toInt();
|
const int targetId = action->data().toInt();
|
||||||
player->getLogic()->getPlayerActions()->actRevealRandomHandCard(targetId);
|
player->getPlayerActions()->actRevealRandomHandCard(targetId);
|
||||||
}
|
}
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerGraphicsItem;
|
class PlayerLogic;
|
||||||
class PlayerActions;
|
class PlayerActions;
|
||||||
|
|
||||||
class HandMenu : public TearOffMenu, public AbstractPlayerComponent
|
class HandMenu : public TearOffMenu, public AbstractPlayerComponent
|
||||||
|
|
@ -21,7 +21,7 @@ class HandMenu : public TearOffMenu, public AbstractPlayerComponent
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HandMenu(PlayerGraphicsItem *player, QWidget *parent = nullptr);
|
HandMenu(PlayerLogic *player, PlayerActions *actions, QWidget *parent = nullptr);
|
||||||
|
|
||||||
QMenu *revealHandMenu() const
|
QMenu *revealHandMenu() const
|
||||||
{
|
{
|
||||||
|
|
@ -43,7 +43,7 @@ private slots:
|
||||||
void onRevealRandomHandCardTriggered();
|
void onRevealRandomHandCardTriggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerGraphicsItem *player;
|
PlayerLogic *player;
|
||||||
|
|
||||||
QAction *aViewHand = nullptr;
|
QAction *aViewHand = nullptr;
|
||||||
QAction *aMulligan = nullptr;
|
QAction *aMulligan = nullptr;
|
||||||
|
|
@ -3,16 +3,14 @@
|
||||||
#include "../../../client/settings/cache_settings.h"
|
#include "../../../client/settings/cache_settings.h"
|
||||||
#include "../../../client/settings/shortcuts_settings.h"
|
#include "../../../client/settings/shortcuts_settings.h"
|
||||||
#include "../../../interface/widgets/tabs/tab_game.h"
|
#include "../../../interface/widgets/tabs/tab_game.h"
|
||||||
#include "../../game/abstract_game.h"
|
#include "../../abstract_game.h"
|
||||||
#include "../../game/player/player_actions.h"
|
#include "../player_actions.h"
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../player_logic.h"
|
||||||
#include "../player_graphics_item.h"
|
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QGraphicsView>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
LibraryMenu::LibraryMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
LibraryMenu::LibraryMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||||
{
|
{
|
||||||
createDrawActions();
|
createDrawActions();
|
||||||
createShuffleActions();
|
createShuffleActions();
|
||||||
|
|
@ -77,8 +75,8 @@ LibraryMenu::LibraryMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOff
|
||||||
bottomLibraryMenu->addSeparator();
|
bottomLibraryMenu->addSeparator();
|
||||||
bottomLibraryMenu->addAction(aShuffleBottomCards);
|
bottomLibraryMenu->addAction(aShuffleBottomCards);
|
||||||
|
|
||||||
connect(player->getLogic(), &PlayerLogic::resetTopCardMenuActions, this, &LibraryMenu::resetTopCardMenuActions);
|
connect(player, &PlayerLogic::resetTopCardMenuActions, this, &LibraryMenu::resetTopCardMenuActions);
|
||||||
connect(player->getLogic(), &PlayerLogic::deckChanged, this, &LibraryMenu::enableOpenInDeckEditorAction);
|
connect(player, &PlayerLogic::deckChanged, this, &LibraryMenu::enableOpenInDeckEditorAction);
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
@ -96,41 +94,41 @@ void LibraryMenu::resetTopCardMenuActions()
|
||||||
|
|
||||||
void LibraryMenu::createDrawActions()
|
void LibraryMenu::createDrawActions()
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
PlayerActions *playerActions = player->getPlayerActions();
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
||||||
aDrawCard = new QAction(this);
|
aDrawCard = new QAction(this);
|
||||||
connect(aDrawCard, &QAction::triggered, playerActions, &PlayerActions::actDrawCard);
|
connect(aDrawCard, &QAction::triggered, playerActions, &PlayerActions::actDrawCard);
|
||||||
aDrawCards = new QAction(this);
|
aDrawCards = new QAction(this);
|
||||||
connect(aDrawCards, &QAction::triggered, playerActions, &PlayerActions::actRequestDrawCardsDialog);
|
connect(aDrawCards, &QAction::triggered, playerActions, &PlayerActions::actDrawCards);
|
||||||
aUndoDraw = new QAction(this);
|
aUndoDraw = new QAction(this);
|
||||||
connect(aUndoDraw, &QAction::triggered, playerActions, &PlayerActions::actUndoDraw);
|
connect(aUndoDraw, &QAction::triggered, playerActions, &PlayerActions::actUndoDraw);
|
||||||
aDrawBottomCard = new QAction(this);
|
aDrawBottomCard = new QAction(this);
|
||||||
connect(aDrawBottomCard, &QAction::triggered, playerActions, &PlayerActions::actDrawBottomCard);
|
connect(aDrawBottomCard, &QAction::triggered, playerActions, &PlayerActions::actDrawBottomCard);
|
||||||
aDrawBottomCards = new QAction(this);
|
aDrawBottomCards = new QAction(this);
|
||||||
connect(aDrawBottomCards, &QAction::triggered, playerActions, &PlayerActions::actRequestDrawBottomCardsDialog);
|
connect(aDrawBottomCards, &QAction::triggered, playerActions, &PlayerActions::actDrawBottomCards);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryMenu::createShuffleActions()
|
void LibraryMenu::createShuffleActions()
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
PlayerActions *playerActions = player->getPlayerActions();
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
||||||
aShuffle = new QAction(this);
|
aShuffle = new QAction(this);
|
||||||
connect(aShuffle, &QAction::triggered, playerActions, &PlayerActions::actShuffle);
|
connect(aShuffle, &QAction::triggered, playerActions, &PlayerActions::actShuffle);
|
||||||
aShuffleTopCards = new QAction(this);
|
aShuffleTopCards = new QAction(this);
|
||||||
connect(aShuffleTopCards, &QAction::triggered, playerActions, &PlayerActions::actRequestShuffleTopDialog);
|
connect(aShuffleTopCards, &QAction::triggered, playerActions, &PlayerActions::actShuffleTop);
|
||||||
aShuffleBottomCards = new QAction(this);
|
aShuffleBottomCards = new QAction(this);
|
||||||
connect(aShuffleBottomCards, &QAction::triggered, playerActions, &PlayerActions::actRequestShuffleBottomDialog);
|
connect(aShuffleBottomCards, &QAction::triggered, playerActions, &PlayerActions::actShuffleBottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryMenu::createMoveActions()
|
void LibraryMenu::createMoveActions()
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
PlayerActions *playerActions = player->getPlayerActions();
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
||||||
aMoveTopToPlay = new QAction(this);
|
aMoveTopToPlay = new QAction(this);
|
||||||
connect(aMoveTopToPlay, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToPlay);
|
connect(aMoveTopToPlay, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToPlay);
|
||||||
aMoveTopToPlayFaceDown = new QAction(this);
|
aMoveTopToPlayFaceDown = new QAction(this);
|
||||||
|
|
@ -151,8 +149,7 @@ void LibraryMenu::createMoveActions()
|
||||||
connect(aMoveTopCardsToExileFaceDown, &QAction::triggered, playerActions,
|
connect(aMoveTopCardsToExileFaceDown, &QAction::triggered, playerActions,
|
||||||
&PlayerActions::actMoveTopCardsToExileFaceDown);
|
&PlayerActions::actMoveTopCardsToExileFaceDown);
|
||||||
aMoveTopCardsUntil = new QAction(this);
|
aMoveTopCardsUntil = new QAction(this);
|
||||||
connect(aMoveTopCardsUntil, &QAction::triggered, playerActions,
|
connect(aMoveTopCardsUntil, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardsUntil);
|
||||||
&PlayerActions::actRequestMoveTopCardsUntilDialog);
|
|
||||||
aMoveTopCardToBottom = new QAction(this);
|
aMoveTopCardToBottom = new QAction(this);
|
||||||
connect(aMoveTopCardToBottom, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToBottom);
|
connect(aMoveTopCardToBottom, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToBottom);
|
||||||
|
|
||||||
|
|
@ -184,16 +181,16 @@ void LibraryMenu::createMoveActions()
|
||||||
|
|
||||||
void LibraryMenu::createViewActions()
|
void LibraryMenu::createViewActions()
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
PlayerActions *playerActions = player->getPlayerActions();
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
|
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
||||||
aViewLibrary = new QAction(this);
|
aViewLibrary = new QAction(this);
|
||||||
connect(aViewLibrary, &QAction::triggered, playerActions, &PlayerActions::actViewLibrary);
|
connect(aViewLibrary, &QAction::triggered, playerActions, &PlayerActions::actViewLibrary);
|
||||||
|
|
||||||
aViewTopCards = new QAction(this);
|
aViewTopCards = new QAction(this);
|
||||||
connect(aViewTopCards, &QAction::triggered, playerActions, &PlayerActions::actRequestViewTopCardsDialog);
|
connect(aViewTopCards, &QAction::triggered, playerActions, &PlayerActions::actViewTopCards);
|
||||||
aViewBottomCards = new QAction(this);
|
aViewBottomCards = new QAction(this);
|
||||||
connect(aViewBottomCards, &QAction::triggered, playerActions, &PlayerActions::actRequestViewBottomCardsDialog);
|
connect(aViewBottomCards, &QAction::triggered, playerActions, &PlayerActions::actViewBottomCards);
|
||||||
aAlwaysRevealTopCard = new QAction(this);
|
aAlwaysRevealTopCard = new QAction(this);
|
||||||
aAlwaysRevealTopCard->setCheckable(true);
|
aAlwaysRevealTopCard->setCheckable(true);
|
||||||
connect(aAlwaysRevealTopCard, &QAction::triggered, playerActions, &PlayerActions::actAlwaysRevealTopCard);
|
connect(aAlwaysRevealTopCard, &QAction::triggered, playerActions, &PlayerActions::actAlwaysRevealTopCard);
|
||||||
|
|
@ -210,7 +207,7 @@ void LibraryMenu::retranslateUi()
|
||||||
{
|
{
|
||||||
setTitle(tr("&Library"));
|
setTitle(tr("&Library"));
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
aViewLibrary->setText(tr("&View library"));
|
aViewLibrary->setText(tr("&View library"));
|
||||||
aViewTopCards->setText(tr("View &top cards of library..."));
|
aViewTopCards->setText(tr("View &top cards of library..."));
|
||||||
aViewBottomCards->setText(tr("View bottom cards of library..."));
|
aViewBottomCards->setText(tr("View bottom cards of library..."));
|
||||||
|
|
@ -266,9 +263,9 @@ void LibraryMenu::populateRevealLibraryMenuWithActivePlayers()
|
||||||
|
|
||||||
mRevealLibrary->addSeparator();
|
mRevealLibrary->addSeparator();
|
||||||
|
|
||||||
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
for (auto *other : players) {
|
for (auto *other : players) {
|
||||||
if (other == player->getLogic()) {
|
if (other == player) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QAction *a = mRevealLibrary->addAction(other->getPlayerInfo()->getName());
|
QAction *a = mRevealLibrary->addAction(other->getPlayerInfo()->getName());
|
||||||
|
|
@ -281,9 +278,9 @@ void LibraryMenu::populateLendLibraryMenuWithActivePlayers()
|
||||||
{
|
{
|
||||||
mLendLibrary->clear();
|
mLendLibrary->clear();
|
||||||
|
|
||||||
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
for (auto *other : players) {
|
for (auto *other : players) {
|
||||||
if (other == player->getLogic()) {
|
if (other == player) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QAction *a = mLendLibrary->addAction(other->getPlayerInfo()->getName());
|
QAction *a = mLendLibrary->addAction(other->getPlayerInfo()->getName());
|
||||||
|
|
@ -302,9 +299,9 @@ void LibraryMenu::populateRevealTopCardMenuWithActivePlayers()
|
||||||
|
|
||||||
mRevealTopCard->addSeparator();
|
mRevealTopCard->addSeparator();
|
||||||
|
|
||||||
const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
|
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
||||||
for (auto *other : players) {
|
for (auto *other : players) {
|
||||||
if (other == player->getLogic()) {
|
if (other == player) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QAction *a = mRevealTopCard->addAction(other->getPlayerInfo()->getName());
|
QAction *a = mRevealTopCard->addAction(other->getPlayerInfo()->getName());
|
||||||
|
|
@ -316,33 +313,27 @@ void LibraryMenu::populateRevealTopCardMenuWithActivePlayers()
|
||||||
void LibraryMenu::onRevealLibraryTriggered()
|
void LibraryMenu::onRevealLibraryTriggered()
|
||||||
{
|
{
|
||||||
if (auto *a = qobject_cast<QAction *>(sender())) {
|
if (auto *a = qobject_cast<QAction *>(sender())) {
|
||||||
player->getLogic()->getPlayerActions()->actRevealLibrary(a->data().toInt());
|
player->getPlayerActions()->actRevealLibrary(a->data().toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryMenu::onLendLibraryTriggered()
|
void LibraryMenu::onLendLibraryTriggered()
|
||||||
{
|
{
|
||||||
if (auto *a = qobject_cast<QAction *>(sender())) {
|
if (auto *a = qobject_cast<QAction *>(sender())) {
|
||||||
player->getLogic()->getPlayerActions()->actLendLibrary(a->data().toInt());
|
player->getPlayerActions()->actLendLibrary(a->data().toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryMenu::onRevealTopCardTriggered()
|
void LibraryMenu::onRevealTopCardTriggered()
|
||||||
{
|
{
|
||||||
QWidget *parent = nullptr;
|
|
||||||
if (auto *view = player->scene() ? player->scene()->views().value(0) : nullptr) {
|
|
||||||
parent = view->window();
|
|
||||||
}
|
|
||||||
if (auto *a = qobject_cast<QAction *>(sender())) {
|
if (auto *a = qobject_cast<QAction *>(sender())) {
|
||||||
|
int deckSize = player->getDeckZone()->getCards().size();
|
||||||
int deckSize = player->getLogic()->getDeckZone()->getCards().size();
|
bool ok;
|
||||||
bool ok = true;
|
int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Reveal top cards of library"),
|
||||||
int number = QInputDialog::getInt(parent, tr("Reveal top cards of library"),
|
|
||||||
tr("Number of cards: (max. %1)").arg(deckSize), defaultNumberTopCards, 1,
|
tr("Number of cards: (max. %1)").arg(deckSize), defaultNumberTopCards, 1,
|
||||||
deckSize, 1, &ok);
|
deckSize, 1, &ok);
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
player->getLogic()->getPlayerActions()->actRevealTopCards(a->data().toInt(), number);
|
player->getPlayerActions()->actRevealTopCards(a->data().toInt(), number);
|
||||||
defaultNumberTopCards = number;
|
defaultNumberTopCards = number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerGraphicsItem;
|
|
||||||
class PlayerLogic;
|
class PlayerLogic;
|
||||||
class PlayerActions;
|
class PlayerActions;
|
||||||
|
|
||||||
|
|
@ -25,7 +24,7 @@ public slots:
|
||||||
void resetTopCardMenuActions();
|
void resetTopCardMenuActions();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LibraryMenu(PlayerGraphicsItem *player, QWidget *parent = nullptr);
|
LibraryMenu(PlayerLogic *player, QWidget *parent = nullptr);
|
||||||
void createDrawActions();
|
void createDrawActions();
|
||||||
void createShuffleActions();
|
void createShuffleActions();
|
||||||
void createMoveActions();
|
void createMoveActions();
|
||||||
|
|
@ -112,7 +111,7 @@ public:
|
||||||
int defaultNumberTopCards = 1;
|
int defaultNumberTopCards = 1;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerGraphicsItem *player;
|
PlayerLogic *player;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCKATRICE_LIBRARY_MENU_H
|
#endif // COCKATRICE_LIBRARY_MENU_H
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
#include "move_menu.h"
|
#include "move_menu.h"
|
||||||
|
|
||||||
#include "../../game/player/player_actions.h"
|
|
||||||
#include "../../game/player/player_logic.h"
|
|
||||||
#include "../card_menu_action_type.h"
|
#include "../card_menu_action_type.h"
|
||||||
#include "../player_graphics_item.h"
|
#include "../player_actions.h"
|
||||||
|
#include "../player_logic.h"
|
||||||
|
|
||||||
MoveMenu::MoveMenu(PlayerGraphicsItem *player) : QMenu(tr("Move to"))
|
MoveMenu::MoveMenu(PlayerLogic *player) : QMenu(tr("Move to"))
|
||||||
{
|
{
|
||||||
aMoveToTopLibrary = new QAction(this);
|
aMoveToTopLibrary = new QAction(this);
|
||||||
aMoveToTopLibrary->setData(cmMoveToTopLibrary);
|
aMoveToTopLibrary->setData(cmMoveToTopLibrary);
|
||||||
|
|
@ -21,22 +20,14 @@ MoveMenu::MoveMenu(PlayerGraphicsItem *player) : QMenu(tr("Move to"))
|
||||||
aMoveToExile = new QAction(this);
|
aMoveToExile = new QAction(this);
|
||||||
aMoveToExile->setData(cmMoveToExile);
|
aMoveToExile->setData(cmMoveToExile);
|
||||||
|
|
||||||
auto *actions = player->getLogic()->getPlayerActions();
|
connect(aMoveToTopLibrary, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
|
||||||
|
connect(aMoveToBottomLibrary, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
|
||||||
auto invoke = [player](CardMenuActionType type) {
|
connect(aMoveToXfromTopOfLibrary, &QAction::triggered, player->getPlayerActions(),
|
||||||
return [type, player]() {
|
&PlayerActions::actMoveCardXCardsFromTop);
|
||||||
player->getLogic()->getPlayerActions()->cardMenuAction(player->getGameScene()->selectedCards(), type);
|
connect(aMoveToTable, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
|
||||||
};
|
connect(aMoveToHand, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
|
||||||
};
|
connect(aMoveToGraveyard, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
|
||||||
|
connect(aMoveToExile, &QAction::triggered, player->getPlayerActions(), &PlayerActions::cardMenuAction);
|
||||||
connect(aMoveToTopLibrary, &QAction::triggered, actions, invoke(cmMoveToTopLibrary));
|
|
||||||
connect(aMoveToBottomLibrary, &QAction::triggered, actions, invoke(cmMoveToBottomLibrary));
|
|
||||||
connect(aMoveToXfromTopOfLibrary, &QAction::triggered, actions,
|
|
||||||
&PlayerActions::actRequestMoveCardXCardsFromTopDialog);
|
|
||||||
connect(aMoveToTable, &QAction::triggered, actions, invoke(cmMoveToTable));
|
|
||||||
connect(aMoveToHand, &QAction::triggered, actions, invoke(cmMoveToHand));
|
|
||||||
connect(aMoveToGraveyard, &QAction::triggered, actions, invoke(cmMoveToGraveyard));
|
|
||||||
connect(aMoveToExile, &QAction::triggered, actions, invoke(cmMoveToExile));
|
|
||||||
|
|
||||||
addAction(aMoveToTopLibrary);
|
addAction(aMoveToTopLibrary);
|
||||||
addAction(aMoveToXfromTopOfLibrary);
|
addAction(aMoveToXfromTopOfLibrary);
|
||||||
|
|
@ -8,13 +8,13 @@
|
||||||
#define COCKATRICE_MOVE_MENU_H
|
#define COCKATRICE_MOVE_MENU_H
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerGraphicsItem;
|
class PlayerLogic;
|
||||||
class MoveMenu : public QMenu
|
class MoveMenu : public QMenu
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MoveMenu(PlayerGraphicsItem *player);
|
explicit MoveMenu(PlayerLogic *player);
|
||||||
void setShortcutsActive();
|
void setShortcutsActive();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
||||||
|
|
@ -5,21 +5,17 @@
|
||||||
#include "../../../game_graphics/zones/table_zone.h"
|
#include "../../../game_graphics/zones/table_zone.h"
|
||||||
#include "../../../interface/widgets/tabs/tab_game.h"
|
#include "../../../interface/widgets/tabs/tab_game.h"
|
||||||
#include "../../board/card_item.h"
|
#include "../../board/card_item.h"
|
||||||
#include "../player_graphics_item.h"
|
|
||||||
#include "card_menu.h"
|
#include "card_menu.h"
|
||||||
#include "hand_menu.h"
|
#include "hand_menu.h"
|
||||||
|
|
||||||
#include <libcockatrice/protocol/pb/command_reveal_cards.pb.h>
|
#include <libcockatrice/protocol/pb/command_reveal_cards.pb.h>
|
||||||
|
|
||||||
PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_player)
|
PlayerMenu::PlayerMenu(PlayerLogic *_player) : QObject(_player), player(_player)
|
||||||
{
|
{
|
||||||
connect(player->getLogic(), &PlayerLogic::requestCardMenuUpdate, this, &PlayerMenu::updateCardMenu);
|
|
||||||
connect(this, &PlayerMenu::cardInfoRequested, player, &PlayerGraphicsItem::cardInfoRequested);
|
|
||||||
|
|
||||||
playerMenu = new TearOffMenu();
|
playerMenu = new TearOffMenu();
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
handMenu = addManagedMenu<HandMenu>(player, playerMenu);
|
handMenu = addManagedMenu<HandMenu>(player, player->getPlayerActions(), playerMenu);
|
||||||
libraryMenu = addManagedMenu<LibraryMenu>(player, playerMenu);
|
libraryMenu = addManagedMenu<LibraryMenu>(player, playerMenu);
|
||||||
} else {
|
} else {
|
||||||
handMenu = nullptr;
|
handMenu = nullptr;
|
||||||
|
|
@ -29,7 +25,7 @@ PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_
|
||||||
graveMenu = addManagedMenu<GraveyardMenu>(player, playerMenu);
|
graveMenu = addManagedMenu<GraveyardMenu>(player, playerMenu);
|
||||||
rfgMenu = addManagedMenu<RfgMenu>(player, playerMenu);
|
rfgMenu = addManagedMenu<RfgMenu>(player, playerMenu);
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
sideboardMenu = addManagedMenu<SideboardMenu>(player, playerMenu);
|
sideboardMenu = addManagedMenu<SideboardMenu>(player, playerMenu);
|
||||||
customZonesMenu = addManagedMenu<CustomZoneMenu>(player);
|
customZonesMenu = addManagedMenu<CustomZoneMenu>(player);
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
|
|
@ -44,7 +40,7 @@ PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_
|
||||||
utilityMenu = nullptr;
|
utilityMenu = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocal()) {
|
if (player->getPlayerInfo()->getLocal()) {
|
||||||
sayMenu = addManagedMenu<SayMenu>(player);
|
sayMenu = addManagedMenu<SayMenu>(player);
|
||||||
} else {
|
} else {
|
||||||
sayMenu = nullptr;
|
sayMenu = nullptr;
|
||||||
|
|
@ -59,13 +55,13 @@ PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_
|
||||||
|
|
||||||
void PlayerMenu::setMenusForGraphicItems()
|
void PlayerMenu::setMenusForGraphicItems()
|
||||||
{
|
{
|
||||||
player->getTableZoneGraphicsItem()->setMenu(playerMenu);
|
player->getGraphicsItem()->getTableZoneGraphicsItem()->setMenu(playerMenu);
|
||||||
player->getGraveyardZoneGraphicsItem()->setMenu(graveMenu, graveMenu->aViewGraveyard);
|
player->getGraphicsItem()->getGraveyardZoneGraphicsItem()->setMenu(graveMenu, graveMenu->aViewGraveyard);
|
||||||
player->getRfgZoneGraphicsItem()->setMenu(rfgMenu, rfgMenu->aViewRfg);
|
player->getGraphicsItem()->getRfgZoneGraphicsItem()->setMenu(rfgMenu, rfgMenu->aViewRfg);
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
player->getHandZoneGraphicsItem()->setMenu(handMenu);
|
player->getGraphicsItem()->getHandZoneGraphicsItem()->setMenu(handMenu);
|
||||||
player->getDeckZoneGraphicsItem()->setMenu(libraryMenu, libraryMenu->aDrawCard);
|
player->getGraphicsItem()->getDeckZoneGraphicsItem()->setMenu(libraryMenu, libraryMenu->aDrawCard);
|
||||||
player->getSideboardZoneGraphicsItem()->setMenu(sideboardMenu);
|
player->getGraphicsItem()->getSideboardZoneGraphicsItem()->setMenu(sideboardMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,14 +74,12 @@ QMenu *PlayerMenu::updateCardMenu(const CardItem *card)
|
||||||
|
|
||||||
// If is spectator (as spectators don't need card menus), return
|
// If is spectator (as spectators don't need card menus), return
|
||||||
// only update the menu if the card is actually selected
|
// only update the menu if the card is actually selected
|
||||||
if ((player->getLogic()->getGame()->getPlayerManager()->isSpectator() &&
|
if ((player->getGame()->getPlayerManager()->isSpectator() && !player->getGame()->getPlayerManager()->isJudge()) ||
|
||||||
!player->getLogic()->getGame()->getPlayerManager()->isJudge()) ||
|
player->getGame()->getActiveCard() != card) {
|
||||||
player->getLogic()->getGame()->getActiveCard() != card) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardMenu *menu = new CardMenu(player, card, shortcutsActive);
|
QMenu *menu = new CardMenu(player, card, shortcutsActive);
|
||||||
connect(menu, &CardMenu::cardInfoRequested, this, &PlayerMenu::cardInfoRequested);
|
|
||||||
emit cardMenuUpdated(menu);
|
emit cardMenuUpdated(menu);
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
|
|
@ -93,7 +87,7 @@ QMenu *PlayerMenu::updateCardMenu(const CardItem *card)
|
||||||
|
|
||||||
void PlayerMenu::retranslateUi()
|
void PlayerMenu::retranslateUi()
|
||||||
{
|
{
|
||||||
playerMenu->setTitle(tr("Player \"%1\"").arg(player->getLogic()->getPlayerInfo()->getName()));
|
playerMenu->setTitle(tr("Player \"%1\"").arg(player->getPlayerInfo()->getName()));
|
||||||
|
|
||||||
for (auto *component : managedComponents) {
|
for (auto *component : managedComponents) {
|
||||||
component->retranslateUi();
|
component->retranslateUi();
|
||||||
|
|
@ -110,8 +104,7 @@ void PlayerMenu::refreshShortcuts()
|
||||||
{
|
{
|
||||||
if (shortcutsActive) {
|
if (shortcutsActive) {
|
||||||
// Judges get access to every player's menus but only want shortcuts to be set for their own.
|
// Judges get access to every player's menus but only want shortcuts to be set for their own.
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge() &&
|
if (player->getPlayerInfo()->getLocalOrJudge() && !player->getPlayerInfo()->getLocal()) {
|
||||||
!player->getLogic()->getPlayerInfo()->getLocal()) {
|
|
||||||
setShortcutsInactive();
|
setShortcutsInactive();
|
||||||
} else {
|
} else {
|
||||||
setShortcutsActive();
|
setShortcutsActive();
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#define COCKATRICE_PLAYER_MENU_H
|
#define COCKATRICE_PLAYER_MENU_H
|
||||||
|
|
||||||
#include "../../../interface/widgets/menus/tearoff_menu.h"
|
#include "../../../interface/widgets/menus/tearoff_menu.h"
|
||||||
|
#include "../player_logic.h"
|
||||||
#include "custom_zone_menu.h"
|
#include "custom_zone_menu.h"
|
||||||
#include "grave_menu.h"
|
#include "grave_menu.h"
|
||||||
#include "hand_menu.h"
|
#include "hand_menu.h"
|
||||||
|
|
@ -22,31 +23,29 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class CardItem;
|
class CardItem;
|
||||||
class CardMenu;
|
|
||||||
class PlayerGraphicsItem;
|
|
||||||
class PlayerMenu : public QObject
|
class PlayerMenu : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void cardMenuUpdated(CardMenu *cardMenu);
|
void cardMenuUpdated(QMenu *cardMenu);
|
||||||
void cardInfoRequested(const CardRef &cardRef);
|
|
||||||
void shortcutsActivated();
|
void shortcutsActivated();
|
||||||
void shortcutsDeactivated();
|
void shortcutsDeactivated();
|
||||||
void retranslateRequested();
|
void retranslateRequested();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setMenusForGraphicItems();
|
void setMenusForGraphicItems();
|
||||||
QMenu *updateCardMenu(const CardItem *card);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void refreshShortcuts();
|
void refreshShortcuts();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PlayerMenu(PlayerGraphicsItem *player);
|
explicit PlayerMenu(PlayerLogic *player);
|
||||||
/** @brief Retranslate all user-visible strings. Called on language change. */
|
/** @brief Retranslate all user-visible strings. Called on language change. */
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
||||||
|
QMenu *updateCardMenu(const CardItem *card);
|
||||||
|
|
||||||
[[nodiscard]] QMenu *getPlayerMenu() const
|
[[nodiscard]] QMenu *getPlayerMenu() const
|
||||||
{
|
{
|
||||||
return playerMenu;
|
return playerMenu;
|
||||||
|
|
@ -78,7 +77,7 @@ public:
|
||||||
void setShortcutsInactive();
|
void setShortcutsInactive();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerGraphicsItem *player;
|
PlayerLogic *player;
|
||||||
TearOffMenu *playerMenu;
|
TearOffMenu *playerMenu;
|
||||||
QMenu *countersMenu;
|
QMenu *countersMenu;
|
||||||
HandMenu *handMenu;
|
HandMenu *handMenu;
|
||||||
|
|
@ -1,43 +1,32 @@
|
||||||
#include "pt_menu.h"
|
#include "pt_menu.h"
|
||||||
|
|
||||||
#include "../../game/player/player_actions.h"
|
#include "../player_actions.h"
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../player_logic.h"
|
||||||
#include "../player_graphics_item.h"
|
|
||||||
|
|
||||||
PtMenu::PtMenu(PlayerGraphicsItem *player) : QMenu(tr("Power / toughness"))
|
PtMenu::PtMenu(PlayerLogic *player) : QMenu(tr("Power / toughness"))
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
PlayerActions *playerActions = player->getPlayerActions();
|
||||||
|
|
||||||
aIncP = new QAction(this);
|
aIncP = new QAction(this);
|
||||||
connect(aIncP, &QAction::triggered, playerActions,
|
connect(aIncP, &QAction::triggered, playerActions, &PlayerActions::actIncP);
|
||||||
[player, playerActions] { playerActions->actIncP(player->getGameScene()->selectedCards()); });
|
|
||||||
aDecP = new QAction(this);
|
aDecP = new QAction(this);
|
||||||
connect(aDecP, &QAction::triggered, playerActions,
|
connect(aDecP, &QAction::triggered, playerActions, &PlayerActions::actDecP);
|
||||||
[player, playerActions] { playerActions->actDecP(player->getGameScene()->selectedCards()); });
|
|
||||||
aIncT = new QAction(this);
|
aIncT = new QAction(this);
|
||||||
connect(aIncT, &QAction::triggered, playerActions,
|
connect(aIncT, &QAction::triggered, playerActions, &PlayerActions::actIncT);
|
||||||
[player, playerActions] { playerActions->actIncT(player->getGameScene()->selectedCards()); });
|
|
||||||
aDecT = new QAction(this);
|
aDecT = new QAction(this);
|
||||||
connect(aDecT, &QAction::triggered, playerActions,
|
connect(aDecT, &QAction::triggered, playerActions, &PlayerActions::actDecT);
|
||||||
[player, playerActions] { playerActions->actDecT(player->getGameScene()->selectedCards()); });
|
|
||||||
aIncPT = new QAction(this);
|
aIncPT = new QAction(this);
|
||||||
connect(aIncPT, &QAction::triggered, playerActions,
|
connect(aIncPT, &QAction::triggered, playerActions, [playerActions] { playerActions->actIncPT(); });
|
||||||
[player, playerActions] { playerActions->actIncPT(player->getGameScene()->selectedCards()); });
|
|
||||||
aDecPT = new QAction(this);
|
aDecPT = new QAction(this);
|
||||||
connect(aDecPT, &QAction::triggered, playerActions,
|
connect(aDecPT, &QAction::triggered, playerActions, &PlayerActions::actDecPT);
|
||||||
[player, playerActions] { playerActions->actDecPT(player->getGameScene()->selectedCards()); });
|
|
||||||
aFlowP = new QAction(this);
|
aFlowP = new QAction(this);
|
||||||
connect(aFlowP, &QAction::triggered, playerActions,
|
connect(aFlowP, &QAction::triggered, playerActions, &PlayerActions::actFlowP);
|
||||||
[player, playerActions] { playerActions->actFlowP(player->getGameScene()->selectedCards()); });
|
|
||||||
aFlowT = new QAction(this);
|
aFlowT = new QAction(this);
|
||||||
connect(aFlowT, &QAction::triggered, playerActions,
|
connect(aFlowT, &QAction::triggered, playerActions, &PlayerActions::actFlowT);
|
||||||
[player, playerActions] { playerActions->actFlowT(player->getGameScene()->selectedCards()); });
|
|
||||||
aSetPT = new QAction(this);
|
aSetPT = new QAction(this);
|
||||||
connect(aSetPT, &QAction::triggered, playerActions,
|
connect(aSetPT, &QAction::triggered, playerActions, &PlayerActions::actSetPT);
|
||||||
[player, playerActions] { playerActions->actRequestSetPTDialog(player->getGameScene()->selectedCards()); });
|
|
||||||
aResetPT = new QAction(this);
|
aResetPT = new QAction(this);
|
||||||
connect(aResetPT, &QAction::triggered, playerActions,
|
connect(aResetPT, &QAction::triggered, playerActions, &PlayerActions::actResetPT);
|
||||||
[player, playerActions] { playerActions->actResetPT(player->getGameScene()->selectedCards()); });
|
|
||||||
|
|
||||||
addAction(aIncP);
|
addAction(aIncP);
|
||||||
addAction(aDecP);
|
addAction(aDecP);
|
||||||
|
|
@ -8,14 +8,14 @@
|
||||||
#define COCKATRICE_PT_MENU_H
|
#define COCKATRICE_PT_MENU_H
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerGraphicsItem;
|
class PlayerLogic;
|
||||||
class PtMenu : public QMenu
|
class PtMenu : public QMenu
|
||||||
{
|
{
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PtMenu(PlayerGraphicsItem *player);
|
explicit PtMenu(PlayerLogic *player);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void setShortcutsActive();
|
void setShortcutsActive();
|
||||||
|
|
||||||
|
|
@ -1,19 +1,18 @@
|
||||||
#include "rfg_menu.h"
|
#include "rfg_menu.h"
|
||||||
|
|
||||||
#include "../../game/player/player_actions.h"
|
#include "../player_actions.h"
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../player_logic.h"
|
||||||
#include "../player_graphics_item.h"
|
|
||||||
|
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
|
||||||
RfgMenu::RfgMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
RfgMenu::RfgMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||||
{
|
{
|
||||||
createMoveActions();
|
createMoveActions();
|
||||||
createViewActions();
|
createViewActions();
|
||||||
|
|
||||||
addAction(aViewRfg);
|
addAction(aViewRfg);
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
addSeparator();
|
addSeparator();
|
||||||
moveRfgMenu = addTearOffMenu(QString());
|
moveRfgMenu = addTearOffMenu(QString());
|
||||||
moveRfgMenu->addAction(aMoveRfgToTopLibrary);
|
moveRfgMenu->addAction(aMoveRfgToTopLibrary);
|
||||||
|
|
@ -29,8 +28,8 @@ RfgMenu::RfgMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(par
|
||||||
|
|
||||||
void RfgMenu::createMoveActions()
|
void RfgMenu::createMoveActions()
|
||||||
{
|
{
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
auto rfg = player->getLogic()->getRfgZone();
|
auto rfg = player->getRfgZone();
|
||||||
|
|
||||||
aMoveRfgToTopLibrary = new QAction(this);
|
aMoveRfgToTopLibrary = new QAction(this);
|
||||||
aMoveRfgToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
aMoveRfgToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
|
||||||
|
|
@ -50,7 +49,7 @@ void RfgMenu::createMoveActions()
|
||||||
|
|
||||||
void RfgMenu::createViewActions()
|
void RfgMenu::createViewActions()
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
PlayerActions *playerActions = player->getPlayerActions();
|
||||||
|
|
||||||
aViewRfg = new QAction(this);
|
aViewRfg = new QAction(this);
|
||||||
connect(aViewRfg, &QAction::triggered, playerActions, &PlayerActions::actViewRfg);
|
connect(aViewRfg, &QAction::triggered, playerActions, &PlayerActions::actViewRfg);
|
||||||
|
|
@ -62,7 +61,7 @@ void RfgMenu::retranslateUi()
|
||||||
|
|
||||||
aViewRfg->setText(tr("&View exile"));
|
aViewRfg->setText(tr("&View exile"));
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
moveRfgMenu->setTitle(tr("&Move exile to..."));
|
moveRfgMenu->setTitle(tr("&Move exile to..."));
|
||||||
aMoveRfgToTopLibrary->setText(tr("&Top of library"));
|
aMoveRfgToTopLibrary->setText(tr("&Top of library"));
|
||||||
aMoveRfgToBottomLibrary->setText(tr("&Bottom of library"));
|
aMoveRfgToBottomLibrary->setText(tr("&Bottom of library"));
|
||||||
|
|
@ -13,12 +13,12 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerGraphicsItem;
|
class PlayerLogic;
|
||||||
class RfgMenu : public TearOffMenu, public AbstractPlayerComponent
|
class RfgMenu : public TearOffMenu, public AbstractPlayerComponent
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit RfgMenu(PlayerGraphicsItem *player, QWidget *parent = nullptr);
|
explicit RfgMenu(PlayerLogic *player, QWidget *parent = nullptr);
|
||||||
void createMoveActions();
|
void createMoveActions();
|
||||||
void createViewActions();
|
void createViewActions();
|
||||||
void retranslateUi() override;
|
void retranslateUi() override;
|
||||||
|
|
@ -38,7 +38,7 @@ public:
|
||||||
QAction *aMoveRfgToGrave = nullptr;
|
QAction *aMoveRfgToGrave = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerGraphicsItem *player;
|
PlayerLogic *player;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCKATRICE_RFG_MENU_H
|
#endif // COCKATRICE_RFG_MENU_H
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
#include "say_menu.h"
|
#include "say_menu.h"
|
||||||
|
|
||||||
#include "../../../client/settings/cache_settings.h"
|
#include "../../../client/settings/cache_settings.h"
|
||||||
#include "../../game/player/player_actions.h"
|
#include "../player_actions.h"
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../player_logic.h"
|
||||||
#include "../player_graphics_item.h"
|
|
||||||
|
|
||||||
SayMenu::SayMenu(PlayerGraphicsItem *_player) : player(_player)
|
SayMenu::SayMenu(PlayerLogic *_player) : player(_player)
|
||||||
{
|
{
|
||||||
connect(&SettingsCache::instance().messages(), &MessageSettings::messageMacrosChanged, this, &SayMenu::initSayMenu);
|
connect(&SettingsCache::instance().messages(), &MessageSettings::messageMacrosChanged, this, &SayMenu::initSayMenu);
|
||||||
initSayMenu();
|
initSayMenu();
|
||||||
|
|
@ -45,7 +44,7 @@ void SayMenu::initSayMenu()
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
auto *newAction = new QAction(SettingsCache::instance().messages().getMessageAt(i), this);
|
auto *newAction = new QAction(SettingsCache::instance().messages().getMessageAt(i), this);
|
||||||
connect(newAction, &QAction::triggered, player->getLogic()->getPlayerActions(), &PlayerActions::actSayMessage);
|
connect(newAction, &QAction::triggered, player->getPlayerActions(), &PlayerActions::actSayMessage);
|
||||||
addAction(newAction);
|
addAction(newAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerGraphicsItem;
|
class PlayerLogic;
|
||||||
class SayMenu : public QMenu, public AbstractPlayerComponent
|
class SayMenu : public QMenu, public AbstractPlayerComponent
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SayMenu(PlayerGraphicsItem *player);
|
explicit SayMenu(PlayerLogic *player);
|
||||||
|
|
||||||
void retranslateUi() override;
|
void retranslateUi() override;
|
||||||
void setShortcutsActive() override;
|
void setShortcutsActive() override;
|
||||||
|
|
@ -26,7 +26,7 @@ private slots:
|
||||||
void initSayMenu();
|
void initSayMenu();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerGraphicsItem *player;
|
PlayerLogic *player;
|
||||||
bool shortcutsActive = false;
|
bool shortcutsActive = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
#include "sideboard_menu.h"
|
#include "sideboard_menu.h"
|
||||||
|
|
||||||
#include "../../game/player/player_actions.h"
|
#include "../player_actions.h"
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../player_logic.h"
|
||||||
#include "../player_graphics_item.h"
|
|
||||||
|
|
||||||
SideboardMenu::SideboardMenu(PlayerGraphicsItem *player, QMenu *playerMenu) : QMenu(playerMenu)
|
SideboardMenu::SideboardMenu(PlayerLogic *player, QMenu *playerMenu) : QMenu(playerMenu)
|
||||||
{
|
{
|
||||||
aViewSideboard = new QAction(this);
|
aViewSideboard = new QAction(this);
|
||||||
connect(aViewSideboard, &QAction::triggered, player->getLogic()->getPlayerActions(),
|
connect(aViewSideboard, &QAction::triggered, player->getPlayerActions(), &PlayerActions::actViewSideboard);
|
||||||
&PlayerActions::actViewSideboard);
|
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
addAction(aViewSideboard);
|
addAction(aViewSideboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -11,19 +11,19 @@
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
class PlayerGraphicsItem;
|
class PlayerLogic;
|
||||||
class SideboardMenu : public QMenu, public AbstractPlayerComponent
|
class SideboardMenu : public QMenu, public AbstractPlayerComponent
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SideboardMenu(PlayerGraphicsItem *player, QMenu *playerMenu);
|
explicit SideboardMenu(PlayerLogic *player, QMenu *playerMenu);
|
||||||
void retranslateUi() override;
|
void retranslateUi() override;
|
||||||
void setShortcutsActive() override;
|
void setShortcutsActive() override;
|
||||||
void setShortcutsInactive() override;
|
void setShortcutsInactive() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerGraphicsItem *player;
|
PlayerLogic *player;
|
||||||
|
|
||||||
QAction *aViewSideboard;
|
QAction *aViewSideboard;
|
||||||
};
|
};
|
||||||
|
|
@ -1,49 +1,41 @@
|
||||||
#include "utility_menu.h"
|
#include "utility_menu.h"
|
||||||
|
|
||||||
#include "../../../interface/deck_loader/deck_loader.h"
|
#include "../../../interface/deck_loader/deck_loader.h"
|
||||||
#include "../../game/player/player_actions.h"
|
#include "../player_actions.h"
|
||||||
#include "../../game/player/player_logic.h"
|
#include "../player_logic.h"
|
||||||
#include "../player_graphics_item.h"
|
|
||||||
#include "player_menu.h"
|
#include "player_menu.h"
|
||||||
|
|
||||||
#include <libcockatrice/deck_list/tree/deck_list_card_node.h>
|
#include <libcockatrice/deck_list/tree/deck_list_card_node.h>
|
||||||
#include <libcockatrice/deck_list/tree/inner_deck_list_node.h>
|
#include <libcockatrice/deck_list/tree/inner_deck_list_node.h>
|
||||||
|
|
||||||
UtilityMenu::UtilityMenu(PlayerGraphicsItem *_player, QMenu *playerMenu) : QMenu(playerMenu), player(_player)
|
UtilityMenu::UtilityMenu(PlayerLogic *_player, QMenu *playerMenu) : QMenu(playerMenu), player(_player)
|
||||||
{
|
{
|
||||||
PlayerActions *playerActions = player->getLogic()->getPlayerActions();
|
PlayerActions *playerActions = player->getPlayerActions();
|
||||||
connect(playerActions, &PlayerActions::requestEnableAndSetCreateAnotherTokenAction, this,
|
|
||||||
&UtilityMenu::setAndEnableCreateAnotherTokenAction);
|
|
||||||
connect(playerActions, &PlayerActions::requestSetLastToken, this, &UtilityMenu::setLastToken);
|
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
aUntapAll = new QAction(this);
|
aUntapAll = new QAction(this);
|
||||||
connect(aUntapAll, &QAction::triggered, playerActions, &PlayerActions::actUntapAll);
|
connect(aUntapAll, &QAction::triggered, playerActions, &PlayerActions::actUntapAll);
|
||||||
|
|
||||||
aRollDie = new QAction(this);
|
aRollDie = new QAction(this);
|
||||||
connect(aRollDie, &QAction::triggered, playerActions, &PlayerActions::actRequestRollDieDialog);
|
connect(aRollDie, &QAction::triggered, playerActions, &PlayerActions::actRollDie);
|
||||||
|
|
||||||
aFlipCoin = new QAction(this);
|
aFlipCoin = new QAction(this);
|
||||||
connect(aFlipCoin, &QAction::triggered, playerActions, &PlayerActions::actFlipCoin);
|
connect(aFlipCoin, &QAction::triggered, playerActions, &PlayerActions::actFlipCoin);
|
||||||
|
|
||||||
aCreateToken = new QAction(this);
|
aCreateToken = new QAction(this);
|
||||||
connect(aCreateToken, &QAction::triggered, playerActions, [this]() {
|
connect(aCreateToken, &QAction::triggered, playerActions, &PlayerActions::actCreateToken);
|
||||||
player->getLogic()->getPlayerActions()->actRequestCreateTokenDialog(getPredefinedTokens());
|
|
||||||
});
|
|
||||||
|
|
||||||
aCreateAnotherToken = new QAction(this);
|
aCreateAnotherToken = new QAction(this);
|
||||||
connect(aCreateAnotherToken, &QAction::triggered, playerActions, &PlayerActions::actCreateAnotherToken);
|
connect(aCreateAnotherToken, &QAction::triggered, playerActions, &PlayerActions::actCreateAnotherToken);
|
||||||
aCreateAnotherToken->setEnabled(false);
|
aCreateAnotherToken->setEnabled(false);
|
||||||
|
|
||||||
aIncrementAllCardCounters = new QAction(this);
|
aIncrementAllCardCounters = new QAction(this);
|
||||||
connect(aIncrementAllCardCounters, &QAction::triggered, playerActions, [this]() {
|
connect(aIncrementAllCardCounters, &QAction::triggered, playerActions,
|
||||||
player->getLogic()->getPlayerActions()->actIncrementAllCardCounters(
|
&PlayerActions::actIncrementAllCardCounters);
|
||||||
player->getGameScene()->selectedCards());
|
|
||||||
});
|
|
||||||
|
|
||||||
createPredefinedTokenMenu = new QMenu(QString());
|
createPredefinedTokenMenu = new QMenu(QString());
|
||||||
createPredefinedTokenMenu->setEnabled(false);
|
createPredefinedTokenMenu->setEnabled(false);
|
||||||
connect(player->getLogic(), &PlayerLogic::deckChanged, this, &UtilityMenu::populatePredefinedTokensMenu);
|
connect(player, &PlayerLogic::deckChanged, this, &UtilityMenu::populatePredefinedTokensMenu);
|
||||||
|
|
||||||
playerMenu->addAction(aIncrementAllCardCounters);
|
playerMenu->addAction(aIncrementAllCardCounters);
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
|
|
@ -74,7 +66,7 @@ void UtilityMenu::populatePredefinedTokensMenu()
|
||||||
clear();
|
clear();
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
predefinedTokens.clear();
|
predefinedTokens.clear();
|
||||||
const DeckList &deckList = player->getLogic()->getDeck();
|
const DeckList &deckList = player->getDeck();
|
||||||
|
|
||||||
if (deckList.isEmpty()) {
|
if (deckList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -92,24 +84,14 @@ void UtilityMenu::populatePredefinedTokensMenu()
|
||||||
if (i < 10) {
|
if (i < 10) {
|
||||||
a->setShortcut(QKeySequence("Alt+" + QString::number((i + 1) % 10)));
|
a->setShortcut(QKeySequence("Alt+" + QString::number((i + 1) % 10)));
|
||||||
}
|
}
|
||||||
connect(a, &QAction::triggered, player->getLogic()->getPlayerActions(),
|
connect(a, &QAction::triggered, player->getPlayerActions(), &PlayerActions::actCreatePredefinedToken);
|
||||||
&PlayerActions::actCreatePredefinedToken);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilityMenu::setLastToken(CardInfoPtr lastToken)
|
|
||||||
{
|
|
||||||
if (!createAnotherTokenActionExists()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
player->getLogic()->getPlayerActions()->setLastTokenInfo(lastToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UtilityMenu::retranslateUi()
|
void UtilityMenu::retranslateUi()
|
||||||
{
|
{
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
aIncrementAllCardCounters->setText(tr("Increment all card counters"));
|
aIncrementAllCardCounters->setText(tr("Increment all card counters"));
|
||||||
aUntapAll->setText(tr("&Untap all permanents"));
|
aUntapAll->setText(tr("&Untap all permanents"));
|
||||||
aRollDie->setText(tr("R&oll die..."));
|
aRollDie->setText(tr("R&oll die..."));
|
||||||
|
|
@ -124,7 +106,7 @@ void UtilityMenu::setShortcutsActive()
|
||||||
{
|
{
|
||||||
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
|
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
|
||||||
|
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
aIncrementAllCardCounters->setShortcuts(shortcuts.getShortcut("Player/aIncrementAllCardCounters"));
|
aIncrementAllCardCounters->setShortcuts(shortcuts.getShortcut("Player/aIncrementAllCardCounters"));
|
||||||
aUntapAll->setShortcuts(shortcuts.getShortcut("Player/aUntapAll"));
|
aUntapAll->setShortcuts(shortcuts.getShortcut("Player/aUntapAll"));
|
||||||
aRollDie->setShortcuts(shortcuts.getShortcut("Player/aRollDie"));
|
aRollDie->setShortcuts(shortcuts.getShortcut("Player/aRollDie"));
|
||||||
|
|
@ -136,7 +118,7 @@ void UtilityMenu::setShortcutsActive()
|
||||||
|
|
||||||
void UtilityMenu::setShortcutsInactive()
|
void UtilityMenu::setShortcutsInactive()
|
||||||
{
|
{
|
||||||
if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
|
if (player->getPlayerInfo()->getLocalOrJudge()) {
|
||||||
aUntapAll->setShortcut(QKeySequence());
|
aUntapAll->setShortcut(QKeySequence());
|
||||||
aRollDie->setShortcut(QKeySequence());
|
aRollDie->setShortcut(QKeySequence());
|
||||||
aFlipCoin->setShortcut(QKeySequence());
|
aFlipCoin->setShortcut(QKeySequence());
|
||||||
|
|
@ -10,21 +10,19 @@
|
||||||
#include "abstract_player_component.h"
|
#include "abstract_player_component.h"
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <libcockatrice/card/card_info.h>
|
|
||||||
|
|
||||||
class PlayerGraphicsItem;
|
class PlayerLogic;
|
||||||
class UtilityMenu : public QMenu, public AbstractPlayerComponent
|
class UtilityMenu : public QMenu, public AbstractPlayerComponent
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public slots:
|
public slots:
|
||||||
void populatePredefinedTokensMenu();
|
void populatePredefinedTokensMenu();
|
||||||
void setLastToken(CardInfoPtr lastToken);
|
|
||||||
void retranslateUi() override;
|
void retranslateUi() override;
|
||||||
void setShortcutsActive() override;
|
void setShortcutsActive() override;
|
||||||
void setShortcutsInactive() override;
|
void setShortcutsInactive() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit UtilityMenu(PlayerGraphicsItem *player, QMenu *playerMenu);
|
explicit UtilityMenu(PlayerLogic *player, QMenu *playerMenu);
|
||||||
|
|
||||||
[[nodiscard]] bool createAnotherTokenActionExists() const
|
[[nodiscard]] bool createAnotherTokenActionExists() const
|
||||||
{
|
{
|
||||||
|
|
@ -33,7 +31,7 @@ public:
|
||||||
|
|
||||||
void setAndEnableCreateAnotherTokenAction(QString text)
|
void setAndEnableCreateAnotherTokenAction(QString text)
|
||||||
{
|
{
|
||||||
aCreateAnotherToken->setText(tr("C&reate another %1 token").arg(text));
|
aCreateAnotherToken->setText(text);
|
||||||
aCreateAnotherToken->setEnabled(true);
|
aCreateAnotherToken->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,7 +41,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerGraphicsItem *player;
|
PlayerLogic *player;
|
||||||
QStringList predefinedTokens;
|
QStringList predefinedTokens;
|
||||||
|
|
||||||
QMenu *createPredefinedTokenMenu;
|
QMenu *createPredefinedTokenMenu;
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -7,11 +7,8 @@
|
||||||
|
|
||||||
#ifndef COCKATRICE_PLAYER_ACTIONS_H
|
#ifndef COCKATRICE_PLAYER_ACTIONS_H
|
||||||
#define COCKATRICE_PLAYER_ACTIONS_H
|
#define COCKATRICE_PLAYER_ACTIONS_H
|
||||||
|
#include "../dialogs/dlg_create_token.h"
|
||||||
#include "../../game_graphics/board/card_item.h"
|
#include "../dialogs/dlg_move_top_cards_until.h"
|
||||||
#include "../../game_graphics/dialogs/dlg_create_token.h"
|
|
||||||
#include "../../game_graphics/dialogs/dlg_move_top_cards_until.h"
|
|
||||||
#include "../../game_graphics/player/card_menu_action_type.h"
|
|
||||||
#include "event_processing_options.h"
|
#include "event_processing_options.h"
|
||||||
#include "player_logic.h"
|
#include "player_logic.h"
|
||||||
|
|
||||||
|
|
@ -28,6 +25,7 @@ class Message;
|
||||||
}
|
}
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|
||||||
|
class CardItem;
|
||||||
class Command_MoveCard;
|
class Command_MoveCard;
|
||||||
class GameEventContext;
|
class GameEventContext;
|
||||||
class PendingCommand;
|
class PendingCommand;
|
||||||
|
|
@ -58,75 +56,30 @@ public:
|
||||||
return movingCardsUntil;
|
return movingCardsUntil;
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
|
||||||
void requestViewTopCardsDialog(int defaultNumberTopCards, int deckSize);
|
|
||||||
void requestViewBottomCardsDialog(int defaultNumberBottomCards, int deckSize);
|
|
||||||
void requestShuffleTopDialog(int defaultNumberTopCards, int maxCards);
|
|
||||||
void requestShuffleBottomDialog(int defaultNumberBottomCards, int maxCards);
|
|
||||||
void requestMulliganDialog(int startSize, int handSize, int deckSize);
|
|
||||||
void requestDrawCardsDialog(int defaultNumberTopCards, int deckSize);
|
|
||||||
void requestMoveTopCardsToDialog(int defaultNumberTopCards,
|
|
||||||
int maxCards,
|
|
||||||
const QString &targetZone,
|
|
||||||
const QString &zoneDisplayName,
|
|
||||||
bool faceDown);
|
|
||||||
void requestMoveTopCardsUntilDialog(MoveTopCardsUntilOptions options);
|
|
||||||
void requestMoveBottomCardsToDialog(int defaultNumberBottomCards,
|
|
||||||
int maxCards,
|
|
||||||
const QString &targetZone,
|
|
||||||
const QString &zoneDisplayName,
|
|
||||||
bool faceDown);
|
|
||||||
void requestDrawBottomCardsDialog(int defaultNumberBottomCards, int maxCards);
|
|
||||||
void requestRollDieDialog();
|
|
||||||
void requestCreateTokenDialog(const QStringList &predefinedTokens);
|
|
||||||
void requestCreateRelatedFromRelationDialog(const CardItem *sourceCard, const CardRelation *cardRelation);
|
|
||||||
void requestMoveCardXCardsFromTopDialog(int defaultNumberTopCardsToPlaceBelow, int deckSize);
|
|
||||||
void requestSetPTDialog(const QString &oldPT);
|
|
||||||
void requestSetAnnotationDialog(const QString &oldAnnotation);
|
|
||||||
void requestSetCardCounterDialog(int counterId, const QString &oldValueForDlg);
|
|
||||||
void requestZoneViewToggle(const QString &zoneName, int numberCards, bool isReversed = false);
|
|
||||||
void requestSortHand(const QList<CardList::SortOption> &options);
|
|
||||||
void requestEnableAndSetCreateAnotherTokenAction(const QString &lastTokenName);
|
|
||||||
void requestSetLastToken(CardInfoPtr lastToken);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setLastToken(CardInfoPtr cardInfo);
|
void setLastToken(CardInfoPtr cardInfo);
|
||||||
void setLastTokenInfo(CardInfoPtr cardInfo);
|
|
||||||
void playCard(CardItem *c, bool faceDown);
|
void playCard(CardItem *c, bool faceDown);
|
||||||
void playCardToTable(const CardItem *c, bool faceDown);
|
void playCardToTable(const CardItem *c, bool faceDown);
|
||||||
|
|
||||||
void actUntapAll();
|
void actUntapAll();
|
||||||
void actRequestRollDieDialog();
|
void actRollDie();
|
||||||
void actRollDie(int sides, int count);
|
|
||||||
void actFlipCoin();
|
void actFlipCoin();
|
||||||
void actRequestCreateTokenDialog(const QStringList &predefinedTokens);
|
void actCreateToken();
|
||||||
void actCreateToken(TokenInfo tokenToCreate);
|
|
||||||
void actCreateAnotherToken();
|
void actCreateAnotherToken();
|
||||||
void actRequestCreateRelatedFromRelationDialog(const CardItem *sourceCard, const CardRelation *cardRelation);
|
|
||||||
bool createRelatedFromRelation(const CardItem *sourceCard, const CardRelation *cardRelation, int variableCount);
|
|
||||||
void onRelatedCardCreated(const CardItem *sourceCard, const CardRelation *cardRelation);
|
|
||||||
void setLastRelatedCreationSucceeded(bool succeeded)
|
|
||||||
{
|
|
||||||
lastRelatedCreationSucceeded = succeeded;
|
|
||||||
}
|
|
||||||
void actShuffle();
|
void actShuffle();
|
||||||
void actRequestShuffleTopDialog();
|
void actShuffleTop();
|
||||||
void actShuffleTop(int number);
|
void actShuffleBottom();
|
||||||
void actRequestShuffleBottomDialog();
|
|
||||||
void actShuffleBottom(int number);
|
|
||||||
void actDrawCard();
|
void actDrawCard();
|
||||||
void actRequestDrawCardsDialog();
|
void actDrawCards();
|
||||||
void actDrawCards(int number);
|
|
||||||
void actUndoDraw();
|
void actUndoDraw();
|
||||||
void actRequestMulliganDialog();
|
void actMulligan();
|
||||||
void actMulligan(int number);
|
|
||||||
void actMulliganSameSize();
|
void actMulliganSameSize();
|
||||||
void actMulliganMinusOne();
|
void actMulliganMinusOne();
|
||||||
void doMulligan(int number);
|
void doMulligan(int number);
|
||||||
|
|
||||||
void actPlay(QList<CardItem *> selectedCards);
|
void actPlay();
|
||||||
void actPlayFacedown(QList<CardItem *> selectedCards);
|
void actPlayFacedown();
|
||||||
void actHide(QList<CardItem *> selectedCards);
|
void actHide();
|
||||||
|
|
||||||
void actMoveTopCardToPlay();
|
void actMoveTopCardToPlay();
|
||||||
void actMoveTopCardToPlayFaceDown();
|
void actMoveTopCardToPlayFaceDown();
|
||||||
|
|
@ -136,14 +89,10 @@ public slots:
|
||||||
void actMoveTopCardsToGraveFaceDown();
|
void actMoveTopCardsToGraveFaceDown();
|
||||||
void actMoveTopCardsToExile();
|
void actMoveTopCardsToExile();
|
||||||
void actMoveTopCardsToExileFaceDown();
|
void actMoveTopCardsToExileFaceDown();
|
||||||
void actRequestMoveTopCardsUntilDialog();
|
void actMoveTopCardsUntil();
|
||||||
void moveTopCardsUntil(const QString &expr, MoveTopCardsUntilOptions options);
|
|
||||||
void actMoveTopCardToBottom();
|
void actMoveTopCardToBottom();
|
||||||
void actRequestMoveTopCardsToDialog(const QString &targetZone, const QString &zoneDisplayName, bool faceDown);
|
|
||||||
void moveTopCardsTo(int number, const QString &targetZone, bool faceDown);
|
|
||||||
void actDrawBottomCard();
|
void actDrawBottomCard();
|
||||||
void actRequestDrawBottomCardsDialog();
|
void actDrawBottomCards();
|
||||||
void actDrawBottomCards(int number);
|
|
||||||
void actMoveBottomCardToPlay();
|
void actMoveBottomCardToPlay();
|
||||||
void actMoveBottomCardToPlayFaceDown();
|
void actMoveBottomCardToPlayFaceDown();
|
||||||
void actMoveBottomCardToGrave();
|
void actMoveBottomCardToGrave();
|
||||||
|
|
@ -153,8 +102,6 @@ public slots:
|
||||||
void actMoveBottomCardsToExile();
|
void actMoveBottomCardsToExile();
|
||||||
void actMoveBottomCardsToExileFaceDown();
|
void actMoveBottomCardsToExileFaceDown();
|
||||||
void actMoveBottomCardToTop();
|
void actMoveBottomCardToTop();
|
||||||
void actRequestMoveBottomCardsToDialog(const QString &targetZone, const QString &zoneDisplayName, bool faceDown);
|
|
||||||
void moveBottomCardsTo(int number, const QString &targetZone, bool faceDown);
|
|
||||||
|
|
||||||
void actSelectAll();
|
void actSelectAll();
|
||||||
void actSelectRow();
|
void actSelectRow();
|
||||||
|
|
@ -162,12 +109,10 @@ public slots:
|
||||||
|
|
||||||
void actViewLibrary();
|
void actViewLibrary();
|
||||||
void actViewHand();
|
void actViewHand();
|
||||||
void actRequestViewTopCardsDialog();
|
void actViewTopCards();
|
||||||
void actViewTopCards(int number);
|
void actViewBottomCards();
|
||||||
void actRequestViewBottomCardsDialog();
|
void actAlwaysRevealTopCard();
|
||||||
void actViewBottomCards(int number);
|
void actAlwaysLookAtTopCard();
|
||||||
void actAlwaysRevealTopCard(bool alwaysRevealTopCard);
|
|
||||||
void actAlwaysLookAtTopCard(bool alwaysRevealTopCard);
|
|
||||||
void actViewGraveyard();
|
void actViewGraveyard();
|
||||||
void actLendLibrary(int lendToPlayerId);
|
void actLendLibrary(int lendToPlayerId);
|
||||||
void actRevealTopCards(int revealToPlayerId, int amount);
|
void actRevealTopCards(int revealToPlayerId, int amount);
|
||||||
|
|
@ -182,41 +127,37 @@ public slots:
|
||||||
void actCreateRelatedCard();
|
void actCreateRelatedCard();
|
||||||
void actCreateAllRelatedCards();
|
void actCreateAllRelatedCards();
|
||||||
|
|
||||||
void actRequestMoveCardXCardsFromTopDialog();
|
void actMoveCardXCardsFromTop();
|
||||||
void actMoveCardXCardsFromTop(QList<CardItem *> selectedCards, int number);
|
void actRemoveCardCounter(int counterId);
|
||||||
void actRemoveCardCounter(QList<CardItem *> selectedCards, int counterId);
|
void actAddCardCounter(int counterId);
|
||||||
void actAddCardCounter(QList<CardItem *> selectedCards, int counterId);
|
void actSetCardCounter(int counterId);
|
||||||
void actRequestSetCardCounterDialog(QList<CardItem *> selectedCards, int counterId);
|
void actIncrementAllCardCounters();
|
||||||
void actSetCardCounter(QList<CardItem *> selectedCards, int counterId, const QString &counterValue);
|
|
||||||
void actIncrementAllCardCounters(QList<CardItem *> cardsToUpdate);
|
|
||||||
void actAttach();
|
void actAttach();
|
||||||
void actUnattach(QList<CardItem *> selectedCards);
|
void actUnattach();
|
||||||
void actDrawArrow();
|
void actDrawArrow();
|
||||||
void actIncPT(QList<CardItem *> selectedCards, int deltaP, int deltaT);
|
void actIncPT(int deltaP, int deltaT);
|
||||||
void actResetPT(QList<CardItem *> selectedCards);
|
void actResetPT();
|
||||||
void actRequestSetPTDialog(QList<CardItem *> selectedCards);
|
void actSetPT();
|
||||||
void actSetPT(QList<CardItem *> selectedCards, const QString &pt);
|
void actIncP();
|
||||||
void actIncP(QList<CardItem *> selectedCards);
|
void actDecP();
|
||||||
void actDecP(QList<CardItem *> selectedCards);
|
void actIncT();
|
||||||
void actIncT(QList<CardItem *> selectedCards);
|
void actDecT();
|
||||||
void actDecT(QList<CardItem *> selectedCards);
|
void actIncPT();
|
||||||
void actIncPT(QList<CardItem *> selectedCards);
|
void actDecPT();
|
||||||
void actDecPT(QList<CardItem *> selectedCards);
|
void actFlowP();
|
||||||
void actFlowP(QList<CardItem *> selectedCards);
|
void actFlowT();
|
||||||
void actFlowT(QList<CardItem *> selectedCards);
|
|
||||||
|
|
||||||
void actReduceLifeByPower(QList<CardItem *> selectedCards);
|
void actReduceLifeByPower();
|
||||||
|
|
||||||
void actRequestSetAnnotationDialog(QList<CardItem *> selectedCards);
|
void actSetAnnotation();
|
||||||
void actSetAnnotation(QList<CardItem *> selectedCards, const QString &annotation);
|
void actReveal(QAction *action);
|
||||||
void actReveal(QList<CardItem *> selectedCards, QAction *action);
|
|
||||||
void actRevealHand(int revealToPlayerId);
|
void actRevealHand(int revealToPlayerId);
|
||||||
void actRevealRandomHandCard(int revealToPlayerId);
|
void actRevealRandomHandCard(int revealToPlayerId);
|
||||||
void actRevealLibrary(int revealToPlayerId);
|
void actRevealLibrary(int revealToPlayerId);
|
||||||
|
|
||||||
void actSortHand();
|
void actSortHand();
|
||||||
|
|
||||||
void cardMenuAction(QList<CardItem *> selectedCards, CardMenuActionType type);
|
void cardMenuAction();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerLogic *player;
|
PlayerLogic *player;
|
||||||
|
|
@ -235,19 +176,21 @@ private:
|
||||||
int movingCardsUntilCounter = 0;
|
int movingCardsUntilCounter = 0;
|
||||||
MoveTopCardsUntilOptions movingCardsUntilOptions;
|
MoveTopCardsUntilOptions movingCardsUntilOptions;
|
||||||
|
|
||||||
bool lastRelatedCreationSucceeded = false;
|
void moveTopCardsTo(const QString &targetZone, const QString &zoneDisplayName, bool faceDown);
|
||||||
|
void moveBottomCardsTo(const QString &targetZone, const QString &zoneDisplayName, bool faceDown);
|
||||||
|
|
||||||
void createCard(const CardItem *sourceCard,
|
void createCard(const CardItem *sourceCard,
|
||||||
const QString &dbCardName,
|
const QString &dbCardName,
|
||||||
CardRelationType attach = CardRelationType::DoesNotAttach,
|
CardRelationType attach = CardRelationType::DoesNotAttach,
|
||||||
bool persistent = false);
|
bool persistent = false);
|
||||||
|
bool createRelatedFromRelation(const CardItem *sourceCard, const CardRelation *cardRelation);
|
||||||
|
|
||||||
void playSelectedCards(QList<CardItem *> selectedCards, bool faceDown = false);
|
void playSelectedCards(bool faceDown = false);
|
||||||
|
|
||||||
void cmdSetTopCard(Command_MoveCard &cmd);
|
void cmdSetTopCard(Command_MoveCard &cmd);
|
||||||
void cmdSetBottomCard(Command_MoveCard &cmd);
|
void cmdSetBottomCard(Command_MoveCard &cmd);
|
||||||
|
|
||||||
void offsetCardCounter(QList<CardItem *> selectedCards, int counterId, int offset);
|
void offsetCardCounter(int counterId, int offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCKATRICE_PLAYER_ACTIONS_H
|
#endif // COCKATRICE_PLAYER_ACTIONS_H
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef COCKATRICE_PLAYER_AREA_H
|
#ifndef COCKATRICE_PLAYER_AREA_H
|
||||||
#define COCKATRICE_PLAYER_AREA_H
|
#define COCKATRICE_PLAYER_AREA_H
|
||||||
|
|
||||||
#include "../board/graphics_item_type.h"
|
#include "../../game_graphics/board/graphics_item_type.h"
|
||||||
#include "QGraphicsItem"
|
#include "QGraphicsItem"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue