summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/nestedvm.c
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2017-04-29 18:21:56 -0400
committerFranklin Wei <git@fwei.tk>2017-04-29 18:24:42 -0400
commit881746789a489fad85aae8317555f73dbe261556 (patch)
treecec2946362c4698c8db3c10f3242ef546c2c22dd /apps/plugins/puzzles/src/nestedvm.c
parent03dd4b92be7dcd5c8ab06da3810887060e06abd5 (diff)
downloadrockbox-881746789a489fad85aae8317555f73dbe261556.zip
rockbox-881746789a489fad85aae8317555f73dbe261556.tar.gz
rockbox-881746789a489fad85aae8317555f73dbe261556.tar.bz2
rockbox-881746789a489fad85aae8317555f73dbe261556.tar.xz
puzzles: refactor and resync with upstream
This brings puzzles up-to-date with upstream revision 2d333750272c3967cfd5cd3677572cddeaad5932, though certain changes made by me, including cursor-only Untangle and some compilation fixes remain. Upstream code has been moved to its separate subdirectory and future syncs can be done by simply copying over the new sources. Change-Id: Ia6506ca5f78c3627165ea6791d38db414ace0804
Diffstat (limited to '')
-rw-r--r--apps/plugins/puzzles/src/nestedvm.c (renamed from apps/plugins/puzzles/nestedvm.c)33
1 files changed, 24 insertions, 9 deletions
diff --git a/apps/plugins/puzzles/nestedvm.c b/apps/plugins/puzzles/src/nestedvm.c
index c61afec..79b7971 100644
--- a/apps/plugins/puzzles/nestedvm.c
+++ b/apps/plugins/puzzles/src/nestedvm.c
@@ -3,7 +3,7 @@
*/
#include <stdio.h>
-#include "rbassert.h"
+#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdarg.h>
@@ -382,6 +382,23 @@ int jcallback_about_event()
return 0;
}
+void preset_menu_populate(struct preset_menu *menu, int menuid)
+{
+ int i;
+
+ for (i = 0; i < menu->n_entries; i++) {
+ struct preset_menu_entry *entry = &menu->entries[i];
+ if (entry->params) {
+ _call_java(5, (int)entry->params, 0, 0);
+ _call_java(1, (int)entry->title, menuid, entry->id);
+ } else {
+ _call_java(5, 0, 0, 0);
+ _call_java(1, (int)entry->title, menuid, entry->id);
+ preset_menu_populate(entry->submenu, entry->id);
+ }
+ }
+}
+
int main(int argc, char **argv)
{
int i, n;
@@ -394,14 +411,12 @@ int main(int argc, char **argv)
midend_game_id(_fe->me, argv[1]); /* ignore failure */
midend_new_game(_fe->me);
- if ((n = midend_num_presets(_fe->me)) > 0) {
- int i;
- for (i = 0; i < n; i++) {
- char *name;
- game_params *params;
- midend_fetch_preset(_fe->me, i, &name, &params);
- _call_java(1, (int)name, (int)params, 0);
- }
+ {
+ struct preset_menu *menu;
+ int nids, topmenu;
+ menu = midend_get_presets(_fe->me, &nids);
+ topmenu = _call_java(1, 0, nids, 0);
+ preset_menu_populate(menu, topmenu);
}
colours = midend_colours(_fe->me, &n);