summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorSND\ckain_cp <SND\ckain_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2014-03-17 20:56:45 +0000
committerSND\ckain_cp <SND\ckain_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2014-03-17 20:56:45 +0000
commit19a65e820e4f1029c9a2273c32e605c77e71550a (patch)
tree7cd4bff1046eaef5fc369dc72f49664fec557963 /gui
parent5660e3f37355999b2877ffbdde86794f2ea2e33d (diff)
downloadpcsxr-19a65e820e4f1029c9a2273c32e605c77e71550a.tar.gz
gtk: UpdateMenuSlots() returns recent save slot -> load most recent save state with just -load switch when no number parameter.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@89458 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'gui')
-rwxr-xr-xgui/GtkGui.c24
-rwxr-xr-xgui/Linux.h2
-rwxr-xr-xgui/LnxMain.c12
3 files changed, 30 insertions, 8 deletions
diff --git a/gui/GtkGui.c b/gui/GtkGui.c
index 2a3c7069..e2c7d3b3 100755
--- a/gui/GtkGui.c
+++ b/gui/GtkGui.c
@@ -266,15 +266,33 @@ gchar* get_cdrom_label_id(const gchar* suffix) {
return g_strdup(buf);
}
-void UpdateMenuSlots() {
+static time_t get_state_time(const char* fn) {
+ struct stat st;
+ int ierr = stat (fn, &st);
+ if (!ierr)
+ return st.st_ctime;
+ else
+ return -1;
+}
+
+int UpdateMenuSlots() {
gchar *str;
- int i;
+ int i, imax=-1;
+ time_t tsmax = -1;
for (i = 0; i < MAX_SLOTS; i++) {
str = get_state_filename (i);
- Slots[i] = CheckState(str);
+ if ((Slots[i] = CheckState(str)) >= 0) {
+ time_t ts = get_state_time(str);
+ if (ts > tsmax) {
+ tsmax=ts;
+ imax=i;
+ }
+ //printf("File %s time %i\n", str, ts);
+ }
g_free (str);
}
+ return imax;
}
void autoloadCheats() {
diff --git a/gui/Linux.h b/gui/Linux.h
index 791f103b..4e1543c0 100755
--- a/gui/Linux.h
+++ b/gui/Linux.h
@@ -51,7 +51,7 @@ void autoloadCheats(); // try load cheat file from default path and filename
void PADhandleKey(int key);
-void UpdateMenuSlots();
+int UpdateMenuSlots();
gchar* get_state_filename(int i);
gchar* get_cdrom_label_id(const gchar* suffix); // get cdrom label and id and append suffix to string
diff --git a/gui/LnxMain.c b/gui/LnxMain.c
index b9c37f69..716a3964 100755
--- a/gui/LnxMain.c
+++ b/gui/LnxMain.c
@@ -274,7 +274,7 @@ int main(int argc, char *argv[]) {
char file[MAXPATHLEN] = "";
char path[MAXPATHLEN];
int runcd = RUN;
- int loadst = 0;
+ int loadst = -1;
int i;
#ifdef ENABLE_NLS
@@ -296,7 +296,7 @@ int main(int argc, char *argv[]) {
else if (!strcmp(argv[i], "-nogui")) UseGui = FALSE;
else if (!strcmp(argv[i], "-psxout")) Config.PsxOut = TRUE;
else if (!strcmp(argv[i], "-slowboot")) Config.SlowBoot = TRUE;
- else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]);
+ else if (!strcmp(argv[i], "-load")) loadst = ((argc > i+1) ? atol(argv[++i]) : 0);
else if (!strcmp(argv[i], "-cfg")) {
if (i+1 >= argc) break;
strncpy(cfgfile_basename, argv[++i], MAXPATHLEN-100); /* TODO buffer overruns */
@@ -444,9 +444,13 @@ int main(int argc, char *argv[]) {
}
}
}
-
+
+ if (loadst==0) {
+ loadst = UpdateMenuSlots() + 1;
+ }
// If a state has been specified, then load that
- if (loadst) {
+ if (loadst > 0) {
+ SysPrintf("Loading slot %i (HLE=%i)\n", loadst, Config.HLE);
StatesC = loadst - 1;
gchar *state_filename = get_state_filename(StatesC);
LoadState(state_filename);