This commit is contained in:
TheKodeToad 2024-06-18 15:28:16 +01:00
parent ebf11a94ab
commit 6052530efc
No known key found for this signature in database
GPG key ID: 5E39D70B4C93C38E
5 changed files with 219 additions and 26 deletions

View file

@ -1,5 +1,19 @@
configure_file(info.hpp.in info.hpp)
add_executable(installer main.cpp ui.cpp ui.hpp meta.cpp meta.hpp info.hpp) add_executable(installer main.cpp ui.cpp ui.hpp meta.cpp meta.hpp info.hpp)
target_link_libraries(installer PRIVATE wx::base wx::core wx::net)
configure_file(info.hpp.in info.hpp)
# From https://docs.wxwidgets.org/latest/overview_cmake.html
set(XRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/InstallerFrame_UI.xrc)
set(WXRC $<TARGET_FILE:wxrc>)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/resources.cpp ${CMAKE_CURRENT_BINARY_DIR}/resources.h
COMMAND ${WXRC} -c -e -o ${CMAKE_CURRENT_BINARY_DIR}/resources.cpp ${XRC_FILES}
DEPENDS ${XRC_FILES}
DEPENDS wxrc
COMMENT "Compiling XRC resources"
)
target_sources(installer PRIVATE resources.cpp resources.h)
target_link_libraries(installer PRIVATE wx::base wx::core wx::net wx::xrc)
include_directories(lib/wx/include) include_directories(lib/wx/include)
include_directories(lib/json/include) include_directories(lib/json/include)

View file

@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
<object class="wxFrame" name="InstallerFrame_UI">
<size>500,500</size>
<style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style>
<title></title>
<centered>1</centered>
<aui_managed>0</aui_managed>
<object class="wxBoxSizer" name="content">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND|wxFIXED_MINSIZE</flag>
<border>5</border>
<option>1</option>
<object class="wxBoxSizer" name="options">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxALL</flag>
<border>5</border>
<option>0</option>
<object class="wxStaticText" name="version_label">
<label>Version</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
<option>0</option>
<object class="wxChoice" name="m_choice1">
<selection>0</selection>
<content/>
</object>
</object>
<object class="sizeritem">
<flag>wxALL</flag>
<border>5</border>
<option>0</option>
<object class="wxStaticText" name="launcher_data_dir_label">
<label>Launcher Data Directory</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>5</border>
<option>0</option>
<object class="wxBoxSizer" name="launcher_data_dir_options">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>5</border>
<option>1</option>
<object class="wxTextCtrl" name="launcher_data_dir_input">
<value></value>
<maxlength>0</maxlength>
</object>
</object>
<object class="sizeritem">
<flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>5</border>
<option>0</option>
<object class="wxButton" name="launcher_data_dir_select">
<label>Select</label>
<default>0</default>
<auth_needed>0</auth_needed>
<markup>0</markup>
<bitmap/>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
<option>0</option>
<object class="wxStaticBoxSizer" name="installation_options">
<orient>wxVERTICAL</orient>
<label>Installation</label>
<object class="sizeritem">
<flag>wxALL|wxEXPAND</flag>
<border>8</border>
<option>1</option>
<object class="wxBoxSizer" name="installation_options_content">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxBOTTOM|wxLEFT|wxRIGHT</flag>
<border>5</border>
<option>0</option>
<object class="wxStaticText" name="name_label">
<label>Name</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
<option>0</option>
<object class="wxTextCtrl" name="name_input">
<value></value>
<maxlength>0</maxlength>
</object>
</object>
<object class="sizeritem">
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
<option>0</option>
<object class="wxStaticText" name="game_directory_label">
<label>Game Directory</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<flag>wxEXPAND</flag>
<border>5</border>
<option>1</option>
<object class="wxBoxSizer" name="game_dir_options">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>5</border>
<option>1</option>
<object class="wxTextCtrl" name="game_data_dir_input">
<value></value>
<maxlength>0</maxlength>
</object>
</object>
<object class="sizeritem">
<flag>wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>5</border>
<option>0</option>
<object class="wxButton" name="game_data_dir_select">
<label>Select</label>
<default>0</default>
<auth_needed>0</auth_needed>
<markup>0</markup>
<bitmap/>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
<option>0</option>
<object class="wxBoxSizer" name="actions">
<orient>wxHORIZONTAL</orient>
<object class="spacer">
<flag>wxEXPAND</flag>
<border>5</border>
<option>1</option>
<size>0,0</size>
</object>
<object class="sizeritem">
<flag>wxALL</flag>
<border>5</border>
<option>0</option>
<object class="wxButton" name="m_button1">
<label>_Cancel</label>
<default>0</default>
<auth_needed>0</auth_needed>
<markup>0</markup>
<bitmap/>
</object>
</object>
<object class="sizeritem">
<flag>wxALL</flag>
<border>5</border>
<option>0</option>
<object class="wxButton" name="m_button2">
<label>_Install</label>
<default>0</default>
<auth_needed>0</auth_needed>
<markup>0</markup>
<bitmap/>
</object>
</object>
</object>
</object>
</object>
</object>
</resource>

View file

@ -11,28 +11,15 @@ public:
wxLog::SetActiveTarget(new wxLogStream(&std::cout)); wxLog::SetActiveTarget(new wxLogStream(&std::cout));
get_loader_version(this, "placeholder", [](std::optional<LoaderVersion> value) { wxXmlResource::Get()->InitAllHandlers();
if (!value.has_value()) InitXmlResource();
return;
wxString buf('\n'); // we need to do this explicitly on Windows for dark mode
if (const auto result = SetAppearance(Appearance::System); result != AppearanceResult::Success)
wxLogWarning("SetAppearance returned %d", result);
buf += "Version: " + value->version + '\n'; auto *frame = new InstallerFrame;
buf += "Release Date: " + value->release_date.Format() + '\n'; frame->Show();
buf += "Libraries:\n";
for (const auto &library : value->libraries) {
buf += "- Name: " + library.name + '\n';
buf += " URL: " + library.url + '\n';
buf += " SHA-1: " + library.sha1 + '\n';
buf += " Size: " + wxString::Format("%ld", library.size) + '\n';
}
wxLogInfo(buf);
});
auto *window = new InstallerWindow;
window->Show();
return true; return true;
} }

View file

@ -1,3 +1,5 @@
#include "ui.hpp" #include "ui.hpp"
InstallerWindow::InstallerWindow() {} InstallerFrame::InstallerFrame() : InstallerFrame_UI(nullptr) {
}

View file

@ -1,8 +1,10 @@
#pragma once #pragma once
#include "wx/window.h" #include "wx/wx.h"
#include "wx/xrc/xmlres.h"
#include "resources.h"
class InstallerWindow final : public wxWindow { class InstallerFrame final : public InstallerFrame_UI {
public: public:
explicit InstallerWindow(); explicit InstallerFrame();
}; };