added experimental wxwidgets implementation
This commit is contained in:
parent
4a9710ce1e
commit
75c61fe193
|
@ -10,3 +10,6 @@
|
|||
[submodule "vendor/mbedtls"]
|
||||
path = vendor/mbedtls
|
||||
url = https://github.com/Mbed-TLS/mbedtls.git
|
||||
[submodule "vendor/wxWidgets"]
|
||||
path = vendor/wxWidgets
|
||||
url = https://github.com/wxWidgets/wxWidgets.git
|
||||
|
|
|
@ -4,9 +4,18 @@ file(GLOB_RECURSE SOURCES "src/*.cpp")
|
|||
add_executable (rpc ${SOURCES})
|
||||
set_property(TARGET rpc PROPERTY CXX_STANDARD 20)
|
||||
add_subdirectory("vendor")
|
||||
set(LIBRARIES discord-rpc libcurl_static mbedcrypto mbedx509 mbedtls)
|
||||
set(LIBRARIES discord-rpc libcurl_static mbedcrypto mbedx509 mbedtls wxmono)
|
||||
if(WIN32)
|
||||
list(APPEND LIBRARIES WindowsApp)
|
||||
endif()
|
||||
target_link_libraries(rpc PUBLIC ${LIBRARIES})
|
||||
target_include_directories(rpc PRIVATE vendor)
|
||||
file(GLOB wx_setup_dir
|
||||
"${CMAKE_BINARY_DIR}/vendor/wxWidgets/lib/*/mswu"
|
||||
"${CMAKE_BINARY_DIR}/vendor/wxWidgets/lib/*/gtk3u"
|
||||
)
|
||||
if(wx_setup_dir)
|
||||
message(STATUS "wxWidgets setup.h directory found: ${wx_setup_dir}")
|
||||
target_include_directories(rpc PRIVATE vendor vendor/wxWidgets/include ${wx_setup_dir})
|
||||
else()
|
||||
message(FATAL_ERROR "wx/setup.h not found. Please check your wxWidgets build configuration.")
|
||||
endif()
|
||||
target_link_libraries(rpc PUBLIC ${LIBRARIES})
|
|
@ -0,0 +1,5 @@
|
|||
#ifdef __APPLE__
|
||||
|
||||
std::shared_ptr<MediaInfo> backend::getMediaInformation() { return nullptr; }
|
||||
|
||||
#endif
|
|
@ -0,0 +1,5 @@
|
|||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
|
||||
std::shared_ptr<MediaInfo> backend::getMediaInformation() { return nullptr; }
|
||||
|
||||
#endif
|
26
src/main.cpp
26
src/main.cpp
|
@ -1,4 +1,5 @@
|
|||
#include <discord-rpc/discord_rpc.h>
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
|
@ -7,6 +8,7 @@
|
|||
|
||||
#include "backend.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
std::string lastPlayingSong = "";
|
||||
std::string lastMediaSource = "";
|
||||
|
||||
|
@ -26,10 +28,7 @@ void handleRPCTasks() {
|
|||
handleRPCTasks(); // this could theoretically cause a stack overflow if discord is restarted often enough
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::thread rpcThread(handleRPCTasks);
|
||||
rpcThread.detach();
|
||||
|
||||
void handleMediaTasks() {
|
||||
while (true) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
auto mediaInformation = backend::getMediaInformation();
|
||||
|
@ -98,4 +97,23 @@ int main() {
|
|||
|
||||
Discord_UpdatePresence(&activity);
|
||||
}
|
||||
}
|
||||
class MyApp : public wxApp {
|
||||
public:
|
||||
virtual bool OnInit() override {
|
||||
wxFrame* frame = new wxFrame(nullptr, wxID_ANY, "Hello wxWidgets", wxDefaultPosition, wxSize(400, 300));
|
||||
wxStaticText* text = new wxStaticText(frame, wxID_ANY, "Hello World", wxPoint(150, 130));
|
||||
frame->Show(true);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
wxIMPLEMENT_APP_NO_MAIN(MyApp);
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
std::thread rpcThread(handleRPCTasks);
|
||||
rpcThread.detach();
|
||||
std::thread mediaThread(handleMediaTasks);
|
||||
mediaThread.detach();
|
||||
return wxEntry(argc, argv);
|
||||
}
|
|
@ -11,3 +11,8 @@ SET(MBEDTLS_INCLUDE_DIRS ../mbedtls/include)
|
|||
file(REMOVE curl/CMake/FindMbedTLS.cmake) #replace curls FindMbedTLS that expects mbedtls to be prebuilt with a dummy
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/dummy ${CMAKE_MODULE_PATH})
|
||||
add_subdirectory("curl")
|
||||
set(wxBUILD_SHARED OFF)
|
||||
set(wxBUILD_MONOLITHIC ON)
|
||||
set(wxUSE_GUI ON)
|
||||
set(wxUSE_WEBVIEW OFF)
|
||||
add_subdirectory("wxWidgets")
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 5ff25322553c1870cf20a2e1ba6f20ed50d9fe9a
|
Loading…
Reference in New Issue