Switched bookmark manager to net object system

This commit is contained in:
Yousef Khadadeh 2025-12-09 19:29:58 +03:00
parent 65436429b8
commit c6f2ff18ef
12 changed files with 71 additions and 176 deletions

View file

@ -1,14 +1,16 @@
#pragma once
#include <Helpers/Serializers.hpp>
#include <cereal/types/string.hpp>
#include <Helpers/NetworkingObjects/NetObjOrderedList.hpp>
#include "SharedTypes.hpp"
#include "CoordSpaceHelper.hpp"
struct Bookmark {
std::string name;
CoordSpaceHelper coords;
Vector<int32_t, 2> windowSize;
template <class Archive> void serialize(Archive& a) {
a(coords, windowSize);
a(name, coords, windowSize);
}
void scale_up(const WorldScalar& scaleUpAmount);
};
@ -18,27 +20,27 @@ class World;
class BookmarkManager {
public:
BookmarkManager(World& w);
void init_client_callbacks();
void add_bookmark(const std::string& name);
void remove_bookmark(const std::string& name);
void jump_to_bookmark(const std::string& name);
void remove_bookmark(uint32_t bookmarkIndex);
void jump_to_bookmark(uint32_t bookmarkIndex);
void scale_up(const WorldScalar& scaleUpAmount);
const std::unordered_map<std::string, Bookmark>& bookmark_list();
template <typename Archive> void save(Archive& a) const {
a(bookmarks);
a(bookmarks->size());
for(uint32_t i = 0; i < bookmarks->size(); i++)
a(*bookmarks->at(i));
}
template <typename Archive> void load(Archive& a) {
a(bookmarks);
changed = true;
uint32_t newSize = bookmarks->size();
for(uint32_t i = 0; i < newSize; i++) {
Bookmark b;
a(b);
bookmarks->emplace_back_direct(bookmarks, b);
}
}
const std::vector<std::string>& sorted_names();
NetworkingObjects::NetObjPtr<NetworkingObjects::NetObjOrderedList<Bookmark>> bookmarks;
private:
bool changed = true;
std::vector<std::string> sortedNames;
std::unordered_map<std::string, Bookmark> bookmarks;
World& world;
};