From 4741e7682af209b7cf92900167566a2ce14d4036 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 2 Jan 2012 13:59:28 +0000 Subject: [PATCH] Save active menu --- includes/defines.h | 3 +++ src/save.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/includes/defines.h b/includes/defines.h index 9c27499eb..bd91ea7ff 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -88,6 +88,8 @@ extern unsigned char ZSIZE; #define STAMP_MAX 240 +#define SAVE_OPS + #define NGOL 25 #define NGOLALT 24 //NGOL should be 24, but use this var until I find out why @@ -159,6 +161,7 @@ extern int sound_enable; extern int kiosk_enable; extern int aheat_enable; extern int decorations_enable; +extern int active_menu; extern int hud_enable; extern int pretty_powder; extern int drawgrav_enable; diff --git a/src/save.c b/src/save.c index f872491f6..faf53ecba 100644 --- a/src/save.c +++ b/src/save.c @@ -530,6 +530,10 @@ void *build_save_OPS(int *size, int orig_x0, int orig_y0, int orig_w, int orig_h bson_append_bool(&b, "paused", sys_pause); bson_append_int(&b, "gravityMode", gravityMode); bson_append_int(&b, "airMode", airMode); + + //bson_append_int(&b, "leftSelectedElement", sl); + //bson_append_int(&b, "rightSelectedElement", sr); + bson_append_int(&b, "activeMenu", active_menu); if(partsData) bson_append_binary(&b, "parts", BSON_BIN_USER, partsData, partsDataLen); if(partsPosData) @@ -862,6 +866,35 @@ int parse_save_OPS(void *save, int size, int replace, int x0, int y0, unsigned c fprintf(stderr, "Wrong type for %s\n", bson_iterator_key(&iter)); } } + /*else if((strcmp(bson_iterator_key(&iter), "leftSelectedElement")==0 || strcmp(bson_iterator_key(&iter), "rightSelectedElement")) && replace) + { + if(bson_iterator_type(&iter)==BSON_INT && bson_iterator_int(&iter) > 0 && bson_iterator_int(&iter) < PT_NUM) + { + if(bson_iterator_key(&iter)[0] == 'l') + { + sl = bson_iterator_int(&iter); + } + else + { + sr = bson_iterator_int(&iter); + } + } + else + { + fprintf(stderr, "Wrong type for %s\n", bson_iterator_key(&iter)); + } + }*/ + else if(strcmp(bson_iterator_key(&iter), "activeMenu")==0 && replace) + { + if(bson_iterator_type(&iter)==BSON_INT && bson_iterator_int(&iter) > 0 && bson_iterator_int(&iter) < SC_TOTAL && msections[bson_iterator_int(&iter)].doshow) + { + active_menu = bson_iterator_int(&iter); + } + else + { + fprintf(stderr, "Wrong value for %s\n", bson_iterator_key(&iter)); + } + } } //Read wall and fan data