Mercurial > wgsdk
comparison src/main.c @ 4:59bf702b2b21
*: stylistic changes
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 14 Aug 2022 13:17:32 -0400 |
parents | 712c7fd6702a |
children | be4835547dd0 |
comparison
equal
deleted
inserted
replaced
3:8df8af626dca | 4:59bf702b2b21 |
---|---|
30 }; | 30 }; |
31 | 31 |
32 WNDPROC g_lpWndProcOld = 0; | 32 WNDPROC g_lpWndProcOld = 0; |
33 | 33 |
34 struct timer_t timer_callbacks = { .interval = 16 }; | 34 struct timer_t timer_callbacks = { .interval = 16 }; |
35 struct config_t config = { | 35 struct config config = { |
36 .display_title = 1, | 36 .display_title = 1, |
37 .show_elapsed_time = 1 | 37 .show_elapsed_time = 1 |
38 }; | 38 }; |
39 | 39 |
40 struct DiscordActivity activity = { | 40 struct DiscordActivity activity = { |
69 activity.timestamps.start = dtn - SendMessage(g_plugin.hwndParent, WM_WA_IPC, 0, IPC_GETOUTPUTTIME) / 1000; | 69 activity.timestamps.start = dtn - SendMessage(g_plugin.hwndParent, WM_WA_IPC, 0, IPC_GETOUTPUTTIME) / 1000; |
70 } else { | 70 } else { |
71 activity.timestamps.start = 0; | 71 activity.timestamps.start = 0; |
72 } | 72 } |
73 | 73 |
74 char* detailsMessage = calloc(256, sizeof(char)); | 74 char* details_message = calloc(256, sizeof(char)); |
75 if (config.display_title) { | 75 if (config.display_title) { |
76 wchar_t* title = (wchar_t*)SendMessageW(g_plugin.hwndParent, WM_WA_IPC, 0, IPC_GET_PLAYING_TITLE); | 76 wchar_t* title = (wchar_t*)SendMessageW(g_plugin.hwndParent, WM_WA_IPC, 0, IPC_GET_PLAYING_TITLE); |
77 assert(WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, title, -1, detailsMessage, 256, NULL, NULL)); | 77 assert(WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, title, -1, details_message, 256, NULL, NULL)); |
78 } else { | 78 free(title); |
79 strcpy(activity.details, ""); | |
80 } | 79 } |
81 strcpy(activity.details, detailsMessage); | 80 strcpy(activity.details, details_message); |
82 free(detailsMessage); | 81 free(details_message); |
83 | 82 |
84 app.activities->update_activity(app.activities, &activity, &app, update_activity_callback); | 83 app.activities->update_activity(app.activities, &activity, &app, update_activity_callback); |
85 } | 84 } |
86 | 85 |
87 void report_idle_status(void) | 86 void report_idle_status(void) |
95 void update_rich_presence_details(void) | 94 void update_rich_presence_details(void) |
96 { | 95 { |
97 LONG isPlayingResult = SendMessageW(g_plugin.hwndParent, WM_WA_IPC, 0, IPC_ISPLAYING); | 96 LONG isPlayingResult = SendMessageW(g_plugin.hwndParent, WM_WA_IPC, 0, IPC_ISPLAYING); |
98 | 97 |
99 switch (isPlayingResult) { | 98 switch (isPlayingResult) { |
100 case 1: | |
101 report_current_song_status(1); | |
102 break; | |
103 case 3: | |
104 report_current_song_status(3); | |
105 break; | |
106 case 0: | 99 case 0: |
107 report_idle_status(); | 100 report_idle_status(); |
108 break; | 101 break; |
109 default: break; | 102 case 1: |
103 case 3: | |
104 report_current_song_status(isPlayingResult); | |
105 default: | |
106 break; | |
110 } | 107 } |
111 } | 108 } |
112 | 109 |
113 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | 110 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) |
114 { | 111 { |
162 void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) { | 159 void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) { |
163 DISCORD_REQUIRE(app.core->run_callbacks(app.core)); | 160 DISCORD_REQUIRE(app.core->run_callbacks(app.core)); |
164 } | 161 } |
165 | 162 |
166 void conf() { | 163 void conf() { |
167 DialogBoxW(g_plugin.hDllInstance, (LPWSTR)DIALOG_CONFIG, g_plugin.hwndParent, &cfg_win_proc); | 164 DialogBoxW(g_plugin.hDllInstance, (LPWSTR)DIALOG_CONFIG, g_plugin.hwndParent, (DLGPROC)cfg_win_proc); |
168 } | 165 } |
169 | 166 |
170 __declspec(dllexport) winamp_general_purpose_plugin* winampGetGeneralPurposePlugin() { | 167 __declspec(dllexport) winamp_general_purpose_plugin* winampGetGeneralPurposePlugin() { |
171 return &g_plugin; | 168 return &g_plugin; |
172 } | 169 } |