- seek support
- about button implementation - cleaned up cmake config
This commit is contained in:
parent
1756c9e368
commit
8cf3fe8cea
|
@ -1,19 +1,28 @@
|
|||
cmake_minimum_required (VERSION 3.8)
|
||||
include("cmake/create_resources.cmake")
|
||||
|
||||
#enable objective c support on mac os, needed for wxwidgets and compile for both intel macs and apple sillicon macs
|
||||
if(APPLE)
|
||||
project ("globalRPC" LANGUAGES C CXX OBJCXX)
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
||||
project ("PlayerLink" LANGUAGES C CXX OBJCXX)
|
||||
else()
|
||||
project ("globalRPC" LANGUAGES C CXX)
|
||||
project ("PlayerLink" LANGUAGES C CXX)
|
||||
endif()
|
||||
|
||||
create_resources("rsrc" "src/rsrc.hpp")
|
||||
file(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||
add_executable (rpc ${SOURCES})
|
||||
set_property(TARGET rpc PROPERTY CXX_STANDARD 20)
|
||||
add_executable (PlayerLink ${SOURCES})
|
||||
set_property(TARGET PlayerLink PROPERTY CXX_STANDARD 20)
|
||||
add_subdirectory("vendor")
|
||||
set(LIBRARIES discord-rpc libcurl_static mbedcrypto mbedx509 mbedtls wxmono)
|
||||
|
||||
#use windows subsystem to disable console window and link winrt
|
||||
if(WIN32)
|
||||
list(APPEND LIBRARIES WindowsApp)
|
||||
target_link_options(PlayerLink PRIVATE "/SUBSYSTEM:WINDOWS" "/ENTRY:mainCRTStartup")
|
||||
endif()
|
||||
|
||||
#search directories for the autogenerated wxwidgets setup.h file for all plattforms
|
||||
file(GLOB wx_setup_dir
|
||||
"${CMAKE_BINARY_DIR}/vendor/wxWidgets/lib/*/mswu"
|
||||
"${CMAKE_BINARY_DIR}/vendor/wxWidgets/lib/*/gtk3u"
|
||||
|
@ -21,8 +30,8 @@ file(GLOB wx_setup_dir
|
|||
)
|
||||
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})
|
||||
target_include_directories(PlayerLink 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})
|
||||
target_link_libraries(PlayerLink PUBLIC ${LIBRARIES})
|
16
src/main.cpp
16
src/main.cpp
|
@ -37,6 +37,7 @@ void handleRPCTasks() {
|
|||
}
|
||||
|
||||
void handleMediaTasks() {
|
||||
int64_t lastMs = 0;
|
||||
while (true) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
auto mediaInformation = backend::getMediaInformation();
|
||||
|
@ -47,6 +48,7 @@ void handleMediaTasks() {
|
|||
}
|
||||
|
||||
if (mediaInformation->paused) {
|
||||
lastMs = 0;
|
||||
lastPlayingSong = "";
|
||||
currentSongTitle = "";
|
||||
Discord_ClearPresence();
|
||||
|
@ -55,8 +57,13 @@ void handleMediaTasks() {
|
|||
|
||||
std::string currentlyPlayingSong = mediaInformation->songTitle + mediaInformation->songArtist +
|
||||
mediaInformation->songAlbum + std::to_string(mediaInformation->songDuration);
|
||||
int64_t currentMs = mediaInformation->songElapsedTime;
|
||||
|
||||
if (currentlyPlayingSong == lastPlayingSong)
|
||||
bool shouldContinue =
|
||||
currentlyPlayingSong == lastPlayingSong && (lastMs <= currentMs) && (lastMs + 3000 >= currentMs);
|
||||
lastMs = currentMs;
|
||||
|
||||
if (shouldContinue)
|
||||
continue;
|
||||
|
||||
lastPlayingSong = currentlyPlayingSong;
|
||||
|
@ -122,10 +129,14 @@ public:
|
|||
|
||||
void OnMenuExit(wxCommandEvent& evt) { settingsFrame->Close(true); }
|
||||
|
||||
void OnMenuAbout(wxCommandEvent& evt) {
|
||||
wxMessageBox(_("Made with <3 by EinTim"), _("PlayerLink"), wxOK | wxICON_INFORMATION);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual wxMenu* CreatePopupMenu() override {
|
||||
wxMenu* menu = new wxMenu;
|
||||
menu->Append(10004, _(currentSongTitle == "" ? "Not Playing" : currentSongTitle)); // TODO: make this dynamic
|
||||
menu->Append(10004, _(currentSongTitle == "" ? "Not Playing" : currentSongTitle));
|
||||
menu->Enable(10004, false);
|
||||
menu->AppendSeparator();
|
||||
menu->Append(10001, _("Settings"));
|
||||
|
@ -134,6 +145,7 @@ protected:
|
|||
menu->Append(10002, _("Quit PlayerLink..."));
|
||||
Bind(wxEVT_MENU, &PlayerLinkIcon::OnMenuOpen, this, 10001);
|
||||
Bind(wxEVT_MENU, &PlayerLinkIcon::OnMenuExit, this, 10002);
|
||||
Bind(wxEVT_MENU, &PlayerLinkIcon::OnMenuAbout, this, 10003);
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue