Hide implementation details of net ordered list

This commit is contained in:
Yousef Khadadeh 2025-12-10 10:24:57 +03:00
parent c6f2ff18ef
commit 67507a9a39
2 changed files with 80 additions and 47 deletions

View file

@ -13,16 +13,36 @@ void Bookmark::scale_up(const WorldScalar& scaleUpAmount) {
BookmarkManager::BookmarkManager(World& w):
world(w)
{
// NOTE: Should find a way for bookmarks added from the network to take into account the client's canvasScale
// Have the canvasScale variable come with the ClientData object, and the grid scale commands can be part of
// the client data class
if(w.netObjMan.is_server())
bookmarks = w.netObjMan.make_obj<NetworkingObjects::NetObjOrderedList<Bookmark>>();
}
void BookmarkManager::add_bookmark(const std::string& name) {
NetworkingObjects::NetObjPtr<Bookmark> a = bookmarks->emplace_back_direct(bookmarks, Bookmark{name, world.drawData.cam.c, world.main.window.size.cast<int32_t>()});
NetworkingObjects::NetObjPtr<Bookmark> bookmarkPtr = bookmarks->emplace_back_direct(bookmarks, Bookmark{name, world.drawData.cam.c, world.main.window.size.cast<int32_t>()});
uint32_t pos = bookmarks->size() - 1;
world.undo.push({[&bookmarks = bookmarks, bookmarkPtr](){
bookmarks->erase(bookmarks, bookmarkPtr);
return true;
},
[&bookmarks = bookmarks, bookmarkPtr, pos]() {
bookmarks->insert_and_send_create(bookmarks, pos, bookmarkPtr);
return true;
}});
}
void BookmarkManager::remove_bookmark(uint32_t bookmarkIndex) {
bookmarks->erase(bookmarks, bookmarkIndex);
NetworkingObjects::NetObjPtr<Bookmark> bookmarkPtr = bookmarks->erase(bookmarks, bookmarkIndex);
world.undo.push({[&bookmarks = bookmarks, bookmarkPtr, bookmarkIndex]() {
bookmarks->insert_and_send_create(bookmarks, bookmarkIndex, bookmarkPtr);
return true;
},
[&bookmarks = bookmarks, bookmarkPtr](){
bookmarks->erase(bookmarks, bookmarkPtr);
return true;
}});
}
void BookmarkManager::jump_to_bookmark(uint32_t bookmarkIndex) {