diff --git a/builds/android/app/src/main/java/org/easyrpg/player/game_browser/Game.java b/builds/android/app/src/main/java/org/easyrpg/player/game_browser/Game.java index 764a3f7f362..7d4c5d59713 100644 --- a/builds/android/app/src/main/java/org/easyrpg/player/game_browser/Game.java +++ b/builds/android/app/src/main/java/org/easyrpg/player/game_browser/Game.java @@ -47,6 +47,11 @@ public Game(String gameFolderPath, String saveFolder, byte[] titleScreen) { } public String getTitle() { + String customTitle = getCustomTitle(); + if (!customTitle.isEmpty()) { + return customTitle; + } + return title; } @@ -56,6 +61,14 @@ public void setTitle(String title) { public native void reencodeTitle(); + public String getCustomTitle() { + return SettingsManager.getCustomGameTitle(this); + } + + public void setCustomTitle(String customTitle) { + SettingsManager.setCustomGameTitle(this, customTitle); + } + public String getGameFolderPath() { return gameFolderPath; } diff --git a/builds/android/app/src/main/java/org/easyrpg/player/game_browser/GameBrowserActivity.java b/builds/android/app/src/main/java/org/easyrpg/player/game_browser/GameBrowserActivity.java index 791dcf3c182..5b622b31419 100644 --- a/builds/android/app/src/main/java/org/easyrpg/player/game_browser/GameBrowserActivity.java +++ b/builds/android/app/src/main/java/org/easyrpg/player/game_browser/GameBrowserActivity.java @@ -8,6 +8,7 @@ import android.net.Uri; import android.os.Bundle; import android.provider.DocumentsContract; +import android.text.InputType; import android.util.DisplayMetrics; import android.util.Log; import android.view.LayoutInflater; @@ -16,6 +17,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.EditText; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.RelativeLayout; @@ -313,6 +315,7 @@ public void onBindViewHolder(final ViewHolder holder, final int position) { holder.settingsButton.setOnClickListener(v -> { String[] choices_list = { activity.getResources().getString(R.string.select_game_region), + activity.getResources().getString(R.string.game_rename), activity.getResources().getString(R.string.launch_debug_mode) }; @@ -323,6 +326,8 @@ public void onBindViewHolder(final ViewHolder holder, final int position) { if (which == 0) { chooseRegion(activity, holder, gameList.get(position)); } else if (which == 1) { + renameGame(activity, holder, gameList.get(position)); + } else if (which == 2) { launchGame(position, true); } }); @@ -390,6 +395,29 @@ public void chooseRegion(final Context context, final ViewHolder holder, final G builder.show(); } + public void renameGame(final Context context, final ViewHolder holder, final Game game) { + AlertDialog.Builder builder = new AlertDialog.Builder(context); + + // Set up text input + final EditText input = new EditText(context); + input.setInputType(InputType.TYPE_CLASS_TEXT); + input.setText(holder.title.getText()); + builder.setView(input); + + builder + .setTitle(R.string.game_rename) + .setPositiveButton(R.string.ok, (dialog, id) -> { + game.setCustomTitle(input.getText().toString()); + holder.title.setText(game.getTitle()); + }) + .setNegativeButton(R.string.cancel, null) + .setNeutralButton(R.string.revert, (dialog, id) -> { + game.setCustomTitle(""); + holder.title.setText(game.getTitle()); + }); + builder.show(); + } + public static class ViewHolder extends RecyclerView.ViewHolder { public TextView title; public ImageView titleScreen; diff --git a/builds/android/app/src/main/java/org/easyrpg/player/settings/SettingsManager.java b/builds/android/app/src/main/java/org/easyrpg/player/settings/SettingsManager.java index 2d64113f01e..8d645ee1976 100644 --- a/builds/android/app/src/main/java/org/easyrpg/player/settings/SettingsManager.java +++ b/builds/android/app/src/main/java/org/easyrpg/player/settings/SettingsManager.java @@ -391,6 +391,15 @@ public static void setGameEncoding(Game game, Encoding encoding) { editor.commit(); } + public static String getCustomGameTitle(Game game) { + return pref.getString(game.getKey() + "_Title", ""); + } + + public static void setCustomGameTitle(Game game, String customTitle) { + editor.putString(game.getKey() + "_Title", customTitle); + editor.commit(); + } + public static int getSpeedModifierA() { return speedModifierA; } diff --git a/builds/android/app/src/main/res/values/strings.xml b/builds/android/app/src/main/res/values/strings.xml index 6d92b8777ca..b7467f943b3 100644 --- a/builds/android/app/src/main/res/values/strings.xml +++ b/builds/android/app/src/main/res/values/strings.xml @@ -22,6 +22,7 @@ Do you really want to quit? Yes No + Revert Creating $PATH directory failed $PATH not readable No RPG Maker 2000/2003 games found.\n\nThe EasyRPG folder you selected contains a \"games\" folder. Use a file manager app to put your games in this folder.\nGames can be put in subfolders or in ZIP/LZH archives.\n\nThe EasyRPG folder can be changed in the settings. @@ -31,6 +32,7 @@ Select game region Change the layout Launch in debug mode + Rename game Choose a layout Unknown region Changing region failed