diff --git a/init.c b/init.c index 02ae91bc7..4e3923bfb 100644 --- a/init.c +++ b/init.c @@ -35,6 +35,7 @@ #include "gl_init.h" #include "hud.h" #include "items.h" +#include "item_lists.h" #include "keys.h" #include "knowledge.h" #include "langselwin.h" @@ -374,6 +375,8 @@ void read_bin_cfg() rz=cfg_mem.camera_z; new_zoom_level=zoom_level=cfg_mem.zoom_level; + item_lists_set_active(cfg_mem.active_item_list); + view_health_bar=cfg_mem.banner_settings & 1; view_ether_bar=(cfg_mem.banner_settings >> 1) & 1; view_names=(cfg_mem.banner_settings >> 2) & 1; @@ -619,6 +622,8 @@ void save_bin_cfg() cfg_mem.banner_settings |= view_hp << 3; cfg_mem.banner_settings |= view_ether << 4; + cfg_mem.active_item_list = item_lists_get_active(); + cfg_mem.quantity_selected=(quantities.selected0) diff --git a/init.h b/init.h index b1810e748..3afa121cf 100644 --- a/init.h +++ b/init.h @@ -121,8 +121,13 @@ typedef struct int banner_settings; /*! @} */ + /*! + * \name Item lists - active list index. + */ + /*! @{ */ + unsigned int active_item_list; + int unused_01; - int unused_02; /*! * \name quest log window position diff --git a/item_lists.cpp b/item_lists.cpp index f0acbd4a3..3e482e2c6 100644 --- a/item_lists.cpp +++ b/item_lists.cpp @@ -107,7 +107,7 @@ namespace ItemLists class List_Container { public: - List_Container(void) : active_list(0), last_mod_time(0), loaded(false) {} + List_Container(void) : active_list(0), initial_active_list(0), last_mod_time(0), loaded(false) {} void load(void); void save(void); bool add(const char *name); @@ -122,6 +122,7 @@ namespace ItemLists const std::vector & get_lists(void) const { return saved_item_lists; } bool set_active(size_t new_active_list) { if (new_active_list >= size()) return false; active_list = new_active_list; return true; } + void set_initial_active(size_t list_index) { initial_active_list = list_index; } void set_quantity(size_t item, int quantity) { assert(valid_active_list()); last_mod_time = SDL_GetTicks(); return saved_item_lists[active_list].set_quantity(item, quantity); } void del_item(size_t i) @@ -135,8 +136,9 @@ namespace ItemLists void check_and_timed_save(bool force); private: std::vector saved_item_lists; - static size_t FILE_REVISION; + static int FILE_REVISION; size_t active_list; + size_t initial_active_list; Uint32 last_mod_time; bool loaded; static const char * filename; @@ -630,7 +632,7 @@ namespace ItemLists } - size_t List_Container::FILE_REVISION = 2; + int List_Container::FILE_REVISION = 2; const char * List_Container::filename = "item_lists.txt"; // Save the item lists to a file in players config directory @@ -647,7 +649,7 @@ namespace ItemLists LOG_TO_CONSOLE(c_red2, item_list_save_error_str); return; } - out << FILE_REVISION << " " << get_active() << std::endl << std::endl; + out << FILE_REVISION << std::endl << std::endl; for (size_t i=0; i []", other parameters could be added.... - size_t revision = 0; - size_t initial_active = 0; - std::string first_line; - if (getline_nocr(in, first_line) && !first_line.empty()) - { - std::vector values; - std::istringstream ss(first_line); - size_t value = 0; - while (ss >> value) - values.push_back(value); - if (values.size() > 0) - revision = values[0]; - if (values.size() > 1) - initial_active = values[1]; - } - + int revision; + in >> revision; if (revision != FILE_REVISION) { LOG_ERROR("%s: %s [%s]\n", __FILE__, item_list_version_error_str, fullpath.c_str() ); @@ -708,7 +694,7 @@ namespace ItemLists } in.close(); sort_list(); - set_active(initial_active); + set_active(initial_active_list); } @@ -1530,9 +1516,20 @@ extern "C" ItemLists::Vars::lists()->save(); ItemLists::Vars::cat_maps()->save(); } - + + unsigned int item_lists_get_active(void) + { + return static_cast(ItemLists::Vars::lists()->get_active()); + } + + void item_lists_set_active(unsigned int active_list) + { + ItemLists::Vars::lists()->set_initial_active(static_cast(active_list)); + } + void item_lists_reset_pickup_fail_time(void) { ItemLists::Vars::win()->reset_pickup_fail_time(); } + } diff --git a/item_lists.h b/item_lists.h index 9fe2be0d9..d487a0385 100644 --- a/item_lists.h +++ b/item_lists.h @@ -11,6 +11,8 @@ extern "C" void toggle_items_list_window(window_info *win); void update_category_maps(int image_id, Uint16 item_id, int cat_id); void save_item_lists(void); +unsigned int item_lists_get_active(void); +void item_lists_set_active(unsigned int active_list); void item_lists_reset_pickup_fail_time(void); #ifdef __cplusplus