Skip to content

Commit b501158

Browse files
authored
Add quest: surface for natural=beach (#6729)
* Add surface quest for beaches * elementFilter optimized * add icon * fix typo
1 parent 999ef1e commit b501158

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed

app/src/androidMain/kotlin/de/westnordost/streetcomplete/quests/QuestsModule.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ import de.westnordost.streetcomplete.quests.step_count.AddStepCountStile
168168
import de.westnordost.streetcomplete.quests.steps_ramp.AddStepsRamp
169169
import de.westnordost.streetcomplete.quests.summit.AddSummitCross
170170
import de.westnordost.streetcomplete.quests.summit.AddSummitRegister
171+
import de.westnordost.streetcomplete.quests.surface.AddBeachSurface
171172
import de.westnordost.streetcomplete.quests.surface.AddCyclewayPartSurface
172173
import de.westnordost.streetcomplete.quests.surface.AddFootwayPartSurface
173174
import de.westnordost.streetcomplete.quests.surface.AddPathSurface
@@ -352,6 +353,8 @@ fun questTypeRegistry(
352353

353354
47 to AddPlaygroundAccess(),
354355

356+
191 to AddBeachSurface(),
357+
355358
/* pulled up in priority to be before CheckExistence because this is basically the check
356359
whether the postbox is still there in countries in which it is enabled */
357360
48 to AddPostboxCollectionTimes(),
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package de.westnordost.streetcomplete.quests.surface
2+
3+
import de.westnordost.streetcomplete.R
4+
import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry
5+
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType
6+
import de.westnordost.streetcomplete.data.quest.AndroidQuest
7+
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.OUTDOORS
8+
import de.westnordost.streetcomplete.osm.Tags
9+
import de.westnordost.streetcomplete.osm.surface.Surface
10+
import de.westnordost.streetcomplete.osm.surface.applyTo
11+
12+
class AddBeachSurface : OsmFilterQuestType<Surface>(), AndroidQuest {
13+
14+
override val elementFilter = """
15+
ways, relations with
16+
natural = beach
17+
and !surface
18+
"""
19+
20+
override val changesetComment = "Specify beach surface"
21+
override val wikiLink = "Key:surface"
22+
override val icon = R.drawable.quest_beach
23+
override val achievements = listOf(OUTDOORS)
24+
25+
override fun getTitle(tags: Map<String, String>) =
26+
R.string.quest_surface_title
27+
28+
override fun createForm() = AddBeachSurfaceForm()
29+
30+
override fun applyAnswerTo(
31+
answer: Surface,
32+
tags: Tags,
33+
geometry: ElementGeometry,
34+
timestampEdited: Long
35+
) {
36+
answer.applyTo(tags)
37+
}
38+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package de.westnordost.streetcomplete.quests.surface
2+
3+
import androidx.compose.runtime.Composable
4+
import de.westnordost.streetcomplete.osm.surface.Surface
5+
import de.westnordost.streetcomplete.osm.surface.icon
6+
import de.westnordost.streetcomplete.osm.surface.title
7+
import de.westnordost.streetcomplete.quests.AItemSelectQuestForm
8+
import de.westnordost.streetcomplete.ui.common.item_select.ImageWithLabel
9+
import kotlinx.serialization.serializer
10+
import org.jetbrains.compose.resources.painterResource
11+
import org.jetbrains.compose.resources.stringResource
12+
13+
class AddBeachSurfaceForm : AItemSelectQuestForm<Surface, Surface>() {
14+
15+
override val items get() = listOf(
16+
Surface.SAND,
17+
Surface.PEBBLES,
18+
Surface.GRAVEL,
19+
Surface.GRASS,
20+
Surface.ROCK,
21+
Surface.FINE_GRAVEL,
22+
Surface.GROUND
23+
)
24+
25+
override val itemsPerRow = 3
26+
override val serializer = serializer<Surface>()
27+
28+
@Composable
29+
override fun ItemContent(item: Surface) {
30+
ImageWithLabel(
31+
item.icon?.let { painterResource(it) },
32+
stringResource(item.title)
33+
)
34+
}
35+
36+
override fun onClickOk(selectedItem: Surface) {
37+
applyAnswer(selectedItem)
38+
}
39+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="128dp"
3+
android:height="128dp"
4+
android:viewportWidth="128"
5+
android:viewportHeight="128">
6+
<path
7+
android:pathData="m128,64c0,35.35 -28.65,64 -64,64s-64,-28.65 -64,-64 28.65,-64 64,-64 64,28.65 64,64"
8+
android:strokeWidth=".2"
9+
android:fillColor="#bdd6e1"/>
10+
<path
11+
android:pathData="m0.68,54.68c-0.44,3.04 -0.68,6.16 -0.68,9.32 0,35.35 28.65,64 64,64s64,-28.65 64,-64c0,-3.17 -0.24,-6.28 -0.68,-9.32 -41.88,-3.83 -84.1,-3.72 -126.63,0z"
12+
android:strokeWidth=".2"
13+
android:fillColor="#529add"/>
14+
<path
15+
android:pathData="m105.72,71.7c-17.88,0 -36.86,4.86 -49.66,6.4 -18.76,2.21 -22.51,-5.3 -40.83,-3.09 -3.9,0.41 -8.82,1.92 -13.48,3.68 6.64,28.27 32,49.32 62.29,49.32 31.87,0 58.28,-23.3 63.18,-53.78 -1.48,-0.35 -11.11,-2.52 -21.49,-2.52z"
16+
android:strokeWidth=".2"
17+
android:fillColor="#f4d4a5"/>
18+
<path
19+
android:pathData="m103.4,82.25 l-1.68,1.68 1.68,1.68 1.68,-1.68zM42.48,82.52 L39.66,85.35 42.48,88.17 45.31,85.35zM88.8,87.37 L87.12,89.05 88.8,90.73 90.48,89.05zM67.09,87.43 L65.41,89.11 67.09,90.79 68.77,89.11zM78.61,87.62 L75.24,90.98 78.61,94.34 81.97,90.98zM33.93,89.44 L32.51,90.85 33.93,92.26 35.34,90.85zM96.62,90.79 L94.94,92.47 96.62,94.16 98.3,92.47zM26.23,91.11 L23.4,93.93 26.23,96.76 29.06,93.93zM106.79,92.71 L103.43,96.07 106.79,99.43 110.16,96.07zM84.01,94.07 L82.32,95.75 84.01,97.43 85.69,95.75zM17.36,95.12 L15.95,96.53 17.36,97.95 18.78,96.53zM43.1,95.25 L41.68,96.66 43.1,98.07 44.51,96.66zM33.92,96.79 L31.1,99.62 33.92,102.44 36.75,99.62zM24.8,100.88 L23.39,102.29 24.8,103.71 26.21,102.29zM61.31,101.53 L56.93,105.9 61.31,110.28 65.68,105.9zM56.89,110.03 L54.7,112.22 56.89,114.41 59.08,112.22zM67.88,111.39 L65.69,113.57 67.88,115.76 70.07,113.57zM55.59,118.93 L53.4,121.12 55.59,123.31 57.77,121.12z"
20+
android:strokeWidth="1.4542"
21+
android:fillColor="#ffebd2"/>
22+
<path
23+
android:pathData="m121.8,85.51c0,2.24 -4.86,1.87 -10.47,1.12 -2.99,4.49 -6.73,6.36 -8.97,6.36 -1.12,0 -2.24,-4.49 -1.87,-8.6 -5.61,-1.5 -9.72,-3.74 -9.34,-5.23 1.12,-9.35 31.02,1.87 30.65,6.36"
24+
android:strokeWidth="1.9048"
25+
android:fillColor="#a38982"/>
26+
<path
27+
android:pathData="m0.09,64c-0.09,0.99 0.05,1.97 0.01,2.98 10.65,-0.06 21.31,-2.31 31.96,0 12.86,3.19 21.83,0.75 31.96,0 6.68,-1.12 12.84,-2.39 31.96,0 10.77,0.34 21.8,1.48 31.96,0 -0.05,-1.01 0.06,-2.01 -0.04,-3 -10.86,1.47 -21.47,0.35 -32.03,0 -10.37,-0.14 -14.75,-3.67 -31.86,0 -11.58,2.31 -21.91,1.6 -31.86,0 -9.56,-1.32 -21.35,-0.12 -32.08,0.02z"
28+
android:strokeWidth=".2"
29+
android:fillColor="#3581c8"/>
30+
<path
31+
android:pathData="m103.11,59.35c1.12,-0.37 4.86,2.99 8.22,7.85 5.98,-1.5 10.47,-2.24 10.47,-1.12 0.37,1.5 -1.12,5.61 -4.48,10.84 2.99,4.86 4.86,8.6 3.74,9.35 -1.5,1.5 -5.23,0.37 -10.84,-1.12 -3.74,4.11 -6.35,7.1 -8.6,6.73 -1.12,0 -1.5,-4.49 -1.87,-10.09 -5.61,-2.24 -8.97,-4.86 -9.34,-6.73 -0.37,-1.12 4.11,-2.99 9.72,-4.86 0.75,-5.61 1.87,-10.47 2.99,-10.84"
32+
android:strokeWidth="1.9048"
33+
android:fillColor="#f27a52"/>
34+
<path
35+
android:pathData="m1.6,49.68c-0.45,1.56 -1.22,7.23 -1.37,9 10.48,-0.65 21.35,-1.85 32.14,0 10.34,1.33 21.02,0.57 31.68,0 10.4,-0.81 20.95,-0.83 31.68,0 11.13,1.7 21.51,0.06 32.05,0 -0.06,-1.15 -0.77,-6.9 -1.28,-9 -2.62,0.53 -8.4,0.85 -31.22,0 -10.38,-0.1 -20.43,-1.55 -31.22,0 -11.73,1.32 -22.72,1.9 -31.22,0 -10.89,-1.46 -21.26,-1.33 -31.22,0z"
36+
android:strokeWidth=".2"
37+
android:fillColor="#3581c8"/>
38+
</vector>

0 commit comments

Comments
 (0)