aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/history/Bookmark.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-07-24 01:05:45 +0200
committer hop311 <hop3114@gmail.com>2024-07-24 01:05:45 +0200
commita9a88a481dbae11eddd6c2268014923a955e38c3 (patch)
tree997ac4ffbbc6e19f2ae606607223fba7ee64e688 /src/openvic-simulation/history/Bookmark.cpp
parentd1f3a96b72dd06b5f97dd4643e5f016a02b42ea6 (diff)
Load bookmark position as fvec2_t with height flippedbookmark-position
Diffstat (limited to 'src/openvic-simulation/history/Bookmark.cpp')
-rw-r--r--src/openvic-simulation/history/Bookmark.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/openvic-simulation/history/Bookmark.cpp b/src/openvic-simulation/history/Bookmark.cpp
index d42bd69..d214260 100644
--- a/src/openvic-simulation/history/Bookmark.cpp
+++ b/src/openvic-simulation/history/Bookmark.cpp
@@ -15,26 +15,24 @@ Bookmark::Bookmark(
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
+ fvec2_t new_initial_camera_position
) : HasIdentifier { std::to_string(new_index) },
HasIndex { new_index },
name { new_name },
description { new_description },
date { new_date },
- initial_camera_x { new_initial_camera_x },
- initial_camera_y { new_initial_camera_y } {}
+ initial_camera_position { new_initial_camera_position } {}
bool BookmarkManager::add_bookmark(
- std::string_view name, std::string_view description, Date date, uint32_t initial_camera_x, uint32_t initial_camera_y
+ std::string_view name, std::string_view description, Date date, fvec2_t initial_camera_position
) {
- return bookmarks.add_item({ bookmarks.size(), name, description, date, initial_camera_x, initial_camera_y });
+ return bookmarks.add_item({ bookmarks.size(), name, description, date, initial_camera_position });
}
-bool BookmarkManager::load_bookmark_file(ast::NodeCPtr root) {
+bool BookmarkManager::load_bookmark_file(fixed_point_t map_height, ast::NodeCPtr root) {
const bool ret = expect_dictionary_reserve_length(
bookmarks,
- [this](std::string_view key, ast::NodeCPtr value) -> bool {
+ [this, map_height](std::string_view key, ast::NodeCPtr value) -> bool {
if (key != "bookmark") {
Logger::error("Invalid bookmark declaration ", key);
return false;
@@ -42,17 +40,18 @@ bool BookmarkManager::load_bookmark_file(ast::NodeCPtr root) {
std::string_view name, description;
Date date;
- uint32_t initial_camera_x, initial_camera_y;
+ fvec2_t initial_camera_position;
bool ret = expect_dictionary_keys(
"name", ONE_EXACTLY, expect_string(assign_variable_callback(name)),
"desc", ONE_EXACTLY, expect_string(assign_variable_callback(description)),
"date", ONE_EXACTLY, expect_date(assign_variable_callback(date)),
- "cameraX", ONE_EXACTLY, expect_uint(assign_variable_callback(initial_camera_x)),
- "cameraY", ONE_EXACTLY, expect_uint(assign_variable_callback(initial_camera_y))
+ "cameraX", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(initial_camera_position.x)),
+ "cameraY", ONE_EXACTLY,
+ expect_fixed_point(flip_height_callback(assign_variable_callback(initial_camera_position.y), map_height))
)(value);
- ret &= add_bookmark(name, description, date, initial_camera_x, initial_camera_y);
+ ret &= add_bookmark(name, description, date, initial_camera_position);
return ret;
}
)(root);