Android: Show warning when Enable Cheats is off
This commit is contained in:
parent
1470dfcf81
commit
215492152c
|
@ -93,7 +93,7 @@ public class GamePropertiesDialog extends DialogFragment
|
|||
SettingsActivity.launch(getContext(), MenuTag.SETTINGS, gameId, revision, isWii));
|
||||
|
||||
itemsBuilder.add(R.string.properties_edit_cheats, (dialog, i) ->
|
||||
CheatsActivity.launch(getContext(), gameId, revision));
|
||||
CheatsActivity.launch(getContext(), gameId, revision, isWii));
|
||||
|
||||
itemsBuilder.add(R.string.properties_clear_game_settings, (dialog, i) ->
|
||||
clearGameSettings(gameId));
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.dolphinemu.dolphinemu.features.cheats.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
||||
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
|
||||
|
||||
public class CheatWarningFragment extends Fragment implements View.OnClickListener
|
||||
{
|
||||
private View mView;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
return inflater.inflate(R.layout.fragment_cheat_warning, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
mView = view;
|
||||
|
||||
Button settingsButton = view.findViewById(R.id.button_settings);
|
||||
settingsButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
|
||||
CheatsActivity activity = (CheatsActivity) requireActivity();
|
||||
try (Settings settings = activity.loadGameSpecificSettings())
|
||||
{
|
||||
boolean cheatsEnabled = BooleanSetting.MAIN_ENABLE_CHEATS.getBoolean(settings);
|
||||
mView.setVisibility(cheatsEnabled ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void onClick(View view)
|
||||
{
|
||||
SettingsActivity.launch(requireContext(), MenuTag.CONFIG_GENERAL);
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ import androidx.slidingpanelayout.widget.SlidingPaneLayout;
|
|||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.Cheat;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.CheatsViewModel;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||
import org.dolphinemu.dolphinemu.ui.TwoPaneOnBackPressedCallback;
|
||||
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
|
||||
|
||||
|
@ -20,18 +21,21 @@ public class CheatsActivity extends AppCompatActivity
|
|||
{
|
||||
private static final String ARG_GAME_ID = "game_id";
|
||||
private static final String ARG_REVISION = "revision";
|
||||
private static final String ARG_IS_WII = "is_wii";
|
||||
|
||||
private String mGameId;
|
||||
private int mRevision;
|
||||
private boolean mIsWii;
|
||||
private CheatsViewModel mViewModel;
|
||||
|
||||
private SlidingPaneLayout mSlidingPaneLayout;
|
||||
|
||||
public static void launch(Context context, String gameId, int revision)
|
||||
public static void launch(Context context, String gameId, int revision, boolean isWii)
|
||||
{
|
||||
Intent intent = new Intent(context, CheatsActivity.class);
|
||||
intent.putExtra(ARG_GAME_ID, gameId);
|
||||
intent.putExtra(ARG_REVISION, revision);
|
||||
intent.putExtra(ARG_IS_WII, isWii);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
|
@ -45,6 +49,7 @@ public class CheatsActivity extends AppCompatActivity
|
|||
Intent intent = getIntent();
|
||||
mGameId = intent.getStringExtra(ARG_GAME_ID);
|
||||
mRevision = intent.getIntExtra(ARG_REVISION, 0);
|
||||
mIsWii = intent.getBooleanExtra(ARG_IS_WII, true);
|
||||
|
||||
setTitle(getString(R.string.cheats_with_game_id, mGameId));
|
||||
|
||||
|
@ -88,4 +93,11 @@ public class CheatsActivity extends AppCompatActivity
|
|||
if (open)
|
||||
mSlidingPaneLayout.open();
|
||||
}
|
||||
|
||||
public Settings loadGameSpecificSettings()
|
||||
{
|
||||
Settings settings = new Settings();
|
||||
settings.loadSettings(null, mGameId, mRevision, mIsWii);
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/cheat_list" />
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/cheat_warning"
|
||||
android:name="org.dolphinemu.dolphinemu.features.cheats.ui.CheatWarningFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/cheat_list" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/cheat_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cheat_warning"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_warning"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/spacing_large"
|
||||
android:text="@string/cheats_disabled_warning"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/button_settings"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_settings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/spacing_small"
|
||||
android:text="@string/cheats_open_settings"
|
||||
app:layout_constraintStart_toEndOf="@id/text_warning"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -406,6 +406,8 @@
|
|||
<string name="cheats_error_no_code_lines">Code can\'t be empty</string>
|
||||
<string name="cheats_error_on_line">Error on line %1$d</string>
|
||||
<string name="cheats_error_mixed_encryption">Lines must either be all encrypted or all decrypted</string>
|
||||
<string name="cheats_disabled_warning">Dolphin\'s cheat system is currently disabled.</string>
|
||||
<string name="cheats_open_settings">Settings</string>
|
||||
|
||||
<!-- Convert Screen -->
|
||||
<string name="convert_format">Format</string>
|
||||
|
|
Loading…
Reference in New Issue