Make question mark optional

This commit is contained in:
Lucas Lima 2020-06-27 21:35:04 -03:00
parent 0cfe5f38c5
commit 9b09b22bcc
No known key found for this signature in database
GPG key ID: 0259A3F43EC1027A
20 changed files with 31 additions and 28 deletions

View file

@ -165,7 +165,7 @@ class GameActivity : AppCompatActivity(), DialogInterface.OnDismissListener {
override fun onResume() {
super.onResume()
if (status == Status.Running) {
viewModel.updateGameControl()
viewModel.refreshUserPreferences()
viewModel.resumeGame()
analyticsManager.sentEvent(Analytics.Resume())
}
@ -592,7 +592,7 @@ class GameActivity : AppCompatActivity(), DialogInterface.OnDismissListener {
override fun onDismiss(dialog: DialogInterface?) {
viewModel.run {
updateGameControl()
refreshUserPreferences()
resumeGame()
}
}

View file

@ -26,6 +26,7 @@ class GameController {
private var firstOpen: FirstOpen = FirstOpen.Unknown
private var gameControl: GameControl = GameControl.Standard
private var mines: Sequence<Area> = emptySequence()
private var useQuestionMark = true
var hasMines = false
private set
@ -268,6 +269,10 @@ class GameController {
this.gameControl = newGameControl
}
fun useQuestionMark(useQuestionMark: Boolean) {
this.useQuestionMark = useQuestionMark
}
/**
* Run a game [actionResponse] on a given tile.
* @return The number of changed tiles.
@ -309,7 +314,7 @@ class GameController {
if (isCovered) {
mark = when (mark) {
Mark.PurposefulNone, Mark.None -> Mark.Flag
Mark.Flag -> Mark.Question
Mark.Flag -> if (useQuestionMark) Mark.Question else Mark.None
Mark.Question -> Mark.None
}
}

View file

@ -62,7 +62,7 @@ class GameViewModel @ViewModelInject constructor(
)
gameController = GameController(minefield, minefieldRepository.randomSeed())
updateGameControl()
refreshUserPreferences()
mineCount.postValue(minefield.mines)
difficulty.postValue(newDifficulty)
@ -88,7 +88,7 @@ class GameViewModel @ViewModelInject constructor(
val setup = save.minefield
gameController = GameController(save)
updateGameControl()
refreshUserPreferences()
mineCount.postValue(setup.mines)
difficulty.postValue(save.difficulty)
@ -117,7 +117,7 @@ class GameViewModel @ViewModelInject constructor(
plantMinesExcept(save.firstOpen.value, true)
singleClick(save.firstOpen.value)
}
updateGameControl()
refreshUserPreferences()
}
mineCount.postValue(setup.mines)
@ -295,11 +295,15 @@ class GameViewModel @ViewModelInject constructor(
}
}
fun updateGameControl() {
fun refreshUserPreferences() {
if (initialized) {
val questionMark = preferencesRepository.useQuestionMark()
val controlType = preferencesRepository.controlType()
val gameControl = GameControl.fromControlType(controlType)
gameController.updateGameControl(gameControl)
gameController.apply {
updateGameControl(gameControl)
useQuestionMark(questionMark)
}
}
}

View file

@ -19,6 +19,7 @@ interface IPreferencesRepository {
fun useHapticFeedback(): Boolean
fun useLargeAreas(): Boolean
fun useAnimations(): Boolean
fun useQuestionMark(): Boolean
}
class PreferencesRepository(
@ -58,6 +59,9 @@ class PreferencesRepository(
override fun useAnimations(): Boolean =
getBoolean("preference_animation", true)
override fun useQuestionMark(): Boolean =
getBoolean("preference_use_question_mark", true)
override fun controlType(): ControlStyle {
val index = getInt("preference_control_type", -1)
return ControlStyle.values().getOrNull(index) ?: ControlStyle.Standard

View file

@ -86,7 +86,6 @@
<string name="settings_general">General</string>
<string name="settings_vibration_desc">Vibrates on explosion or flag toggle</string>
<string name="settings_sound_desc">Makes a sound of explosion</string>
<string name="settings_auto_flag_desc">Adds a flag on resolved mines automatically</string>
<string name="settings_gameplay">Gameplay</string>
<string name="settings_accessibility">Accessibility</string>
<string name="settings_large_areas">Use Large Areas</string>

View file

@ -86,7 +86,6 @@
<string name="settings_general">Obecné</string>
<string name="settings_vibration_desc">Vibrovat při výbuchu miny nebo umístění vlajky</string>
<string name="settings_sound_desc">Zazní exploze</string>
<string name="settings_auto_flag_desc">Automaticky přidá vlajku na vyřešené miny</string>
<string name="settings_gameplay">Hra</string>
<string name="settings_accessibility">Přístupnost</string>
<string name="settings_large_areas">Použít velké oblasti</string>

View file

@ -86,7 +86,6 @@
<string name="settings_general">Allgemein</string>
<string name="settings_vibration_desc">Vibriert bei Explosion oder Schalten einer Markierung</string>
<string name="settings_sound_desc">Erzeugt ein Explosionsgeräusch</string>
<string name="settings_auto_flag_desc">Fügt bei beseitigten Minen automatisch eine Markierung hinzu</string>
<string name="settings_gameplay">Spielablauf</string>
<string name="settings_accessibility">Barrierefreiheit</string>
<string name="settings_large_areas">Große Flächen verwenden</string>

View file

@ -86,7 +86,6 @@
<string name="settings_general">Γενικά</string>
<string name="settings_vibration_desc">Δόνηση σε έκρηξη ή εναλλαγή σημαίας</string>
<string name="settings_sound_desc">Κάνει έναν ήχο έκρηξης</string>
<string name="settings_auto_flag_desc">Προσθέτει μια σημαία αυτόματα όταν αφαιρούνται οι νάρκες</string>
<string name="settings_gameplay">Gameplay</string>
<string name="settings_accessibility">Προσβασιμότητα</string>
<string name="settings_large_areas">Χρησιμοποιήστε μεγάλες περιοχές</string>

View file

@ -86,7 +86,6 @@
<string name="settings_general">General</string>
<string name="settings_vibration_desc">Vibrar al activar la explosión o la bandera</string>
<string name="settings_sound_desc">Hace un sonido de explosión</string>
<string name="settings_auto_flag_desc">Añade una bandera en minas resueltas automáticamente</string>
<string name="settings_gameplay">Jugabilidad</string>
<string name="settings_accessibility">Accesibilidad</string>
<string name="settings_large_areas">Usar áreas grandes</string>

View file

@ -86,7 +86,6 @@
<string name="settings_general">Général</string>
<string name="settings_vibration_desc">Vibrations lors d\'une explosion ou de la pose un drapeau</string>
<string name="settings_sound_desc">Fait un bruit d\'explosion</string>
<string name="settings_auto_flag_desc">Ajouter un drapeau sur des mines sûres automatiquement</string>
<string name="settings_gameplay">Jouabilité</string>
<string name="settings_accessibility">Accessibilité</string>
<string name="settings_large_areas">Utiliser des grandes cases</string>

View file

@ -86,7 +86,6 @@
<string name="settings_general">Generale</string>
<string name="settings_vibration_desc">Vibra all\'esplosione di una mina oppure quando si piazza una bandiera</string>
<string name="settings_sound_desc">Fa un suono di esplosione</string>
<string name="settings_auto_flag_desc">Aggiunge automaticamente una bandiera sulle mine risolte</string>
<string name="settings_gameplay">Gameplay</string>
<string name="settings_accessibility">Accessibilità</string>
<string name="settings_large_areas">Usa grandi aree</string>

View file

@ -86,7 +86,6 @@
<string name="settings_general">全般</string>
<string name="settings_vibration_desc">爆発またはフラグの切り替え時にバイブレーションを鳴らします</string>
<string name="settings_sound_desc">爆発音を鳴らします</string>
<string name="settings_auto_flag_desc">解決された地雷に自動でフラグを追加します</string>
<string name="settings_gameplay">ゲームプレイ</string>
<string name="settings_accessibility">アクセシビリティ</string>
<string name="settings_large_areas">範囲を広くする</string>

View file

@ -87,7 +87,6 @@
<string name="settings_gameplay">Jogabilidade</string>
<string name="settings_vibration_desc">Vibra ao explodir ou alternar marcação</string>
<string name="settings_sound_desc">Faz um som ao explodir</string>
<string name="settings_auto_flag_desc">Faz marcação automaticamente em minas resolvidas</string>
<string name="settings_accessibility">Acessibilidade</string>
<string name="settings_large_areas">Usar Área Grande</string>
<string name="settings_large_areas_desc">Aumenta a área tocável</string>

View file

@ -86,7 +86,6 @@
<string name="settings_general">Общее</string>
<string name="settings_vibration_desc">Вибрировать при взрывах и при установке флага</string>
<string name="settings_sound_desc">Звуки взрывов</string>
<string name="settings_auto_flag_desc">Автоматически добавлять флаг на обезвреженные мины</string>
<string name="settings_gameplay">Геймплей</string>
<string name="settings_accessibility">Специальные возможности</string>
<string name="settings_large_areas">Использовать большие области</string>

View file

@ -86,7 +86,6 @@
<string name="settings_general">Genel</string>
<string name="settings_vibration_desc">Patlama veya bayrak yerleştirme/kaldırmada titretir</string>
<string name="settings_sound_desc">Patlama sesi çıkarır</string>
<string name="settings_auto_flag_desc">Çözülmüş mayınlara otomatik olarak bayrak ekler</string>
<string name="settings_gameplay">Oynanış</string>
<string name="settings_accessibility">Erişilebilirlik</string>
<string name="settings_large_areas">Geniş Alanlar Kullan</string>

View file

@ -86,7 +86,6 @@
<string name="settings_general">Загальне</string>
<string name="settings_vibration_desc">Вібрує під час вибуху або встановлення прапірця</string>
<string name="settings_sound_desc">Додає звук вибуху</string>
<string name="settings_auto_flag_desc">Встановлювати прапорець на розгаданих ділянках автоматично</string>
<string name="settings_gameplay">Геймплей</string>
<string name="settings_accessibility">Спеціальні можливості</string>
<string name="settings_large_areas">Використовувати збільшену територію</string>

View file

@ -86,7 +86,6 @@
<string name="settings_general">Tổng quan</string>
<string name="settings_vibration_desc">Rung khi mìn nổ hoặc cắm/dỡ cờ</string>
<string name="settings_sound_desc">Phát âm thanh nổ mìn</string>
<string name="settings_auto_flag_desc">Tự cắm cờ vào những chỗ chắc chắn có mìn</string>
<string name="settings_gameplay">Cách thức chơi</string>
<string name="settings_accessibility">Trợ năng</string>
<string name="settings_large_areas">Vùng chạm lớn</string>

View file

@ -86,7 +86,6 @@
<string name="settings_general">通用</string>
<string name="settings_vibration_desc">爆炸或标记时振动</string>
<string name="settings_sound_desc">播放爆炸声音</string>
<string name="settings_auto_flag_desc">自动在已解决的地雷上添加旗帜</string>
<string name="settings_gameplay">游戏性</string>
<string name="settings_accessibility">无障碍</string>
<string name="settings_large_areas">使用大区域</string>

View file

@ -78,7 +78,7 @@
<string name="width">Width</string>
<string name="height">Height</string>
<string name="mines">Mines</string>
<string name="auto_flag">Game Assistant</string>
<string name="enable_automatic_flags">Enable automatic placing of flags</string>
<string name="desc_convered_area">Covered area</string>
<string name="desc_marked_area">Marked area</string>
<string name="desc_question_area">Doubtful area</string>
@ -86,7 +86,6 @@
<string name="settings_general">General</string>
<string name="settings_vibration_desc">Vibrates on explosion or flag toggle</string>
<string name="settings_sound_desc">Makes a sound of explosion</string>
<string name="settings_auto_flag_desc">Adds a flag on resolved mines automatically</string>
<string name="settings_gameplay">Gameplay</string>
<string name="settings_accessibility">Accessibility</string>
<string name="settings_large_areas">Use Large Areas</string>
@ -100,7 +99,7 @@
<string name="total_time">Total Time</string>
<string name="average_time">Average Time</string>
<string name="performance">Performance</string>
<string name="use_question_mark">Use Question Flags</string>
<string name="control">Control</string>
<string name="arrow"></string>
<string name="flag_first">Flag First</string>
@ -109,5 +108,4 @@
<string name="long_press">Long Press</string>
<string name="open_tile">Open Tile</string>
<string name="flag_tile">Flag Tile</string>
</resources>

View file

@ -7,12 +7,18 @@
android:title="@string/settings_gameplay"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:checked="true"
android:defaultValue="true"
android:key="preference_use_question_mark"
android:title="@string/use_question_mark"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:checked="true"
android:defaultValue="true"
android:key="preference_assistant"
android:title="@string/auto_flag"
android:summary="@string/settings_auto_flag_desc"
android:title="@string/enable_automatic_flags"
app:iconSpaceReserved="false" />
</PreferenceCategory>