Add a screen to download gltf models
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "configuration.h"
|
||||
#include "crypto.h"
|
||||
#include "file_picker.h"
|
||||
#include "libcurl.h"
|
||||
#include "scene.h"
|
||||
#include "scenes/lobby_keyboard.h"
|
||||
#include "utils/mapped_file.h"
|
||||
@@ -33,7 +35,9 @@
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
#include <compare>
|
||||
#include <optional>
|
||||
#include <uni_algo/case.h>
|
||||
#include <vector>
|
||||
|
||||
#include "input_profile.h"
|
||||
@@ -65,6 +69,9 @@ class lobby : public scene_impl<lobby>
|
||||
std::optional<input_profile> input;
|
||||
entt::entity lobby_entity;
|
||||
|
||||
file_picker lobby_file_picker;
|
||||
std::future<file_picker_result> lobby_file_picker_future;
|
||||
|
||||
std::optional<imgui_context> imgui_ctx;
|
||||
|
||||
std::optional<xr::hand_tracker> left_hand;
|
||||
@@ -114,6 +121,7 @@ class lobby : public scene_impl<lobby>
|
||||
server_list,
|
||||
settings,
|
||||
post_processing,
|
||||
customize,
|
||||
#if WIVRN_CLIENT_DEBUG_MENU
|
||||
debug,
|
||||
#endif
|
||||
@@ -140,6 +148,73 @@ class lobby : public scene_impl<lobby>
|
||||
thread_safe_notifyable<pin_request_data> pin_request;
|
||||
std::string pin_buffer;
|
||||
|
||||
struct environment_model
|
||||
{
|
||||
// Data from the JSON
|
||||
std::string name;
|
||||
std::string author;
|
||||
std::string description;
|
||||
std::string screenshot_url;
|
||||
std::string gltf_url;
|
||||
size_t size{};
|
||||
|
||||
bool builtin = false;
|
||||
int override_order = 0;
|
||||
std::filesystem::path local_screenshot_path;
|
||||
std::filesystem::path local_gltf_path;
|
||||
std::vector<std::byte> screenshot_png;
|
||||
ImTextureID screenshot{};
|
||||
|
||||
std::strong_ordering operator<=>(const environment_model & other) const
|
||||
{
|
||||
// Reverse order for the builtin member: we want the built-in models first
|
||||
if (auto cmp = override_order <=> other.override_order; cmp != std::strong_ordering::equal)
|
||||
return cmp;
|
||||
|
||||
return una::casesens::collate_utf8(name, other.name) <=> 0;
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<environment_model> downloadable_environments;
|
||||
std::vector<environment_model> local_environments;
|
||||
environment_model * environment_to_be_deleted = nullptr;
|
||||
|
||||
std::map<std::string, std::pair<libcurl::curl_handle, std::function<void(libcurl::curl_handle & handle)>>> current_transfers;
|
||||
libcurl curl; // needs to be after current_transfers
|
||||
|
||||
void update_file_picker();
|
||||
void update_transfers();
|
||||
void download(const std::string & url, const std::filesystem::path & path, std::function<void(libcurl::curl_handle & handle)> = {});
|
||||
void download(const std::string & url, std::function<void(libcurl::curl_handle & handle)> = {});
|
||||
libcurl::curl_handle * try_get_download_handle(const std::string & url);
|
||||
|
||||
std::string downloadable_environment_list_status;
|
||||
|
||||
std::vector<environment_model> load_environment_json(const std::string & json);
|
||||
void save_environment_json();
|
||||
void download_environment(const environment_model & model, bool use_after_downloading);
|
||||
void delete_environment(const environment_model & model);
|
||||
enum class environment_item_action
|
||||
{
|
||||
none,
|
||||
delete_model,
|
||||
download_model,
|
||||
use_model,
|
||||
};
|
||||
environment_item_action environment_item(environment_model & model, bool download_screenshot);
|
||||
void environment_list(std::vector<environment_model> & model, bool download_screenshot);
|
||||
void use_environment(const environment_model & model);
|
||||
void popup_load_environment();
|
||||
utils::future<std::pair<std::string, std::shared_ptr<entt::registry>>, float> future_environment;
|
||||
std::string load_environment_status;
|
||||
|
||||
void download_environment_list();
|
||||
libcurl::curl_handle * parse_environment_list();
|
||||
|
||||
#if WIVRN_CLIENT_DEBUG_MENU
|
||||
std::pair<entt::entity, int> debug_primitive_to_highlight = {entt::null, 0};
|
||||
#endif
|
||||
|
||||
void draw_features_status(XrTime predicted_display_time);
|
||||
void gui_connecting(locked_notifiable<pin_request_data> & request);
|
||||
void gui_enter_pin(locked_notifiable<pin_request_data> & request);
|
||||
@@ -148,6 +223,8 @@ class lobby : public scene_impl<lobby>
|
||||
void gui_new_server();
|
||||
void gui_settings();
|
||||
void gui_post_processing();
|
||||
void gui_customize();
|
||||
void gui_debug_node_hierarchy(entt::entity root = entt::null);
|
||||
void gui_debug();
|
||||
void gui_about();
|
||||
void gui_licenses();
|
||||
|
||||
Reference in New Issue
Block a user