Add license screen

This commit is contained in:
Patrick Nicolas
2024-06-09 17:37:36 +02:00
parent de4715cd86
commit 70a8072430
3 changed files with 72 additions and 1 deletions
+15
View File
@@ -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")
+4
View File
@@ -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<lobby>
std::array<XrAction, 2> haptic_output;
std::string selected_item;
std::unique_ptr<asset> license;
ImGuiID hovered_item;
std::vector<xr::swapchain> swapchains_lobby;
@@ -99,6 +101,7 @@ class lobby : public scene_impl<lobby>
new_server,
settings,
about,
licenses,
exit
};
@@ -111,6 +114,7 @@ class lobby : public scene_impl<lobby>
void gui_add_server();
void gui_settings();
void gui_about();
void gui_licenses();
void gui_keyboard(ImVec2 size);
void setup_passthrough();
+53 -1
View File
@@ -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<asset>(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<asset>(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"), &current_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"), &current_tab, tab::about, {TabWidth, 0});
vibrate_on_hover();
RadioButtonWithoutCheckBox(ICON_FA_SCALE_BALANCED " " + _("Licenses"), &current_tab, tab::licenses, {TabWidth, 0});
vibrate_on_hover();
RadioButtonWithoutCheckBox(ICON_FA_DOOR_OPEN " " + _("Exit"), &current_tab, tab::exit, {TabWidth, 0});
vibrate_on_hover();