From 81f68d59f0e9cf6fa183a86db7128580ea7a986a Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Tue, 17 Oct 2023 06:08:30 -0400 Subject: Make Bookmarks indexed by indices --- src/openvic-simulation/history/Bookmark.cpp | 14 ++++---------- src/openvic-simulation/history/Bookmark.hpp | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/openvic-simulation/history/Bookmark.cpp b/src/openvic-simulation/history/Bookmark.cpp index 7ab96b4..1786821 100644 --- a/src/openvic-simulation/history/Bookmark.cpp +++ b/src/openvic-simulation/history/Bookmark.cpp @@ -12,14 +12,14 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; Bookmark::Bookmark( - std::string_view new_identifier, + size_t new_index, std::string_view new_name, std::string_view new_description, Date new_date, uint32_t new_initial_camera_x, uint32_t new_initial_camera_y ) - : HasIdentifier { new_identifier }, + : HasIdentifier { std::to_string(new_index) }, name { new_name }, description { new_description }, date { new_date }, @@ -50,19 +50,13 @@ uint32_t Bookmark::get_initial_camera_y() const { BookmarkManager::BookmarkManager() : bookmarks { "bookmarks" } {} bool BookmarkManager::add_bookmark( - std::string_view identifier, std::string_view name, std::string_view description, Date date, uint32_t initial_camera_x, uint32_t initial_camera_y ) { - if (identifier.empty()) { - Logger::error("Invalid bookmark identifier - empty!"); - return false; - } - - return bookmarks.add_item({ identifier, name, description, date, initial_camera_x, initial_camera_y }); + return bookmarks.add_item({ bookmarks.size(), name, description, date, initial_camera_x, initial_camera_y }); } bool BookmarkManager::load_bookmark_file(ast::NodeCPtr root) { @@ -85,7 +79,7 @@ bool BookmarkManager::load_bookmark_file(ast::NodeCPtr root) { "cameraY", ONE_EXACTLY, expect_uint(assign_variable_callback(initial_camera_y)) )(value); - ret &= add_bookmark(date.to_string(), name, description, date, initial_camera_x, initial_camera_y); + ret &= add_bookmark(name, description, date, initial_camera_x, initial_camera_y); return ret; } )(root); diff --git a/src/openvic-simulation/history/Bookmark.hpp b/src/openvic-simulation/history/Bookmark.hpp index ec230ca..63e1b3b 100644 --- a/src/openvic-simulation/history/Bookmark.hpp +++ b/src/openvic-simulation/history/Bookmark.hpp @@ -20,7 +20,7 @@ namespace OpenVic { const uint32_t initial_camera_y; Bookmark( - std::string_view new_identifier, + size_t new_index, std::string_view new_name, std::string_view new_description, Date new_date, @@ -45,7 +45,7 @@ namespace OpenVic { public: BookmarkManager(); - bool add_bookmark(std::string_view identifier, std::string_view name, std::string_view description, Date date, uint32_t initial_camera_x, uint32_t initial_camera_y); + bool add_bookmark(std::string_view name, std::string_view description, Date date, uint32_t initial_camera_x, uint32_t initial_camera_y); IDENTIFIER_REGISTRY_ACCESSORS(bookmark); bool load_bookmark_file(ast::NodeCPtr root); -- cgit v1.2.3-56-ga3b1