Ver código fonte

Merge branch 'master' of http://8.136.234.80:10002/WangYongJun/GameConsole

wangyongj 2 anos atrás
pai
commit
8703a2aa93

+ 1 - 1
app/src/main/cpp/frontend/drivers/platform_unix.c

@@ -1625,7 +1625,7 @@ static void frontend_unix_get_env(int *argc,
                /* sdcard is writable, this should be the case most of the time*/
                case INTERNAL_STORAGE_WRITABLE:
                   fill_pathname_join(parent_path,
-                        internal_storage_path, "RetroArch",
+                        internal_storage_path, "arcade",
                         sizeof(parent_path));
                   break;
             }

+ 21 - 1
app/src/main/cpp/play_feature_delivery/play_feature_delivery.c

@@ -78,11 +78,31 @@ static play_feature_delivery_state_t* play_feature_delivery_get_state(void)
 /**********************/
 
 JNIEXPORT void JNICALL Java_com_retroarch_browser_retroactivity_RetroActivityCommon_exitLocalGame
-        (JNIEnv *env, jobject thisObj){
+      (JNIEnv *env, jobject thisObj){
     RARCH_LOG("[Menu]: func: exitLocalGame");
     command_event(CMD_EVENT_QUIT, NULL);
 }
 
+JNIEXPORT jboolean JNICALL Java_com_retroarch_browser_retroactivity_RetroActivityCommon_saveState
+      (JNIEnv *env, jobject thisObj, jint state_index) {
+   settings_t *settings        = config_get_ptr();
+   if (settings == NULL)
+      return false;
+
+   settings->ints.state_slot = state_index;
+   return command_event_main_state(CMD_EVENT_SAVE_STATE);
+}
+
+JNIEXPORT jboolean JNICALL Java_com_retroarch_browser_retroactivity_RetroActivityCommon_loadState
+      (JNIEnv *env, jobject thisObj, jint state_index) {
+   settings_t *settings        = config_get_ptr();
+   if (settings == NULL)
+      return false;
+
+   settings->ints.state_slot = state_index;
+   return command_event_main_state(CMD_EVENT_LOAD_STATE);
+}
+
 /*
  * Class:     com_retroarch_browser_retroactivity_RetroActivityCommon
  * Method:    coreInstallInitiated

+ 14 - 0
app/src/main/java/com/retroarch/browser/retroactivity/RetroActivityCommon.java

@@ -469,6 +469,20 @@ public class RetroActivityCommon extends NativeActivity
    */
   public native void exitLocalGame();
 
+  /**
+   * 保存状态
+   * @param stateIndex 状态索引
+   * @return 成功返回true,失败返回false
+   */
+  public native boolean saveState(int stateIndex);
+
+  /**
+   * 加载状态
+   * @param stateIndex 状态索引
+   * @return 成功返回true,失败返回false
+   */
+  public native boolean loadState(int stateIndex);
+
   /**
    * 切换渲染路径
    */

+ 9 - 3
app/src/main/java/com/xugame/gameconsole/dialog/gamemenu/GameMenuDialog.java

@@ -60,7 +60,10 @@ public class GameMenuDialog extends BaseDialog
             archiveTexts[i].setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
-                    Toast.makeText(mContext,"写入存档"+tempIndex,Toast.LENGTH_SHORT).show();
+                    if (mListener != null && mListener.onSaveState(tempIndex))
+                        // todo: save state error handler
+                        ;
+                    dismiss();
                 }
             });
         }
@@ -70,8 +73,11 @@ public class GameMenuDialog extends BaseDialog
             readArchiveTexts[i].setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
-                    mReadArchiveIndex=tempIndex;
-                    Toast.makeText(mContext,"读取存档"+tempIndex,Toast.LENGTH_SHORT).show();
+                    mReadArchiveIndex = tempIndex;
+                    if (mListener != null && mListener.onLoadState(tempIndex))
+                        // todo: load state error handler
+                        ;
+                    dismiss();
                 }
             });
         }

+ 2 - 0
app/src/main/java/com/xugame/gameconsole/dialog/gamemenu/GameMenuDialogListener.java

@@ -5,4 +5,6 @@ import com.xugame.gameconsole.emulator.ScreenType;
 public interface GameMenuDialogListener {
     void onExitGame();
     void onResumeGame(ScreenType type, int archiveIndex);
+    boolean onSaveState(int stateIndex);
+    boolean onLoadState(int stateIndex);
 }

+ 12 - 1
app/src/main/java/com/xugame/gameconsole/emulator/RetroArchEmulatorActivity.java

@@ -27,7 +27,6 @@ import java.lang.reflect.Method;
 //        }
 public class RetroArchEmulatorActivity extends RetroActivityCamera {
     private static final String TAG = "RetroArchEmulatorActivityTAG";
-    private Context mCotext;
     private ScreenType mScreenType = ScreenType.NORMAL;
     private boolean mUpdateScreen = false;
     // If set to true then Retroarch will completely exit when it loses focus
@@ -171,6 +170,18 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
                 mScreenType = type;
                 mUpdateScreen = true;
             }
+
+            @Override
+            public boolean onSaveState(int stateIndex) {
+                // Toast.makeText(mContext, "写入存档" + stateIndex, Toast.LENGTH_SHORT).show();
+                return saveState(stateIndex);
+            }
+
+            @Override
+            public boolean onLoadState(int stateIndex) {
+                // Toast.makeText(mContext,"读取存档"+stateIndex,Toast.LENGTH_SHORT).show();
+                return loadState(stateIndex);
+            }
         });
         menuDialog.setCanceledOnTouchOutside(true);
         menuDialog.show();