diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 160b36c7..e45ec2a7 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -206,3 +206,18 @@ endforeach() add_custom_target(translations ALL DEPENDS ${MO_FILES}) add_dependencies(wivrn translations) + +if(ANDROID) + set(LICENSES_DIR "${CMAKE_ANDROID_ASSETS_DIRECTORIES}/licenses") +else() + set(LICENSES_DIR "licenses") +endif() + +file(MAKE_DIRECTORY "${LICENSES_DIR}") +file(COPY_FILE "${CMAKE_SOURCE_DIR}/COPYING" "${LICENSES_DIR}/WiVRn") +file(COPY_FILE "${simdjson_SOURCE_DIR}/LICENSE" "${LICENSES_DIR}/simdjson") +if (OPENXR_SOURCE_DIR) + file(COPY_FILE "${OPENXR_SOURCE_DIR}/LICENSE" "${LICENSES_DIR}/openxr-loader") +endif() + +install(DIRECTORY "${LICENSES_DIR}" DESTINATION "${CMAKE_INSTALL_DATADIR}/wivrn") diff --git a/client/scenes/lobby.h b/client/scenes/lobby.h index 3b108dd5..a73e8d10 100644 --- a/client/scenes/lobby.h +++ b/client/scenes/lobby.h @@ -19,6 +19,7 @@ #pragma once +#include "asset.h" #include "configuration.h" #include "render/scene_data.h" #include "scene.h" @@ -73,6 +74,7 @@ class lobby : public scene_impl std::array haptic_output; std::string selected_item; + std::unique_ptr license; ImGuiID hovered_item; std::vector swapchains_lobby; @@ -99,6 +101,7 @@ class lobby : public scene_impl new_server, settings, about, + licenses, exit }; @@ -111,6 +114,7 @@ class lobby : public scene_impl void gui_add_server(); void gui_settings(); void gui_about(); + void gui_licenses(); void gui_keyboard(ImVec2 size); void setup_passthrough(); diff --git a/client/scenes/lobby_gui.cpp b/client/scenes/lobby_gui.cpp index 0e370b34..a77c4b36 100644 --- a/client/scenes/lobby_gui.cpp +++ b/client/scenes/lobby_gui.cpp @@ -20,6 +20,7 @@ #define IMGUI_DEFINE_MATH_OPERATORS #include "application.h" +#include "asset.h" #include "imgui.h" #include "imgui_internal.h" #include "implot.h" @@ -493,6 +494,50 @@ void scenes::lobby::gui_about() ImGui::Image(about_picture, {win_width / 2, win_width / 2}); } +void scenes::lobby::gui_licenses() +{ + ImGui::PushFont(imgui_ctx->large_font); + ImGui::Text("%s", _("Licenses").c_str()); + ImGui::PopFont(); + + const auto components = {"WiVRn", "openxr-loader", "simdjson"}; + if (not license) + { + selected_item = *components.begin(); + try + { + license = std::make_unique(std::filesystem::path("licenses") / selected_item); + } + catch (...) + { + spdlog::warn("No license file for {}", selected_item); + } + } + if (ImGui::BeginCombo("", selected_item.c_str())) + { + for (const auto & component: components) + { + try + { + auto current = std::make_unique(std::filesystem::path("licenses") / component); + if (ImGui::Selectable(component, component == selected_item)) + { + selected_item = component; + license = std::move(current); + } + } + catch (...) + { + spdlog::debug("No license file for {}", component); + } + } + ImGui::EndCombo(); + } + vibrate_on_hover(); + if (license) + ImGui::TextUnformatted((const char *)license->data(), (const char *)license->data() + license->size()); +} + static bool RadioButtonWithoutCheckBox(const std::string & label, bool active, ImVec2 size_arg) { ImGuiWindow * window = ImGui::GetCurrentWindow(); @@ -605,6 +650,10 @@ XrCompositionLayerQuad scenes::lobby::draw_gui(XrTime predicted_display_time) gui_about(); break; + case tab::licenses: + gui_licenses(); + break; + case tab::exit: application::pop_scene(); break; @@ -637,10 +686,13 @@ XrCompositionLayerQuad scenes::lobby::draw_gui(XrTime predicted_display_time) RadioButtonWithoutCheckBox(ICON_FA_GEARS " " + _("Settings"), ¤t_tab, tab::settings, {TabWidth, 0}); vibrate_on_hover(); - ImGui::SetCursorPosY(ImGui::GetContentRegionMax().y - 2 * ImGui::GetCurrentContext()->FontSize - 4 * style.FramePadding.y - style.ItemSpacing.y - style.WindowPadding.y); + ImGui::SetCursorPosY(ImGui::GetContentRegionMax().y - 3 * ImGui::GetCurrentContext()->FontSize - 6 * style.FramePadding.y - 2 * style.ItemSpacing.y - style.WindowPadding.y); RadioButtonWithoutCheckBox(ICON_FA_CIRCLE_INFO " " + _("About"), ¤t_tab, tab::about, {TabWidth, 0}); vibrate_on_hover(); + RadioButtonWithoutCheckBox(ICON_FA_SCALE_BALANCED " " + _("Licenses"), ¤t_tab, tab::licenses, {TabWidth, 0}); + vibrate_on_hover(); + RadioButtonWithoutCheckBox(ICON_FA_DOOR_OPEN " " + _("Exit"), ¤t_tab, tab::exit, {TabWidth, 0}); vibrate_on_hover();