Permalink
Browse files

Merge pull request #507 from fzurita/no_resume_with_no_autosave

No resume with no autosave
  • Loading branch information...
Gillou68310 committed Nov 2, 2015
2 parents 08e4638 + 15ac242 commit 0ef2375b8808a65397fd2ee5d5f7495e797cdd17
@@ -43,6 +43,7 @@
import paulscode.android.mupen64plusae.persistent.AppData;
import paulscode.android.mupen64plusae.persistent.ConfigFile;
import paulscode.android.mupen64plusae.persistent.ConfigFile.ConfigSection;
import paulscode.android.mupen64plusae.persistent.GamePrefs;
import paulscode.android.mupen64plusae.persistent.GlobalPrefs;
import paulscode.android.mupen64plusae.task.ComputeMd5Task;
import paulscode.android.mupen64plusae.task.ComputeMd5Task.ComputeMd5Listener;
@@ -114,6 +115,9 @@
private CacheRomInfoFragment mCacheRomInfoFragment = null;
//True if the restart promp is enabled
boolean mRestartPromptEnabled = true;
@Override
protected void onNewIntent( Intent intent )
{
@@ -483,29 +487,42 @@ public void onGameSidebarAction(MenuItem menuItem)
{
case R.id.menuItem_resume:
launchGameActivity( finalItem.romFile.getAbsolutePath(),
finalItem.zipFile == null ? null : finalItem.zipFile.getAbsolutePath(),
finalItem.isExtracted, finalItem.md5, finalItem.crc, finalItem.headerName,
finalItem.countryCode, finalItem.artPath, finalItem.goodName, false );
finalItem.zipFile == null ? null : finalItem.zipFile.getAbsolutePath(),
finalItem.isExtracted, finalItem.md5, finalItem.crc, finalItem.headerName,
finalItem.countryCode, finalItem.artPath, finalItem.goodName, false );
break;
case R.id.menuItem_restart:
CharSequence title = getText( R.string.confirm_title );
CharSequence message = getText( R.string.confirmResetGame_message );
Prompt.promptConfirm( this, title, message,
new PromptConfirmListener()
{
@Override
public void onDialogClosed(int which)
//Don't show the prompt if this is the first time we start a game
if(mRestartPromptEnabled)
{
CharSequence title = getText( R.string.confirm_title );
CharSequence message = getText( R.string.confirmResetGame_message );
Prompt.promptConfirm( this, title, message,
new PromptConfirmListener()
{
if( which == DialogInterface.BUTTON_POSITIVE )
@Override
public void onDialogClosed(int which)
{
launchGameActivity( finalItem.romFile.getAbsolutePath(),
finalItem.zipFile == null ? null : finalItem.zipFile.getAbsolutePath(),
finalItem.isExtracted, finalItem.md5, finalItem.crc,
finalItem.headerName, finalItem.countryCode, finalItem.artPath,
finalItem.goodName, true );
if( which == DialogInterface.BUTTON_POSITIVE )
{
launchGameActivity( finalItem.romFile.getAbsolutePath(),
finalItem.zipFile == null ? null : finalItem.zipFile.getAbsolutePath(),
finalItem.isExtracted, finalItem.md5, finalItem.crc,
finalItem.headerName, finalItem.countryCode, finalItem.artPath,
finalItem.goodName, true );
}
}
}
} );
} );
}
else
{
launchGameActivity( finalItem.romFile.getAbsolutePath(),
finalItem.zipFile == null ? null : finalItem.zipFile.getAbsolutePath(),
finalItem.isExtracted, finalItem.md5, finalItem.crc,
finalItem.headerName, finalItem.countryCode, finalItem.artPath,
finalItem.goodName, true );
}
break;
case R.id.menuItem_settings:
ActivityHelper.startGamePrefsActivity( GalleryActivity.this, finalItem.romFile.getAbsolutePath(),
@@ -515,26 +532,52 @@ public void onDialogClosed(int which)
}
}
public void onGalleryItemClick( GalleryItem item )
public void onGalleryItemClick(GalleryItem item)
{
mSelectedItem = item;
// Show the game info sidebar
mDrawerList.setVisibility( View.GONE );
mGameSidebar.setVisibility( View.VISIBLE );
mGameSidebar.scrollTo( 0, 0 );
mDrawerList.setVisibility(View.GONE);
mGameSidebar.setVisibility(View.VISIBLE);
mGameSidebar.scrollTo(0, 0);
// Set the cover art in the sidebar
item.loadBitmap();
mGameSidebar.setImage( item.artBitmap );
mGameSidebar.setImage(item.artBitmap);
// Set the game title
mGameSidebar.setTitle( item.goodName );
mGameSidebar.setTitle(item.goodName);
// If there are no saves for this game, disable the resume
// option
String gameDataPath = GamePrefs.getGameDataPath(mSelectedItem.md5, mSelectedItem.headerName,
RomHeader.countryCodeToSymbol(mSelectedItem.countryCode), mGlobalPrefs);
String autoSavePath = gameDataPath + "/" + GamePrefs.AUTO_SAVES_DIR + "/";
File autoSavePathFile = new File(autoSavePath);
File[] allFilesInSavePath = autoSavePathFile.listFiles();
//No saves, go ahead and remove it
boolean visible = allFilesInSavePath != null && allFilesInSavePath.length != 0;
if (visible)
{
// Restore the menu
mGameSidebar.setActionHandler(GalleryActivity.this, R.menu.gallery_game_drawer);
mRestartPromptEnabled = true;
}
else
{
// Disable the action handler
mGameSidebar.getMenu().removeItem(R.id.menuItem_resume);
mGameSidebar.reload();
mRestartPromptEnabled = false;
}
// Open the navigation drawer
mDrawerLayout.openDrawer( GravityCompat.START );
mDrawerLayout.openDrawer(GravityCompat.START);
}
public boolean onGalleryItemLongClick( GalleryItem item )
{
launchGameActivity( item.romFile.getAbsolutePath(),
@@ -27,6 +27,7 @@
import android.support.v7.internal.view.menu.MenuBuilder;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -150,15 +151,22 @@ public OnClickListener getOnClickListener()
return mListener;
}
public View getViewFromMenuId(int menuId)
{
return mAdapter.getViewFromMenuId(menuId);
}
public static class MenuListAdapter extends BaseExpandableListAdapter
{
private MenuListView mListView;
private Menu mListData;
private SparseArray<View> mMenuViews;
public MenuListAdapter( MenuListView listView, Menu listData )
{
mListView = listView;
mListData = listData;
mMenuViews = new SparseArray<View>();
}
@Override
@@ -197,6 +205,7 @@ public View getChildView( int groupPosition, final int childPosition, boolean is
view = inflater.inflate( R.layout.list_item_menu, mListView, false );
MenuItem item = getChild( groupPosition, childPosition );
if( item != null )
{
TextView text1 = (TextView) view.findViewById( R.id.text1 );
@@ -233,6 +242,9 @@ else if( item.isChecked() )
else
indicator.setImageResource( R.drawable.ic_box );
}
mMenuViews.put(item.getItemId(), view);
return view;
}
@@ -296,6 +308,8 @@ else if( isExpanded )
indicator.setImageResource( R.drawable.ic_arrow_d );
}
mMenuViews.put(item.getItemId(), view);
return view;
}
@@ -304,6 +318,11 @@ public boolean hasStableIds()
{
return true;
}
protected View getViewFromMenuId(int menuId)
{
return mMenuViews.get(menuId);
}
}
public static class OnClickListener
@@ -20,42 +20,17 @@
*/
package paulscode.android.mupen64plusae.game;
import paulscode.android.mupen64plusae.jni.CoreInterface;
import paulscode.android.mupen64plusae.persistent.AppData;
import paulscode.android.mupen64plusae.persistent.GlobalPrefs;
import android.app.Activity;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
public class GameActivity extends Activity
{
private GameLifecycleHandler mLifecycleHandler;
private GameMenuHandler mMenuHandler;
@Override
public boolean onCreateOptionsMenu( Menu menu )
{
mMenuHandler.onCreateOptionsMenu( menu );
return super.onCreateOptionsMenu( menu );
}
@Override
public boolean onPrepareOptionsMenu( Menu menu )
{
mMenuHandler.onPrepareOptionsMenu( menu );
return super.onPrepareOptionsMenu( menu );
}
@Override
public boolean onOptionsItemSelected( MenuItem item )
{
mMenuHandler.onOptionsItemSelected( item );
return super.onOptionsItemSelected( item );
}
@Override
public void onWindowFocusChanged( boolean hasFocus )
@@ -68,8 +43,6 @@ public void onWindowFocusChanged( boolean hasFocus )
protected void onCreate( Bundle savedInstanceState )
{
super.setTheme( android.support.v7.appcompat.R.style.Theme_AppCompat_NoActionBar );
mMenuHandler = new GameMenuHandler( this );
CoreInterface.addOnStateCallbackListener( mMenuHandler );
//Allow volume keys to control media volume if they are not mapped
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
@@ -117,9 +90,7 @@ protected void onStop()
@Override
protected void onDestroy()
{
CoreInterface.removeOnStateCallbackListener( mMenuHandler );
{
super.onDestroy();
mLifecycleHandler.onDestroy();
}
@@ -20,7 +20,6 @@
*/
package paulscode.android.mupen64plusae.game;
import paulscode.android.mupen64plusae.jni.CoreInterface;
import paulscode.android.mupen64plusae.persistent.AppData;
import paulscode.android.mupen64plusae.persistent.GlobalPrefs;
import android.annotation.TargetApi;
@@ -29,41 +28,17 @@
import android.media.AudioManager;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
@TargetApi( 9 )
public class GameActivityXperiaPlay extends NativeActivity
{
private GameLifecycleHandler mLifecycleHandler;
private GameMenuHandler mMenuHandler;
public GameActivityXperiaPlay()
{
System.loadLibrary( "xperia-touchpad" );
}
@Override
public boolean onCreateOptionsMenu( Menu menu )
{
mMenuHandler.onCreateOptionsMenu( menu );
return super.onCreateOptionsMenu( menu );
}
@Override
public boolean onPrepareOptionsMenu( Menu menu )
{
mMenuHandler.onPrepareOptionsMenu( menu );
return super.onPrepareOptionsMenu( menu );
}
@Override
public boolean onOptionsItemSelected( MenuItem item )
{
mMenuHandler.onOptionsItemSelected( item );
return super.onOptionsItemSelected( item );
}
@Override
public void onWindowFocusChanged( boolean hasFocus )
{
@@ -75,8 +50,6 @@ public void onWindowFocusChanged( boolean hasFocus )
protected void onCreate( Bundle savedInstanceState )
{
super.setTheme( android.support.v7.appcompat.R.style.Theme_AppCompat_NoActionBar );
mMenuHandler = new GameMenuHandler( this );
CoreInterface.addOnStateCallbackListener( mMenuHandler );
//Allow volume keys to control media volume if they are not mapped
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
@@ -125,9 +98,7 @@ protected void onStop()
@Override
protected void onDestroy()
{
CoreInterface.removeOnStateCallbackListener( mMenuHandler );
{
super.onDestroy();
mLifecycleHandler.onDestroy();
}
Oops, something went wrong.

0 comments on commit 0ef2375

Please sign in to comment.