[Android] Add recent roms
This commit is contained in:
parent
5b546a0fcb
commit
c189bfe8e3
|
@ -11,7 +11,7 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/info"
|
android:id="@+id/info"
|
||||||
android:layout_width="@dimen/galleryImageWidth"
|
android:layout_width="@dimen/galleryImageWidth"
|
||||||
android:layout_height="@dimen/galleryImageHeight"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -62,6 +62,10 @@
|
||||||
<string name="about_copyright" translatable="false">Copyleft © 1998–2016 by Project64.\n</string>
|
<string name="about_copyright" translatable="false">Copyleft © 1998–2016 by Project64.\n</string>
|
||||||
<string name="authors" translatable="false">Zilmar, Jabo, Smiff, Gent, Jahra!n, Witten, RadeonUser, Trotterwatch, pixi, Azimer, Gonetz, cxd4, AmbientMalice, LegendOfDragoon, Nekokabu, Lithium64, death-droid, LuigiBlood, dsx.</string>
|
<string name="authors" translatable="false">Zilmar, Jabo, Smiff, Gent, Jahra!n, Witten, RadeonUser, Trotterwatch, pixi, Azimer, Gonetz, cxd4, AmbientMalice, LegendOfDragoon, Nekokabu, Lithium64, death-droid, LuigiBlood, dsx.</string>
|
||||||
|
|
||||||
|
<!-- Gallery sections -->
|
||||||
|
<string name="galleryRecentlyPlayed">Recently played</string>
|
||||||
|
<string name="galleryLibrary">Games</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="preferences">Settings</string>
|
<string name="preferences">Settings</string>
|
||||||
<string name="settings_title">Settings</string>
|
<string name="settings_title">Settings</string>
|
||||||
|
|
|
@ -28,6 +28,7 @@ import emu.project64.inAppPurchase.Purchase;
|
||||||
import emu.project64.jni.NativeExports;
|
import emu.project64.jni.NativeExports;
|
||||||
import emu.project64.jni.SettingsID;
|
import emu.project64.jni.SettingsID;
|
||||||
import emu.project64.jni.SystemEvent;
|
import emu.project64.jni.SystemEvent;
|
||||||
|
import emu.project64.jni.UISettingID;
|
||||||
import emu.project64.settings.GameSettingsActivity;
|
import emu.project64.settings.GameSettingsActivity;
|
||||||
import emu.project64.settings.SettingsActivity;
|
import emu.project64.settings.SettingsActivity;
|
||||||
import emu.project64.util.Utility;
|
import emu.project64.util.Utility;
|
||||||
|
@ -83,6 +84,7 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
|
||||||
|
|
||||||
// Misc.
|
// Misc.
|
||||||
private static List<GalleryItem> mGalleryItems = new ArrayList<GalleryItem>();
|
private static List<GalleryItem> mGalleryItems = new ArrayList<GalleryItem>();
|
||||||
|
private static List<GalleryItem> mRecentItems = new ArrayList<GalleryItem>();
|
||||||
private static GalleryActivity mActiveGalleryActivity = null;
|
private static GalleryActivity mActiveGalleryActivity = null;
|
||||||
|
|
||||||
// The IAB helper object
|
// The IAB helper object
|
||||||
|
@ -256,7 +258,7 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
|
||||||
Log.d("GalleryActivity", "Purchased save support " + (SaveSupportPurchase!= null ? "Yes" : "No"));
|
Log.d("GalleryActivity", "Purchased save support " + (SaveSupportPurchase!= null ? "Yes" : "No"));
|
||||||
if (SaveSupportPurchase != null)
|
if (SaveSupportPurchase != null)
|
||||||
{
|
{
|
||||||
mHasSaveSupport = true;
|
mHasSaveSupport = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
setWaitScreen(false);
|
setWaitScreen(false);
|
||||||
|
@ -519,8 +521,8 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
|
||||||
//Purchase save support
|
//Purchase save support
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String payload = NativeExports.appVersion();
|
String payload = NativeExports.appVersion();
|
||||||
mIabHelper.launchPurchaseFlow(finalActivity, SKU_SAVESUPPORT, RC_REQUEST, mPurchaseFinishedListener, payload);
|
mIabHelper.launchPurchaseFlow(finalActivity, SKU_SAVESUPPORT, RC_REQUEST, mPurchaseFinishedListener, payload);
|
||||||
}
|
}
|
||||||
catch (IabAsyncInProgressException e)
|
catch (IabAsyncInProgressException e)
|
||||||
{
|
{
|
||||||
|
@ -634,21 +636,36 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
|
||||||
// billing...
|
// billing...
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void refreshGrid( )
|
void refreshGrid( )
|
||||||
{
|
{
|
||||||
mGridView.setAdapter( new GalleryItem.Adapter( this, mGalleryItems ) );
|
List<GalleryItem> items;
|
||||||
|
items = new ArrayList<GalleryItem>();
|
||||||
|
|
||||||
|
if (mRecentItems.size() > 0)
|
||||||
|
{
|
||||||
|
items.add( new GalleryItem( this, getString( R.string.galleryRecentlyPlayed ) ) );
|
||||||
|
items.addAll( mRecentItems );
|
||||||
|
|
||||||
|
items.add( new GalleryItem( this, getString( R.string.galleryLibrary ) ) );
|
||||||
|
}
|
||||||
|
items.addAll( mGalleryItems );
|
||||||
|
|
||||||
|
mGridView.setAdapter( new GalleryItem.Adapter( this, items ) );
|
||||||
|
|
||||||
// Allow the headings to take up the entire width of the layout
|
// Allow the headings to take up the entire width of the layout
|
||||||
//final List<GalleryItem> finalItems = mGalleryItems;
|
final List<GalleryItem> finalItems = items;
|
||||||
GridLayoutManager layoutManager = new GridLayoutManager( this, galleryColumns );
|
GridLayoutManager layoutManager = new GridLayoutManager( this, galleryColumns );
|
||||||
layoutManager.setSpanSizeLookup( new GridLayoutManager.SpanSizeLookup()
|
layoutManager.setSpanSizeLookup( new GridLayoutManager.SpanSizeLookup()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public int getSpanSize( int position )
|
public int getSpanSize( int position )
|
||||||
{
|
{
|
||||||
|
// Headings will take up every span (column) in the grid
|
||||||
|
if( finalItems.get( position ).isHeading )
|
||||||
|
return galleryColumns;
|
||||||
|
|
||||||
// Games will fit in a single column
|
// Games will fit in a single column
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -752,6 +769,27 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
|
||||||
|
|
||||||
public static void RomListLoadDone()
|
public static void RomListLoadDone()
|
||||||
{
|
{
|
||||||
|
mRecentItems = new ArrayList<GalleryItem>();
|
||||||
|
|
||||||
|
Log.d("GalleryActivity","File_RecentGameFileCount = " + NativeExports.UISettingsLoadDword(UISettingID.File_RecentGameFileCount.getValue()));
|
||||||
|
|
||||||
|
for (int i = 0, n = NativeExports.UISettingsLoadDword(UISettingID.File_RecentGameFileCount.getValue()); i < n; i++)
|
||||||
|
{
|
||||||
|
String RecentFile = NativeExports.UISettingsLoadStringIndex(UISettingID.File_RecentGameFileIndex.getValue(), i);
|
||||||
|
if (RecentFile.length() == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (int z = 0; z < mGalleryItems.size(); z++)
|
||||||
|
{
|
||||||
|
if (RecentFile.equals(mGalleryItems.get(z).romFile.getAbsolutePath()))
|
||||||
|
{
|
||||||
|
mRecentItems.add(mGalleryItems.get(z));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mActiveGalleryActivity != null && mActiveGalleryActivity.mProgress != null)
|
if (mActiveGalleryActivity != null && mActiveGalleryActivity.mProgress != null)
|
||||||
{
|
{
|
||||||
Handler h = new Handler(Looper.getMainLooper());
|
Handler h = new Handler(Looper.getMainLooper());
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class GalleryItem
|
||||||
public final File romFile;
|
public final File romFile;
|
||||||
public final int textColor;
|
public final int textColor;
|
||||||
public final Context context;
|
public final Context context;
|
||||||
|
public final boolean isHeading;
|
||||||
|
|
||||||
public GalleryItem( Context context, String goodName, String fileName, String romPath, int textColor )
|
public GalleryItem( Context context, String goodName, String fileName, String romPath, int textColor )
|
||||||
{
|
{
|
||||||
|
@ -42,9 +43,20 @@ public class GalleryItem
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.textColor = textColor;
|
this.textColor = textColor;
|
||||||
|
this.isHeading = false;
|
||||||
this.romFile = TextUtils.isEmpty( romPath ) ? null : new File( romPath );
|
this.romFile = TextUtils.isEmpty( romPath ) ? null : new File( romPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GalleryItem( Context context, String headingName )
|
||||||
|
{
|
||||||
|
this.goodName = headingName;
|
||||||
|
this.fileName = null;
|
||||||
|
this.context = context;
|
||||||
|
this.isHeading = true;
|
||||||
|
this.romFile = null;
|
||||||
|
this.textColor = 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@ -139,7 +151,7 @@ public class GalleryItem
|
||||||
@Override
|
@Override
|
||||||
public int getItemViewType( int position )
|
public int getItemViewType( int position )
|
||||||
{
|
{
|
||||||
return 0;
|
return mObjects.get( position ).isHeading ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBindViewHolder( ViewHolder holder, int position )
|
public void onBindViewHolder( ViewHolder holder, int position )
|
||||||
|
@ -158,14 +170,24 @@ public class GalleryItem
|
||||||
LinearLayout linearLayout = (LinearLayout) view.findViewById( R.id.galleryItem );
|
LinearLayout linearLayout = (LinearLayout) view.findViewById( R.id.galleryItem );
|
||||||
GalleryActivity activity = (GalleryActivity) item.context;
|
GalleryActivity activity = (GalleryActivity) item.context;
|
||||||
|
|
||||||
view.setClickable( true );
|
if( item.isHeading )
|
||||||
view.setLongClickable( true );
|
{
|
||||||
linearLayout.setPadding( activity.galleryHalfSpacing,
|
view.setClickable( false );
|
||||||
activity.galleryHalfSpacing, activity.galleryHalfSpacing,
|
view.setLongClickable( false );
|
||||||
activity.galleryHalfSpacing );
|
linearLayout.setPadding( 0, 0, 0, 0 );
|
||||||
tv1.setPadding( 0, 0, 0, 0 );
|
tv1.setPadding( 5, 10, 0, 0 );
|
||||||
tv1.setTextSize( TypedValue.COMPLEX_UNIT_DIP, 13.0f );
|
tv1.setTextSize( TypedValue.COMPLEX_UNIT_DIP, 18.0f );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view.setClickable( true );
|
||||||
|
view.setLongClickable( true );
|
||||||
|
linearLayout.setPadding( activity.galleryHalfSpacing,
|
||||||
|
activity.galleryHalfSpacing, activity.galleryHalfSpacing,
|
||||||
|
activity.galleryHalfSpacing );
|
||||||
|
tv1.setPadding( 0, 0, 0, 0 );
|
||||||
|
tv1.setTextSize( TypedValue.COMPLEX_UNIT_DIP, 13.0f );
|
||||||
|
}
|
||||||
LinearLayout layout = (LinearLayout) view.findViewById( R.id.info );
|
LinearLayout layout = (LinearLayout) view.findViewById( R.id.info );
|
||||||
layout.getLayoutParams().width = activity.galleryWidth;
|
layout.getLayoutParams().width = activity.galleryWidth;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,4 +47,5 @@ public class NativeExports
|
||||||
|
|
||||||
public static native boolean UISettingsLoadBool(int Type);
|
public static native boolean UISettingsLoadBool(int Type);
|
||||||
public static native int UISettingsLoadDword(int Type);
|
public static native int UISettingsLoadDword(int Type);
|
||||||
|
public static native String UISettingsLoadStringIndex(int Type, int Index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,10 @@ public enum UISettingID
|
||||||
{
|
{
|
||||||
Asserts_Version,
|
Asserts_Version,
|
||||||
Screen_Orientation,
|
Screen_Orientation,
|
||||||
|
|
||||||
|
//Recent Game
|
||||||
|
File_RecentGameFileCount,
|
||||||
|
File_RecentGameFileIndex,
|
||||||
;
|
;
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
|
|
|
@ -10,12 +10,15 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <Project64-core/Settings/SettingsClass.h>
|
#include <Project64-core/Settings/SettingsClass.h>
|
||||||
#include <Project64-core/Settings/SettingType/SettingsType-Application.h>
|
#include <Project64-core/Settings/SettingType/SettingsType-Application.h>
|
||||||
|
#include <Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.h>
|
||||||
#include "UISettings.h"
|
#include "UISettings.h"
|
||||||
|
|
||||||
void RegisterUISettings(void)
|
void RegisterUISettings(void)
|
||||||
{
|
{
|
||||||
g_Settings->AddHandler((SettingID)(FirstUISettings + Asserts_Version), new CSettingTypeApplication("", "Asserts Version", (uint32_t)0));
|
g_Settings->AddHandler((SettingID)(FirstUISettings + Asserts_Version), new CSettingTypeApplication("", "Asserts Version", (uint32_t)0));
|
||||||
g_Settings->AddHandler((SettingID)(FirstUISettings + Screen_Orientation), new CSettingTypeApplication("", "Screen Orientation", (uint32_t)0));
|
g_Settings->AddHandler((SettingID)(FirstUISettings + Screen_Orientation), new CSettingTypeApplication("", "Screen Orientation", (uint32_t)0));
|
||||||
|
g_Settings->AddHandler((SettingID)(FirstUISettings + File_RecentGameFileCount), new CSettingTypeApplication("", "Remembered Rom Files", (uint32_t)10));
|
||||||
|
g_Settings->AddHandler((SettingID)(FirstUISettings + File_RecentGameFileIndex), new CSettingTypeApplicationIndex("Recent File", "Recent Rom", Default_None));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UISettingsSaveBool(UISettingID Type, bool Value)
|
void UISettingsSaveBool(UISettingID Type, bool Value)
|
||||||
|
@ -39,4 +42,3 @@ uint32_t UISettingsLoadDword(UISettingID Type)
|
||||||
{
|
{
|
||||||
return g_Settings->LoadDword((SettingID)(FirstUISettings + Type));
|
return g_Settings->LoadDword((SettingID)(FirstUISettings + Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,10 @@ enum UISettingID
|
||||||
{
|
{
|
||||||
Asserts_Version,
|
Asserts_Version,
|
||||||
Screen_Orientation,
|
Screen_Orientation,
|
||||||
|
|
||||||
|
//Recent Game
|
||||||
|
File_RecentGameFileCount,
|
||||||
|
File_RecentGameFileIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
void RegisterUISettings(void);
|
void RegisterUISettings(void);
|
||||||
|
|
|
@ -90,6 +90,68 @@ EXPORT jint CALL JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||||
return JNI_VERSION_1_4;
|
return JNI_VERSION_1_4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string UISettingsLoadStringIndex(UISettingID Type, int32_t index)
|
||||||
|
{
|
||||||
|
return g_Settings->LoadStringIndex((SettingID)(FirstUISettings + Type), index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UISettingsSaveStringIndex(UISettingID Type, int32_t index, const std::string & Value)
|
||||||
|
{
|
||||||
|
g_Settings->SaveStringIndex((SettingID)(FirstUISettings + Type), index, Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddRecentRom(const char * ImagePath)
|
||||||
|
{
|
||||||
|
if (ImagePath == NULL) { return; }
|
||||||
|
WriteTrace(TraceUserInterface, TraceDebug, "Start (ImagePath: %s)",ImagePath);
|
||||||
|
|
||||||
|
//Get Information about the stored rom list
|
||||||
|
size_t MaxRememberedFiles = UISettingsLoadDword(File_RecentGameFileCount);
|
||||||
|
strlist RecentGames;
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < MaxRememberedFiles; i++)
|
||||||
|
{
|
||||||
|
stdstr RecentGame = UISettingsLoadStringIndex(File_RecentGameFileIndex, i);
|
||||||
|
if (RecentGame.empty())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
RecentGames.push_back(RecentGame);
|
||||||
|
}
|
||||||
|
|
||||||
|
//See if the dir is already in the list if so then move it to the top of the list
|
||||||
|
strlist::iterator iter;
|
||||||
|
for (iter = RecentGames.begin(); iter != RecentGames.end(); iter++)
|
||||||
|
{
|
||||||
|
if (_stricmp(ImagePath, iter->c_str()) != 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
RecentGames.erase(iter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
RecentGames.push_front(ImagePath);
|
||||||
|
if (RecentGames.size() > MaxRememberedFiles)
|
||||||
|
{
|
||||||
|
RecentGames.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0, iter = RecentGames.begin(); iter != RecentGames.end(); iter++, i++)
|
||||||
|
{
|
||||||
|
UISettingsSaveStringIndex(File_RecentGameFileIndex, i, *iter);
|
||||||
|
}
|
||||||
|
WriteTrace(TraceUserInterface, TraceDebug, "Done");
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameLoaded(void * /*NotUsed*/)
|
||||||
|
{
|
||||||
|
stdstr FileLoc = g_Settings->LoadStringVal(Game_File);
|
||||||
|
if (FileLoc.length() > 0)
|
||||||
|
{
|
||||||
|
AddRecentRom(FileLoc.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GameCpuRunning(void * /*NotUsed*/)
|
void GameCpuRunning(void * /*NotUsed*/)
|
||||||
{
|
{
|
||||||
WriteTrace(TraceUserInterface, TraceDebug, "Start");
|
WriteTrace(TraceUserInterface, TraceDebug, "Start");
|
||||||
|
@ -169,6 +231,7 @@ EXPORT jboolean CALL Java_emu_project64_jni_NativeExports_appInit(JNIEnv* env, j
|
||||||
|
|
||||||
RegisterUISettings();
|
RegisterUISettings();
|
||||||
g_Settings->RegisterChangeCB(GameRunning_CPU_Running, NULL, (CSettings::SettingChangedFunc)GameCpuRunning);
|
g_Settings->RegisterChangeCB(GameRunning_CPU_Running, NULL, (CSettings::SettingChangedFunc)GameCpuRunning);
|
||||||
|
g_Settings->RegisterChangeCB(Game_File, NULL, (CSettings::SettingChangedFunc)GameLoaded);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -348,6 +411,11 @@ EXPORT int CALL Java_emu_project64_jni_NativeExports_UISettingsLoadDword(JNIEnv*
|
||||||
return UISettingsLoadDword((UISettingID)Type);
|
return UISettingsLoadDword((UISettingID)Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXPORT jstring CALL Java_emu_project64_jni_NativeExports_UISettingsLoadStringIndex(JNIEnv* env, jclass cls, jint Type, jint Index)
|
||||||
|
{
|
||||||
|
return env->NewStringUTF(UISettingsLoadStringIndex((UISettingID)Type, Index).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
EXPORT void CALL Java_emu_project64_jni_NativeExports_StopEmulation(JNIEnv* env, jclass cls)
|
EXPORT void CALL Java_emu_project64_jni_NativeExports_StopEmulation(JNIEnv* env, jclass cls)
|
||||||
{
|
{
|
||||||
WriteTrace(TraceUserInterface, TraceDebug, "Start");
|
WriteTrace(TraceUserInterface, TraceDebug, "Start");
|
||||||
|
|
Loading…
Reference in New Issue