Android: Fix up showing menu

This commit is contained in:
zilmar 2023-10-26 12:13:08 +10:30
parent d3f4132770
commit 0dc1fa7f45
2 changed files with 34 additions and 30 deletions
Android/app/src/main/java/emu/project64

View File

@ -5,7 +5,7 @@ import java.sql.Date;
import java.text.SimpleDateFormat;
import emu.project64.R;
//import emu.project64.jni.LanguageStringID;
import emu.project64.jni.LanguageStringID;
import emu.project64.jni.NativeExports;
import emu.project64.jni.SettingsID;
import emu.project64.jni.SystemEvent;
@ -32,7 +32,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
public GameMenuHandler( Activity activity, GameLifecycleHandler LifecycleHandler )
{
/*mActivity = activity;
mActivity = activity;
mLifecycleHandler = LifecycleHandler;
final ImageButton MenuButton = (ImageButton)activity.findViewById( R.id.gameMenu );
@ -43,9 +43,9 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
@Override
public void onClick(View view)
{
/*Boolean GamePaused = NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Paused.getValue());
Boolean RecordExecutionTimes = NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordExecutionTimes.getValue());
Boolean ShowDebugMenu = NativeExports.SettingsLoadBool(SettingsID.Debugger_Enabled.getValue());
Boolean GamePaused = NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Paused.toString());
Boolean RecordExecutionTimes = NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordExecutionTimes.toString());
Boolean ShowDebugMenu = NativeExports.SettingsLoadBool(SettingsID.Debugger_Enabled.toString());
if (!RecordExecutionTimes)
{
@ -59,7 +59,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
popupMenu.setOnMenuItemClickListener(menuHandler);
popupMenu.inflate(R.menu.game_activity);
int CurrentSaveState = NativeExports.SettingsLoadDword(SettingsID.Game_CurrentSaveState.getValue());
int CurrentSaveState = NativeExports.SettingsLoadDword(SettingsID.Game_CurrentSaveState.toString());
Menu menu = popupMenu.getMenu();
Strings.SetMenuTitle(menu, R.id.menuItem_SaveState, LanguageStringID.ANDROID_MENU_SAVESTATE);
@ -82,10 +82,10 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
menu.findItem(R.id.menuItem_DumpFunctionTimes).setVisible(RecordExecutionTimes);
menu.findItem(R.id.menuItem_DebuggingMenu).setVisible(ShowDebugMenu);
String SaveDirectory = NativeExports.SettingsLoadString(SettingsID.Directory_InstantSave.getValue());
if ( NativeExports.SettingsLoadBool(SettingsID.Setting_UniqueSaveDir.getValue()))
String SaveDirectory = NativeExports.SettingsLoadString(SettingsID.Directory_InstantSave.toString());
if ( NativeExports.SettingsLoadBool(SettingsID.Setting_UniqueSaveDir.toString()))
{
SaveDirectory += "/" + NativeExports.SettingsLoadString(SettingsID.Game_UniqueSaveDir.getValue());
SaveDirectory += "/" + NativeExports.SettingsLoadString(SettingsID.Game_UniqueSaveDir.toString());
}
FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSaveAuto, 0);
@ -99,9 +99,9 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSave8, 8);
FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSave9, 9);
FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSave10, 10);
popupMenu.show();*/
/*}
});*/
popupMenu.show();
}
});
}
public boolean onMenuItemClick(MenuItem item)
@ -122,39 +122,39 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
case R.id.menuItem_LoadState:
NativeExports.ExternalEvent(SystemEvent.SysEvent_LoadMachineState.getValue());
break;
/*case R.id.menuItem_CurrentSaveAuto:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 0);
case R.id.menuItem_CurrentSaveAuto:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 0);
break;
case R.id.menuItem_CurrentSave1:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 1);
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 1);
break;
case R.id.menuItem_CurrentSave2:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 2);
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 2);
break;
case R.id.menuItem_CurrentSave3:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 3);
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 3);
break;
case R.id.menuItem_CurrentSave4:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 4);
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 4);
break;
case R.id.menuItem_CurrentSave5:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 5);
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 5);
break;
case R.id.menuItem_CurrentSave6:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 6);
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 6);
break;
case R.id.menuItem_CurrentSave7:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 7);
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 7);
break;
case R.id.menuItem_CurrentSave8:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 8);
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 8);
break;
case R.id.menuItem_CurrentSave9:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 9);
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 9);
break;
case R.id.menuItem_CurrentSave10:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 10);
break;*/
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 10);
break;
case R.id.menuItem_pause:
NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_FromMenu.getValue());
break;
@ -195,12 +195,12 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
@SuppressLint("SimpleDateFormat")
private void FixSaveStateMenu(String SaveDirectory, int CurrentSaveState,Menu menu, int MenuId, int SaveSlot )
{
/*MenuItem item = menu.findItem(MenuId);
MenuItem item = menu.findItem(MenuId);
if (CurrentSaveState == SaveSlot)
{
item.setChecked(true);
}
String SaveFileName = SaveDirectory + "/" + NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.getValue()) + ".pj";
String SaveFileName = SaveDirectory + "/" + NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.toString()) + ".pj";
String Timestamp = "";
if (SaveSlot != 0)
{
@ -219,12 +219,12 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
}
String SlotName = SaveSlot == 0 ? Strings.GetString(LanguageStringID.ANDROID_MENU_CURRENTSAVEAUTO) :
Strings.GetString(LanguageStringID.ANDROID_MENU_CURRENTSAVESLOT) + " " + SaveSlot;
item.setTitle(SlotName + Timestamp);*/
item.setTitle(SlotName + Timestamp);
}
private void SelectGameSpeed()
{
/*NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_AppLostActive.getValue());
NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_AppLostActive.getValue());
final int MAX_SPEED = 300;
final int MIN_SPEED = 10;
final int initial = (NativeExports.GetSpeed() * 100) / NativeExports.GetBaseSpeed();
@ -291,6 +291,6 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
dialog.dismiss();
NativeExports.ExternalEvent( SystemEvent.SysEvent_ResumeCPU_AppGainedActive.getValue());
}
});*/
});
}
}

View File

@ -29,6 +29,10 @@ public class NativeExports
public static native void RefreshRomDir(String RomDir, boolean Recursive);
public static native void ExternalEvent(int Type);
public static native byte[] GetString(int StringId);
public static native void SetSpeed(int Speed);
public static native int GetSpeed();
public static native int GetBaseSpeed();
public static native void onSurfaceCreated();
public static native void onSurfaceChanged(int width, int height);