Compare commits
96 Commits
1b9c8633c9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| da8a3c5398 | |||
|
|
143271adf9 | ||
| 1a07f944ca | |||
| 08b5ec6312 | |||
| 842e6faf24 | |||
|
|
222a09ee21 | ||
|
|
10a0be5fd0 | ||
|
|
4dc87e5f5b | ||
| cc33616663 | |||
| 90818d0bf1 | |||
| efac02216e | |||
| 054d229b97 | |||
| e66199d0dd | |||
| 80c510874f | |||
| 255a61cf56 | |||
| e5f840a873 | |||
| 3489613afc | |||
| 6d58b93477 | |||
| 1527ab0cb0 | |||
|
|
1836f53d7b | ||
|
|
1800174087 | ||
| 1fb3b39590 | |||
|
|
27ba44ad4b | ||
|
|
145abfe1ca | ||
| 00c783ffd7 | |||
|
|
7f88095a4b | ||
|
|
3dbc994dc5 | ||
|
|
a8a00d24ef | ||
|
|
a7e8325b26 | ||
|
|
85763485d3 | ||
|
|
dedc686e9e | ||
|
|
f69933c74d | ||
|
|
dafb588626 | ||
|
|
fe45a0255c | ||
| 935115ca65 | |||
|
|
6d9e50fb88 | ||
|
|
d146ae11f7 | ||
|
|
b05f971ec1 | ||
|
|
f8d7702fca | ||
| d02043bbdb | |||
|
|
53c535e127 | ||
|
|
c27e4a7f6f | ||
|
|
54c22beddc | ||
|
|
3eeeca34fc | ||
|
|
a3611cb9a7 | ||
|
|
63f6fca83f | ||
|
|
370dc2a2a2 | ||
|
|
f9dc62d148 | ||
|
|
7b8d5cb244 | ||
|
|
dfcbc63419 | ||
| e5a0a0adb0 | |||
|
|
8399f98d75 | ||
| 082899152f | |||
| 9175e54c69 | |||
| e70c89fe58 | |||
| 631799b479 | |||
| 3a2865f199 | |||
| a019ea406d | |||
| e673b3cb4d | |||
|
|
75a0789fb4 | ||
|
|
3cae93e5bf | ||
| 630d24f3c4 | |||
| a29c117b85 | |||
| aa8bac13ce | |||
|
|
6356e0f4ac | ||
| 5a96849108 | |||
|
|
40250ebeae | ||
| 7190e4faef | |||
| db37835aa4 | |||
| 0ece3a770e | |||
| ca22fb9f2f | |||
| fbf6e466c7 | |||
|
|
7ad0b69933 | ||
| 82a5660bc9 | |||
|
|
9a38d85e84 | ||
| 5b97b789a5 | |||
|
|
d33d80e875 | ||
| 1f588e6596 | |||
|
|
767dc018c6 | ||
| f82af3af32 | |||
| 69bb20d12a | |||
| 593939a082 | |||
|
|
4c7cc68024 | ||
| f76be158a0 | |||
|
|
a598218cf2 | ||
| abe163d09f | |||
|
|
1248288e98 | ||
| fcbebe802f | |||
| 755c3de295 | |||
|
|
f7a1725029 | ||
| e4f89afe94 | |||
| 6384a65cbb | |||
|
|
98c4d27741 | ||
|
|
baa371ac51 | ||
| 60204f3b04 | |||
| f891dea885 |
42
.gitea/workflows/sonar.yaml
Normal file
@@ -0,0 +1,42 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
name: SonarQube Scan
|
||||
jobs:
|
||||
sonarqube:
|
||||
name: SonarQube Trigger
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checking out
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
# Disabling shallow clone is recommended for improving relevancy of reporting
|
||||
fetch-depth: 0
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 21
|
||||
distribution: 'temurin'
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v3
|
||||
- name: Cache SonarQube packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.sonar/cache
|
||||
key: ${{ runner.os }}-sonar
|
||||
restore-keys: ${{ runner.os }}-sonar
|
||||
- name: Cache Gradle packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
|
||||
restore-keys: ${{ runner.os }}-gradle
|
||||
- name: SonarQube Scan
|
||||
env:
|
||||
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
|
||||
SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST }}
|
||||
run: ./gradlew sonar
|
||||
12
.gitignore
vendored
@@ -1,10 +1,11 @@
|
||||
*.iml
|
||||
.gradle
|
||||
**/build/
|
||||
build
|
||||
xcuserdata
|
||||
!src/**/build/
|
||||
local.properties
|
||||
.idea
|
||||
.idea/*
|
||||
!.idea/icon.svg
|
||||
.DS_Store
|
||||
captures
|
||||
.externalNativeBuild
|
||||
@@ -15,3 +16,10 @@ captures
|
||||
!*.xcodeproj/project.xcworkspace/
|
||||
!*.xcworkspace/contents.xcworkspacedata
|
||||
**/xcshareddata/WorkspaceSettings.xcsettings
|
||||
.kotlin
|
||||
|
||||
# Flatpak Build
|
||||
.flatpak-builder
|
||||
flatpak/_build
|
||||
flatpak/_repo
|
||||
flatpak/*.flatpak
|
||||
|
||||
34
.idea/icon.svg
generated
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="48" height="48" version="1.1" viewBox="0 0 48 48" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<filter id="filter31" x="-.03237" y="-.0332" width="1.077" height="1.079" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-color="rgb(0,0,0)" flood-opacity=".498" in="SourceGraphic" result="flood"/>
|
||||
<feGaussianBlur in="SourceGraphic" result="blur" stdDeviation="1.600000"/>
|
||||
<feOffset dx="1.500000" dy="1.500000" in="blur" result="offset"/>
|
||||
<feComposite in="flood" in2="offset" operator="in" result="comp1"/>
|
||||
<feComposite in="SourceGraphic" in2="comp1" result="comp2"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<rect x=".0004669" width="48" height="48" ry="0" fill="#64bb8b" stroke-width=".375"/><g transform="matrix(1.732 0 0 1.732 -4.058 -4.317)"><g transform="matrix(.2167 0 0 .2167 2.134 2.151)" filter="url(#filter31)">
|
||||
<path d="m48.37 30.91s-11.64-10.14-12.76-11.26c-1.13-1.13-3.94-3.19-3.38-4.69s9.971-5.159 16.52-6.57c61.25-13.19 87.04 66.99 69.07 103.2z" fill="#464c4f"/>
|
||||
<path d="m122.8 94.29c-0.5595 4.738-1.756 9.477-3.588 14.22l-60.44-79.85-12.88-19.56c4.272-1.136 8.53-1.823 12.77-2.06l6.657 26.2 8.494-24.95c3.945 0.9298 7.612 2.24 11 3.931l-12.95 27.01 4.08 1.48 17.2-23.38c2.031 1.525 3.874 3.085 5.53 4.68l-17.1 22.64 5.63 4.15 17.61-20.03c2.189 2.771 4.174 5.674 5.953 8.709l-17.15 15.97 3.38 5.56 18.56-12.08c0.8559 1.981 1.623 3.93 2.302 5.847l-18.55 10.95 4.65 5.21 16.18-8.818c0.5694 2.125 1.065 4.261 1.488 6.408l-17.46 8.82 2.96 6.69 15.9-5.81c0.193 2.146 0.3103 4.149 0.352 6.009l-13.65 5.012 3.24 8.09z" fill="#dfdfe0"/>
|
||||
<path d="m56.53 27.11c-9.516 0.6828-16.74 5.918-36.32 31.67 3.278 11.31 6.066 22.03 13.09 31.4 14.76 1.845 25.78-4.514 29.98-7.46-1.57 13.01-3.422 25.25-4.98 38.29-0.3775 3.16 58.74 1 60.58-0.84 4.007-4.007-2.527-67.62-40.1-85.32 0.7087-19.88-8.565-27.38-9.16-27.45-0.0978-0.01053-9.538 2.494-13.09 19.71z" fill="#2f2f2f"/>
|
||||
<g fill="#fff">
|
||||
<path d="m22.53 58.86 10.49-13.09c1.82 2.611-1.21 6.546-7.11 13.86z"/>
|
||||
<path d="m28.47 78.02c16.34-15.16 24.96-8.079 23.51 6.76-2.066 1.049-3.371 1.31-5.45 1.67 1.594-13.42-5.84-12.49-16.75-5.89z"/>
|
||||
<path d="m32.69 85.39c2.974-3.546 7.702-3.297 8.03 1.97-3.067 0.1987-4.479 0.1548-8.68 0z"/>
|
||||
<path d="m29.97 69.81s8.49-10.46 21.02-6.01 7.27 17.55 7.27 17.55l3.43-1.6c3.135-14.52-6.072-15.23-4.5-23.22 0.9881-3.903 1.347-10.12 5.957-11.45 3.973 0.1429 0.08547 6.597 0.7128 12.11 0.9848 8.655 7.527 7.781 3.8 29.32 12.49-6.333 23.42-14.89 33.78-24.22-0.5165-1.271-1.566-2.996-2.49-4.03-19.02 13.86-26.9 18.24-27.36 17.7-0.6832-0.805 7.523-23.24 12.01-34.26-1.74-1.554-2.447-1.879-5.58-3.05-1.498 2.874-3.624 12.45-8.11 11.55-1.88-1.36-1.83-7.65 1.41-11.97 1.73-2.31 3.8-3.05 4.08-9.43 0.4061-9.253-4.874-17.14-5.92-17.08-6.44 4.087-8.193 11.18-9.15 18.21l-2.02 0.75s-0.96 10.46-3.26 12.2-6.05 1.2-6.45-1.78c-0.52-3.91-0.33-7.93-0.33-7.93-3.254 1.182-4.495 3.709-5.2 6.94-0.6171 6.754-10.17 11.48-11.99 22.8z"/>
|
||||
<path d="m89.76 47.43s-5.33 11.83-5.16 12.44 10.23-7.46 10.23-7.46c-3.009-3.735-4.308-4.572-5.07-4.98z"/>
|
||||
</g>
|
||||
<path d="m54.23 53.58c0 2.8-1.08 5.58-4.22 5.3-2.34-0.21-4.27-2.5-4.27-5.3s1.9-5.07 4.25-5.07 4.24 2.27 4.24 5.07z" fill="#0b0b0b"/>
|
||||
<g fill="#fff">
|
||||
<path d="m63.71 101.5-0.84 7.67c28.97-11.09 43.7-32.11 44.98-34-0.5754-2.122-1.508-4.063-2.82-6.13-20.85 22.14-22.95 23.97-41.32 32.46z"/>
|
||||
<path d="m66.88 118.9c4.883-4.883 10.68 3.176 44.13-36.04 0.4748 2.343 1.097 3.836 1.47 5.78-8.404 12.68-15.72 22.85-30.84 30.62-4.826 0.2567-9.638 0.0546-14.76-0.36z"/>
|
||||
<path d="m114.5 99.82c-5.164 9.147-5.757 10.87-11.12 18.16 4.868-0.1117 9.091-0.4384 12.67-0.98 0.343-5.512-0.1736-11.24-1.55-17.18z"/>
|
||||
</g>
|
||||
<path d="m68.64 18.45c-2.435-0.2632-8.507 16.82-1.34 16.82 6.086 0 3.386-16.59 1.34-16.82z" fill="#454c50"/>
|
||||
<path d="m29.88 60c-2.89-2.64-7.41-3.57-9.67-1.22-2.25 2.35-3.57 5.35-5.44 7.32-7.025 6.534-13.12 15.92-8.17 25.53 3 4.97 9.1 8.26 16.61 5.63s10.51-6.48 10.79-9.29c1.036-10.4-6.915-9.81-5.44-13.33 0.75-1.79 6.76-9.66 1.32-14.64z" fill="#464c4f"/>
|
||||
<path d="m11.11 79.71c-0.1 1.56 1.92 1.27 2.63 2.72 0.7 1.45-0.94 4.27 0.89 4.6s4.18-3.28 3.05-6.71c-1.13-3.42-6.43-2.86-6.57-0.61z" fill="#303030"/>
|
||||
<path d="m14.23 97.64s5-2.44 7.25-4.55c2.19-2.06 4.32-4.55 4.83-5.35 0.52-0.8 1.6-2.25 2.53-1.6 0.94 0.66 0.52 1.83-0.09 2.72s-2.16 3.1-4.6 5.35c-2.11 1.95-3.14 2.44-4.69 3.28-1.13 0.61-2.21 0.7-2.21 0.7s-0.88 0.01-1.79-0.14c-0.35-0.05-1.23-0.41-1.23-0.41z" fill="#303030"/>
|
||||
</g></g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.7 KiB |
74
.run/Android.run.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Android" type="AndroidRunConfigurationType" factoryName="Android App">
|
||||
<module name="YAEP.android" />
|
||||
<option name="ANDROID_RUN_CONFIGURATION_SCHEMA_VERSION" value="1" />
|
||||
<option name="DEPLOY" value="true" />
|
||||
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
|
||||
<option name="DEPLOY_AS_INSTANT" value="false" />
|
||||
<option name="ARTIFACT_NAME" value="" />
|
||||
<option name="PM_INSTALL_OPTIONS" value="" />
|
||||
<option name="ALL_USERS" value="false" />
|
||||
<option name="ALWAYS_INSTALL_WITH_PM" value="false" />
|
||||
<option name="ALLOW_ASSUME_VERIFIED" value="false" />
|
||||
<option name="CLEAR_APP_STORAGE" value="false" />
|
||||
<option name="DYNAMIC_FEATURES_DISABLED_LIST" value="" />
|
||||
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
|
||||
<option name="MODE" value="default_activity" />
|
||||
<option name="RESTORE_ENABLED" value="false" />
|
||||
<option name="RESTORE_FILE" value="" />
|
||||
<option name="RESTORE_FRESH_INSTALL_ONLY" value="false" />
|
||||
<option name="CLEAR_LOGCAT" value="false" />
|
||||
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
|
||||
<option name="TARGET_SELECTION_MODE" value="DEVICE_AND_SNAPSHOT_COMBO_BOX" />
|
||||
<option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
|
||||
<option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
|
||||
<option name="DEBUGGER_TYPE" value="Java" />
|
||||
<Auto>
|
||||
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||
<option name="SHOW_STATIC_VARS" value="true" />
|
||||
<option name="WORKING_DIR" value="" />
|
||||
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
|
||||
<option name="DEBUG_SANDBOX_SDK" value="false" />
|
||||
</Auto>
|
||||
<Hybrid>
|
||||
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||
<option name="SHOW_STATIC_VARS" value="true" />
|
||||
<option name="WORKING_DIR" value="" />
|
||||
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
|
||||
<option name="DEBUG_SANDBOX_SDK" value="false" />
|
||||
</Hybrid>
|
||||
<Java>
|
||||
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
|
||||
<option name="DEBUG_SANDBOX_SDK" value="false" />
|
||||
</Java>
|
||||
<Native>
|
||||
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||
<option name="SHOW_STATIC_VARS" value="true" />
|
||||
<option name="WORKING_DIR" value="" />
|
||||
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
|
||||
<option name="DEBUG_SANDBOX_SDK" value="false" />
|
||||
</Native>
|
||||
<Profilers>
|
||||
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
|
||||
<option name="STARTUP_PROFILING_ENABLED" value="false" />
|
||||
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
|
||||
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Java/Kotlin Method Sample (legacy)" />
|
||||
<option name="STARTUP_NATIVE_MEMORY_PROFILING_ENABLED" value="false" />
|
||||
<option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" />
|
||||
</Profilers>
|
||||
<option name="DEEP_LINK" value="" />
|
||||
<option name="ACTIVITY" value="" />
|
||||
<option name="ACTIVITY_CLASS" value="" />
|
||||
<option name="SEARCH_ACTIVITY_IN_GLOBAL_SCOPE" value="false" />
|
||||
<option name="SKIP_ACTIVITY_VALIDATION" value="false" />
|
||||
<method v="2">
|
||||
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
24
.run/Desktop.run.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Desktop" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/desktop" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="run" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||
<DebugAllEnabled>false</DebugAllEnabled>
|
||||
<RunAsTest>false</RunAsTest>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
1
.tool-versions
Normal file
@@ -0,0 +1 @@
|
||||
java temurin-21
|
||||
674
LICENSE.txt
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
64
android/build.gradle.kts
Normal file
@@ -0,0 +1,64 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.kover)
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.compose.compiler)
|
||||
alias(libs.plugins.compose)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "ch.dissem.yaep"
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "ch.dissem.yaep"
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
versionCode = libs.versions.app.version.code.get().toInt()
|
||||
versionName = libs.versions.app.version.name.get()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(compose.components.resources)
|
||||
implementation(compose.runtime)
|
||||
// implementation(compose.foundation)
|
||||
implementation(compose.material3)
|
||||
implementation(compose.ui)
|
||||
implementation(compose.components.resources)
|
||||
implementation(libs.androidx.activity.compose)
|
||||
// implementation(libs.compose.ui.text.googlefonts)
|
||||
implementation(projects.commonUI)
|
||||
// implementation(compose.components.uiToolingPreview)
|
||||
implementation(libs.androidx.tooling.preview)
|
||||
|
||||
testImplementation(libs.kotlin.test)
|
||||
testImplementation(libs.atrium)
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.toVersion(libs.versions.jdk.get())
|
||||
targetCompatibility = JavaVersion.toVersion(libs.versions.jdk.get())
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
}
|
||||
|
||||
debug {
|
||||
enableAndroidTestCoverage = true
|
||||
enableUnitTestCoverage = true
|
||||
}
|
||||
}
|
||||
|
||||
packaging {
|
||||
resources {
|
||||
merges += "/META-INF/{AL2.0,LGPL2.1}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.core.ktx)
|
||||
debugImplementation(libs.androidx.tooling)
|
||||
}
|
||||
79
android/ic_launcher_monochrome.svg
Normal file
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg version="1.1" id="Layer_2" x="0px" y="0px" viewBox="0 0 32 32" xml:space="preserve"
|
||||
sodipodi:docname="ic_launcher_monochrome.svg" inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
|
||||
width="32" height="32" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg"><defs
|
||||
id="defs16"><filter
|
||||
style="color-interpolation-filters:sRGB"
|
||||
inkscape:label="Drop Shadow"
|
||||
id="filter31"
|
||||
x="-0.55904404"
|
||||
y="-0.85795969"
|
||||
width="2.3364646"
|
||||
height="3.0510599"><feFlood
|
||||
result="flood"
|
||||
in="SourceGraphic"
|
||||
flood-opacity="0.498039"
|
||||
flood-color="rgb(0,0,0)"
|
||||
id="feFlood30" /><feGaussianBlur
|
||||
result="blur"
|
||||
in="SourceGraphic"
|
||||
stdDeviation="1.600000"
|
||||
id="feGaussianBlur30" /><feOffset
|
||||
result="offset"
|
||||
in="blur"
|
||||
dx="1.500000"
|
||||
dy="1.500000"
|
||||
id="feOffset30" /><feComposite
|
||||
result="comp1"
|
||||
operator="in"
|
||||
in="flood"
|
||||
in2="offset"
|
||||
id="feComposite30" /><feComposite
|
||||
result="comp2"
|
||||
operator="over"
|
||||
in="SourceGraphic"
|
||||
in2="comp1"
|
||||
id="feComposite31" /></filter></defs><sodipodi:namedview
|
||||
id="namedview16"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:zoom="20.237396"
|
||||
inkscape:cx="14.008719"
|
||||
inkscape:cy="17.442956"
|
||||
inkscape:window-width="1854"
|
||||
inkscape:window-height="1011"
|
||||
inkscape:window-x="66"
|
||||
inkscape:window-y="32"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_2"
|
||||
showgrid="false" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<path
|
||||
id="path297"
|
||||
style="opacity:1;fill:#464c4f;fill-opacity:1"
|
||||
d="M 32.232058,14.964389 C 30.238754,16.211328 42.062733,25.392416 47.29124,29.951475 37.005353,37.443038 30.603699,44.616915 14.76665,66.098921 -11.12197,89.90536 17.767543,110.29771 33.376592,90.16117 48.224417,92.012172 59.075721,85.662685 63.278667,82.717193 L 58.304,121.00951 c -0.40996,3.15565 58.7391,1.00197 60.57919,-0.83812 1.01534,-1.01534 1.32985,-5.89735 0.65788,-12.85122 C 131.90095,74.334856 113.9841,14.197679 69.983654,7.8899074 57.797171,6.1428898 42.788604,8.6238343 32.232058,14.964389 Z m 26.910065,-7.011397 1.856489,7.299783 c -1.563222,2.56175 -3.006137,5.94218 -4.07346,10.390927 L 46.606323,9.9716975 Z M 74.021065,9.1786346 84.826546,13.035804 78.391923,26.463801 C 77.514228,19.290295 75.29722,14.385562 73.273062,11.377582 Z m -4.542088,2.5414064 c 5.989219,5.949073 9.158705,19.862777 1.838464,26.513534 -3.239958,4.319944 -3.285856,10.608054 -1.405884,11.96804 4.48619,0.896797 6.612988,-8.679676 8.11087,-11.553484 l 5.578477,3.055094 -12.013101,34.25491 c 0,0 8.341872,-3.843438 27.36067,-17.699722 l 2.487337,4.028399 C 91.073299,71.618772 80.152326,80.178589 67.658537,86.511278 71.958134,62.317667 62.001283,65.922421 64.21502,51.989151 c 2.144878,-13.499869 -5.964945,-6.613243 -7.028518,4.538943 -0.773232,8.107789 7.640966,8.707857 4.50604,23.224126 L 58.25894,81.347357 C 64.184703,66.761222 46.911937,54.864116 31.628248,68.144663 32.23809,66.093848 32.408197,63.876807 31.339862,61.881268 33.570654,51.344734 42.476577,46.642449 43.073588,40.108087 c 0.704837,-3.231403 1.945855,-5.75734 5.199969,-6.9393 0.217232,6.214406 -0.770364,10.526805 3.871414,10.700538 5.044818,0.188819 5.030749,-6.885794 6.168041,-13.187872 l 2.018706,-0.748002 c 0.956805,-7.034544 2.707513,-14.126477 9.147259,-18.21341 z m 23.521524,6.335491 5.434284,4.59616 -12.436668,16.456055 -5.902912,-3.496687 z m -24.359647,0.396531 c -2.435024,-0.263247 -8.510048,16.816538 -1.3428,16.816538 6.086494,0 3.388843,-16.590989 1.3428,-16.816538 z m 35.823016,10.832518 5.83982,8.552463 -12.860234,11.986064 -5.686621,-6.083153 z M 33.016108,45.767672 c 1.686259,2.419167 -0.908892,6.100412 -5.975007,12.427656 l -3.37953,-0.748002 z m 82.000902,1.3428 2.25302,5.740694 -12.58988,7.434965 -2.84781,-4.59616 z m -25.260857,0.315423 5.0738,4.983679 -10.228708,7.462001 z m -39.770301,1.081449 c -2.34999,0 -4.244689,2.273815 -4.244689,5.0738 0,2.799985 1.931735,5.089107 4.271725,5.299102 3.139985,0.28 4.217653,-2.499117 4.217653,-5.299102 0,-2.799985 -1.894699,-5.0738 -4.244689,-5.0738 z m 69.528188,11.553485 1.45995,6.29043 -10.61623,5.362187 -2.43326,-5.335151 z m -14.48241,8.985042 2.82078,6.137225 C 106.571,77.074409 91.845279,98.082717 62.873124,109.17666 l 0.838123,-7.66928 C 82.078479,93.018988 84.184176,91.189804 105.03163,69.045871 Z M 51.977521,84.780959 46.534226,86.448194 C 48.02724,73.876168 41.551577,73.97771 31.76343,79.454821 l -2.325117,-2.244007 c 11.409795,-11.110613 24.277243,-8.710083 22.539208,7.570145 z m 70.375319,-8.903933 0.34246,5.893899 -7.71434,2.829793 -1.74834,-5.389223 z M 15.155442,87.033979 c -2.479251,0.360251 -0.796714,-3.118984 -1.416169,-4.605172 -0.605192,-1.451969 -3.8757689,-1.325968 -2.268777,-3.568065 1.073467,-1.497716 5.027098,-1.074024 6.1892,1.437988 1.0646,2.30125 -0.535009,6.449105 -2.504254,6.735249 z m 95.851188,-4.172592 1.46897,5.776742 C 104.0721,101.32122 96.751314,111.48858 81.636271,119.26117 l -14.752772,-0.36048 c 4.883266,-4.88331 10.678678,3.17665 44.123131,-36.039303 z m -70.285195,4.497027 h -6.686962 l -0.08111,-3.073119 c 4.151301,-2.286005 5.51265,0.487638 6.768072,3.073119 z m 81.388075,6.263394 -2.84781,11.850882 -1.84748,-11.355218 z m -7.65125,6.20031 c 1.37637,5.941512 1.89312,11.665282 1.55008,17.177022 l -12.67098,0.98232 z"
|
||||
sodipodi:nodetypes="cccccsscsccccccccccccccccccccssccccccscccccccccscccccccccccccccccccsscssccccccccccccccccccccsssssccccccccccccccccc"
|
||||
transform="matrix(0.21672304,0,0,0.21672304,2.1337111,2.1514034)" /></svg>
|
||||
|
After Width: | Height: | Size: 5.8 KiB |
@@ -5,13 +5,13 @@
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:usesCleartextTraffic="false"
|
||||
android:theme="@android:style/Theme.Material.Light.NoActionBar">
|
||||
<activity
|
||||
android:exported="true"
|
||||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode"
|
||||
android:name=".MainActivity">
|
||||
android:name="ch.dissem.yaep.android.MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
BIN
android/src/main/ic_launcher-playstore.png
Normal file
|
After Width: | Height: | Size: 50 KiB |
@@ -0,0 +1,90 @@
|
||||
package ch.dissem.yaep.android
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.CenterAlignedTopAppBar
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ch.dissem.yaep.domain.generateGame
|
||||
import ch.dissem.yaep.ui.common.App
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import yaep.commonui.generated.resources.action_restart
|
||||
import yaep.commonui.generated.resources.app_name
|
||||
import yaep.commonui.generated.resources.restart
|
||||
import yaep.commonui.generated.resources.Res as CRes
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContent {
|
||||
var game by remember { mutableStateOf(generateGame()) }
|
||||
var resetCluesBeacon by remember { mutableStateOf(Any()) }
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
CenterAlignedTopAppBar(
|
||||
title = {
|
||||
Text(text = stringResource(CRes.string.app_name))
|
||||
},
|
||||
navigationIcon = { },
|
||||
actions = {
|
||||
IconButton(
|
||||
onClick = {
|
||||
do {
|
||||
// continue
|
||||
} while (game.grid.undo())
|
||||
resetCluesBeacon = Any()
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(CRes.drawable.action_restart),
|
||||
contentDescription = stringResource(CRes.string.restart)
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
) { insets ->
|
||||
App(
|
||||
modifier = Modifier.padding(insets),
|
||||
spacing = 4.dp,
|
||||
selectDirectly = false,
|
||||
game = game,
|
||||
onNewGame = { game = generateGame() },
|
||||
resetCluesBeacon = resetCluesBeacon
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun AppAndroidPreview() {
|
||||
var game by remember { mutableStateOf(generateGame()) }
|
||||
var resetCluesBeacon by remember { mutableStateOf(Any()) }
|
||||
|
||||
App(
|
||||
game = game,
|
||||
spacing = 4.dp,
|
||||
selectDirectly = false,
|
||||
onNewGame = { game = generateGame() },
|
||||
resetCluesBeacon = resetCluesBeacon
|
||||
)
|
||||
}
|
||||
59
android/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="128"
|
||||
android:viewportHeight="128">
|
||||
<group android:scaleX="0.6072"
|
||||
android:scaleY="0.6072"
|
||||
android:translateX="25.1392"
|
||||
android:translateY="24.419556">
|
||||
<path
|
||||
android:pathData="M48.37,30.91c0,0 -11.64,-10.14 -12.76,-11.26c-1.13,-1.13 -3.94,-3.19 -3.38,-4.69c0.56,-1.5 9.95,-5.26 16.52,-6.57s20.23,-3.38 32.43,2.25s22.01,13.14 30.64,27.03s10.91,33.24 11.45,43.92c0.56,11.23 -3.63,27.24 -3.63,27.24l-1.82,2.79L48.37,30.91z"
|
||||
android:fillColor="#464C4F"/>
|
||||
<path
|
||||
android:pathData="M122.49,94.27c-0.74,8.26 -2.86,14.73 -2.86,14.73l-1.5,3.19L48.67,31.47l10.11,-2.82L45.9,9.09c2.43,-1.02 7.29,-1.97 12.78,-1.97l6.65,26.11l8.55,-25.09c3.7,0.53 9.54,3.27 10.88,4.26L71.88,39.22l4.08,1.48l17.1,-23.3c2.39,1.23 3.98,2.39 5.84,4.5L81.59,44.64l5.63,4.15l17.95,-20.41c2.5,2.36 4.29,4.8 6.16,8.41l-17.7,16.65L97.01,59l19.22,-12.67c1.16,2.32 1.79,3.84 2.22,6.02L99.33,63.71l4.65,5.21l16.61,-9.08c0.81,2.18 1.27,4.01 1.37,6.55l-17.77,8.94l2.96,6.69l15.94,-5.77c0.49,2.39 0.53,3.7 0.21,6.05l-13.55,4.93l3.24,8.09L122.49,94.27z"
|
||||
android:fillColor="#DFDFE0"/>
|
||||
<path
|
||||
android:pathData="M56.53,27.11c0,0 -6.48,0.28 -10.56,3.38S34.01,41.61 30.21,46.11s-10,12.67 -10,12.67l8.02,24.64l5.07,6.76c0,0 9.15,1.27 17.03,-1.27c7.88,-2.53 12.95,-6.19 12.95,-6.19s-1.55,9.85 -2.82,18.44c-1.27,8.59 -2.86,19.01 -2.16,19.85c0.7,0.84 15.67,1.69 30.88,1.27s29,-1.41 29.7,-2.11c0.7,-0.7 2.82,-20.27 -6.76,-45.19S86.38,38.93 84.83,37.95c-1.55,-0.99 -6.05,-3.1 -6.05,-3.1s0.56,-12.11 -2.82,-18.16S71.8,7.64 69.62,7.4c-2.6,-0.28 -7.67,6.26 -9.43,9.01C57.97,19.87 56.53,27.11 56.53,27.11z"
|
||||
android:fillColor="#2F2F2F"/>
|
||||
<path
|
||||
android:pathData="M22.53,58.86l10.49,-13.09c0,0 1.62,2.04 -1.13,6.05c-1.83,2.68 -5.98,7.81 -5.98,7.81L22.53,58.86z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
<path
|
||||
android:pathData="M28.47,78.02c0,0 10.3,-9.82 16.89,-8.54c8.26,1.6 6.62,15.3 6.62,15.3s-1.36,0.7 -2.63,1.08c-0.89,0.26 -2.82,0.59 -2.82,0.59s0.8,-8.52 -2.67,-10.02c-3.47,-1.5 -7.23,0.19 -10.14,1.88c-2.91,1.69 -3.94,2.25 -3.94,2.25L28.47,78.02z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
<path
|
||||
android:pathData="M32.69,85.39c0,0 2.25,-2.82 5.07,-2.35c2.82,0.47 2.96,4.32 2.96,4.32s-2.11,0.14 -3.52,0.14s-5.16,-0.14 -5.16,-0.14L32.69,85.39z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
<path
|
||||
android:pathData="M28.47,64.04l1.5,5.77c0,0 8.49,-10.46 21.02,-6.01s7.27,17.55 7.27,17.55l3.43,-1.6c0,0 1.32,-5.78 0.19,-9.85c-1.5,-5.4 -5.77,-7.88 -4.69,-13.37s2.06,-7.84 2.91,-9.29c0.48,-0.83 2.91,-3.43 4.25,-1.41c2.23,3.36 -1.2,5.12 -0.49,11.36s2.61,5.46 4.69,12.76c0.84,2.96 -0.14,9.1 -0.19,10.98c-0.05,1.88 -0.7,5.58 -0.7,5.58s12.2,-6.89 16.14,-9.67c7.37,-5.19 17.64,-14.55 17.64,-14.55s-0.44,-1.11 -1.27,-2.39c-0.63,-0.99 -1.22,-1.64 -1.22,-1.64s-7.53,5.49 -11.1,7.98c-3.57,2.49 -12.88,8.26 -13.68,8.73s-2.2,1.41 -2.58,0.99c-0.63,-0.7 1.29,-5.56 2.18,-8.38c0.89,-2.82 4.95,-13.21 6.31,-16.96c1.36,-3.75 3.52,-8.92 3.52,-8.92s-1.45,-1.31 -2.44,-1.78s-3.14,-1.27 -3.14,-1.27s-2.44,6.19 -3.28,7.51c-0.84,1.31 -2.96,5.4 -4.83,4.04c-1.88,-1.36 -1.83,-7.65 1.41,-11.97c1.73,-2.31 3.8,-3.05 4.08,-9.43s-1.85,-10.51 -2.82,-12.67c-1.08,-2.42 -2.16,-4.46 -3.1,-4.41c-0.94,0.05 -4.15,3.85 -5.56,5.96c-1.27,1.9 -2.42,3.71 -2.98,7.79c-0.56,4.08 -0.61,4.46 -0.61,4.46l-2.02,0.75c0,0 -0.96,10.46 -3.26,12.2c-2.3,1.74 -6.05,1.2 -6.45,-1.78c-0.52,-3.91 -0.33,-7.93 -0.33,-7.93s-1.5,0.52 -2.53,1.5c-1.03,0.99 -1.83,1.22 -2.67,5.44c-0.84,4.22 -0.91,9.58 -2.82,12.72c-2.11,3.47 -3.94,6.34 -7.32,8.82S28.47,64.04 28.47,64.04z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
<path
|
||||
android:pathData="M89.76,47.43c0,0 -5.33,11.83 -5.16,12.44s10.23,-7.46 10.23,-7.46s-0.97,-1.21 -2.25,-2.63C91.05,48.09 89.76,47.43 89.76,47.43z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
<path
|
||||
android:pathData="M54.23,53.58c0,2.8 -1.08,5.58 -4.22,5.3c-2.34,-0.21 -4.27,-2.5 -4.27,-5.3c0,-2.8 1.9,-5.07 4.25,-5.07S54.23,50.78 54.23,53.58z"
|
||||
android:fillColor="#0B0B0B"/>
|
||||
<path
|
||||
android:pathData="M63.71,101.51l-0.84,7.67c0,0 11.76,-4.43 19.29,-9.36c7.53,-4.93 19.36,-17.25 21.89,-19.99s3.8,-4.65 3.8,-4.65s-0.46,-1.74 -1.2,-3.24c-0.73,-1.5 -1.62,-2.89 -1.62,-2.89S90.39,84.62 88.35,86.24c-2.04,1.62 -7.81,6.76 -12.18,9.15C71.81,97.78 63.71,101.51 63.71,101.51z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
<path
|
||||
android:pathData="M66.88,118.9c0.78,-0.78 14.15,-5.84 19.22,-10.35c1.79,-1.59 13.23,-12.32 17.03,-16.61s7.88,-9.08 7.88,-9.08s0.28,1.41 0.77,3.03c0.48,1.57 0.7,2.75 0.7,2.75s-4.79,7.25 -7.32,10.49c-2.53,3.24 -8.52,9.71 -10,11.12c-1.48,1.41 -2.96,3.1 -6.9,5.49c-1.4,0.85 -6.62,3.52 -6.62,3.52s-4.15,0.07 -6.97,0.14C73.42,119.42 66.53,119.25 66.88,118.9z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
<path
|
||||
android:pathData="M114.46,99.82c0,0 -4.15,8.02 -5.56,10.28c-1.41,2.25 -5.56,7.88 -5.56,7.88s5.7,-0.21 7.67,-0.28s5,-0.35 5,-0.7c0,-0.8 -0.56,-9.08 -0.63,-10.91S115.03,98.77 114.46,99.82z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
<path
|
||||
android:pathData="M68.64,18.45c-1.48,-0.16 -3.52,4.86 -3.94,7.11c-1.27,6.69 -1.06,9.71 2.6,9.71c4.05,0 3.73,-7.32 3.73,-8.94C71.03,24.72 69.91,18.59 68.64,18.45z"
|
||||
android:fillColor="#454C50"/>
|
||||
<path
|
||||
android:pathData="M29.88,60c-2.89,-2.64 -7.41,-3.57 -9.67,-1.22c-2.25,2.35 -3.57,5.35 -5.44,7.32c-1.88,1.97 -5.82,5.35 -7.98,9.95S3.6,86.66 6.6,91.63s9.1,8.26 16.61,5.63c7.51,-2.63 10.51,-6.48 10.79,-9.29s0,-6.95 -2.91,-9.29c-1.18,-0.95 -3.28,-2.25 -2.53,-4.04S35.32,64.98 29.88,60z"
|
||||
android:fillColor="#464C4F"/>
|
||||
<path
|
||||
android:pathData="M11.11,79.71c-0.1,1.56 1.92,1.27 2.63,2.72c0.7,1.45 -0.94,4.27 0.89,4.6c1.83,0.33 4.18,-3.28 3.05,-6.71C16.55,76.9 11.25,77.46 11.11,79.71z"
|
||||
android:fillColor="#303030"/>
|
||||
<path
|
||||
android:pathData="M14.23,97.64c0,0 5,-2.44 7.25,-4.55c2.19,-2.06 4.32,-4.55 4.83,-5.35c0.52,-0.8 1.6,-2.25 2.53,-1.6c0.94,0.66 0.52,1.83 -0.09,2.72c-0.61,0.89 -2.16,3.1 -4.6,5.35c-2.11,1.95 -3.14,2.44 -4.69,3.28c-1.13,0.61 -2.21,0.7 -2.21,0.7s-0.88,0.01 -1.79,-0.14C15.11,98 14.23,97.64 14.23,97.64z"
|
||||
android:fillColor="#303030"/>
|
||||
</group>
|
||||
</vector>
|
||||
9
android/src/main/res/drawable/ic_launcher_monochrome.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="32dp"
|
||||
android:height="32dp"
|
||||
android:viewportWidth="32"
|
||||
android:viewportHeight="32">
|
||||
<path
|
||||
android:pathData="M9.1,5.4C8.7,5.7 11.3,7.7 12.4,8.6 10.2,10.3 8.8,11.8 5.3,16.5 -0.3,21.6 6,26.1 9.4,21.7 12.6,22.1 14.9,20.7 15.8,20.1L14.8,28.4c-0.1,0.7 12.7,0.2 13.1,-0.2 0.2,-0.2 0.3,-1.3 0.1,-2.8C30.7,18.3 26.8,5.2 17.3,3.9 14.7,3.5 11.4,4 9.1,5.4ZM15,3.9 L15.4,5.5c-0.3,0.6 -0.7,1.3 -0.9,2.3L12.2,4.3ZM18.2,4.1 L20.5,5 19.1,7.9C18.9,6.3 18.5,5.3 18,4.6ZM17.2,4.7c1.3,1.3 2,4.3 0.4,5.7 -0.7,0.9 -0.7,2.3 -0.3,2.6 1,0.2 1.4,-1.9 1.8,-2.5l1.2,0.7 -2.6,7.4c0,0 1.8,-0.8 5.9,-3.8l0.5,0.9C21.9,17.7 19.5,19.5 16.8,20.9 17.7,15.7 15.6,16.4 16.1,13.4c0.5,-2.9 -1.3,-1.4 -1.5,1 -0.2,1.8 1.7,1.9 1,5L14.8,19.8C16,16.6 12.3,14 9,16.9 9.1,16.5 9.2,16 8.9,15.6 9.4,13.3 11.3,12.3 11.5,10.8c0.2,-0.7 0.4,-1.2 1.1,-1.5 0,1.3 -0.2,2.3 0.8,2.3 1.1,0 1.1,-1.5 1.3,-2.9l0.4,-0.2c0.2,-1.5 0.6,-3.1 2,-3.9zM22.3,6.1 L23.5,7.1 20.8,10.6 19.5,9.9zM17,6.2c-0.5,-0.1 -1.8,3.6 -0.3,3.6 1.3,0 0.7,-3.6 0.3,-3.6zM24.8,8.5 L26,10.4 23.3,12.9 22,11.6zM9.3,12.1c0.4,0.5 -0.2,1.3 -1.3,2.7l-0.7,-0.2zM27.1,12.4 L27.5,13.6 24.8,15.2 24.2,14.2zM21.6,12.4 L22.7,13.5 20.5,15.1zM13,12.7c-0.5,0 -0.9,0.5 -0.9,1.1 0,0.6 0.4,1.1 0.9,1.1 0.7,0.1 0.9,-0.5 0.9,-1.1 0,-0.6 -0.4,-1.1 -0.9,-1.1zM28,15.2 L28.4,16.5 26.1,17.7 25.5,16.5zM24.9,17.1 L25.5,18.4C25.2,18.9 22,23.4 15.8,25.8l0.2,-1.7C19.9,22.3 20.4,21.9 24.9,17.1ZM13.4,20.5 L12.2,20.9C12.5,18.2 11.1,18.2 9,19.4l-0.5,-0.5c2.5,-2.4 5.3,-1.9 4.9,1.6zM28.7,18.6 L28.7,19.9 27.1,20.5 26.7,19.3zM5.4,21c-0.5,0.1 -0.2,-0.7 -0.3,-1 -0.1,-0.3 -0.8,-0.3 -0.5,-0.8 0.2,-0.3 1.1,-0.2 1.3,0.3 0.2,0.5 -0.1,1.4 -0.5,1.5zM26.2,20.1 L26.5,21.4C24.7,24.1 23.1,26.3 19.8,28l-3.2,-0.1c1.1,-1.1 2.3,0.7 9.6,-7.8zM11,21.1l-1.4,0l-0,-0.7c0.9,-0.5 1.2,0.1 1.5,0.7zM28.6,22.4 L28,25 27.6,22.5zM26.9,23.8c0.3,1.3 0.4,2.5 0.3,3.7l-2.7,0.2z"
|
||||
android:fillColor="#464c4f"/>
|
||||
</vector>
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
<monochrome android:drawable="@drawable/ic_launcher_monochrome"/>
|
||||
</adaptive-icon>
|
||||
4
android/src/main/res/values/ic_launcher_background.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#64BB8B</color>
|
||||
</resources>
|
||||
12
android/src/test/kotlin/ch/dissem/yaep/android/DummyTest.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
package ch.dissem.yaep.android
|
||||
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
|
||||
import ch.tutteli.atrium.api.verbs.expect
|
||||
import kotlin.test.Test
|
||||
|
||||
class DummyTest {
|
||||
@Test
|
||||
fun `ensure some test is run`() {
|
||||
expect(true).toEqual(true)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,73 @@
|
||||
import com.android.build.gradle.internal.lint.AndroidLintTask
|
||||
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
|
||||
import org.sonarqube.gradle.SonarTask
|
||||
|
||||
plugins {
|
||||
// this is necessary to avoid the plugins to be loaded multiple times
|
||||
// in each subproject's classloader
|
||||
alias(libs.plugins.androidApplication) apply false
|
||||
alias(libs.plugins.androidLibrary) apply false
|
||||
alias(libs.plugins.jetbrainsCompose) apply false
|
||||
alias(libs.plugins.kotlinMultiplatform) apply false
|
||||
alias(libs.plugins.versions)
|
||||
alias(libs.plugins.sonarqube)
|
||||
alias(libs.plugins.kotlin.kover)
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.android.library) apply false
|
||||
alias(libs.plugins.compose) apply false
|
||||
alias(libs.plugins.compose.compiler) apply false
|
||||
alias(libs.plugins.kotlin.multiplatform) apply false
|
||||
alias(libs.plugins.kotlin.jvm) apply false
|
||||
alias(libs.plugins.kotlin.android) apply false
|
||||
}
|
||||
|
||||
sonar {
|
||||
properties {
|
||||
property("sonar.projectKey", "YAEP")
|
||||
property("sonar.projectName", "YAEP")
|
||||
|
||||
property(
|
||||
"sonar.coverage.jacoco.xmlReportPaths",
|
||||
"${layout.buildDirectory.asFile.get()}/reports/kover/report.xml"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<SonarTask>().configureEach {
|
||||
dependsOn(
|
||||
subprojects
|
||||
.flatMap { it.tasks.withType<AndroidLintTask>() }
|
||||
.filter { it.variantName != "release" }
|
||||
)
|
||||
dependsOn("koverXmlReport")
|
||||
}
|
||||
|
||||
tasks.withType<KotlinJvmCompile>().configureEach {
|
||||
compilerOptions {
|
||||
jvmTarget.set(JvmTarget.fromTarget(libs.versions.jdk.get()))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<DependencyUpdatesTask> {
|
||||
rejectVersionIf {
|
||||
isNonStable(candidate.version) && !isNonStable(currentVersion)
|
||||
}
|
||||
}
|
||||
|
||||
fun isNonStable(version: String): Boolean {
|
||||
return version.contains("dev", ignoreCase = true)
|
||||
|| version.contains("alpha", ignoreCase = true)
|
||||
|| version.contains("beta", ignoreCase = true)
|
||||
|| version.contains("RC", ignoreCase = true)
|
||||
}
|
||||
|
||||
subprojects {
|
||||
tasks.withType<Test> {
|
||||
testLogging {
|
||||
events("passed", "skipped", "failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
kover(projects.domain)
|
||||
kover(projects.commonUI)
|
||||
kover(projects.desktop)
|
||||
kover(projects.android)
|
||||
}
|
||||
82
commonUI/build.gradle.kts
Normal file
@@ -0,0 +1,82 @@
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.kover)
|
||||
alias(libs.plugins.kotlin.multiplatform)
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.compose)
|
||||
alias(libs.plugins.compose.compiler)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(libs.versions.jdk.get().toInt())
|
||||
|
||||
jvm()
|
||||
androidTarget {
|
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||
instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test)
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain.dependencies {
|
||||
api(projects.domain)
|
||||
|
||||
implementation(compose.components.resources)
|
||||
implementation(compose.runtime)
|
||||
implementation(compose.foundation)
|
||||
implementation(compose.ui)
|
||||
implementation(compose.components.uiToolingPreview)
|
||||
|
||||
implementation(compose.material3)
|
||||
|
||||
implementation(libs.bundles.logging)
|
||||
}
|
||||
|
||||
commonTest.dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
implementation(libs.atrium)
|
||||
|
||||
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
|
||||
implementation(compose.uiTest)
|
||||
}
|
||||
|
||||
jvmTest.dependencies {
|
||||
implementation(compose.desktop.currentOs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "ch.dissem.yaep.common.ui"
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.compose.foundation)
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
compose = true
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
getByName("test") {
|
||||
resources.srcDirs("src/commonTest/resources")
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
enableAndroidTestCoverage = true
|
||||
enableUnitTestCoverage = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compose.resources {
|
||||
publicResClass = true
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.FUNCTION])
|
||||
actual annotation class IgnoreAndroidUnitTest actual constructor()
|
||||
@@ -0,0 +1,15 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import ch.dissem.yaep.domain.Game
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
private val log = KotlinLogging.logger {}
|
||||
|
||||
actual fun CoroutineScope.logGame(game: Game, dispatcher: CoroutineContext) {
|
||||
launch(dispatcher) {
|
||||
log.debug { "Game: $game" }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
actual fun Modifier.onPointerAction(
|
||||
primary: () -> Unit,
|
||||
secondary: () -> Unit
|
||||
): Modifier {
|
||||
return this
|
||||
.combinedClickable(
|
||||
onClick = primary,
|
||||
onLongClick = secondary
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
actual typealias IgnoreAndroidUnitTest = org.junit.Ignore
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M360,840L303,784L367,720L360,720Q243,720 161.5,638.5Q80,557 80,440Q80,323 161.5,241.5Q243,160 360,160L600,160Q717,160 798.5,241.5Q880,323 880,440Q880,557 798.5,638.5Q717,720 600,720L600,640Q683,640 741.5,581.5Q800,523 800,440Q800,357 741.5,298.5Q683,240 600,240L360,240Q277,240 218.5,298.5Q160,357 160,440Q160,523 218.5,582.5Q277,642 360,648L376,648L304,576L360,520L520,680L360,840Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#fff"
|
||||
android:pathData="M480,880Q447,880 423.5,856.5Q400,833 400,800L560,800Q560,833 536.5,856.5Q513,880 480,880ZM320,760L320,680L640,680L640,760L320,760ZM330,640Q261,599 220.5,530Q180,461 180,380Q180,255 267.5,167.5Q355,80 480,80Q605,80 692.5,167.5Q780,255 780,380Q780,461 739.5,530Q699,599 630,640L330,640ZM354,560L606,560Q651,528 675.5,481Q700,434 700,380Q700,288 636,224Q572,160 480,160Q388,160 324,224Q260,288 260,380Q260,434 284.5,481Q309,528 354,560ZM480,560Q480,560 480,560Q480,560 480,560Q480,560 480,560Q480,560 480,560Q480,560 480,560Q480,560 480,560Q480,560 480,560Q480,560 480,560Z"/>
|
||||
</vector>
|
||||
10
commonUI/src/commonMain/composeResources/drawable/moon.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M480,840Q330,840 225,735Q120,630 120,480Q120,330 225,225Q330,120 480,120Q494,120 507.5,121Q521,122 534,124Q493,153 468.5,199.5Q444,246 444,300Q444,390 507,453Q570,516 660,516Q715,516 761,491.5Q807,467 836,426Q838,439 839,452.5Q840,466 840,480Q840,630 735,735Q630,840 480,840ZM480,760Q568,760 638,711.5Q708,663 740,585Q720,590 700,593Q680,596 660,596Q537,596 450.5,509.5Q364,423 364,300Q364,280 367,260Q370,240 375,220Q297,252 248.5,322Q200,392 200,480Q200,596 282,678Q364,760 480,760ZM470,490Q470,490 470,490Q470,490 470,490Q470,490 470,490Q470,490 470,490Q470,490 470,490Q470,490 470,490Q470,490 470,490Q470,490 470,490Q470,490 470,490Q470,490 470,490Q470,490 470,490Q470,490 470,490Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M280,680L80,480L280,280L336,336L233,440L727,440L624,336L680,280L880,480L680,680L624,624L727,520L233,520L336,624L280,680Z"/>
|
||||
</vector>
|
||||
10
commonUI/src/commonMain/composeResources/drawable/order.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M240,560Q207,560 183.5,536.5Q160,513 160,480Q160,447 183.5,423.5Q207,400 240,400Q273,400 296.5,423.5Q320,447 320,480Q320,513 296.5,536.5Q273,560 240,560ZM480,560Q447,560 423.5,536.5Q400,513 400,480Q400,447 423.5,423.5Q447,400 480,400Q513,400 536.5,423.5Q560,447 560,480Q560,513 536.5,536.5Q513,560 480,560ZM720,560Q687,560 663.5,536.5Q640,513 640,480Q640,447 663.5,423.5Q687,400 720,400Q753,400 776.5,423.5Q800,447 800,480Q800,513 776.5,536.5Q753,560 720,560Z"/>
|
||||
</vector>
|
||||
10
commonUI/src/commonMain/composeResources/drawable/sun.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M480,600Q530,600 565,565Q600,530 600,480Q600,430 565,395Q530,360 480,360Q430,360 395,395Q360,430 360,480Q360,530 395,565Q430,600 480,600ZM480,680Q397,680 338.5,621.5Q280,563 280,480Q280,397 338.5,338.5Q397,280 480,280Q563,280 621.5,338.5Q680,397 680,480Q680,563 621.5,621.5Q563,680 480,680ZM200,520L40,520L40,440L200,440L200,520ZM920,520L760,520L760,440L920,440L920,520ZM440,200L440,40L520,40L520,200L440,200ZM440,920L440,760L520,760L520,920L440,920ZM256,310L155,213L212,154L308,254L256,310ZM748,806L651,705L704,650L805,747L748,806ZM650,256L747,155L806,212L706,308L650,256ZM154,748L255,651L310,704L213,805L154,748ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M256,760L200,704L424,480L200,256L256,200L480,424L704,200L760,256L536,480L760,704L704,760L480,536L256,760Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M200,840Q167,840 143.5,816.5Q120,793 120,760L120,200Q120,167 143.5,143.5Q167,120 200,120L760,120Q793,120 816.5,143.5Q840,167 840,200L840,760Q840,793 816.5,816.5Q793,840 760,840L200,840ZM200,760L760,760Q760,760 760,760Q760,760 760,760L760,200Q760,200 760,200Q760,200 760,200L200,200Q200,200 200,200Q200,200 200,200L200,760Q200,760 200,760Q200,760 200,760ZM200,760Q200,760 200,760Q200,760 200,760L200,200Q200,200 200,200Q200,200 200,200L200,200Q200,200 200,200Q200,200 200,200L200,760Q200,760 200,760Q200,760 200,760L200,760Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M240,840L240,760L720,760L720,840L240,840Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,89 @@
|
||||
<resources>
|
||||
<string name="app_name">NERä</string>
|
||||
<string name="app_name_full">Noch so ein Einstein Rätsel</string>
|
||||
<string name="solved_congrats">Gratulation!</string>
|
||||
<string name="solved_time">Du hast das Rätsel in %1$s gelöst</string>
|
||||
<string name="restart">Von Anfang beginnen</string>
|
||||
<string name="use_light_mode">Heller Modus</string>
|
||||
<string name="use_dark_mode">Dunkler Modus</string>
|
||||
<string name="window_minimize">Fenster minimieren</string>
|
||||
<string name="window_maximize">Fenster maximieren</string>
|
||||
<string name="window_close">Fenster schließen</string>
|
||||
|
||||
<!-- Clues -->
|
||||
<string name="clue_next_to">%1$s ist neben %2$s</string>
|
||||
<string name="clue_left_of">%1$s ist links von %2$s</string>
|
||||
<string name="clue_triplet">%2$s ist zwischen den Nachbarn %1$s und %3$s auf beiden Seiten</string>
|
||||
<string name="clue_same_column">%1$s und %2$s sind in der gleichen Spalte</string>
|
||||
<string name="clue_fixed_position">%1$s auf Position %2$i</string>
|
||||
|
||||
<!-- Animals -->
|
||||
<string name="zebra">Zebra</string>
|
||||
<string name="octopus">Oktopus</string>
|
||||
<string name="goat">Ziege</string>
|
||||
<string name="sloth">Faultier</string>
|
||||
<string name="dog">Hund</string>
|
||||
<string name="snail">Schnecke</string>
|
||||
<string name="ant">Ameise</string>
|
||||
|
||||
<!-- Desserts -->
|
||||
<string name="ice_cream">Eis</string>
|
||||
<string name="doughnut">Donut</string>
|
||||
<string name="cookie">Keks</string>
|
||||
<string name="cake">Torte</string>
|
||||
<string name="cupcake">Cupcake</string>
|
||||
<string name="pie">Kuchen</string>
|
||||
<string name="chocolate">Schokolade</string>
|
||||
<string name="lollipop">Lollipop</string>
|
||||
<string name="custard">Vanillepudding</string>
|
||||
|
||||
<!-- Drinks -->
|
||||
<string name="milk">Milch</string>
|
||||
<string name="mate">Mate</string>
|
||||
<string name="water">Wasser</string>
|
||||
<string name="coffee">Kaffee</string>
|
||||
<string name="tea">Tee</string>
|
||||
<string name="bubble_tea">Bubble Tea</string>
|
||||
<string name="beverage">Süssgetränk</string>
|
||||
|
||||
<!-- Fruits -->
|
||||
<string name="banana">Banane</string>
|
||||
<string name="cherries">Kirsche</string>
|
||||
<string name="grapes">Trauben</string>
|
||||
<string name="kiwi">Kiwi</string>
|
||||
<string name="lemon">Zitrone</string>
|
||||
<string name="mango">Mango</string>
|
||||
<string name="pear">Birne</string>
|
||||
<string name="pineapple">Ananas</string>
|
||||
<string name="strawberry">Erdbeere</string>
|
||||
<string name="watermelon">Wassermelone</string>
|
||||
|
||||
<!-- Nationalities -->
|
||||
<string name="canadian">Kanada</string>
|
||||
<string name="japanese">Japan</string>
|
||||
<string name="norwegian">Norwegen</string>
|
||||
<string name="spanish">Spanien</string>
|
||||
<string name="swedish">Schweden</string>
|
||||
<string name="swiss">Schweiz</string>
|
||||
<string name="british">Großbritannien</string>
|
||||
<string name="ukrainian">Ukraine</string>
|
||||
|
||||
<!-- Professions -->
|
||||
<string name="astronaut">Astronauty</string>
|
||||
<string name="health_worker">Pflegy</string>
|
||||
<string name="farmer">Bauy</string>
|
||||
<string name="rock_star">Rock Star</string>
|
||||
<string name="scientist">Wissenschaftly</string>
|
||||
<string name="software_dev">Softwareentwickly</string>
|
||||
<string name="firefighter">Feuerwehrperson</string>
|
||||
<string name="teacher">Lehry</string>
|
||||
|
||||
<!-- Transportation -->
|
||||
<string name="bicycle">Fahrrad</string>
|
||||
<string name="motor_scooter">Roller</string>
|
||||
<string name="skateboard">Rollbrett</string>
|
||||
<string name="taxi">Taxi</string>
|
||||
<string name="locomotive">Lok</string>
|
||||
<string name="tram_car">Tram</string>
|
||||
<string name="bus">Bus</string>
|
||||
</resources>
|
||||
89
commonUI/src/commonMain/composeResources/values/strings.xml
Normal file
@@ -0,0 +1,89 @@
|
||||
<resources>
|
||||
<string name="app_name">YAEP</string>
|
||||
<string name="app_name_full">Yet Another Einstein Puzzle</string>
|
||||
<string name="solved_congrats">Congratulations!</string>
|
||||
<string name="solved_time">You solved the puzzle in %1$s</string>
|
||||
<string name="restart">Restart</string>
|
||||
<string name="use_light_mode">Use light mode</string>
|
||||
<string name="use_dark_mode">Use dark mode</string>
|
||||
<string name="window_minimize">Minimize window</string>
|
||||
<string name="window_maximize">Maximize window</string>
|
||||
<string name="window_close">Close window</string>
|
||||
|
||||
<!-- Clues -->
|
||||
<string name="clue_next_to">%1$s is next to %2$s</string>
|
||||
<string name="clue_left_of">%1$s is left of %2$s</string>
|
||||
<string name="clue_triplet">%2$s is between the neighbours %1$s and %3$s to both sides</string>
|
||||
<string name="clue_same_column">%1$s and %2$s are in the same column</string>
|
||||
<string name="clue_fixed_position">%1$s at position %2$i</string>
|
||||
|
||||
<!-- Animals -->
|
||||
<string name="zebra">Zebra</string>
|
||||
<string name="octopus">Octopus</string>
|
||||
<string name="goat">Goat</string>
|
||||
<string name="sloth">Sloth</string>
|
||||
<string name="dog">Dog</string>
|
||||
<string name="snail">Snail</string>
|
||||
<string name="ant">Ant</string>
|
||||
|
||||
<!-- Desserts -->
|
||||
<string name="ice_cream">Ice Cream</string>
|
||||
<string name="doughnut">Doughnut</string>
|
||||
<string name="cookie">Cookie</string>
|
||||
<string name="cake">Cake</string>
|
||||
<string name="cupcake">Cupcake</string>
|
||||
<string name="pie">Pie</string>
|
||||
<string name="chocolate">Chocolate</string>
|
||||
<string name="lollipop">Lollipop</string>
|
||||
<string name="custard">Custard</string>
|
||||
|
||||
<!-- Drinks -->
|
||||
<string name="milk">Milk</string>
|
||||
<string name="mate">Mate</string>
|
||||
<string name="water">Water</string>
|
||||
<string name="coffee">Coffee</string>
|
||||
<string name="tea">Tea</string>
|
||||
<string name="bubble_tea">Bubble Tea</string>
|
||||
<string name="beverage">Beverage</string>
|
||||
|
||||
<!-- Fruits -->
|
||||
<string name="banana">Banana</string>
|
||||
<string name="cherries">Cherries</string>
|
||||
<string name="grapes">Grapes</string>
|
||||
<string name="kiwi">Kiwi</string>
|
||||
<string name="lemon">Lemon</string>
|
||||
<string name="mango">Mango</string>
|
||||
<string name="pear">Pear</string>
|
||||
<string name="pineapple">Pineapple</string>
|
||||
<string name="strawberry">Strawberry</string>
|
||||
<string name="watermelon">Watermelon</string>
|
||||
|
||||
<!-- Nationalities -->
|
||||
<string name="canadian">Canadian</string>
|
||||
<string name="japanese">Japanese</string>
|
||||
<string name="norwegian">Norwegian</string>
|
||||
<string name="spanish">Spaniard</string>
|
||||
<string name="swedish">Swede</string>
|
||||
<string name="swiss">Swiss</string>
|
||||
<string name="british">British</string>
|
||||
<string name="ukrainian">Ukrainian</string>
|
||||
|
||||
<!-- Professions -->
|
||||
<string name="astronaut">Astronaut</string>
|
||||
<string name="health_worker">Health Worker</string>
|
||||
<string name="farmer">Farmer</string>
|
||||
<string name="rock_star">Rock Star</string>
|
||||
<string name="scientist">Scientist</string>
|
||||
<string name="software_dev">Software Developer</string>
|
||||
<string name="firefighter">Firefighter</string>
|
||||
<string name="teacher">Teacher</string>
|
||||
|
||||
<!-- Transportation -->
|
||||
<string name="bicycle">Bicycle</string>
|
||||
<string name="motor_scooter">Motor Scooter</string>
|
||||
<string name="skateboard">Skateboard</string>
|
||||
<string name="taxi">Taxi</string>
|
||||
<string name="locomotive">Locomotive</string>
|
||||
<string name="tram_car">Tram Car</string>
|
||||
<string name="bus">Bus</string>
|
||||
</resources>
|
||||
101
commonUI/src/commonMain/kotlin/ch/dissem/yaep/ui/common/App.kt
Normal file
@@ -0,0 +1,101 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.TextUnit
|
||||
import androidx.compose.ui.unit.TextUnitType
|
||||
import ch.dissem.yaep.domain.Game
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
|
||||
@Composable
|
||||
@OptIn(ExperimentalTime::class)
|
||||
fun App(
|
||||
modifier: Modifier = Modifier,
|
||||
selectDirectly: Boolean,
|
||||
spacing: Dp,
|
||||
game: Game,
|
||||
onNewGame: () -> Unit,
|
||||
resetCluesBeacon: Any = Any()
|
||||
) {
|
||||
val horizontalClues =
|
||||
remember(game, resetCluesBeacon) { game.horizontalClues.map { DisplayClue(it) } }
|
||||
val verticalClues =
|
||||
remember(game, resetCluesBeacon) { game.verticalClues.map { DisplayClue(it) } }
|
||||
val timer = remember(game) { GameTimer() }
|
||||
val time by timer.elapsedTime.collectAsState("00:00")
|
||||
var isSolved by remember(game) { mutableStateOf(false) }
|
||||
LaunchedEffect(game) {
|
||||
logGame(game)
|
||||
|
||||
game.onStart {
|
||||
timer.start()
|
||||
}
|
||||
|
||||
game.onSolved {
|
||||
timer.stop()
|
||||
isSolved = true
|
||||
}
|
||||
}
|
||||
|
||||
Box(modifier = modifier) {
|
||||
AdaptiveGameLayout(
|
||||
modifier = Modifier.blurOnFinished(isSolved),
|
||||
grid = {
|
||||
PuzzleGrid(
|
||||
grid = game.grid,
|
||||
spacing = spacing,
|
||||
selectDirectly = selectDirectly,
|
||||
onUpdate = {
|
||||
horizontalClues.forEach { it.update(game.grid) }
|
||||
verticalClues.forEach { it.update(game.grid) }
|
||||
}
|
||||
)
|
||||
},
|
||||
horizontalClues = {
|
||||
for (clue in horizontalClues) {
|
||||
HorizontalClue(
|
||||
modifier = Modifier.forClue(clue, spacing),
|
||||
spacing = spacing,
|
||||
clue = clue.clue,
|
||||
isClueViolated = clue.isViolated
|
||||
)
|
||||
}
|
||||
},
|
||||
verticalClues = {
|
||||
for (clue in verticalClues) {
|
||||
VerticalClue(
|
||||
modifier = Modifier.forClue(clue, spacing),
|
||||
spacing = spacing,
|
||||
clue = clue.clue,
|
||||
isClueViolated = clue.isViolated
|
||||
)
|
||||
}
|
||||
},
|
||||
time = {
|
||||
Text(
|
||||
time,
|
||||
fontSize = TextUnit(4f, TextUnitType.Companion.Em),
|
||||
textAlign = TextAlign.End
|
||||
)
|
||||
},
|
||||
spacing = spacing
|
||||
)
|
||||
EndOfGame(isSolved = isSolved, time = time, onRestart = onNewGame)
|
||||
}
|
||||
}
|
||||
|
||||
expect fun CoroutineScope.logGame(game: Game, dispatcher: CoroutineContext = Dispatchers.IO)
|
||||
@@ -0,0 +1,57 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
class GameTimer {
|
||||
|
||||
private var startTime: Long = 0L
|
||||
private var stopTime: Long = 0L
|
||||
|
||||
val isRunning: Boolean
|
||||
get() = startTime != 0L && stopTime == 0L
|
||||
|
||||
val elapsedSeconds: Flow<Long> = flow {
|
||||
emit(0L)
|
||||
while (startTime == 0L) {
|
||||
delay(100)
|
||||
}
|
||||
var previousSeconds = 0L
|
||||
while (stopTime == 0L) {
|
||||
val elapsedSeconds = System.currentTimeMillis() / 1000 - startTime
|
||||
if (elapsedSeconds != previousSeconds) {
|
||||
emit(elapsedSeconds)
|
||||
}
|
||||
delay(100)
|
||||
previousSeconds = elapsedSeconds
|
||||
}
|
||||
emit(stopTime - startTime)
|
||||
}
|
||||
|
||||
val elapsedTime: Flow<String> = elapsedSeconds.map { seconds ->
|
||||
val minutes = seconds / 60
|
||||
val hours = minutes / 60
|
||||
val remainingMinutes = minutes % 60
|
||||
val remainingSeconds = seconds % 60
|
||||
if (hours == 0L) {
|
||||
"%02d:%02d".format(minutes, remainingSeconds)
|
||||
} else {
|
||||
"%02d:%02d:%02d".format(hours, remainingMinutes, remainingSeconds)
|
||||
}
|
||||
}
|
||||
|
||||
fun start() {
|
||||
if (startTime == 0L) {
|
||||
startTime = System.currentTimeMillis() / 1000
|
||||
}
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
if (isRunning) {
|
||||
stopTime = System.currentTimeMillis() / 1000
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.layout.Layout
|
||||
import androidx.compose.ui.layout.Measurable
|
||||
import androidx.compose.ui.layout.Placeable
|
||||
import androidx.compose.ui.unit.Constraints
|
||||
import androidx.compose.ui.unit.Constraints.Companion.fixed
|
||||
import androidx.compose.ui.unit.Constraints.Companion.fixedWidth
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ch.dissem.yaep.ui.common.AspectRatio.LANDSCAPE
|
||||
import ch.dissem.yaep.ui.common.AspectRatio.PORTRAIT
|
||||
import ch.dissem.yaep.ui.common.AspectRatio.SQUARISH
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
|
||||
private enum class AspectRatio {
|
||||
PORTRAIT, LANDSCAPE, SQUARISH;
|
||||
|
||||
companion object {
|
||||
private const val ASPECT_RATIO_LANDSCAPE = 1.4f
|
||||
private const val ASPECT_RATIO_PORTRAIT = 1 / ASPECT_RATIO_LANDSCAPE
|
||||
|
||||
fun from(constraints: Constraints): AspectRatio {
|
||||
val ratio = constraints.maxWidth.toFloat() / constraints.maxHeight.toFloat()
|
||||
return when {
|
||||
ratio < ASPECT_RATIO_PORTRAIT -> PORTRAIT
|
||||
ratio > ASPECT_RATIO_LANDSCAPE -> LANDSCAPE
|
||||
else -> SQUARISH
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun AdaptiveGameLayout(
|
||||
modifier: Modifier = Modifier,
|
||||
grid: @Composable () -> Unit,
|
||||
horizontalClues: @Composable () -> Unit,
|
||||
verticalClues: @Composable () -> Unit,
|
||||
time: @Composable () -> Unit,
|
||||
divider: @Composable () -> Unit = { HorizontalDivider() },
|
||||
spacing: Dp = 8.dp
|
||||
) {
|
||||
Layout(
|
||||
contents = listOf(grid, horizontalClues, verticalClues, time, divider, divider),
|
||||
modifier = modifier
|
||||
) { measurables, constraints ->
|
||||
layout(width = constraints.maxWidth, height = constraints.maxHeight) {
|
||||
val aspectRatio = AspectRatio.from(constraints)
|
||||
|
||||
val gridMeasurable = measurables[0][0]
|
||||
val horizontalCluesMeasurables = measurables[1]
|
||||
val verticalCluesMeasurables = measurables[2]
|
||||
val timeMeasurable = measurables[3][0]
|
||||
val dividerMeasurable = measurables[4][0]
|
||||
|
||||
val spacingPx = spacing.roundToPx()
|
||||
|
||||
when (aspectRatio) {
|
||||
PORTRAIT -> {
|
||||
val divider2Measurable = measurables[5][0]
|
||||
portrait(
|
||||
constraints,
|
||||
spacingPx,
|
||||
gridMeasurable,
|
||||
horizontalCluesMeasurables,
|
||||
verticalCluesMeasurables,
|
||||
timeMeasurable,
|
||||
dividerMeasurable,
|
||||
divider2Measurable
|
||||
)
|
||||
}
|
||||
|
||||
SQUARISH -> {
|
||||
squarish(
|
||||
constraints,
|
||||
spacingPx,
|
||||
gridMeasurable,
|
||||
horizontalCluesMeasurables,
|
||||
verticalCluesMeasurables,
|
||||
timeMeasurable
|
||||
)
|
||||
}
|
||||
|
||||
LANDSCAPE -> {
|
||||
landscape(
|
||||
constraints,
|
||||
spacingPx,
|
||||
gridMeasurable,
|
||||
horizontalCluesMeasurables,
|
||||
verticalCluesMeasurables,
|
||||
timeMeasurable,
|
||||
dividerMeasurable
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Placeable.PlacementScope.portrait(
|
||||
constraints: Constraints,
|
||||
spacingPx: Int,
|
||||
gridMeasurable: Measurable,
|
||||
horizontalCluesMeasurables: List<Measurable>,
|
||||
verticalCluesMeasurables: List<Measurable>,
|
||||
timeMeasurable: Measurable,
|
||||
divider1Measurable: Measurable,
|
||||
divider2Measurable: Measurable
|
||||
) {
|
||||
val gridSize = constraints.maxWidth
|
||||
val gridItemSize = (gridSize - 12 * spacingPx) / 18
|
||||
|
||||
val gridConstraints = fixed(gridSize, gridSize)
|
||||
val horizontalCluesConstraints = fixed(
|
||||
width = 3 * gridItemSize + 2 * spacingPx,
|
||||
height = gridItemSize + 2 * spacingPx
|
||||
)
|
||||
val verticalCluesConstraints = fixed(
|
||||
width = gridItemSize + 2 * spacingPx,
|
||||
height = 3 * gridItemSize + 2 * spacingPx
|
||||
)
|
||||
val timeConstraints = Constraints()
|
||||
val dividerConstraints = fixedWidth(gridSize)
|
||||
|
||||
val gridPlaceable = gridMeasurable.measure(gridConstraints)
|
||||
val horizontalCluesPlaceables = horizontalCluesMeasurables.map {
|
||||
it.measure(horizontalCluesConstraints)
|
||||
}
|
||||
val verticalCluesPlaceables = verticalCluesMeasurables.map {
|
||||
it.measure(verticalCluesConstraints)
|
||||
}
|
||||
val timePlaceable = timeMeasurable.measure(timeConstraints)
|
||||
val divider1Placeable = divider1Measurable.measure(dividerConstraints)
|
||||
val divider2Placeable = divider2Measurable.measure(dividerConstraints)
|
||||
|
||||
// Position the grid
|
||||
gridPlaceable.place(0, 0)
|
||||
|
||||
divider1Placeable.place(0, gridSize + spacingPx)
|
||||
|
||||
// Position the horizontal clues
|
||||
var offsetY = placeClues(
|
||||
placeables = horizontalCluesPlaceables,
|
||||
offsetX = 0,
|
||||
offsetY = gridSize + 2 * spacingPx,
|
||||
maxWidth = gridSize
|
||||
)
|
||||
|
||||
// Add divider in between
|
||||
divider2Placeable.place(0, offsetY + spacingPx)
|
||||
|
||||
// Position the vertical clues
|
||||
offsetY = placeClues(
|
||||
placeables = verticalCluesPlaceables,
|
||||
offsetX = 0,
|
||||
offsetY = offsetY + spacingPx + divider2Placeable.height,
|
||||
maxWidth = gridSize
|
||||
)
|
||||
|
||||
// Position the time
|
||||
val remainingSpace = constraints.maxHeight - offsetY
|
||||
if (remainingSpace < timePlaceable.height) {
|
||||
val scale = remainingSpace.toFloat() / timePlaceable.height.toFloat()
|
||||
if (scale > 0.1f) {
|
||||
timePlaceable.placeWithLayer(
|
||||
x = constraints.maxWidth - timePlaceable.width - spacingPx,
|
||||
y = constraints.maxHeight - timePlaceable.height
|
||||
) {
|
||||
scaleX = scale
|
||||
scaleY = scale
|
||||
translationX = (timePlaceable.width * (1 - scale)) / 2f
|
||||
translationY = (timePlaceable.height * (1 - scale)) / 2f
|
||||
}
|
||||
}
|
||||
} else {
|
||||
timePlaceable.place(
|
||||
x = constraints.maxWidth - timePlaceable.width - spacingPx,
|
||||
y = constraints.maxHeight - timePlaceable.height
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun Placeable.PlacementScope.squarish(
|
||||
constraints: Constraints,
|
||||
spacingPx: Int,
|
||||
gridMeasurable: Measurable,
|
||||
horizontalCluesMeasurables: List<Measurable>,
|
||||
verticalCluesMeasurables: List<Measurable>,
|
||||
timeMeasurable: Measurable
|
||||
) {
|
||||
val gridSize = (7 * min(constraints.maxWidth, constraints.maxHeight)) / 10
|
||||
val gridItemSize = (gridSize - 12 * spacingPx) / 18
|
||||
val rightBarWidth = constraints.maxWidth - gridSize - spacingPx
|
||||
|
||||
val gridConstraints = fixed(gridSize, gridSize)
|
||||
val horizontalCluesConstraints = fixed(
|
||||
width = 3 * gridItemSize + 2 * spacingPx,
|
||||
height = gridItemSize + 2 * spacingPx
|
||||
)
|
||||
val verticalCluesConstraints = fixed(
|
||||
width = gridItemSize + 2 * spacingPx,
|
||||
height = 3 * gridItemSize + 2 * spacingPx
|
||||
)
|
||||
val timeConstraints = Constraints()
|
||||
|
||||
val gridPlaceable = gridMeasurable.measure(gridConstraints)
|
||||
val horizontalCluesPlaceables = horizontalCluesMeasurables.map {
|
||||
it.measure(horizontalCluesConstraints)
|
||||
}
|
||||
val verticalCluesPlaceables = verticalCluesMeasurables.map {
|
||||
it.measure(verticalCluesConstraints)
|
||||
}
|
||||
val timePlaceable = timeMeasurable.measure(timeConstraints)
|
||||
|
||||
// Position the grid
|
||||
gridPlaceable.place(0, 0)
|
||||
|
||||
// Position the horizontal clues
|
||||
placeClues(
|
||||
placeables = horizontalCluesPlaceables,
|
||||
offsetX = gridSize + 2 * spacingPx,
|
||||
offsetY = 0,
|
||||
maxWidth = rightBarWidth
|
||||
)
|
||||
|
||||
// Position the vertical clues
|
||||
placeClues(
|
||||
placeables = verticalCluesPlaceables,
|
||||
offsetX = 0,
|
||||
offsetY = gridSize + 2 * spacingPx,
|
||||
maxWidth = gridSize
|
||||
)
|
||||
|
||||
// Position the time
|
||||
timePlaceable.place(
|
||||
x = constraints.maxWidth - timePlaceable.width - spacingPx,
|
||||
y = constraints.maxHeight - timePlaceable.height
|
||||
)
|
||||
}
|
||||
|
||||
private fun Placeable.PlacementScope.landscape(
|
||||
constraints: Constraints,
|
||||
spacingPx: Int,
|
||||
gridMeasurable: Measurable,
|
||||
horizontalCluesMeasurables: List<Measurable>,
|
||||
verticalCluesMeasurables: List<Measurable>,
|
||||
timeMeasurable: Measurable,
|
||||
dividerMeasurable: Measurable
|
||||
) {
|
||||
val gridSize = constraints.maxHeight
|
||||
val gridItemSize = (gridSize - 12 * spacingPx) / 18
|
||||
val rightBarWidth = constraints.maxWidth - gridSize - 2 * spacingPx
|
||||
|
||||
val gridConstraints = fixed(gridSize, gridSize)
|
||||
val baseSpace = gridSize - 2 * spacingPx
|
||||
val horizontalCluesConstraints = fixed(
|
||||
width = 3 * gridItemSize + 2 * spacingPx,
|
||||
height = gridItemSize + 2 * spacingPx
|
||||
)
|
||||
val verticalCluesConstraints = fixed(
|
||||
width = gridItemSize + 2 * spacingPx,
|
||||
height = 3 * gridItemSize + 2 * spacingPx
|
||||
)
|
||||
val timeConstraints = Constraints.fixedHeight(baseSpace / 10)
|
||||
val dividerConstraints = fixedWidth(rightBarWidth - 2 * spacingPx)
|
||||
|
||||
val gridPlaceable = gridMeasurable.measure(gridConstraints)
|
||||
val horizontalCluesPlaceables = horizontalCluesMeasurables.map {
|
||||
it.measure(horizontalCluesConstraints)
|
||||
}
|
||||
val verticalCluesPlaceables = verticalCluesMeasurables.map {
|
||||
it.measure(verticalCluesConstraints)
|
||||
}
|
||||
val timePlaceable = timeMeasurable.measure(timeConstraints)
|
||||
val dividerPlaceable = dividerMeasurable.measure(dividerConstraints)
|
||||
|
||||
// Position the grid
|
||||
gridPlaceable.place(0, 0)
|
||||
|
||||
// Position the horizontal clues
|
||||
val offsetY = placeClues(
|
||||
placeables = horizontalCluesPlaceables,
|
||||
offsetX = gridSize + 2 * spacingPx,
|
||||
offsetY = 0,
|
||||
maxWidth = rightBarWidth
|
||||
)
|
||||
|
||||
// Add divider in between
|
||||
dividerPlaceable.place(gridSize + 3 * spacingPx, offsetY + spacingPx)
|
||||
|
||||
// Position the vertical clues
|
||||
placeClues(
|
||||
placeables = verticalCluesPlaceables,
|
||||
offsetX = gridSize + 2 * spacingPx,
|
||||
offsetY = offsetY + spacingPx + dividerPlaceable.height,
|
||||
maxWidth = rightBarWidth
|
||||
)
|
||||
|
||||
// Position the time
|
||||
timePlaceable.place(
|
||||
x = constraints.maxWidth - timePlaceable.width - spacingPx,
|
||||
y = constraints.maxHeight - timePlaceable.height
|
||||
)
|
||||
}
|
||||
|
||||
private fun Placeable.PlacementScope.placeClues(
|
||||
placeables: List<Placeable>,
|
||||
offsetX: Int,
|
||||
offsetY: Int,
|
||||
maxWidth: Int
|
||||
): Int {
|
||||
if (placeables.isEmpty()) return offsetY
|
||||
|
||||
val itemWidth = placeables.first().width
|
||||
val itemHeight = placeables.first().height
|
||||
val columns = max(1, maxWidth / itemWidth)
|
||||
val spacing = if (columns == 1) 0 else (maxWidth - columns * itemWidth) / (columns - 1)
|
||||
var currentX = offsetX
|
||||
var currentY = offsetY
|
||||
var i = 0
|
||||
for (placeable in placeables) {
|
||||
placeable.place(currentX, currentY)
|
||||
currentX += itemWidth + spacing
|
||||
i++
|
||||
if (i % columns == 0 && i < placeables.size) {
|
||||
currentX = offsetX
|
||||
currentY += itemHeight
|
||||
}
|
||||
}
|
||||
return currentY + itemHeight
|
||||
}
|
||||
|
||||
144
commonUI/src/commonMain/kotlin/ch/dissem/yaep/ui/common/clues.kt
Normal file
@@ -0,0 +1,144 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedCard
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ch.dissem.yaep.domain.Clue
|
||||
import ch.dissem.yaep.domain.Grid
|
||||
import ch.dissem.yaep.domain.HorizontalClue
|
||||
import ch.dissem.yaep.domain.NeighbourClue
|
||||
import ch.dissem.yaep.domain.OrderClue
|
||||
import ch.dissem.yaep.domain.SameColumnClue
|
||||
import ch.dissem.yaep.domain.TripletClue
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import yaep.commonui.generated.resources.Res
|
||||
import yaep.commonui.generated.resources.neighbour
|
||||
import yaep.commonui.generated.resources.order
|
||||
|
||||
fun Modifier.forClue(clue: DisplayClue<out Clue>, padding: Dp = 8.dp): Modifier = this
|
||||
.alpha(if (clue.isActive) 1f else 0.2f)
|
||||
.padding(padding)
|
||||
.onEitherPointerAction { clue.isActive = !clue.isActive }
|
||||
|
||||
@Composable
|
||||
fun HorizontalClue(
|
||||
modifier: Modifier = Modifier,
|
||||
spacing: Dp,
|
||||
clue: HorizontalClue,
|
||||
isClueViolated: Boolean
|
||||
) {
|
||||
ClueCard(
|
||||
modifier = modifier,
|
||||
spacing = spacing,
|
||||
isClueViolated = isClueViolated
|
||||
) {
|
||||
Row {
|
||||
when (clue) {
|
||||
is NeighbourClue<*, *> -> {
|
||||
DrawItem(modifier = Modifier.weight(1f), spacing = spacing, item = clue.a)
|
||||
Icon(
|
||||
modifier = Modifier.aspectRatio(1f).weight(1f),
|
||||
painter = painterResource(Res.drawable.neighbour),
|
||||
contentDescription = null
|
||||
)
|
||||
DrawItem(modifier = Modifier.weight(1f), spacing = spacing, item = clue.b)
|
||||
}
|
||||
|
||||
is OrderClue<*, *> -> {
|
||||
DrawItem(modifier = Modifier.weight(1f), spacing = spacing, item = clue.left)
|
||||
Icon(
|
||||
modifier = Modifier.aspectRatio(1f).weight(1f),
|
||||
painter = painterResource(Res.drawable.order),
|
||||
contentDescription = null
|
||||
)
|
||||
DrawItem(modifier = Modifier.weight(1f), spacing = spacing, item = clue.right)
|
||||
}
|
||||
|
||||
is TripletClue<*, *, *> -> {
|
||||
DrawItem(modifier = Modifier.weight(1f), spacing = spacing, item = clue.a)
|
||||
DrawItem(modifier = Modifier.weight(1f), spacing = spacing, item = clue.b)
|
||||
DrawItem(modifier = Modifier.weight(1f), spacing = spacing, item = clue.c)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun VerticalClue(
|
||||
modifier: Modifier = Modifier,
|
||||
spacing: Dp,
|
||||
clue: SameColumnClue<*, *>,
|
||||
isClueViolated: Boolean = false
|
||||
) {
|
||||
ClueCard(
|
||||
modifier = modifier.aspectRatio(0.5f),
|
||||
spacing = spacing,
|
||||
isClueViolated = isClueViolated
|
||||
) {
|
||||
Column {
|
||||
DrawItem(modifier = Modifier.weight(1f), spacing = spacing, item = clue.a)
|
||||
DrawItem(modifier = Modifier.weight(1f), spacing = spacing, item = clue.b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ClueCard(
|
||||
modifier: Modifier = Modifier,
|
||||
spacing: Dp,
|
||||
isClueViolated: Boolean,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
OutlinedCard(
|
||||
modifier = if (isClueViolated) {
|
||||
modifier.shadow(
|
||||
8.dp,
|
||||
shape = CardDefaults.outlinedShape,
|
||||
ambientColor = colors.error,
|
||||
spotColor = colors.error
|
||||
)
|
||||
} else {
|
||||
modifier
|
||||
},
|
||||
shape = RoundedCornerShape(spacing),
|
||||
border = if (isClueViolated) {
|
||||
remember { BorderStroke(1.0.dp, colors.error) }
|
||||
} else {
|
||||
CardDefaults.outlinedCardBorder()
|
||||
}
|
||||
) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
|
||||
class DisplayClue<C : Clue>(val clue: C) {
|
||||
var isActive: Boolean by mutableStateOf(true)
|
||||
|
||||
var isViolated: Boolean by mutableStateOf(false)
|
||||
|
||||
fun update(grid: Grid) {
|
||||
isViolated = !clue.isValid(grid)
|
||||
if (isViolated) {
|
||||
isActive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.graphics.BlurEffect
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import yaep.commonui.generated.resources.Res
|
||||
import yaep.commonui.generated.resources.restart
|
||||
import yaep.commonui.generated.resources.solved_congrats
|
||||
import yaep.commonui.generated.resources.solved_time
|
||||
|
||||
@Composable
|
||||
fun EndOfGame(
|
||||
modifier: Modifier = Modifier,
|
||||
isSolved: Boolean,
|
||||
time: String,
|
||||
onRestart: () -> Unit
|
||||
) {
|
||||
AnimatedVisibility(
|
||||
visible = isSolved,
|
||||
modifier = modifier,
|
||||
enter = fadeIn(),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
val background = MaterialTheme.colorScheme.background
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.drawBehind {
|
||||
drawRect(color = background.copy(alpha = 0.8f))
|
||||
}
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.align(Alignment.Center)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(Res.string.solved_congrats),
|
||||
fontSize = 128.sp,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.testTag("EndOfGame.solved_congrats")
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text(
|
||||
text = stringResource(Res.string.solved_time, time),
|
||||
fontSize = 64.sp,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.testTag("EndOfGame.solved_time")
|
||||
)
|
||||
Spacer(modifier = Modifier.height(32.dp))
|
||||
Button(
|
||||
modifier = Modifier.align(CenterHorizontally)
|
||||
.testTag("EndOfGame.restart"),
|
||||
onClick = onRestart
|
||||
) {
|
||||
Text(stringResource(Res.string.restart))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Modifier.blurOnFinished(isSolved: Boolean): Modifier = graphicsLayer {
|
||||
if (isSolved) {
|
||||
this.renderEffect = BlurEffect(8f, 8f)
|
||||
}
|
||||
}
|
||||
118
commonUI/src/commonMain/kotlin/ch/dissem/yaep/ui/common/grid.kt
Normal file
@@ -0,0 +1,118 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ch.dissem.yaep.domain.GameCell
|
||||
import ch.dissem.yaep.domain.GameRow
|
||||
import ch.dissem.yaep.domain.Grid
|
||||
import ch.dissem.yaep.domain.Item
|
||||
import ch.dissem.yaep.domain.ItemClass
|
||||
|
||||
@Composable
|
||||
fun PuzzleGrid(
|
||||
modifier: Modifier = Modifier,
|
||||
selectDirectly: Boolean,
|
||||
spacing: Dp = 8.dp,
|
||||
grid: Grid,
|
||||
onUpdate: () -> Unit
|
||||
) {
|
||||
Column(modifier = modifier) {
|
||||
for (row in grid) {
|
||||
PuzzleRow(
|
||||
row = row,
|
||||
onUpdate = onUpdate,
|
||||
onSnapshot = { grid.snapshot() },
|
||||
onUndo = { grid.undo() },
|
||||
spacing = spacing,
|
||||
selectDirectly = selectDirectly
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PuzzleRow(
|
||||
row: GameRow<ItemClass<*>>,
|
||||
onUpdate: () -> Unit,
|
||||
onSnapshot: () -> Unit,
|
||||
onUndo: () -> Boolean,
|
||||
spacing: Dp,
|
||||
selectDirectly: Boolean
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.wrapContentHeight()
|
||||
) {
|
||||
val allOptions = row.options
|
||||
for (cell in row) {
|
||||
var selection by remember(cell) { mutableStateOf(cell.selection) }
|
||||
val options = remember(cell) {
|
||||
allOptions.map { Toggleable(it, cell.options.contains(it)) }
|
||||
}
|
||||
LaunchedEffect(cell) {
|
||||
cell.optionsChangedListeners.add { enabled ->
|
||||
options.forEach { it.enabled = enabled.contains(it.item) }
|
||||
}
|
||||
cell.selectionChangedListeners.add {
|
||||
selection = it
|
||||
onUpdate()
|
||||
}
|
||||
}
|
||||
Selector(
|
||||
modifier = Modifier
|
||||
.padding(spacing)
|
||||
.weight(1f),
|
||||
spacing,
|
||||
selectDirectly = selectDirectly,
|
||||
options = options,
|
||||
onOptionRemoved = {
|
||||
onSnapshot()
|
||||
cell.options.remove(it)
|
||||
row.cleanupOptions()
|
||||
},
|
||||
onOptionAdded = {
|
||||
cell.options.add(it)
|
||||
},
|
||||
selectedItem = selection,
|
||||
onSelectItem = { selectedItem ->
|
||||
onSelectItem(row, cell, options, selectedItem, onSnapshot, onUndo)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onSelectItem(
|
||||
row: GameRow<ItemClass<*>>,
|
||||
cell: GameCell<ItemClass<*>>,
|
||||
options: List<Toggleable<Item<ItemClass<*>>>>,
|
||||
selectedItem: Item<ItemClass<*>>?,
|
||||
onSnapshot: () -> Unit,
|
||||
onUndo: () -> Boolean
|
||||
) {
|
||||
if (selectedItem != null) {
|
||||
onSnapshot()
|
||||
cell.selection = selectedItem
|
||||
row.cleanupOptions()
|
||||
} else {
|
||||
while (cell.selection != null) {
|
||||
if (!onUndo()) break
|
||||
}
|
||||
options.forEach { option ->
|
||||
option.enabled = cell.options.contains(option.item)
|
||||
}
|
||||
}
|
||||
}
|
||||
163
commonUI/src/commonMain/kotlin/ch/dissem/yaep/ui/common/names.kt
Normal file
@@ -0,0 +1,163 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import ch.dissem.yaep.domain.Animal
|
||||
import ch.dissem.yaep.domain.Dessert
|
||||
import ch.dissem.yaep.domain.Drink
|
||||
import ch.dissem.yaep.domain.Fruit
|
||||
import ch.dissem.yaep.domain.ItemClass
|
||||
import ch.dissem.yaep.domain.Nationality
|
||||
import ch.dissem.yaep.domain.Profession
|
||||
import ch.dissem.yaep.domain.Transportation
|
||||
import org.jetbrains.compose.resources.StringResource
|
||||
import yaep.commonui.generated.resources.Res
|
||||
import yaep.commonui.generated.resources.ant
|
||||
import yaep.commonui.generated.resources.astronaut
|
||||
import yaep.commonui.generated.resources.banana
|
||||
import yaep.commonui.generated.resources.bubble_tea
|
||||
import yaep.commonui.generated.resources.beverage
|
||||
import yaep.commonui.generated.resources.bicycle
|
||||
import yaep.commonui.generated.resources.british
|
||||
import yaep.commonui.generated.resources.bus
|
||||
import yaep.commonui.generated.resources.cake
|
||||
import yaep.commonui.generated.resources.canadian
|
||||
import yaep.commonui.generated.resources.cherries
|
||||
import yaep.commonui.generated.resources.chocolate
|
||||
import yaep.commonui.generated.resources.water
|
||||
import yaep.commonui.generated.resources.coffee
|
||||
import yaep.commonui.generated.resources.cookie
|
||||
import yaep.commonui.generated.resources.cupcake
|
||||
import yaep.commonui.generated.resources.custard
|
||||
import yaep.commonui.generated.resources.dog
|
||||
import yaep.commonui.generated.resources.doughnut
|
||||
import yaep.commonui.generated.resources.farmer
|
||||
import yaep.commonui.generated.resources.firefighter
|
||||
import yaep.commonui.generated.resources.goat
|
||||
import yaep.commonui.generated.resources.grapes
|
||||
import yaep.commonui.generated.resources.health_worker
|
||||
import yaep.commonui.generated.resources.ice_cream
|
||||
import yaep.commonui.generated.resources.japanese
|
||||
import yaep.commonui.generated.resources.kiwi
|
||||
import yaep.commonui.generated.resources.lemon
|
||||
import yaep.commonui.generated.resources.locomotive
|
||||
import yaep.commonui.generated.resources.lollipop
|
||||
import yaep.commonui.generated.resources.mango
|
||||
import yaep.commonui.generated.resources.milk
|
||||
import yaep.commonui.generated.resources.motor_scooter
|
||||
import yaep.commonui.generated.resources.norwegian
|
||||
import yaep.commonui.generated.resources.octopus
|
||||
import yaep.commonui.generated.resources.pear
|
||||
import yaep.commonui.generated.resources.pie
|
||||
import yaep.commonui.generated.resources.pineapple
|
||||
import yaep.commonui.generated.resources.rock_star
|
||||
import yaep.commonui.generated.resources.scientist
|
||||
import yaep.commonui.generated.resources.skateboard
|
||||
import yaep.commonui.generated.resources.sloth
|
||||
import yaep.commonui.generated.resources.snail
|
||||
import yaep.commonui.generated.resources.software_dev
|
||||
import yaep.commonui.generated.resources.spanish
|
||||
import yaep.commonui.generated.resources.strawberry
|
||||
import yaep.commonui.generated.resources.swedish
|
||||
import yaep.commonui.generated.resources.swiss
|
||||
import yaep.commonui.generated.resources.taxi
|
||||
import yaep.commonui.generated.resources.tea
|
||||
import yaep.commonui.generated.resources.teacher
|
||||
import yaep.commonui.generated.resources.tram_car
|
||||
import yaep.commonui.generated.resources.ukrainian
|
||||
import yaep.commonui.generated.resources.watermelon
|
||||
import yaep.commonui.generated.resources.mate
|
||||
import yaep.commonui.generated.resources.zebra
|
||||
|
||||
val ItemClass<*>.localName: StringResource
|
||||
get() = when (this) {
|
||||
is Animal -> this.stringResource
|
||||
is Dessert -> this.stringResource
|
||||
is Drink -> this.stringResource
|
||||
is Fruit -> this.stringResource
|
||||
is Nationality -> this.stringResource
|
||||
is Profession -> this.stringResource
|
||||
is Transportation -> this.stringResource
|
||||
}
|
||||
|
||||
private val Animal.stringResource: StringResource
|
||||
get() = when (this) {
|
||||
Animal.ANT -> Res.string.ant
|
||||
Animal.DOG -> Res.string.dog
|
||||
Animal.GOAT -> Res.string.goat
|
||||
Animal.OCTOPUS -> Res.string.octopus
|
||||
Animal.SLOTH -> Res.string.sloth
|
||||
Animal.SNAIL -> Res.string.snail
|
||||
Animal.ZEBRA -> Res.string.zebra
|
||||
}
|
||||
|
||||
private val Dessert.stringResource: StringResource
|
||||
get() = when (this) {
|
||||
Dessert.CAKE -> Res.string.cake
|
||||
Dessert.CHOCOLATE -> Res.string.chocolate
|
||||
Dessert.COOKIE -> Res.string.cookie
|
||||
Dessert.CUPCAKE -> Res.string.cupcake
|
||||
Dessert.CUSTARD -> Res.string.custard
|
||||
Dessert.DOUGHNUT -> Res.string.doughnut
|
||||
Dessert.ICE_CREAM -> Res.string.ice_cream
|
||||
Dessert.LOLLIPOP -> Res.string.lollipop
|
||||
Dessert.PIE -> Res.string.pie
|
||||
}
|
||||
|
||||
private val Drink.stringResource: StringResource
|
||||
get() = when (this) {
|
||||
Drink.BEVERAGE -> Res.string.beverage
|
||||
Drink.BUBBLE_TEA -> Res.string.bubble_tea
|
||||
Drink.COFFEE -> Res.string.coffee
|
||||
Drink.MATE -> Res.string.mate
|
||||
Drink.MILK -> Res.string.milk
|
||||
Drink.TEA -> Res.string.tea
|
||||
Drink.WATER -> Res.string.water
|
||||
}
|
||||
|
||||
private val Fruit.stringResource: StringResource
|
||||
get() = when (this) {
|
||||
Fruit.BANANA -> Res.string.banana
|
||||
Fruit.CHERRIES -> Res.string.cherries
|
||||
Fruit.GRAPES -> Res.string.grapes
|
||||
Fruit.KIWI -> Res.string.kiwi
|
||||
Fruit.LEMON -> Res.string.lemon
|
||||
Fruit.MANGO -> Res.string.mango
|
||||
Fruit.PEAR -> Res.string.pear
|
||||
Fruit.PINEAPPLE -> Res.string.pineapple
|
||||
Fruit.STRAWBERRY -> Res.string.strawberry
|
||||
Fruit.WATERMELON -> Res.string.watermelon
|
||||
}
|
||||
|
||||
private val Nationality.stringResource: StringResource
|
||||
get() = when (this) {
|
||||
Nationality.CANADA -> Res.string.canadian
|
||||
Nationality.JAPAN -> Res.string.japanese
|
||||
Nationality.NORWAY -> Res.string.norwegian
|
||||
Nationality.SPAIN -> Res.string.spanish
|
||||
Nationality.SWEDEN -> Res.string.swedish
|
||||
Nationality.SWITZERLAND -> Res.string.swiss
|
||||
Nationality.UNITED_KINGDOM -> Res.string.british
|
||||
Nationality.UKRAINE -> Res.string.ukrainian
|
||||
}
|
||||
|
||||
private val Profession.stringResource: StringResource
|
||||
get() = when (this) {
|
||||
Profession.ASTRONAUT -> Res.string.astronaut
|
||||
Profession.FARMER -> Res.string.farmer
|
||||
Profession.FIREFIGHTER -> Res.string.firefighter
|
||||
Profession.HEALTH_WORKER -> Res.string.health_worker
|
||||
Profession.ROCK_STAR -> Res.string.rock_star
|
||||
Profession.SCIENTIST -> Res.string.scientist
|
||||
Profession.SOFTWARE_DEV -> Res.string.software_dev
|
||||
Profession.TEACHER -> Res.string.teacher
|
||||
}
|
||||
|
||||
private val Transportation.stringResource: StringResource
|
||||
get() = when (this) {
|
||||
Transportation.BICYCLE -> Res.string.bicycle
|
||||
Transportation.BUS -> Res.string.bus
|
||||
Transportation.LOCOMOTIVE -> Res.string.locomotive
|
||||
Transportation.MOTOR_SCOOTER -> Res.string.motor_scooter
|
||||
Transportation.SKATEBOARD -> Res.string.skateboard
|
||||
Transportation.TAXI -> Res.string.taxi
|
||||
Transportation.TRAM_CAR -> Res.string.tram_car
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
expect fun Modifier.onPointerAction(primary: () -> Unit = {}, secondary: () -> Unit = {}): Modifier
|
||||
|
||||
fun Modifier.onEitherPointerAction(action: () -> Unit): Modifier =
|
||||
onPointerAction(primary = action, secondary = action)
|
||||
@@ -0,0 +1,145 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.OutlinedCard
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.drawText
|
||||
import androidx.compose.ui.text.rememberTextMeasurer
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import ch.dissem.yaep.domain.Item
|
||||
import ch.dissem.yaep.domain.ItemClass
|
||||
import ch.dissem.yaep.ui.common.theme.emojiFontFamily
|
||||
import kotlin.math.min
|
||||
|
||||
@Composable
|
||||
fun <C : ItemClass<C>> Selector(
|
||||
modifier: Modifier = Modifier,
|
||||
spacing: Dp,
|
||||
selectDirectly: Boolean,
|
||||
options: List<Toggleable<Item<C>>>,
|
||||
onOptionRemoved: (Item<C>) -> Unit,
|
||||
onOptionAdded: (Item<C>) -> Unit,
|
||||
selectedItem: Item<C>?,
|
||||
onSelectItem: (Item<C>?) -> Unit,
|
||||
) {
|
||||
val radius = spacing * 1.5f
|
||||
if (selectedItem != null) {
|
||||
DrawItem(
|
||||
item = selectedItem,
|
||||
modifier = modifier.clickable { onSelectItem(null) },
|
||||
spacing = radius
|
||||
)
|
||||
} else {
|
||||
OutlinedCard(
|
||||
modifier = modifier.aspectRatio(1f),
|
||||
shape = RoundedCornerShape(radius)
|
||||
) {
|
||||
LazyVerticalGrid(
|
||||
columns = GridCells.Fixed(3),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalArrangement = Arrangement.Center
|
||||
) {
|
||||
for (option in options) {
|
||||
item {
|
||||
DrawItem(
|
||||
item = option.item,
|
||||
modifier = Modifier
|
||||
.alpha(if (option.enabled) 1f else 0.1f)
|
||||
.onPointerAction(
|
||||
primary = { onSelectItem(option.item) },
|
||||
secondary = {
|
||||
if (option.enabled) {
|
||||
option.enabled = false
|
||||
onOptionRemoved(option.item)
|
||||
} else {
|
||||
option.enabled = true
|
||||
onOptionAdded(option.item)
|
||||
}
|
||||
}
|
||||
),
|
||||
spacing = radius
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun <C : ItemClass<C>> DrawItem(
|
||||
modifier: Modifier = Modifier,
|
||||
spacing: Dp,
|
||||
item: Item<C>
|
||||
) {
|
||||
OutlinedCard(modifier = modifier.aspectRatio(1f), shape = RoundedCornerShape(spacing)) {
|
||||
val emoji = item.symbol
|
||||
|
||||
val textMeasurer = rememberTextMeasurer()
|
||||
|
||||
Canvas(
|
||||
modifier = Modifier.fillMaxSize(1f),
|
||||
onDraw = {
|
||||
val textSize = textMeasurer.measure(text = emoji)
|
||||
val minTextSizeDimension = min(
|
||||
textSize.size.width,
|
||||
textSize.size.height
|
||||
)
|
||||
val fontSizeBase = minTextSizeDimension * min(
|
||||
size.width / textSize.size.width,
|
||||
size.height / textSize.size.height
|
||||
)
|
||||
val fontSize = (0.9f * fontSizeBase).toDp().toSp()
|
||||
|
||||
val offset = Offset(
|
||||
x = size.width / 2 - textSize.size.width * fontSizeBase / (2f * minTextSizeDimension),
|
||||
y = size.height / 2 - textSize.size.height * fontSizeBase / (2f * minTextSizeDimension)
|
||||
)
|
||||
drawText(
|
||||
textMeasurer = textMeasurer,
|
||||
text = emoji,
|
||||
style = TextStyle(
|
||||
fontSize = fontSize,
|
||||
fontFamily = emojiFontFamily ?: TextStyle.Default.fontFamily
|
||||
),
|
||||
topLeft = offset
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class Toggleable<T>(val item: T, enabled: Boolean = true) {
|
||||
|
||||
var enabled: Boolean by mutableStateOf(enabled)
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Toggleable<*>) return false
|
||||
|
||||
if (item != other.item) return false
|
||||
if (enabled != other.enabled) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = item.hashCode()
|
||||
result = 31 * result + enabled.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package ch.dissem.yaep.ui.common.theme
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val primaryLight = Color(0xFF6D5E0F)
|
||||
val onPrimaryLight = Color(0xFFFFFFFF)
|
||||
val primaryContainerLight = Color(0xFFF8E287)
|
||||
val onPrimaryContainerLight = Color(0xFF221B00)
|
||||
val secondaryLight = Color(0xFF665E40)
|
||||
val onSecondaryLight = Color(0xFFFFFFFF)
|
||||
val secondaryContainerLight = Color(0xFFEEE2BC)
|
||||
val onSecondaryContainerLight = Color(0xFF211B04)
|
||||
val tertiaryLight = Color(0xFF166683)
|
||||
val onTertiaryLight = Color(0xFFFFFFFF)
|
||||
val tertiaryContainerLight = Color(0xFFC0E8FF)
|
||||
val onTertiaryContainerLight = Color(0xFF001E2B)
|
||||
val errorLight = Color(0xFFBA1A1A)
|
||||
val onErrorLight = Color(0xFFFFFFFF)
|
||||
val errorContainerLight = Color(0xFFFFDAD6)
|
||||
val onErrorContainerLight = Color(0xFF410002)
|
||||
val backgroundLight = Color(0xFFFFF9EE)
|
||||
val onBackgroundLight = Color(0xFF1E1B13)
|
||||
val surfaceLight = Color(0xFFFFF9EE)
|
||||
val onSurfaceLight = Color(0xFF1E1B13)
|
||||
val surfaceVariantLight = Color(0xFFEAE2D0)
|
||||
val onSurfaceVariantLight = Color(0xFF4B4739)
|
||||
val outlineLight = Color(0xFF7C7767)
|
||||
val outlineVariantLight = Color(0xFFCDC6B4)
|
||||
val scrimLight = Color(0xFF000000)
|
||||
val inverseSurfaceLight = Color(0xFF333027)
|
||||
val inverseOnSurfaceLight = Color(0xFFF7F0E2)
|
||||
val inversePrimaryLight = Color(0xFFDBC66E)
|
||||
val surfaceDimLight = Color(0xFFE0D9CC)
|
||||
val surfaceBrightLight = Color(0xFFFFF9EE)
|
||||
val surfaceContainerLowestLight = Color(0xFFFFFFFF)
|
||||
val surfaceContainerLowLight = Color(0xFFFAF3E5)
|
||||
val surfaceContainerLight = Color(0xFFF4EDDF)
|
||||
val surfaceContainerHighLight = Color(0xFFEEE8DA)
|
||||
val surfaceContainerHighestLight = Color(0xFFE8E2D4)
|
||||
|
||||
val primaryLightMediumContrast = Color(0xFF4F4200)
|
||||
val onPrimaryLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val primaryContainerLightMediumContrast = Color(0xFF857425)
|
||||
val onPrimaryContainerLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val secondaryLightMediumContrast = Color(0xFF4A4327)
|
||||
val onSecondaryLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val secondaryContainerLightMediumContrast = Color(0xFF7D7455)
|
||||
val onSecondaryContainerLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val tertiaryLightMediumContrast = Color(0xFF004960)
|
||||
val onTertiaryLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val tertiaryContainerLightMediumContrast = Color(0xFF357C9B)
|
||||
val onTertiaryContainerLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val errorLightMediumContrast = Color(0xFF8C0009)
|
||||
val onErrorLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val errorContainerLightMediumContrast = Color(0xFFDA342E)
|
||||
val onErrorContainerLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val backgroundLightMediumContrast = Color(0xFFFFF9EE)
|
||||
val onBackgroundLightMediumContrast = Color(0xFF1E1B13)
|
||||
val surfaceLightMediumContrast = Color(0xFFFFF9EE)
|
||||
val onSurfaceLightMediumContrast = Color(0xFF1E1B13)
|
||||
val surfaceVariantLightMediumContrast = Color(0xFFEAE2D0)
|
||||
val onSurfaceVariantLightMediumContrast = Color(0xFF474335)
|
||||
val outlineLightMediumContrast = Color(0xFF645F50)
|
||||
val outlineVariantLightMediumContrast = Color(0xFF807A6B)
|
||||
val scrimLightMediumContrast = Color(0xFF000000)
|
||||
val inverseSurfaceLightMediumContrast = Color(0xFF333027)
|
||||
val inverseOnSurfaceLightMediumContrast = Color(0xFFF7F0E2)
|
||||
val inversePrimaryLightMediumContrast = Color(0xFFDBC66E)
|
||||
val surfaceDimLightMediumContrast = Color(0xFFE0D9CC)
|
||||
val surfaceBrightLightMediumContrast = Color(0xFFFFF9EE)
|
||||
val surfaceContainerLowestLightMediumContrast = Color(0xFFFFFFFF)
|
||||
val surfaceContainerLowLightMediumContrast = Color(0xFFFAF3E5)
|
||||
val surfaceContainerLightMediumContrast = Color(0xFFF4EDDF)
|
||||
val surfaceContainerHighLightMediumContrast = Color(0xFFEEE8DA)
|
||||
val surfaceContainerHighestLightMediumContrast = Color(0xFFE8E2D4)
|
||||
|
||||
val primaryLightHighContrast = Color(0xFF292200)
|
||||
val onPrimaryLightHighContrast = Color(0xFFFFFFFF)
|
||||
val primaryContainerLightHighContrast = Color(0xFF4F4200)
|
||||
val onPrimaryContainerLightHighContrast = Color(0xFFFFFFFF)
|
||||
val secondaryLightHighContrast = Color(0xFF282209)
|
||||
val onSecondaryLightHighContrast = Color(0xFFFFFFFF)
|
||||
val secondaryContainerLightHighContrast = Color(0xFF4A4327)
|
||||
val onSecondaryContainerLightHighContrast = Color(0xFFFFFFFF)
|
||||
val tertiaryLightHighContrast = Color(0xFF002634)
|
||||
val onTertiaryLightHighContrast = Color(0xFFFFFFFF)
|
||||
val tertiaryContainerLightHighContrast = Color(0xFF004960)
|
||||
val onTertiaryContainerLightHighContrast = Color(0xFFFFFFFF)
|
||||
val errorLightHighContrast = Color(0xFF4E0002)
|
||||
val onErrorLightHighContrast = Color(0xFFFFFFFF)
|
||||
val errorContainerLightHighContrast = Color(0xFF8C0009)
|
||||
val onErrorContainerLightHighContrast = Color(0xFFFFFFFF)
|
||||
val backgroundLightHighContrast = Color(0xFFFFF9EE)
|
||||
val onBackgroundLightHighContrast = Color(0xFF1E1B13)
|
||||
val surfaceLightHighContrast = Color(0xFFFFF9EE)
|
||||
val onSurfaceLightHighContrast = Color(0xFF000000)
|
||||
val surfaceVariantLightHighContrast = Color(0xFFEAE2D0)
|
||||
val onSurfaceVariantLightHighContrast = Color(0xFF272418)
|
||||
val outlineLightHighContrast = Color(0xFF474335)
|
||||
val outlineVariantLightHighContrast = Color(0xFF474335)
|
||||
val scrimLightHighContrast = Color(0xFF000000)
|
||||
val inverseSurfaceLightHighContrast = Color(0xFF333027)
|
||||
val inverseOnSurfaceLightHighContrast = Color(0xFFFFFFFF)
|
||||
val inversePrimaryLightHighContrast = Color(0xFFFFECA2)
|
||||
val surfaceDimLightHighContrast = Color(0xFFE0D9CC)
|
||||
val surfaceBrightLightHighContrast = Color(0xFFFFF9EE)
|
||||
val surfaceContainerLowestLightHighContrast = Color(0xFFFFFFFF)
|
||||
val surfaceContainerLowLightHighContrast = Color(0xFFFAF3E5)
|
||||
val surfaceContainerLightHighContrast = Color(0xFFF4EDDF)
|
||||
val surfaceContainerHighLightHighContrast = Color(0xFFEEE8DA)
|
||||
val surfaceContainerHighestLightHighContrast = Color(0xFFE8E2D4)
|
||||
|
||||
val primaryDark = Color(0xFFDBC66E)
|
||||
val onPrimaryDark = Color(0xFF3A3000)
|
||||
val primaryContainerDark = Color(0xFF534600)
|
||||
val onPrimaryContainerDark = Color(0xFFF8E287)
|
||||
val secondaryDark = Color(0xFFD1C6A1)
|
||||
val onSecondaryDark = Color(0xFF363016)
|
||||
val secondaryContainerDark = Color(0xFF4E472A)
|
||||
val onSecondaryContainerDark = Color(0xFFEEE2BC)
|
||||
val tertiaryDark = Color(0xFF8DCFF1)
|
||||
val onTertiaryDark = Color(0xFF003547)
|
||||
val tertiaryContainerDark = Color(0xFF004D66)
|
||||
val onTertiaryContainerDark = Color(0xFFC0E8FF)
|
||||
val errorDark = Color(0xFFFFB4AB)
|
||||
val onErrorDark = Color(0xFF690005)
|
||||
val errorContainerDark = Color(0xFF93000A)
|
||||
val onErrorContainerDark = Color(0xFFFFDAD6)
|
||||
val backgroundDark = Color(0xFF15130B)
|
||||
val onBackgroundDark = Color(0xFFE8E2D4)
|
||||
val surfaceDark = Color(0xFF15130B)
|
||||
val onSurfaceDark = Color(0xFFE8E2D4)
|
||||
val surfaceVariantDark = Color(0xFF4B4739)
|
||||
val onSurfaceVariantDark = Color(0xFFCDC6B4)
|
||||
val outlineDark = Color(0xFF969080)
|
||||
val outlineVariantDark = Color(0xFF4B4739)
|
||||
val scrimDark = Color(0xFF000000)
|
||||
val inverseSurfaceDark = Color(0xFFE8E2D4)
|
||||
val inverseOnSurfaceDark = Color(0xFF333027)
|
||||
val inversePrimaryDark = Color(0xFF6D5E0F)
|
||||
val surfaceDimDark = Color(0xFF15130B)
|
||||
val surfaceBrightDark = Color(0xFF3C3930)
|
||||
val surfaceContainerLowestDark = Color(0xFF100E07)
|
||||
val surfaceContainerLowDark = Color(0xFF1E1B13)
|
||||
val surfaceContainerDark = Color(0xFF222017)
|
||||
val surfaceContainerHighDark = Color(0xFF2D2A21)
|
||||
val surfaceContainerHighestDark = Color(0xFF38352B)
|
||||
|
||||
val primaryDarkMediumContrast = Color(0xFFE0CA72)
|
||||
val onPrimaryDarkMediumContrast = Color(0xFF1C1600)
|
||||
val primaryContainerDarkMediumContrast = Color(0xFFA3903F)
|
||||
val onPrimaryContainerDarkMediumContrast = Color(0xFF000000)
|
||||
val secondaryDarkMediumContrast = Color(0xFFD6CAA5)
|
||||
val onSecondaryDarkMediumContrast = Color(0xFF1B1602)
|
||||
val secondaryContainerDarkMediumContrast = Color(0xFF9A916F)
|
||||
val onSecondaryContainerDarkMediumContrast = Color(0xFF000000)
|
||||
val tertiaryDarkMediumContrast = Color(0xFF91D3F5)
|
||||
val onTertiaryDarkMediumContrast = Color(0xFF001924)
|
||||
val tertiaryContainerDarkMediumContrast = Color(0xFF5599B8)
|
||||
val onTertiaryContainerDarkMediumContrast = Color(0xFF000000)
|
||||
val errorDarkMediumContrast = Color(0xFFFFBAB1)
|
||||
val onErrorDarkMediumContrast = Color(0xFF370001)
|
||||
val errorContainerDarkMediumContrast = Color(0xFFFF5449)
|
||||
val onErrorContainerDarkMediumContrast = Color(0xFF000000)
|
||||
val backgroundDarkMediumContrast = Color(0xFF15130B)
|
||||
val onBackgroundDarkMediumContrast = Color(0xFFE8E2D4)
|
||||
val surfaceDarkMediumContrast = Color(0xFF15130B)
|
||||
val onSurfaceDarkMediumContrast = Color(0xFFFFFAF5)
|
||||
val surfaceVariantDarkMediumContrast = Color(0xFF4B4739)
|
||||
val onSurfaceVariantDarkMediumContrast = Color(0xFFD1CAB8)
|
||||
val outlineDarkMediumContrast = Color(0xFFA9A292)
|
||||
val outlineVariantDarkMediumContrast = Color(0xFF888373)
|
||||
val scrimDarkMediumContrast = Color(0xFF000000)
|
||||
val inverseSurfaceDarkMediumContrast = Color(0xFFE8E2D4)
|
||||
val inverseOnSurfaceDarkMediumContrast = Color(0xFF2D2A21)
|
||||
val inversePrimaryDarkMediumContrast = Color(0xFF554700)
|
||||
val surfaceDimDarkMediumContrast = Color(0xFF15130B)
|
||||
val surfaceBrightDarkMediumContrast = Color(0xFF3C3930)
|
||||
val surfaceContainerLowestDarkMediumContrast = Color(0xFF100E07)
|
||||
val surfaceContainerLowDarkMediumContrast = Color(0xFF1E1B13)
|
||||
val surfaceContainerDarkMediumContrast = Color(0xFF222017)
|
||||
val surfaceContainerHighDarkMediumContrast = Color(0xFF2D2A21)
|
||||
val surfaceContainerHighestDarkMediumContrast = Color(0xFF38352B)
|
||||
|
||||
val primaryDarkHighContrast = Color(0xFFFFFAF5)
|
||||
val onPrimaryDarkHighContrast = Color(0xFF000000)
|
||||
val primaryContainerDarkHighContrast = Color(0xFFE0CA72)
|
||||
val onPrimaryContainerDarkHighContrast = Color(0xFF000000)
|
||||
val secondaryDarkHighContrast = Color(0xFFFFFAF5)
|
||||
val onSecondaryDarkHighContrast = Color(0xFF000000)
|
||||
val secondaryContainerDarkHighContrast = Color(0xFFD6CAA5)
|
||||
val onSecondaryContainerDarkHighContrast = Color(0xFF000000)
|
||||
val tertiaryDarkHighContrast = Color(0xFFF7FBFF)
|
||||
val onTertiaryDarkHighContrast = Color(0xFF000000)
|
||||
val tertiaryContainerDarkHighContrast = Color(0xFF91D3F5)
|
||||
val onTertiaryContainerDarkHighContrast = Color(0xFF000000)
|
||||
val errorDarkHighContrast = Color(0xFFFFF9F9)
|
||||
val onErrorDarkHighContrast = Color(0xFF000000)
|
||||
val errorContainerDarkHighContrast = Color(0xFFFFBAB1)
|
||||
val onErrorContainerDarkHighContrast = Color(0xFF000000)
|
||||
val backgroundDarkHighContrast = Color(0xFF15130B)
|
||||
val onBackgroundDarkHighContrast = Color(0xFFE8E2D4)
|
||||
val surfaceDarkHighContrast = Color(0xFF15130B)
|
||||
val onSurfaceDarkHighContrast = Color(0xFFFFFFFF)
|
||||
val surfaceVariantDarkHighContrast = Color(0xFF4B4739)
|
||||
val onSurfaceVariantDarkHighContrast = Color(0xFFFFFAF5)
|
||||
val outlineDarkHighContrast = Color(0xFFD1CAB8)
|
||||
val outlineVariantDarkHighContrast = Color(0xFFD1CAB8)
|
||||
val scrimDarkHighContrast = Color(0xFF000000)
|
||||
val inverseSurfaceDarkHighContrast = Color(0xFFE8E2D4)
|
||||
val inverseOnSurfaceDarkHighContrast = Color(0xFF000000)
|
||||
val inversePrimaryDarkHighContrast = Color(0xFF322A00)
|
||||
val surfaceDimDarkHighContrast = Color(0xFF15130B)
|
||||
val surfaceBrightDarkHighContrast = Color(0xFF3C3930)
|
||||
val surfaceContainerLowestDarkHighContrast = Color(0xFF100E07)
|
||||
val surfaceContainerLowDarkHighContrast = Color(0xFF1E1B13)
|
||||
val surfaceContainerDarkHighContrast = Color(0xFF222017)
|
||||
val surfaceContainerHighDarkHighContrast = Color(0xFF2D2A21)
|
||||
val surfaceContainerHighestDarkHighContrast = Color(0xFF38352B)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package ch.dissem.yaep.ui.common.theme
|
||||
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
private val lightScheme = lightColorScheme(
|
||||
primary = primaryLight,
|
||||
onPrimary = onPrimaryLight,
|
||||
primaryContainer = primaryContainerLight,
|
||||
onPrimaryContainer = onPrimaryContainerLight,
|
||||
secondary = secondaryLight,
|
||||
onSecondary = onSecondaryLight,
|
||||
secondaryContainer = secondaryContainerLight,
|
||||
onSecondaryContainer = onSecondaryContainerLight,
|
||||
tertiary = tertiaryLight,
|
||||
onTertiary = onTertiaryLight,
|
||||
tertiaryContainer = tertiaryContainerLight,
|
||||
onTertiaryContainer = onTertiaryContainerLight,
|
||||
error = errorLight,
|
||||
onError = onErrorLight,
|
||||
errorContainer = errorContainerLight,
|
||||
onErrorContainer = onErrorContainerLight,
|
||||
background = backgroundLight,
|
||||
onBackground = onBackgroundLight,
|
||||
surface = surfaceLight,
|
||||
onSurface = onSurfaceLight,
|
||||
surfaceVariant = surfaceVariantLight,
|
||||
onSurfaceVariant = onSurfaceVariantLight,
|
||||
outline = outlineLight,
|
||||
outlineVariant = outlineVariantLight,
|
||||
scrim = scrimLight,
|
||||
inverseSurface = inverseSurfaceLight,
|
||||
inverseOnSurface = inverseOnSurfaceLight,
|
||||
inversePrimary = inversePrimaryLight,
|
||||
surfaceDim = surfaceDimLight,
|
||||
surfaceBright = surfaceBrightLight,
|
||||
surfaceContainerLowest = surfaceContainerLowestLight,
|
||||
surfaceContainerLow = surfaceContainerLowLight,
|
||||
surfaceContainer = surfaceContainerLight,
|
||||
surfaceContainerHigh = surfaceContainerHighLight,
|
||||
surfaceContainerHighest = surfaceContainerHighestLight,
|
||||
)
|
||||
|
||||
private val darkScheme = darkColorScheme(
|
||||
primary = primaryDark,
|
||||
onPrimary = onPrimaryDark,
|
||||
primaryContainer = primaryContainerDark,
|
||||
onPrimaryContainer = onPrimaryContainerDark,
|
||||
secondary = secondaryDark,
|
||||
onSecondary = onSecondaryDark,
|
||||
secondaryContainer = secondaryContainerDark,
|
||||
onSecondaryContainer = onSecondaryContainerDark,
|
||||
tertiary = tertiaryDark,
|
||||
onTertiary = onTertiaryDark,
|
||||
tertiaryContainer = tertiaryContainerDark,
|
||||
onTertiaryContainer = onTertiaryContainerDark,
|
||||
error = errorDark,
|
||||
onError = onErrorDark,
|
||||
errorContainer = errorContainerDark,
|
||||
onErrorContainer = onErrorContainerDark,
|
||||
background = backgroundDark,
|
||||
onBackground = onBackgroundDark,
|
||||
surface = surfaceDark,
|
||||
onSurface = onSurfaceDark,
|
||||
surfaceVariant = surfaceVariantDark,
|
||||
onSurfaceVariant = onSurfaceVariantDark,
|
||||
outline = outlineDark,
|
||||
outlineVariant = outlineVariantDark,
|
||||
scrim = scrimDark,
|
||||
inverseSurface = inverseSurfaceDark,
|
||||
inverseOnSurface = inverseOnSurfaceDark,
|
||||
inversePrimary = inversePrimaryDark,
|
||||
surfaceDim = surfaceDimDark,
|
||||
surfaceBright = surfaceBrightDark,
|
||||
surfaceContainerLowest = surfaceContainerLowestDark,
|
||||
surfaceContainerLow = surfaceContainerLowDark,
|
||||
surfaceContainer = surfaceContainerDark,
|
||||
surfaceContainerHigh = surfaceContainerHighDark,
|
||||
surfaceContainerHighest = surfaceContainerHighestDark,
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun AppTheme(
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
content: @Composable() () -> Unit
|
||||
) {
|
||||
val colorScheme = when {
|
||||
darkTheme -> darkScheme
|
||||
else -> lightScheme
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package ch.dissem.yaep.ui.common.theme
|
||||
|
||||
//import androidx.compose.material3.Typography
|
||||
//import androidx.compose.ui.text.TextStyle
|
||||
//import androidx.compose.ui.text.font.FontFamily
|
||||
//import androidx.compose.ui.text.font.FontWeight
|
||||
//import androidx.compose.ui.unit.sp
|
||||
//
|
||||
//import androidx.compose.ui.text.googlefonts.GoogleFont
|
||||
//import androidx.compose.ui.text.googlefonts.Font
|
||||
//
|
||||
//val provider = GoogleFont.Provider(
|
||||
// providerAuthority = "com.google.android.gms.fonts",
|
||||
// providerPackage = "com.google.android.gms",
|
||||
// certificates = "MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANbOLggKv+IxTdGNs8/TGFy0PTP6DHThvbbR24kT9ixcOd9W+EaBPWW+wPPKQmsHxajtWjmQwWfna8mZuSeJS48LIgAZlKkpFeVyxW0qMBujb8X8ETrWy550NaFtI6t9+u7hZeTfHwqNvacKhp1RbE6dBRGWynwMVX8XW8N1+UjFaq6GCJukT4qmpN2afb8sCjUigq0GuMwYXrFVee74bQgLHWGJwPmvmLHC69EH6kWr22ijx4OKXlSIx2xT1AsSHee70w5iDBiK4aph27yH3TxkXy9V89TDdexAcKk/cVHYNnDBapcavl7y0RiQ4biu8ymM8Ga/nmzhRKya6G0cGw8CAQOjgfwwgfkwHQYDVR0OBBYEFI0cxb6VTEM8YYY6FbBMvAPyT+CyMIHJBgNVHSMEgcEwgb6AFI0cxb6VTEM8YYY6FbBMvAPyT+CyoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJANWFuGx90071MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBABnTDPEF+3iSP0wNfdIjIz1AlnrPzgAIHVvXxunW7SBrDhEglQZBbKJEk5kT0mtKoOD1JMrSu1xuTKEBahWRbqHsXclaXjoBADb0kkjVEJu/Lh5hgYZnOjvlba8Ld7HCKePCVePoTJBdI4fvugnL8TsgK05aIskyY0hKI9L8KfqfGTl1lzOv2KoWD0KWwtAWPoGChZxmQ+nBli+gwYMzM1vAkP+aayLe0a1EQimlOalO762r0GXO0ks+UeXde2Z4e+8S/pf7pITEI/tP+MxJTALw9QUWEv9lKTk+jkbqxbsh8nfBUapfKqYn0eidpwq2AzVp3juYl7//fKnaPhJD9gs="
|
||||
//)
|
||||
//
|
||||
//val bodyFontFamily = FontFamily(
|
||||
// Font(
|
||||
// googleFont = GoogleFont("Roboto"),
|
||||
// fontProvider = provider,
|
||||
// )
|
||||
//)
|
||||
//
|
||||
//val displayFontFamily = FontFamily(
|
||||
// Font(
|
||||
// googleFont = GoogleFont("Shadows Into Light Two"),
|
||||
// fontProvider = provider,
|
||||
// )
|
||||
//)
|
||||
//
|
||||
//// Default Material 3 typography values
|
||||
//val baseline = Typography()
|
||||
//
|
||||
//val AppTypography = Typography(
|
||||
// displayLarge = baseline.displayLarge.copy(fontFamily = displayFontFamily),
|
||||
// displayMedium = baseline.displayMedium.copy(fontFamily = displayFontFamily),
|
||||
// displaySmall = baseline.displaySmall.copy(fontFamily = displayFontFamily),
|
||||
// headlineLarge = baseline.headlineLarge.copy(fontFamily = displayFontFamily),
|
||||
// headlineMedium = baseline.headlineMedium.copy(fontFamily = displayFontFamily),
|
||||
// headlineSmall = baseline.headlineSmall.copy(fontFamily = displayFontFamily),
|
||||
// titleLarge = baseline.titleLarge.copy(fontFamily = displayFontFamily),
|
||||
// titleMedium = baseline.titleMedium.copy(fontFamily = displayFontFamily),
|
||||
// titleSmall = baseline.titleSmall.copy(fontFamily = displayFontFamily),
|
||||
// bodyLarge = baseline.bodyLarge.copy(fontFamily = bodyFontFamily),
|
||||
// bodyMedium = baseline.bodyMedium.copy(fontFamily = bodyFontFamily),
|
||||
// bodySmall = baseline.bodySmall.copy(fontFamily = bodyFontFamily),
|
||||
// labelLarge = baseline.labelLarge.copy(fontFamily = bodyFontFamily),
|
||||
// labelMedium = baseline.labelMedium.copy(fontFamily = bodyFontFamily),
|
||||
// labelSmall = baseline.labelSmall.copy(fontFamily = bodyFontFamily),
|
||||
//)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package ch.dissem.yaep.ui.common.theme
|
||||
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
|
||||
var emojiFontFamily: FontFamily? = null
|
||||
@@ -0,0 +1,33 @@
|
||||
import androidx.compose.ui.test.ExperimentalTestApi
|
||||
import androidx.compose.ui.test.assertTextContains
|
||||
import androidx.compose.ui.test.onNodeWithTag
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.runComposeUiTest
|
||||
import ch.dissem.yaep.ui.common.EndOfGame
|
||||
import ch.dissem.yaep.ui.common.IgnoreAndroidUnitTest
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
|
||||
import ch.tutteli.atrium.api.verbs.expect
|
||||
import kotlin.test.Test
|
||||
|
||||
@IgnoreAndroidUnitTest
|
||||
@OptIn(ExperimentalTestApi::class)
|
||||
class EndOfGameTest {
|
||||
|
||||
@Test
|
||||
fun ensure_end_of_game_works_correctly() = runComposeUiTest {
|
||||
var restart = false
|
||||
setContent {
|
||||
EndOfGame(
|
||||
isSolved = true,
|
||||
time = "42:42",
|
||||
onRestart = { restart = true }
|
||||
)
|
||||
}
|
||||
|
||||
onNodeWithTag("EndOfGame.solved_time").assertTextContains(value = "42:42", substring = true)
|
||||
onNodeWithTag("EndOfGame.restart").performClick()
|
||||
|
||||
expect(restart).toEqual(true)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
|
||||
expect annotation class IgnoreAndroidUnitTest()
|
||||
@@ -0,0 +1,33 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import ch.dissem.yaep.domain.Game
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.createFile
|
||||
import kotlin.io.path.isDirectory
|
||||
import kotlin.io.path.writeText
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
private val log = KotlinLogging.logger {}
|
||||
|
||||
@OptIn(ExperimentalTime::class)
|
||||
actual fun CoroutineScope.logGame(game: Game, dispatcher: CoroutineContext) {
|
||||
launch(dispatcher) {
|
||||
val dirName = """${System.getProperty("user.home")}/.yaep"""
|
||||
val dir = Path(dirName)
|
||||
if (dir.isDirectory()) {
|
||||
val fileName = "$dirName/${Clock.System.now()}.yaep"
|
||||
Path(fileName)
|
||||
.createFile()
|
||||
.writeText(game.toString())
|
||||
log.info { "Saved game to $fileName" }
|
||||
} else {
|
||||
log.debug { "Yaep data directory does not exist or is not a directory: $dir" }
|
||||
log.debug { "Game: $game" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.PointerMatcher
|
||||
import androidx.compose.foundation.PointerMatcher.Companion.mouse
|
||||
import androidx.compose.foundation.onClick
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.pointer.PointerButton.Companion.Secondary
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
actual fun Modifier.onPointerAction(primary: () -> Unit, secondary: () -> Unit): Modifier {
|
||||
return this
|
||||
.onClick(matcher = PointerMatcher.Primary, onClick = primary)
|
||||
.onClick(matcher = mouse(Secondary), onClick = secondary)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package ch.dissem.yaep.ui.common
|
||||
|
||||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.FUNCTION])
|
||||
actual annotation class IgnoreAndroidUnitTest actual constructor()
|
||||
@@ -1,85 +0,0 @@
|
||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
alias(libs.plugins.androidApplication)
|
||||
alias(libs.plugins.jetbrainsCompose)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
androidTarget {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jvm("desktop")
|
||||
|
||||
sourceSets {
|
||||
val desktopMain by getting
|
||||
|
||||
androidMain.dependencies {
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
implementation(libs.androidx.activity.compose)
|
||||
}
|
||||
commonMain.dependencies {
|
||||
implementation(compose.runtime)
|
||||
implementation(compose.foundation)
|
||||
implementation(compose.material)
|
||||
implementation(compose.ui)
|
||||
implementation(compose.components.resources)
|
||||
implementation(compose.components.uiToolingPreview)
|
||||
}
|
||||
desktopMain.dependencies {
|
||||
implementation(compose.desktop.currentOs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "ch.dissem.yaep"
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
|
||||
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
|
||||
sourceSets["main"].res.srcDirs("src/androidMain/res")
|
||||
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "ch.dissem.yaep"
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
}
|
||||
packaging {
|
||||
resources {
|
||||
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
getByName("release") {
|
||||
isMinifyEnabled = false
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
dependencies {
|
||||
debugImplementation(libs.compose.ui.tooling)
|
||||
}
|
||||
}
|
||||
|
||||
compose.desktop {
|
||||
application {
|
||||
mainClass = "MainKt"
|
||||
|
||||
nativeDistributions {
|
||||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
|
||||
packageName = "ch.dissem.yaep"
|
||||
packageVersion = "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import android.os.Build
|
||||
|
||||
class AndroidPlatform : Platform {
|
||||
override val name: String = "Android ${Build.VERSION.SDK_INT}"
|
||||
}
|
||||
|
||||
actual fun getPlatform(): Platform = AndroidPlatform()
|
||||
@@ -1,24 +0,0 @@
|
||||
package ch.dissem.yaep
|
||||
|
||||
import App
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContent {
|
||||
App()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun AppAndroidPreview() {
|
||||
App()
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
@@ -1,170 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 16 KiB |
@@ -1,37 +0,0 @@
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material.Button
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import org.jetbrains.compose.resources.ExperimentalResourceApi
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import org.jetbrains.compose.ui.tooling.preview.Preview
|
||||
|
||||
import yaep.composeapp.generated.resources.Res
|
||||
import yaep.composeapp.generated.resources.compose_multiplatform
|
||||
|
||||
@OptIn(ExperimentalResourceApi::class)
|
||||
@Composable
|
||||
@Preview
|
||||
fun App() {
|
||||
MaterialTheme {
|
||||
var showContent by remember { mutableStateOf(false) }
|
||||
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Button(onClick = { showContent = !showContent }) {
|
||||
Text("Click me!")
|
||||
}
|
||||
AnimatedVisibility(showContent) {
|
||||
val greeting = remember { Greeting().greet() }
|
||||
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Image(painterResource(Res.drawable.compose_multiplatform), null)
|
||||
Text("Compose: $greeting")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
class Greeting {
|
||||
private val platform = getPlatform()
|
||||
|
||||
fun greet(): String {
|
||||
return "Hello, ${platform.name}!"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
interface Platform {
|
||||
val name: String
|
||||
}
|
||||
|
||||
expect fun getPlatform(): Platform
|
||||
@@ -1,5 +0,0 @@
|
||||
class JVMPlatform: Platform {
|
||||
override val name: String = "Java ${System.getProperty("java.version")}"
|
||||
}
|
||||
|
||||
actual fun getPlatform(): Platform = JVMPlatform()
|
||||
@@ -1,11 +0,0 @@
|
||||
import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.application
|
||||
|
||||
fun main() = application {
|
||||
Window(
|
||||
onCloseRequest = ::exitApplication,
|
||||
title = "YAEP",
|
||||
) {
|
||||
App()
|
||||
}
|
||||
}
|
||||
52
desktop/build.gradle.kts
Normal file
@@ -0,0 +1,52 @@
|
||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.kover)
|
||||
alias(libs.plugins.kotlin.jvm)
|
||||
alias(libs.plugins.compose.compiler)
|
||||
alias(libs.plugins.compose)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(libs.versions.jdk.get().toInt())
|
||||
|
||||
dependencies {
|
||||
implementation(compose.desktop.currentOs)
|
||||
implementation(compose.material3)
|
||||
implementation(compose.components.resources)
|
||||
implementation(projects.commonUI)
|
||||
implementation(compose.components.uiToolingPreview)
|
||||
|
||||
testImplementation(libs.kotlin.test)
|
||||
testImplementation(libs.atrium)
|
||||
testImplementation(compose.desktop.uiTestJUnit4)
|
||||
testImplementation(compose.desktop.currentOs)
|
||||
}
|
||||
}
|
||||
|
||||
compose.desktop {
|
||||
application {
|
||||
mainClass = "ch.dissem.yaep.ui.desktop.MainKt"
|
||||
|
||||
nativeDistributions {
|
||||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
|
||||
packageName = "YAEP"
|
||||
packageVersion = libs.versions.app.version.name.get()
|
||||
macOS {
|
||||
iconFile.set(project.file("icon.icns"))
|
||||
}
|
||||
windows {
|
||||
iconFile.set(project.file("icon.ico"))
|
||||
}
|
||||
linux {
|
||||
iconFile.set(project.file("icon.png"))
|
||||
}
|
||||
|
||||
buildTypes.release.proguard {
|
||||
configurationFiles.from(project.file("proguard-rules.pro"))
|
||||
isEnabled.set(false)
|
||||
obfuscate.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
desktop/icon.icns
Normal file
BIN
desktop/icon.ico
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
desktop/icon.png
Normal file
|
After Width: | Height: | Size: 174 KiB |
25
desktop/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)
|
||||
|
||||
-keepclasseswithmembers public class MainKt {
|
||||
public static void main(java.lang.String[]);
|
||||
}
|
||||
|
||||
-dontwarn kotlinx.coroutines.debug.*
|
||||
-dontwarn kotlinx.datetime.**
|
||||
|
||||
-keep class kotlin.** { *; }
|
||||
-keep class kotlinx.coroutines.** { *; }
|
||||
-keep class org.jetbrains.skia.** { *; }
|
||||
-keep class org.jetbrains.skiko.** { *; }
|
||||
|
||||
-ignorewarnings
|
||||
|
||||
# Windows folders
|
||||
-keep class com.sun.jna.* { *; }
|
||||
-keepclassmembers class * extends com.sun.jna.* { public *; }
|
||||
|
||||
-assumenosideeffects public class androidx.compose.runtime.ComposerKt {
|
||||
void sourceInformation(androidx.compose.runtime.Composer,java.lang.String);
|
||||
void sourceInformationMarkerStart(androidx.compose.runtime.Composer,int,java.lang.String);
|
||||
void sourceInformationMarkerEnd(androidx.compose.runtime.Composer);
|
||||
}
|
||||
157
desktop/src/main/composeResources/drawable/ic_launcher.svg
Normal file
@@ -0,0 +1,157 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
version="1.1"
|
||||
id="Layer_2"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 32 32"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="ic_launcher.svg"
|
||||
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
|
||||
width="32"
|
||||
height="32"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
||||
id="defs16"><filter
|
||||
style="color-interpolation-filters:sRGB"
|
||||
inkscape:label="Drop Shadow"
|
||||
id="filter31"
|
||||
x="-0.032370995"
|
||||
y="-0.033195397"
|
||||
width="1.0773869"
|
||||
height="1.0793577"><feFlood
|
||||
result="flood"
|
||||
in="SourceGraphic"
|
||||
flood-opacity="0.498039"
|
||||
flood-color="rgb(0,0,0)"
|
||||
id="feFlood30" /><feGaussianBlur
|
||||
result="blur"
|
||||
in="SourceGraphic"
|
||||
stdDeviation="1.600000"
|
||||
id="feGaussianBlur30" /><feOffset
|
||||
result="offset"
|
||||
in="blur"
|
||||
dx="1.500000"
|
||||
dy="1.500000"
|
||||
id="feOffset30" /><feComposite
|
||||
result="comp1"
|
||||
operator="in"
|
||||
in="flood"
|
||||
in2="offset"
|
||||
id="feComposite30" /><feComposite
|
||||
result="comp2"
|
||||
operator="over"
|
||||
in="SourceGraphic"
|
||||
in2="comp1"
|
||||
id="feComposite31" /></filter></defs><sodipodi:namedview
|
||||
id="namedview16"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:zoom="5.0602329"
|
||||
inkscape:cx="18.47741"
|
||||
inkscape:cy="88.632284"
|
||||
inkscape:window-width="2514"
|
||||
inkscape:window-height="1376"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_2" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<g
|
||||
id="g1"
|
||||
transform="scale(0.25)"><rect
|
||||
style="fill:#64bb8b;fill-opacity:1;stroke:none;stroke-width:1.06961;stroke-linecap:round;stroke-linejoin:round"
|
||||
id="rect16"
|
||||
width="128"
|
||||
height="128"
|
||||
x="0"
|
||||
y="0"
|
||||
ry="34.385769" /><g
|
||||
id="g16"
|
||||
transform="matrix(0.86689217,0,0,0.86689217,8.5348442,8.6056136)"
|
||||
style="filter:url(#filter31)"><path
|
||||
style="fill:#464c4f"
|
||||
d="m 48.37,30.91 c 0,0 -11.64,-10.14 -12.76,-11.26 -1.13,-1.13 -3.94,-3.19 -3.38,-4.69 0.56,-1.5 9.970869,-5.1593697 16.52,-6.57 61.24673,-13.1920546 87.03498,66.992265 69.07,103.23 z"
|
||||
id="path1"
|
||||
sodipodi:nodetypes="cssscc" /><path
|
||||
style="fill:#dfdfe0"
|
||||
d="m 122.80319,94.287388 c -0.55952,4.737883 -1.7556,9.476742 -3.58825,14.216582 L 58.78,28.65 45.9,9.09 C 50.172499,7.9539441 54.430312,7.2672185 58.673441,7.0298231 L 65.33,33.23 73.824086,8.2778223 c 3.944588,0.9298418 7.612394,2.2400637 11.003419,3.9306647 L 71.88,39.22 75.96,40.7 93.154829,17.321488 c 2.030666,1.525255 3.874009,3.08539 5.530028,4.680406 L 81.59,44.64 l 5.63,4.15 17.60648,-20.033392 c 2.18905,2.770551 4.17347,5.673589 5.95327,8.709114 L 93.63,53.44 97.01,59 115.57372,46.917431 c 0.85589,1.980725 1.62329,3.929695 2.3022,5.84691 L 99.33,63.71 l 4.65,5.21 16.1781,-8.818231 c 0.56937,2.125057 1.06545,4.261013 1.48824,6.407868 L 104.19,75.33 l 2.96,6.69 15.8982,-5.810371 c 0.19299,2.146165 0.3103,4.149076 0.35195,6.008735 L 109.75,87.23 l 3.24,8.09 z"
|
||||
id="path2"
|
||||
sodipodi:nodetypes="ccccccccccccccccccccccccccccccc" /><path
|
||||
style="fill:#2f2f2f"
|
||||
d="m 56.53,27.11 c -9.515632,0.68283 -16.735265,5.918392 -36.32,31.67 3.278036,11.308288 6.065802,22.034403 13.09,31.4 14.754823,1.844912 25.776979,-4.514463 29.98,-7.46 -1.570069,13.010422 -3.421949,25.24918 -4.98,38.29 -0.377505,3.1597 58.73991,1.00009 60.58,-0.84 4.00672,-4.00672 -2.52698,-67.624889 -40.1,-85.32 C 79.488656,14.965582 70.214593,7.4654598 69.62,7.4 69.522198,7.3894675 60.081987,9.8944679 56.53,27.11 Z"
|
||||
id="path3"
|
||||
sodipodi:nodetypes="ccccssccc" /><path
|
||||
style="fill:#ffffff"
|
||||
d="M 22.53,58.86 33.02,45.77 c 1.819925,2.610936 -1.210179,6.546081 -7.11,13.86 z"
|
||||
id="path4"
|
||||
sodipodi:nodetypes="cccc" /><path
|
||||
style="fill:#ffffff"
|
||||
d="m 28.47,78.02 c 16.344125,-15.16343 24.960791,-8.079215 23.51,6.76 -2.066549,1.049292 -3.371337,1.310501 -5.45,1.67 1.593813,-13.420769 -5.839561,-12.487267 -16.75,-5.89 z"
|
||||
id="path5"
|
||||
sodipodi:nodetypes="ccccc" /><path
|
||||
style="fill:#ffffff"
|
||||
d="m 32.69,85.39 c 2.974025,-3.546509 7.702141,-3.296661 8.03,1.97 -3.066857,0.198745 -4.479365,0.154746 -8.68,0 z"
|
||||
id="path6"
|
||||
sodipodi:nodetypes="cccc" /><path
|
||||
style="fill:#ffffff"
|
||||
d="m 29.97,69.81 c 0,0 8.49,-10.46 21.02,-6.01 12.53,4.45 7.27,17.55 7.27,17.55 l 3.43,-1.6 c 3.134982,-14.516465 -6.072104,-15.228473 -4.5,-23.22 0.988119,-3.902791 1.347111,-10.123287 5.957155,-11.45065 3.973341,0.142932 0.08547,6.596839 0.712845,12.11065 0.984765,8.654834 7.526674,7.780843 3.8,29.32 C 80.153957,80.177213 91.077391,71.622086 101.44,62.29 100.92352,61.019029 99.873769,59.293652 98.95,58.26 79.930936,72.11648 72.049452,76.501362 71.59,75.96 70.906762,75.154956 79.113363,52.72085 83.6,41.7 c -1.739551,-1.553843 -2.447211,-1.879108 -5.58,-3.05 -1.49791,2.87385 -3.62374,12.446811 -8.11,11.55 -1.88,-1.36 -1.83,-7.65 1.41,-11.97 1.73,-2.31 3.8,-3.05 4.08,-9.43 0.406083,-9.252901 -4.874232,-17.135626 -5.92,-17.08 -6.439844,4.086989 -8.193181,11.175358 -9.15,18.21 l -2.02,0.75 c 0,0 -0.96,10.46 -3.26,12.2 -2.3,1.74 -6.05,1.2 -6.45,-1.78 -0.52,-3.91 -0.33,-7.93 -0.33,-7.93 -3.254156,1.181974 -4.495149,3.708555 -5.2,6.94 -0.617081,6.754115 -10.168497,11.485223 -11.988628,22.794533 z"
|
||||
id="path7"
|
||||
sodipodi:nodetypes="csccssscccsccccssccsccssc" /><path
|
||||
style="fill:#ffffff"
|
||||
d="m 89.76,47.43 c 0,0 -5.33,11.83 -5.16,12.44 0.17,0.61 10.23,-7.46 10.23,-7.46 -3.009379,-3.73527 -4.307475,-4.571497 -5.07,-4.98 z"
|
||||
id="path8"
|
||||
sodipodi:nodetypes="cscc" /><path
|
||||
style="fill:#0b0b0b"
|
||||
d="m 54.23,53.58 c 0,2.8 -1.08,5.58 -4.22,5.3 -2.34,-0.21 -4.27,-2.5 -4.27,-5.3 0,-2.8 1.9,-5.07 4.25,-5.07 2.35,0 4.24,2.27 4.24,5.07 z"
|
||||
id="path9" /><path
|
||||
style="fill:#ffffff"
|
||||
d="m 63.71,101.51 -0.84,7.67 c 28.972358,-11.093985 43.69859,-32.108673 44.98,-34 -0.57539,-2.121581 -1.50834,-4.063048 -2.82,-6.13 -20.847573,22.144094 -22.952642,23.971573 -41.32,32.46 z"
|
||||
id="path10"
|
||||
sodipodi:nodetypes="ccccc" /><path
|
||||
style="fill:#ffffff"
|
||||
d="m 66.88,118.9 c 4.883311,-4.88331 10.685214,3.17631 44.13,-36.04 0.47481,2.342723 1.09693,3.835453 1.47,5.78 -8.40359,12.68318 -15.724822,22.84732 -30.84,30.62 -4.826151,0.25674 -9.638547,0.0546 -14.76,-0.36 z"
|
||||
id="path11"
|
||||
sodipodi:nodetypes="ccccc" /><path
|
||||
style="fill:#ffffff"
|
||||
d="m 114.46,99.82 c -5.1642,9.14719 -5.75663,10.86854 -11.12,18.16 4.86811,-0.11174 9.09144,-0.43841 12.67,-0.98 0.34304,-5.51174 -0.17363,-11.23841 -1.55,-17.18 z"
|
||||
id="path12"
|
||||
sodipodi:nodetypes="cccc" /><path
|
||||
style="fill:#454c50"
|
||||
d="m 68.64,18.45 c -2.435036,-0.263247 -8.50729,16.82 -1.34,16.82 6.08653,0 3.386055,-16.594451 1.34,-16.82 z"
|
||||
id="path13"
|
||||
sodipodi:nodetypes="csc" /><path
|
||||
style="fill:#464c4f"
|
||||
d="m 29.88,60 c -2.89,-2.64 -7.41,-3.57 -9.67,-1.22 -2.25,2.35 -3.57,5.35 -5.44,7.32 -7.0250353,6.534018 -13.116568,15.916769 -8.17,25.53 3,4.97 9.1,8.26 16.61,5.63 C 30.72,94.63 33.72,90.78 34,87.97 35.035769,77.575321 27.08491,78.160548 28.56,74.64 29.31,72.85 35.32,64.98 29.88,60 Z"
|
||||
id="path14"
|
||||
sodipodi:nodetypes="cccssssc" /><path
|
||||
style="fill:#303030"
|
||||
d="m 11.11,79.71 c -0.1,1.56 1.92,1.27 2.63,2.72 0.7,1.45 -0.94,4.27 0.89,4.6 1.83,0.33 4.18,-3.28 3.05,-6.71 -1.13,-3.42 -6.43,-2.86 -6.57,-0.61 z"
|
||||
id="path15" /><path
|
||||
style="fill:#303030"
|
||||
d="m 14.23,97.64 c 0,0 5,-2.44 7.25,-4.55 2.19,-2.06 4.32,-4.55 4.83,-5.35 0.52,-0.8 1.6,-2.25 2.53,-1.6 0.94,0.66 0.52,1.83 -0.09,2.72 -0.61,0.89 -2.16,3.1 -4.6,5.35 -2.11,1.95 -3.14,2.44 -4.69,3.28 -1.13,0.61 -2.21,0.7 -2.21,0.7 0,0 -0.88,0.01 -1.79,-0.14 C 15.11,98 14.23,97.64 14.23,97.64 Z"
|
||||
id="path16" /></g></g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.1 KiB |
@@ -0,0 +1,146 @@
|
||||
package ch.dissem.yaep.ui.desktop
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.window.WindowDraggableArea
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.SwitchDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.WindowPlacement
|
||||
import androidx.compose.ui.window.WindowScope
|
||||
import androidx.compose.ui.window.WindowState
|
||||
import ch.dissem.yaep.ui.common.theme.AppTheme
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import yaep.commonui.generated.resources.action_restart
|
||||
import yaep.commonui.generated.resources.app_name_full
|
||||
import yaep.commonui.generated.resources.moon
|
||||
import yaep.commonui.generated.resources.restart
|
||||
import yaep.commonui.generated.resources.sun
|
||||
import yaep.commonui.generated.resources.use_dark_mode
|
||||
import yaep.commonui.generated.resources.use_light_mode
|
||||
import yaep.commonui.generated.resources.window_close
|
||||
import yaep.commonui.generated.resources.window_maximize
|
||||
import yaep.commonui.generated.resources.window_minimize
|
||||
import yaep.desktop.generated.resources.ic_launcher
|
||||
import yaep.commonui.generated.resources.Res as CRes
|
||||
import yaep.desktop.generated.resources.Res as DRes
|
||||
|
||||
@Composable
|
||||
fun WindowScope.DesktopWindow(
|
||||
useDarkMode: Boolean,
|
||||
topBar: @Composable () -> Unit,
|
||||
content: @Composable (PaddingValues) -> Unit
|
||||
) {
|
||||
AppTheme(darkTheme = useDarkMode) {
|
||||
Scaffold(
|
||||
topBar = {
|
||||
WindowDraggableArea {
|
||||
topBar()
|
||||
}
|
||||
}
|
||||
) { paddingValues ->
|
||||
content(paddingValues)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun AppBar(
|
||||
useDarkMode: Boolean,
|
||||
setDarkMode: (Boolean) -> Unit,
|
||||
onCloseRequest: () -> Unit,
|
||||
onRestart: () -> Unit,
|
||||
windowState: WindowState,
|
||||
) {
|
||||
TopAppBar(
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { /* do nothing */ }) {
|
||||
Image(
|
||||
painter = painterResource(DRes.drawable.ic_launcher),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
},
|
||||
title = { Text(text = stringResource(CRes.string.app_name_full)) },
|
||||
actions = {
|
||||
IconButton(
|
||||
onClick = onRestart
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(CRes.drawable.action_restart),
|
||||
contentDescription = stringResource(CRes.string.restart),
|
||||
modifier = Modifier.size(SwitchDefaults.IconSize),
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Switch(
|
||||
checked = useDarkMode,
|
||||
onCheckedChange = setDarkMode,
|
||||
thumbContent = {
|
||||
Icon(
|
||||
painter = painterResource(
|
||||
if (useDarkMode) {
|
||||
CRes.drawable.moon
|
||||
} else {
|
||||
CRes.drawable.sun
|
||||
}
|
||||
),
|
||||
contentDescription = stringResource(
|
||||
if (useDarkMode) {
|
||||
CRes.string.use_dark_mode
|
||||
} else {
|
||||
CRes.string.use_light_mode
|
||||
}
|
||||
),
|
||||
modifier = Modifier.size(SwitchDefaults.IconSize),
|
||||
)
|
||||
}
|
||||
)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
IconButton(
|
||||
onClick = { windowState.isMinimized = !windowState.isMinimized }
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(CRes.drawable.window_minimize),
|
||||
contentDescription = stringResource(CRes.string.window_minimize),
|
||||
modifier = Modifier.size(SwitchDefaults.IconSize),
|
||||
)
|
||||
}
|
||||
IconButton(
|
||||
onClick = {
|
||||
windowState.placement =
|
||||
if (windowState.placement == WindowPlacement.Maximized)
|
||||
WindowPlacement.Floating else WindowPlacement.Maximized
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(CRes.drawable.window_maximize),
|
||||
contentDescription = stringResource(CRes.string.window_maximize),
|
||||
modifier = Modifier.size(SwitchDefaults.IconSize),
|
||||
)
|
||||
}
|
||||
IconButton(
|
||||
onClick = onCloseRequest
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(CRes.drawable.window_close),
|
||||
contentDescription = stringResource(CRes.string.window_close),
|
||||
modifier = Modifier.size(SwitchDefaults.IconSize),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
78
desktop/src/main/kotlin/ch/dissem/yaep/ui/desktop/main.kt
Normal file
@@ -0,0 +1,78 @@
|
||||
package ch.dissem.yaep.ui.desktop
|
||||
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.platform.Font
|
||||
import androidx.compose.ui.unit.DpSize
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.WindowPlacement
|
||||
import androidx.compose.ui.window.application
|
||||
import androidx.compose.ui.window.rememberWindowState
|
||||
import ch.dissem.yaep.domain.generateGame
|
||||
import ch.dissem.yaep.ui.common.App
|
||||
import ch.dissem.yaep.ui.common.theme.emojiFontFamily
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import yaep.commonui.generated.resources.app_name
|
||||
import yaep.desktop.generated.resources.ic_launcher
|
||||
import yaep.commonui.generated.resources.Res as CRes
|
||||
import yaep.desktop.generated.resources.Res as DRes
|
||||
|
||||
fun main(): Unit = application {
|
||||
emojiFontFamily = FontFamily(
|
||||
Font(
|
||||
resource = "NotoColorEmoji-Regular.ttf",
|
||||
weight = FontWeight.W400,
|
||||
style = FontStyle.Normal
|
||||
)
|
||||
)
|
||||
val windowState = rememberWindowState(
|
||||
placement = WindowPlacement.Floating,
|
||||
size = DpSize(1250.dp, 800.dp)
|
||||
)
|
||||
var game by remember { mutableStateOf(generateGame()) }
|
||||
|
||||
Window(
|
||||
onCloseRequest = ::exitApplication,
|
||||
undecorated = true,
|
||||
title = stringResource(CRes.string.app_name),
|
||||
state = windowState,
|
||||
icon = painterResource(DRes.drawable.ic_launcher)
|
||||
) {
|
||||
var useDarkMode by remember { mutableStateOf(true) }
|
||||
var resetCluesBeacon by remember { mutableStateOf(Any()) }
|
||||
DesktopWindow(
|
||||
useDarkMode = useDarkMode,
|
||||
topBar = {
|
||||
AppBar(
|
||||
useDarkMode = useDarkMode,
|
||||
setDarkMode = { useDarkMode = it },
|
||||
onCloseRequest = ::exitApplication,
|
||||
onRestart = {
|
||||
@Suppress("ControlFlowWithEmptyBody")
|
||||
do /* nothing */ while (game.grid.undo())
|
||||
resetCluesBeacon = Any()
|
||||
},
|
||||
windowState = windowState,
|
||||
)
|
||||
}
|
||||
) {
|
||||
App(
|
||||
modifier = Modifier.padding(it),
|
||||
spacing = 8.dp,
|
||||
selectDirectly = true,
|
||||
game = game,
|
||||
onNewGame = { game = generateGame() },
|
||||
resetCluesBeacon = resetCluesBeacon
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
desktop/src/main/resources/NotoColorEmoji-Regular.ttf
Normal file
34
docs/icons/yaep-icon-square.svg
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="48" height="48" version="1.1" viewBox="0 0 48 48" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<filter id="filter31" x="-.03237" y="-.0332" width="1.077" height="1.079" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-color="rgb(0,0,0)" flood-opacity=".498" in="SourceGraphic" result="flood"/>
|
||||
<feGaussianBlur in="SourceGraphic" result="blur" stdDeviation="1.600000"/>
|
||||
<feOffset dx="1.500000" dy="1.500000" in="blur" result="offset"/>
|
||||
<feComposite in="flood" in2="offset" operator="in" result="comp1"/>
|
||||
<feComposite in="SourceGraphic" in2="comp1" result="comp2"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<rect x=".0004669" width="48" height="48" ry="0" fill="#64bb8b" stroke-width=".375"/><g transform="matrix(1.732 0 0 1.732 -4.058 -4.317)"><g transform="matrix(.2167 0 0 .2167 2.134 2.151)" filter="url(#filter31)">
|
||||
<path d="m48.37 30.91s-11.64-10.14-12.76-11.26c-1.13-1.13-3.94-3.19-3.38-4.69s9.971-5.159 16.52-6.57c61.25-13.19 87.04 66.99 69.07 103.2z" fill="#464c4f"/>
|
||||
<path d="m122.8 94.29c-0.5595 4.738-1.756 9.477-3.588 14.22l-60.44-79.85-12.88-19.56c4.272-1.136 8.53-1.823 12.77-2.06l6.657 26.2 8.494-24.95c3.945 0.9298 7.612 2.24 11 3.931l-12.95 27.01 4.08 1.48 17.2-23.38c2.031 1.525 3.874 3.085 5.53 4.68l-17.1 22.64 5.63 4.15 17.61-20.03c2.189 2.771 4.174 5.674 5.953 8.709l-17.15 15.97 3.38 5.56 18.56-12.08c0.8559 1.981 1.623 3.93 2.302 5.847l-18.55 10.95 4.65 5.21 16.18-8.818c0.5694 2.125 1.065 4.261 1.488 6.408l-17.46 8.82 2.96 6.69 15.9-5.81c0.193 2.146 0.3103 4.149 0.352 6.009l-13.65 5.012 3.24 8.09z" fill="#dfdfe0"/>
|
||||
<path d="m56.53 27.11c-9.516 0.6828-16.74 5.918-36.32 31.67 3.278 11.31 6.066 22.03 13.09 31.4 14.76 1.845 25.78-4.514 29.98-7.46-1.57 13.01-3.422 25.25-4.98 38.29-0.3775 3.16 58.74 1 60.58-0.84 4.007-4.007-2.527-67.62-40.1-85.32 0.7087-19.88-8.565-27.38-9.16-27.45-0.0978-0.01053-9.538 2.494-13.09 19.71z" fill="#2f2f2f"/>
|
||||
<g fill="#fff">
|
||||
<path d="m22.53 58.86 10.49-13.09c1.82 2.611-1.21 6.546-7.11 13.86z"/>
|
||||
<path d="m28.47 78.02c16.34-15.16 24.96-8.079 23.51 6.76-2.066 1.049-3.371 1.31-5.45 1.67 1.594-13.42-5.84-12.49-16.75-5.89z"/>
|
||||
<path d="m32.69 85.39c2.974-3.546 7.702-3.297 8.03 1.97-3.067 0.1987-4.479 0.1548-8.68 0z"/>
|
||||
<path d="m29.97 69.81s8.49-10.46 21.02-6.01 7.27 17.55 7.27 17.55l3.43-1.6c3.135-14.52-6.072-15.23-4.5-23.22 0.9881-3.903 1.347-10.12 5.957-11.45 3.973 0.1429 0.08547 6.597 0.7128 12.11 0.9848 8.655 7.527 7.781 3.8 29.32 12.49-6.333 23.42-14.89 33.78-24.22-0.5165-1.271-1.566-2.996-2.49-4.03-19.02 13.86-26.9 18.24-27.36 17.7-0.6832-0.805 7.523-23.24 12.01-34.26-1.74-1.554-2.447-1.879-5.58-3.05-1.498 2.874-3.624 12.45-8.11 11.55-1.88-1.36-1.83-7.65 1.41-11.97 1.73-2.31 3.8-3.05 4.08-9.43 0.4061-9.253-4.874-17.14-5.92-17.08-6.44 4.087-8.193 11.18-9.15 18.21l-2.02 0.75s-0.96 10.46-3.26 12.2-6.05 1.2-6.45-1.78c-0.52-3.91-0.33-7.93-0.33-7.93-3.254 1.182-4.495 3.709-5.2 6.94-0.6171 6.754-10.17 11.48-11.99 22.8z"/>
|
||||
<path d="m89.76 47.43s-5.33 11.83-5.16 12.44 10.23-7.46 10.23-7.46c-3.009-3.735-4.308-4.572-5.07-4.98z"/>
|
||||
</g>
|
||||
<path d="m54.23 53.58c0 2.8-1.08 5.58-4.22 5.3-2.34-0.21-4.27-2.5-4.27-5.3s1.9-5.07 4.25-5.07 4.24 2.27 4.24 5.07z" fill="#0b0b0b"/>
|
||||
<g fill="#fff">
|
||||
<path d="m63.71 101.5-0.84 7.67c28.97-11.09 43.7-32.11 44.98-34-0.5754-2.122-1.508-4.063-2.82-6.13-20.85 22.14-22.95 23.97-41.32 32.46z"/>
|
||||
<path d="m66.88 118.9c4.883-4.883 10.68 3.176 44.13-36.04 0.4748 2.343 1.097 3.836 1.47 5.78-8.404 12.68-15.72 22.85-30.84 30.62-4.826 0.2567-9.638 0.0546-14.76-0.36z"/>
|
||||
<path d="m114.5 99.82c-5.164 9.147-5.757 10.87-11.12 18.16 4.868-0.1117 9.091-0.4384 12.67-0.98 0.343-5.512-0.1736-11.24-1.55-17.18z"/>
|
||||
</g>
|
||||
<path d="m68.64 18.45c-2.435-0.2632-8.507 16.82-1.34 16.82 6.086 0 3.386-16.59 1.34-16.82z" fill="#454c50"/>
|
||||
<path d="m29.88 60c-2.89-2.64-7.41-3.57-9.67-1.22-2.25 2.35-3.57 5.35-5.44 7.32-7.025 6.534-13.12 15.92-8.17 25.53 3 4.97 9.1 8.26 16.61 5.63s10.51-6.48 10.79-9.29c1.036-10.4-6.915-9.81-5.44-13.33 0.75-1.79 6.76-9.66 1.32-14.64z" fill="#464c4f"/>
|
||||
<path d="m11.11 79.71c-0.1 1.56 1.92 1.27 2.63 2.72 0.7 1.45-0.94 4.27 0.89 4.6s4.18-3.28 3.05-6.71c-1.13-3.42-6.43-2.86-6.57-0.61z" fill="#303030"/>
|
||||
<path d="m14.23 97.64s5-2.44 7.25-4.55c2.19-2.06 4.32-4.55 4.83-5.35 0.52-0.8 1.6-2.25 2.53-1.6 0.94 0.66 0.52 1.83-0.09 2.72s-2.16 3.1-4.6 5.35c-2.11 1.95-3.14 2.44-4.69 3.28-1.13 0.61-2.21 0.7-2.21 0.7s-0.88 0.01-1.79-0.14c-0.35-0.05-1.23-0.41-1.23-0.41z" fill="#303030"/>
|
||||
</g></g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.7 KiB |
BIN
docs/screenshots/desktop/dark_new_game.png
Normal file
|
After Width: | Height: | Size: 194 KiB |
BIN
docs/screenshots/desktop/dark_ongoing_game.png
Normal file
|
After Width: | Height: | Size: 271 KiB |
BIN
docs/screenshots/desktop/dark_solved_game.png
Normal file
|
After Width: | Height: | Size: 316 KiB |
BIN
docs/screenshots/desktop/light_new_game.png
Normal file
|
After Width: | Height: | Size: 190 KiB |
BIN
docs/screenshots/desktop/light_ongoing_game.png
Normal file
|
After Width: | Height: | Size: 265 KiB |
BIN
docs/screenshots/desktop/light_solved_game.png
Normal file
|
After Width: | Height: | Size: 308 KiB |
45
domain/build.gradle.kts
Normal file
@@ -0,0 +1,45 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.kover)
|
||||
alias(libs.plugins.kotlin.multiplatform)
|
||||
alias(libs.plugins.android.library)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(libs.versions.jdk.get().toInt())
|
||||
|
||||
jvm()
|
||||
androidTarget()
|
||||
|
||||
sourceSets {
|
||||
commonMain.dependencies {
|
||||
implementation(libs.bundles.logging)
|
||||
}
|
||||
|
||||
commonTest.dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
implementation(libs.atrium)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "ch.dissem.yaep.domain"
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
getByName("test") {
|
||||
resources.srcDirs("src/commonTest/resources")
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
enableAndroidTestCoverage = true
|
||||
enableUnitTestCoverage = true
|
||||
}
|
||||
}
|
||||
}
|
||||
131
domain/src/commonMain/kotlin/ch/dissem/yaep/domain/Game.kt
Normal file
@@ -0,0 +1,131 @@
|
||||
package ch.dissem.yaep.domain
|
||||
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
|
||||
class Game(
|
||||
val grid: Grid,
|
||||
val clues: Collection<Clue>
|
||||
) {
|
||||
private val log = KotlinLogging.logger { }
|
||||
val horizontalClues: List<HorizontalClue> = clues.filterIsInstance<HorizontalClue>()
|
||||
val verticalClues: List<SameColumnClue<ItemClass<*>, ItemClass<*>>> =
|
||||
clues.filterIsInstance<SameColumnClue<ItemClass<*>, ItemClass<*>>>()
|
||||
|
||||
private val onStartListeners = mutableListOf<() -> Unit>()
|
||||
private val onSolvedListeners = mutableListOf<() -> Unit>()
|
||||
|
||||
/**
|
||||
* Make sure that no category is used more than once.
|
||||
*/
|
||||
val areCategoriesValid: Boolean
|
||||
get() = grid.rows.map { it.category }.distinct().size == grid.rows.size
|
||||
|
||||
val isValid: Boolean
|
||||
get() = areCategoriesValid && clues.all { it.isValid(grid) }
|
||||
|
||||
val isSolved: Boolean
|
||||
get() = grid.rows.all { it.isSolved } && isValid
|
||||
|
||||
|
||||
init {
|
||||
for (position in clues.filterIsInstance<PositionClue<ItemClass<*>>>()) {
|
||||
val row = grid[position.item.itemType.companion]
|
||||
row.forEachIndexed { index, gameCell ->
|
||||
if (index == position.index) {
|
||||
gameCell.selection = position.item
|
||||
gameCell.mutable = false
|
||||
} else {
|
||||
gameCell.options.remove(position.item)
|
||||
}
|
||||
}
|
||||
}
|
||||
grid.forEach { row ->
|
||||
row.forEach { cell ->
|
||||
cell.optionsChangedListeners.add {
|
||||
if (onStartListeners.isNotEmpty()) {
|
||||
onStartListeners.forEach { it() }
|
||||
onStartListeners.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
row.onSolved {
|
||||
log.debug { "Is game valid: $isValid" }
|
||||
log.debug { "Is game solved: $isSolved" }
|
||||
if (onSolvedListeners.isNotEmpty() && isSolved) {
|
||||
log.debug { "Game solved, notifying listeners" }
|
||||
onSolvedListeners.forEach { it() }
|
||||
}
|
||||
}
|
||||
}
|
||||
grid.snapshot()
|
||||
}
|
||||
|
||||
fun onStart(listener: () -> Unit) {
|
||||
onStartListeners.add(listener)
|
||||
}
|
||||
|
||||
fun onSolved(listener: () -> Unit) {
|
||||
onSolvedListeners.add(listener)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return grid.toString() + "\n\n" + clues.joinToString("\n* ", prefix = "* ")
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun parse(description: String): Game {
|
||||
val optionsRegex = Regex("[A-Z]+(?:_[A-Z]+)*")
|
||||
val options = optionsRegex.findAll(description)
|
||||
.map { it.value }
|
||||
.distinct()
|
||||
.map { Item(ItemClass.parse(it)) }
|
||||
.groupBy { it.itemType.companion }
|
||||
.toMutableMap()
|
||||
val size = options.size
|
||||
// Fill up missing items (one item per row might not appear in the clues)
|
||||
// (This could be improved by looking which items are in the grid part, but this will
|
||||
// not always work.)
|
||||
options
|
||||
.filter { it.value.size < size }
|
||||
.forEach { entry ->
|
||||
val missing = size - entry.value.size
|
||||
val used = entry.value.map { it.itemType }.toSet()
|
||||
val fillers = entry.key.items
|
||||
.filter { !used.contains(it) }
|
||||
.take(missing)
|
||||
.map { Item(it) }
|
||||
options[entry.key] = entry.value + fillers
|
||||
}
|
||||
val optionMap = options.values.flatten().associateBy(
|
||||
keySelector = { it.itemType },
|
||||
valueTransform = { it }
|
||||
)
|
||||
val clues: Collection<Clue> = description.lines()
|
||||
.filter { it.startsWith("* ") }
|
||||
.map { line ->
|
||||
Clue.parse(line) {
|
||||
optionMap[it] ?: throw IllegalArgumentException("Unknown option $it")
|
||||
}
|
||||
}
|
||||
|
||||
return Game(
|
||||
grid = Grid(
|
||||
rows = options.values
|
||||
.map { createRow<ItemClass<*>>(it.sorted()) }
|
||||
.toList()
|
||||
),
|
||||
clues = clues
|
||||
)
|
||||
}
|
||||
|
||||
private fun <C : ItemClass<C>> createRow(options: List<Item<*>>): GameRow<*> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
options as List<Item<C>>
|
||||
return GameRow(
|
||||
category = options.first().itemType.companion,
|
||||
options = options,
|
||||
cells = options.map { GameCell(options = options.toMutableList()) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package ch.dissem.yaep.domain
|
||||
|
||||
class GameCell<C : ItemClass<C>>(
|
||||
selection: Item<C>? = null,
|
||||
val solution: Item<C>? = null,
|
||||
options: Collection<Item<C>>,
|
||||
/*** If mutable is false, the cell will silently ignore all changes to 'selection'. */
|
||||
var mutable: Boolean = true
|
||||
) {
|
||||
val selectionChangedListeners: MutableList<(Item<C>?) -> Unit> =
|
||||
mutableListOf<(Item<C>?) -> Unit>()
|
||||
val optionsChangedListeners: MutableList<(Collection<Item<C>>) -> Unit> =
|
||||
mutableListOf<(Collection<Item<C>>) -> Unit>()
|
||||
|
||||
var selection: Item<C>? = selection
|
||||
set(value) {
|
||||
if (mutable) {
|
||||
field = value
|
||||
selectionChangedListeners.forEach { listener -> listener(value) }
|
||||
}
|
||||
}
|
||||
val options: ObservableSet<Item<C>> = ObservableSet(options) { _, after ->
|
||||
optionsChangedListeners.forEach { listener ->
|
||||
listener(after)
|
||||
}
|
||||
}
|
||||
|
||||
private val snapshots = ArrayDeque<Pair<Item<C>?, Collection<Item<C>>>>()
|
||||
|
||||
fun snapshot() {
|
||||
snapshots.addLast(selection to options.toSet())
|
||||
}
|
||||
|
||||
fun undo(): Boolean {
|
||||
val (selection, options) = snapshots.removeLastOrNull() ?: return false
|
||||
this.selection = selection
|
||||
this.options.clear()
|
||||
this.options.addAll(options)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
fun <C : ItemClass<C>> GameCell<C>?.mayBe(item: Item<C>, mayHaveSelection: Boolean = true): Boolean =
|
||||
this != null &&
|
||||
((mayHaveSelection && selection == item) || (selection == null && options.contains(item)))
|
||||
|
||||
fun <C : ItemClass<C>> GameCell<C>?.hasNoSelection(): Boolean =
|
||||
this != null && this.selection == null
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package ch.dissem.yaep.domain
|
||||
|
||||
@Suppress("JavaDefaultMethodsNotOverriddenByDelegation")
|
||||
class GameRow<C : ItemClass<C>>(
|
||||
val category: ItemClassCompanion<C>,
|
||||
val options: List<Item<C>>,
|
||||
val cells: List<GameCell<C>>
|
||||
) : List<GameCell<C>> by cells {
|
||||
var isSolved: Boolean = false
|
||||
private set(value) {
|
||||
field = value
|
||||
if (value) {
|
||||
onSolvedListener()
|
||||
}
|
||||
}
|
||||
var onSolvedListener: () -> Unit = {}
|
||||
|
||||
fun onSolved(listener: () -> Unit) {
|
||||
onSolvedListener = listener
|
||||
}
|
||||
|
||||
fun indexOf(element: C): Int = indexOfFirst { it.selection?.itemType == element }
|
||||
|
||||
fun cleanupOptions() {
|
||||
if (isSolved && all {
|
||||
it.solution != null
|
||||
&& it.options.size == 1
|
||||
&& it.options.single() == it.selection
|
||||
}
|
||||
) return
|
||||
do {
|
||||
var changed = false
|
||||
val selections = filter { it.selection != null }.let { cellsWithSelection ->
|
||||
cellsWithSelection
|
||||
.filter { it.options.size != 1 }
|
||||
.forEach {
|
||||
it.options.clear()
|
||||
it.options.add(it.selection!!)
|
||||
}
|
||||
cellsWithSelection.mapNotNull { it.selection }.toSet()
|
||||
}
|
||||
filter { it.selection == null }
|
||||
.forEach { it.options.removeAll(selections) }
|
||||
filter { it.selection == null && it.options.size == 1 }
|
||||
.forEach {
|
||||
changed = true
|
||||
it.selection = it.options.single()
|
||||
}
|
||||
if (!changed) {
|
||||
filter { it.selection == null }
|
||||
.flatMap { c -> c.options.map { o -> o to c } }
|
||||
.groupBy { it.first }
|
||||
.filter { it.value.size == 1 }
|
||||
.forEach {
|
||||
val c = it.value.single().second
|
||||
c.selection = it.key
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
} while (changed)
|
||||
isSolved = all {
|
||||
it.solution != null
|
||||
&& it.options.size == 1
|
||||
&& it.options.single() == it.selection
|
||||
}
|
||||
}
|
||||
|
||||
fun snapshot() {
|
||||
cells.forEach { it.snapshot() }
|
||||
}
|
||||
|
||||
fun undo(): Boolean {
|
||||
val didChange = cells.map { it.undo() }.reduce { a, b -> a || b }
|
||||
if (didChange) {
|
||||
isSolved = all {
|
||||
it.solution != null
|
||||
&& it.options.size == 1
|
||||
&& it.options.single() == it.selection
|
||||
}
|
||||
}
|
||||
return didChange
|
||||
}
|
||||
|
||||
}
|
||||
58
domain/src/commonMain/kotlin/ch/dissem/yaep/domain/Grid.kt
Normal file
@@ -0,0 +1,58 @@
|
||||
package ch.dissem.yaep.domain
|
||||
|
||||
@Suppress("UNCHECKED_CAST", "JavaDefaultMethodsNotOverriddenByDelegation")
|
||||
class Grid(
|
||||
val rows: List<GameRow<*>>
|
||||
) : List<GameRow<ItemClass<*>>> by rows as List<GameRow<ItemClass<*>>> {
|
||||
|
||||
val cells: List<GameCell<*>>
|
||||
get() = rows.flatten()
|
||||
|
||||
fun <C : ItemClass<C>> indexOf(element: C): Int {
|
||||
return this[element.companion]
|
||||
.indexOfFirst { it.selection?.itemType == element }
|
||||
}
|
||||
|
||||
operator fun <C : ItemClass<C>> get(itemType: ItemClassCompanion<C>): GameRow<C> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return rows.first { it.category == itemType } as GameRow<C>
|
||||
}
|
||||
|
||||
operator fun <C : ItemClass<C>> get(item: Item<C>): GameCell<C> {
|
||||
return this[item.itemType.companion].first { it.selection == item }
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return joinToString("\n") { row ->
|
||||
row.joinToString("") { it.selection?.symbol ?: "⬛" }
|
||||
}
|
||||
}
|
||||
|
||||
fun cleanupOptions() {
|
||||
forEach { row -> row.cleanupOptions() }
|
||||
}
|
||||
|
||||
fun snapshot() {
|
||||
forEach { row -> row.snapshot() }
|
||||
}
|
||||
|
||||
fun undo(): Boolean {
|
||||
return map { row -> row.undo() }.reduce { a, b -> a || b }
|
||||
}
|
||||
}
|
||||
|
||||
fun List<List<Item<ItemClass<*>>>>.toGrid(): Grid = Grid(
|
||||
map { row ->
|
||||
GameRow(
|
||||
category = row.first().itemType.companion,
|
||||
options = row.sorted(),
|
||||
cells = row.map {
|
||||
GameCell(
|
||||
selection = null,
|
||||
solution = it,
|
||||
options = row.toMutableList()
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
25
domain/src/commonMain/kotlin/ch/dissem/yaep/domain/Item.kt
Normal file
@@ -0,0 +1,25 @@
|
||||
package ch.dissem.yaep.domain
|
||||
|
||||
|
||||
class Item<C : ItemClass<C>>(
|
||||
val itemType: C,
|
||||
val symbol: String = itemType.symbols.random()
|
||||
) : Comparable<Item<C>> {
|
||||
constructor(itemType: C) : this(itemType, itemType.symbols.random())
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Item<*>) return false
|
||||
return itemType == other.itemType
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return itemType.hashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return itemType.toString() + symbol
|
||||
}
|
||||
|
||||
override fun compareTo(other: Item<C>): Int = itemType.compareTo(other.itemType)
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package ch.dissem.yaep.domain
|
||||
|
||||
@Suppress("JavaDefaultMethodsNotOverriddenByDelegation")
|
||||
class ObservableSet<E> private constructor(
|
||||
private val mutableSet: MutableSet<E>,
|
||||
private val onElementChanged: (before: Set<E>, after: Set<E>) -> Unit
|
||||
) : MutableSet<E> by mutableSet {
|
||||
constructor(
|
||||
elements: Collection<E>,
|
||||
onElementChanged: (before: Set<E>, after: Set<E>) -> Unit
|
||||
) : this(
|
||||
elements.toMutableSet(),
|
||||
onElementChanged
|
||||
)
|
||||
|
||||
private inner class ObservableIterator(
|
||||
private val delegate: MutableIterator<E>
|
||||
) : MutableIterator<E> by delegate {
|
||||
|
||||
override fun remove() {
|
||||
val previous = mutableSet.toSet()
|
||||
delegate.remove()
|
||||
onElementChanged(previous, mutableSet.toSet())
|
||||
}
|
||||
}
|
||||
|
||||
override fun iterator(): MutableIterator<E> {
|
||||
return ObservableIterator(mutableSet.iterator())
|
||||
}
|
||||
|
||||
override fun add(element: E): Boolean {
|
||||
return observe(setOf(element)) { mutableSet.add(element) }
|
||||
}
|
||||
|
||||
|
||||
override fun remove(element: E): Boolean {
|
||||
return observe(setOf(element)) { mutableSet.remove(element) }
|
||||
}
|
||||
|
||||
override fun addAll(elements: Collection<E>): Boolean {
|
||||
return observe(elements.toSet()) { mutableSet.addAll(elements) }
|
||||
}
|
||||
|
||||
override fun removeAll(elements: Collection<E>): Boolean =
|
||||
observe(elements.toSet(), mutableSet::removeAll)
|
||||
|
||||
override fun retainAll(elements: Collection<E>): Boolean =
|
||||
observe(elements.toSet(), mutableSet::retainAll)
|
||||
|
||||
override fun clear() {
|
||||
return observe(setOf()) { mutableSet.clear() }
|
||||
}
|
||||
|
||||
private fun <R> observe(values: Set<E>, operation: (Set<E>) -> R): R {
|
||||
val previous = mutableSet.toSet()
|
||||
val result = operation(values)
|
||||
val changed = !(previous.containsAll(mutableSet) && previous.size == mutableSet.size)
|
||||
if (changed) {
|
||||
val new = mutableSet.toSet()
|
||||
onElementChanged(previous, new)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package ch.dissem.yaep.domain
|
||||
|
||||
class UnsolvablePuzzleException(e: Exception) : Exception(e)
|
||||
450
domain/src/commonMain/kotlin/ch/dissem/yaep/domain/clues.kt
Normal file
@@ -0,0 +1,450 @@
|
||||
package ch.dissem.yaep.domain
|
||||
|
||||
sealed class Clue {
|
||||
abstract fun isValid(grid: Grid): Boolean
|
||||
|
||||
/**
|
||||
* @return `true` if any option was removed
|
||||
*/
|
||||
abstract fun removeForbiddenOptions(grid: Grid): Boolean
|
||||
|
||||
companion object {
|
||||
fun <T : ItemClass<T>> parse(line: String, mapper: (ItemClass<*>) -> Item<T>): Clue {
|
||||
return NeighbourClue.parse(line, mapper)
|
||||
?: OrderClue.parse(line, mapper)
|
||||
?: TripletClue.parse(line, mapper)
|
||||
?: SameColumnClue.parse(line, mapper)
|
||||
?: PositionClue.parse(line, mapper)
|
||||
?: throw IllegalStateException("Unknown clue: $line")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sealed interface ClueParser {
|
||||
/**
|
||||
* Parses a string description of a clue into a clue.
|
||||
*
|
||||
* Returns `null` if `line` isn't a representation of that clue.
|
||||
*/
|
||||
fun <T : ItemClass<T>> parse(line: String, mapper: (ItemClass<*>) -> Item<T>): Clue?
|
||||
}
|
||||
|
||||
sealed class HorizontalClue : Clue()
|
||||
|
||||
class NeighbourClue<A : ItemClass<A>, B : ItemClass<B>>(val a: Item<A>, val b: Item<B>) :
|
||||
HorizontalClue() {
|
||||
private val aType = a.itemType
|
||||
private val bType = b.itemType
|
||||
|
||||
override fun isValid(grid: Grid): Boolean {
|
||||
val rowA = grid[aType.companion]
|
||||
val rowB = grid[bType.companion]
|
||||
|
||||
val ia = rowA.indexOf(aType)
|
||||
val ib = rowB.indexOf(bType)
|
||||
|
||||
if (ia != -1) {
|
||||
if (ib != -1) return ib == ia - 1 || ib == ia + 1
|
||||
return rowB.getOrNull(ia - 1).hasNoSelection() || rowB.getOrNull(ia + 1)
|
||||
.hasNoSelection()
|
||||
}
|
||||
if (ib != -1) {
|
||||
return rowA.getOrNull(ib - 1).hasNoSelection() || rowA.getOrNull(ib + 1)
|
||||
.hasNoSelection()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun removeForbiddenOptions(grid: Grid): Boolean {
|
||||
val rowA: GameRow<A> = grid[aType.companion]
|
||||
val rowB: GameRow<B> = grid[bType.companion]
|
||||
|
||||
var removed = removeForbiddenOptions(a, b, rowA, rowB)
|
||||
removed = removeForbiddenOptions(b, a, rowB, rowA) || removed
|
||||
|
||||
return removed
|
||||
}
|
||||
|
||||
private fun <X : ItemClass<X>, Y : ItemClass<Y>> removeForbiddenOptions(
|
||||
x: Item<X>,
|
||||
y: Item<Y>,
|
||||
rowX: GameRow<X>,
|
||||
rowY: GameRow<Y>
|
||||
): Boolean {
|
||||
var removed = false
|
||||
|
||||
for (iX in rowX.indices) {
|
||||
val cellX = rowX[iX]
|
||||
if (
|
||||
cellX.mayBe(x, mayHaveSelection = false)
|
||||
&& !rowY.getOrNull(iX - 1).mayBe(y)
|
||||
&& !rowY.getOrNull(iX + 1).mayBe(y)
|
||||
) {
|
||||
removed = cellX.options.remove(x) || removed
|
||||
}
|
||||
}
|
||||
|
||||
return removed
|
||||
}
|
||||
|
||||
override fun toString(): String = "$aType is next to $bType"
|
||||
|
||||
companion object : ClueParser {
|
||||
override fun <T : ItemClass<T>> parse(
|
||||
line: String,
|
||||
mapper: (ItemClass<*>) -> Item<T>
|
||||
): Clue? {
|
||||
val regex = Regex("^(?:\\* )?(?<a>[A-Z_]+) is next to (?<b>[A-Z_]+)$")
|
||||
val matchResult = regex.matchEntire(line) ?: return null
|
||||
|
||||
val a = ItemClass.parse(matchResult.groups["a"]!!.value)
|
||||
val b = ItemClass.parse(matchResult.groups["b"]!!.value)
|
||||
|
||||
return NeighbourClue(mapper(a), mapper(b))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OrderClue<L : ItemClass<L>, R : ItemClass<R>>(val left: Item<L>, val right: Item<R>) :
|
||||
HorizontalClue() {
|
||||
private val leftType = left.itemType
|
||||
private val rightType = right.itemType
|
||||
|
||||
override fun isValid(grid: Grid): Boolean {
|
||||
val rowLeft = grid[leftType.companion]
|
||||
val rowRight = grid[rightType.companion]
|
||||
|
||||
val iLeft = rowLeft.indexOf(leftType)
|
||||
val iRight by lazy { rowRight.indexOf(rightType) }
|
||||
|
||||
if (iLeft != -1) {
|
||||
if (iRight != -1) return iRight > iLeft
|
||||
|
||||
return rowRight.indexOfLast { it.hasNoSelection() } > iLeft
|
||||
}
|
||||
if (iRight != -1) {
|
||||
return rowLeft.indexOfFirst { it.hasNoSelection() } in 0 until iRight
|
||||
}
|
||||
return rowLeft.indexOfFirst { it.hasNoSelection() } < rowRight.indexOfLast { it.hasNoSelection() }
|
||||
}
|
||||
|
||||
override fun removeForbiddenOptions(grid: Grid): Boolean {
|
||||
val rowL = grid[leftType.companion]
|
||||
val rowR = grid[rightType.companion]
|
||||
|
||||
val firstL = rowL.indexOfFirst { it.options.contains(left) }
|
||||
val lastR = rowR.indexOfLast { it.options.contains(right) }
|
||||
|
||||
var removed = false
|
||||
try {
|
||||
rowL.takeLast(rowL.size - lastR)
|
||||
.filter { it.selection == null }
|
||||
.forEach { removed = it.options.remove(left) || removed }
|
||||
rowR.take(firstL + 1)
|
||||
.filter { it.selection == null }
|
||||
.forEach { removed = it.options.remove(right) || removed }
|
||||
} catch (e: IllegalArgumentException) {
|
||||
throw UnsolvablePuzzleException(e)
|
||||
}
|
||||
return removed
|
||||
}
|
||||
|
||||
override fun toString(): String = "$leftType is left of $rightType"
|
||||
|
||||
companion object : ClueParser {
|
||||
override fun <T : ItemClass<T>> parse(
|
||||
line: String,
|
||||
mapper: (ItemClass<*>) -> Item<T>
|
||||
): Clue? {
|
||||
val regex = Regex("^(?:\\* )?(?<left>[A-Z_]+) is left of (?<right>[A-Z_]+)$")
|
||||
val matchResult = regex.matchEntire(line) ?: return null
|
||||
|
||||
val left = ItemClass.parse(matchResult.groups["left"]!!.value)
|
||||
val right = ItemClass.parse(matchResult.groups["right"]!!.value)
|
||||
|
||||
return OrderClue(mapper(left), mapper(right))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TripletClue<A : ItemClass<A>, B : ItemClass<B>, C : ItemClass<C>>(
|
||||
val a: Item<A>,
|
||||
val b: Item<B>,
|
||||
val c: Item<C>
|
||||
) :
|
||||
HorizontalClue() {
|
||||
private val aType = a.itemType
|
||||
private val bType = b.itemType
|
||||
private val cType = c.itemType
|
||||
|
||||
override fun isValid(grid: Grid): Boolean {
|
||||
val rowA = grid[aType.companion]
|
||||
val rowB by lazy { grid[bType.companion] }
|
||||
val rowC by lazy { grid[cType.companion] }
|
||||
|
||||
val ia = rowA.indexOf(aType)
|
||||
val ib by lazy { rowB.indexOf(bType) }
|
||||
val ic by lazy { rowC.indexOf(cType) }
|
||||
|
||||
if (ia != -1) {
|
||||
return isValidWithASet(ia, ib, ic, rowB, rowC)
|
||||
}
|
||||
if (ib != -1) {
|
||||
return isValidWithBSet(ib, ic, rowA, rowC)
|
||||
}
|
||||
if (ic != -1) {
|
||||
return isValidWithCSet(ic, rowA, rowB)
|
||||
}
|
||||
return isValidWithNoneSet(rowA, rowB, rowC)
|
||||
}
|
||||
|
||||
private fun isValidWithASet(
|
||||
ia: Int,
|
||||
ib: Int,
|
||||
ic: Int,
|
||||
rowB: GameRow<B>,
|
||||
rowC: GameRow<C>
|
||||
): Boolean =
|
||||
when (ib) {
|
||||
-1 -> when (ic) {
|
||||
-1 -> (rowB.getOrNull(ia - 1).hasNoSelection() && rowC.getOrNull(ia - 2)
|
||||
.hasNoSelection()) ||
|
||||
(rowB.getOrNull(ia + 1).hasNoSelection() && rowC.getOrNull(ia + 2)
|
||||
.hasNoSelection())
|
||||
|
||||
ia - 2 -> rowB.getOrNull(ia - 1).hasNoSelection()
|
||||
ia + 2 -> rowB.getOrNull(ia + 1).hasNoSelection()
|
||||
else -> false
|
||||
}
|
||||
|
||||
ia - 1 -> when (ic) {
|
||||
-1 -> rowC.getOrNull(ia - 2).hasNoSelection()
|
||||
ia - 2 -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
ia + 1 -> when (ic) {
|
||||
-1 -> rowC.getOrNull(ia + 2).hasNoSelection()
|
||||
ia + 2 -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
|
||||
private fun isValidWithBSet(ib: Int, ic: Int, rowA: GameRow<A>, rowC: GameRow<C>): Boolean =
|
||||
when (ic) {
|
||||
-1 -> (rowA.getOrNull(ib - 1).hasNoSelection() && rowC.getOrNull(ib + 1)
|
||||
.hasNoSelection()) ||
|
||||
(rowA.getOrNull(ib + 1).hasNoSelection() && rowC.getOrNull(ib - 1)
|
||||
.hasNoSelection())
|
||||
|
||||
ib - 1 -> rowA.getOrNull(ib + 1).hasNoSelection()
|
||||
ib + 1 -> rowA.getOrNull(ib - 1).hasNoSelection()
|
||||
else -> false
|
||||
}
|
||||
|
||||
private fun isValidWithCSet(ic: Int, rowA: GameRow<A>, rowB: GameRow<B>): Boolean =
|
||||
(rowB.getOrNull(ic - 1).hasNoSelection() && rowA.getOrNull(ic - 2)
|
||||
.hasNoSelection()) ||
|
||||
(rowB.getOrNull(ic + 1).hasNoSelection() && rowA.getOrNull(ic + 2)
|
||||
.hasNoSelection())
|
||||
|
||||
private fun isValidWithNoneSet(rowA: GameRow<A>, rowB: GameRow<B>, rowC: GameRow<C>): Boolean =
|
||||
rowA.mapIndexed { index, gameCell -> if (gameCell.hasNoSelection()) index else null }
|
||||
.filterNotNull()
|
||||
.any { index ->
|
||||
(rowB.getOrNull(index - 1).hasNoSelection() && rowC.getOrNull(index - 2)
|
||||
.hasNoSelection()) ||
|
||||
(rowB.getOrNull(index + 1).hasNoSelection() && rowC.getOrNull(index + 2)
|
||||
.hasNoSelection())
|
||||
}
|
||||
|
||||
override fun removeForbiddenOptions(grid: Grid): Boolean {
|
||||
val rowA = grid[aType.companion]
|
||||
val rowB = grid[bType.companion]
|
||||
val rowC = grid[cType.companion]
|
||||
|
||||
var removed = false
|
||||
|
||||
for (i in rowA.indices) {
|
||||
removed = removeForbiddenOptionsGivenX(
|
||||
i = i,
|
||||
x = Group(a, rowA),
|
||||
y = Group(b, rowB, 1),
|
||||
z = Group(c, rowC, 2)
|
||||
) || removed
|
||||
}
|
||||
for (i in rowB.indices) {
|
||||
removed = removeForbiddenOptionsGivenX(
|
||||
i = i,
|
||||
x = Group(b, rowB),
|
||||
y = Group(a, rowA, 1),
|
||||
z = Group(c, rowC, -1)
|
||||
) || removed
|
||||
}
|
||||
|
||||
for (i in rowC.indices) {
|
||||
removed = removeForbiddenOptionsGivenX(
|
||||
i = i,
|
||||
x = Group(c, rowC),
|
||||
y = Group(b, rowB, 1),
|
||||
z = Group(a, rowA, 2)
|
||||
) || removed
|
||||
}
|
||||
return removed
|
||||
}
|
||||
|
||||
private fun <X : ItemClass<X>, Y : ItemClass<Y>, Z : ItemClass<Z>> removeForbiddenOptionsGivenX(
|
||||
i: Int,
|
||||
x: Group<X>,
|
||||
y: Group<Y>,
|
||||
z: Group<Z>
|
||||
): Boolean {
|
||||
val cellX = x.row[i]
|
||||
if (cellX.mayBe(x.item, mayHaveSelection = false)) {
|
||||
val cellYR = y.row.getOrNull(i + y.offset)
|
||||
val cellZR = z.row.getOrNull(i + z.offset)
|
||||
val cellYL = y.row.getOrNull(i - y.offset)
|
||||
val cellZL = z.row.getOrNull(i - z.offset)
|
||||
|
||||
if (
|
||||
!(cellYR.mayBe(y.item) && cellZR.mayBe(z.item))
|
||||
&& !(cellYL.mayBe(y.item) && cellZL.mayBe(z.item))
|
||||
) {
|
||||
return cellX.options.remove(x.item)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private class Group<T : ItemClass<T>>(
|
||||
val item: Item<T>,
|
||||
val row: GameRow<T>,
|
||||
val offset: Int = 0
|
||||
)
|
||||
|
||||
override fun toString(): String =
|
||||
"$bType is between the neighbours $aType and $cType to both sides"
|
||||
|
||||
companion object : ClueParser {
|
||||
override fun <T : ItemClass<T>> parse(
|
||||
line: String,
|
||||
mapper: (ItemClass<*>) -> Item<T>
|
||||
): Clue? {
|
||||
val regex =
|
||||
Regex("^(?:\\* )?(?<b>[A-Z_]+) is between the neighbours (?<a>[A-Z_]+) and (?<c>[A-Z_]+) to both sides$")
|
||||
val matchResult = regex.matchEntire(line) ?: return null
|
||||
|
||||
val a = ItemClass.parse(matchResult.groups["a"]!!.value)
|
||||
val b = ItemClass.parse(matchResult.groups["b"]!!.value)
|
||||
val c = ItemClass.parse(matchResult.groups["c"]!!.value)
|
||||
|
||||
return TripletClue(mapper(a), mapper(b), mapper(c))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SameColumnClue<A : ItemClass<A>, B : ItemClass<B>>(val a: Item<A>, val b: Item<B>) : Clue() {
|
||||
private val aType = a.itemType
|
||||
private val bType = b.itemType
|
||||
|
||||
override fun isValid(grid: Grid): Boolean {
|
||||
val rowA = grid[aType.companion]
|
||||
val rowB = grid[bType.companion]
|
||||
|
||||
val ia = rowA.indexOf(aType)
|
||||
val ib by lazy { rowB.indexOf(bType) }
|
||||
|
||||
if (ia != -1) {
|
||||
return if (ib == -1) rowB[ia].hasNoSelection()
|
||||
else ib == ia
|
||||
}
|
||||
if (ib != -1) {
|
||||
return rowA[ib].hasNoSelection()
|
||||
}
|
||||
return rowA.mapIndexed { index, gameCell -> if (gameCell.hasNoSelection()) index else null }
|
||||
.filterNotNull()
|
||||
.any { index -> rowB[index].hasNoSelection() }
|
||||
}
|
||||
|
||||
override fun removeForbiddenOptions(grid: Grid): Boolean {
|
||||
val rowA = grid[aType.companion]
|
||||
val rowB = grid[bType.companion]
|
||||
|
||||
var removed = false
|
||||
for (i in rowA.indices) {
|
||||
val cellA = rowA[i]
|
||||
val cellB = rowB[i]
|
||||
|
||||
if (cellB.hasNoSelection() && !cellA.mayBe(a)) {
|
||||
removed = cellB.options.remove(b) || removed
|
||||
}
|
||||
if (cellA.hasNoSelection() && !cellB.mayBe(b)) {
|
||||
removed = cellA.options.remove(a) || removed
|
||||
}
|
||||
}
|
||||
return removed
|
||||
}
|
||||
|
||||
override fun toString(): String = "$aType and $bType are in the same column"
|
||||
|
||||
companion object : ClueParser {
|
||||
override fun <T : ItemClass<T>> parse(
|
||||
line: String,
|
||||
mapper: (ItemClass<*>) -> Item<T>
|
||||
): Clue? {
|
||||
val regex = Regex("^(?:\\* )?(?<a>[A-Z_]+) and (?<b>[A-Z_]+) are in the same column$")
|
||||
val matchResult = regex.matchEntire(line) ?: return null
|
||||
|
||||
val a = ItemClass.parse(matchResult.groups["a"]!!.value)
|
||||
val b = ItemClass.parse(matchResult.groups["b"]!!.value)
|
||||
|
||||
return SameColumnClue(mapper(a), mapper(b))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PositionClue<C : ItemClass<C>>(val item: Item<C>, val index: Int) : Clue() {
|
||||
val itemType: C = item.itemType
|
||||
|
||||
override fun isValid(grid: Grid): Boolean {
|
||||
val i = grid.indexOf(item.itemType)
|
||||
if (i != -1) return i == index
|
||||
|
||||
return grid[item].hasNoSelection()
|
||||
}
|
||||
|
||||
override fun removeForbiddenOptions(grid: Grid): Boolean {
|
||||
val row = grid[itemType.companion]
|
||||
var removed = false
|
||||
row.forEachIndexed { i, cell ->
|
||||
if (cell.hasNoSelection()) {
|
||||
removed = if (i == index) {
|
||||
cell.options.retainAll { it == item } || removed
|
||||
} else {
|
||||
cell.options.remove(item) || removed
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed
|
||||
}
|
||||
|
||||
override fun toString(): String = "$itemType is at position $index"
|
||||
|
||||
companion object : ClueParser {
|
||||
override fun <T : ItemClass<T>> parse(
|
||||
line: String,
|
||||
mapper: (ItemClass<*>) -> Item<T>
|
||||
): Clue? {
|
||||
val regex = Regex("^(?:\\* )?(?<type>[A-Z_]+) is at position (?<pos>\\d+)$")
|
||||
val matchResult = regex.matchEntire(line) ?: return null
|
||||
|
||||
val type = ItemClass.parse(matchResult.groups["type"]!!.value)
|
||||
val pos = matchResult.groups["pos"]!!.value.toInt()
|
||||
|
||||
return PositionClue(mapper(type), pos)
|
||||
}
|
||||
}
|
||||
}
|
||||