Android: Split AbstractCheat into ReadOnlyCheat and AbstractCheat

ReadOnlyCheat will be used by graphics mods.
This commit is contained in:
JosJuice 2022-07-23 14:51:18 +02:00
parent 41a26f76fa
commit 45f6d36c45
2 changed files with 37 additions and 23 deletions

View File

@ -3,12 +3,9 @@
package org.dolphinemu.dolphinemu.features.cheats.model; package org.dolphinemu.dolphinemu.features.cheats.model;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public abstract class AbstractCheat implements Cheat public abstract class AbstractCheat extends ReadOnlyCheat
{ {
private Runnable mChangedCallback = null;
public boolean supportsCode() public boolean supportsCode()
{ {
return true; return true;
@ -43,25 +40,6 @@ public abstract class AbstractCheat implements Cheat
return result; return result;
} }
public void setEnabled(boolean enabled)
{
setEnabledImpl(enabled);
onChanged();
}
public void setChangedCallback(@Nullable Runnable callback)
{
mChangedCallback = callback;
}
protected void onChanged()
{
if (mChangedCallback != null)
mChangedCallback.run();
}
protected abstract int trySetImpl(@NonNull String name, @NonNull String creator, protected abstract int trySetImpl(@NonNull String name, @NonNull String creator,
@NonNull String notes, @NonNull String code); @NonNull String notes, @NonNull String code);
protected abstract void setEnabledImpl(boolean enabled);
} }

View File

@ -0,0 +1,36 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.features.cheats.model;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public abstract class ReadOnlyCheat implements Cheat
{
private Runnable mChangedCallback = null;
public int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes,
@NonNull String code)
{
throw new UnsupportedOperationException();
}
public void setEnabled(boolean enabled)
{
setEnabledImpl(enabled);
onChanged();
}
public void setChangedCallback(@Nullable Runnable callback)
{
mChangedCallback = callback;
}
protected void onChanged()
{
if (mChangedCallback != null)
mChangedCallback.run();
}
protected abstract void setEnabledImpl(boolean enabled);
}