From 1227797028359155afb7ecd311e9475a43f08ddd Mon Sep 17 00:00:00 2001 From: Koosemose Date: Thu, 22 Oct 2015 05:08:57 -0400 Subject: [PATCH] Implemented File Selection for text --- Marquee Text/overlayMarqueeText.cpp | 99 +++++++++++++++--- Marquee Text/overlayMarqueeText.h | 3 +- Marquee Text/overlayMarqueeText.rc | Bin 5290 -> 5542 bytes Marquee Text/resource.h | Bin 1550 -> 1738 bytes lang/English.txt | Bin 1016 -> 1058 bytes "lang/Fran\303\247ais.txt" | Bin 598 -> 654 bytes lang/Magyar.txt | Bin 606 -> 662 bytes lang/Polski.txt | Bin 538 -> 594 bytes "lang/Portugu\303\252s (Brasil).txt" | Bin 560 -> 622 bytes lang/Suomi.txt | Bin 572 -> 630 bytes ...1\201\321\201\320\272\320\270\320\271.txt" | Bin 550 -> 608 bytes .../\346\227\245\346\234\254\350\252\236.txt" | Bin 486 -> 532 bytes 12 files changed, 86 insertions(+), 16 deletions(-) diff --git a/Marquee Text/overlayMarqueeText.cpp b/Marquee Text/overlayMarqueeText.cpp index 444d069..ac9331e 100644 --- a/Marquee Text/overlayMarqueeText.cpp +++ b/Marquee Text/overlayMarqueeText.cpp @@ -5,8 +5,8 @@ #include "resource.h" #include #include -#include +#include // add your own path for PlayClaw5.lib #ifdef _DEBUG #pragma comment(lib, "../playclaw5.lib") @@ -29,12 +29,14 @@ Gdiplus::Pen* pAxisPen = 0; Gdiplus::Font* pFont = 0; BOOL bShowBackground = true; -wchar_t wcTextContents[256]; +wchar_t wcTextContents[256]; + +const WCHAR *pFileName = L""; int cycleCount = 0; int scroll = 0; int textLength = 0; -time_t oldModifyTime; +FILETIME oldModifyTime; // // Init plugin @@ -77,6 +79,8 @@ PLUGIN_EXPORT void PluginSetDefaultVars() PC_SetPluginVar(m_dwPluginID, VAR_TEXT_FONT_SIZE, 24); PC_SetPluginVar(m_dwPluginID, VAR_TEXT_FONT_STYLE, (int)0); // flags: 1 - bold, 2 - italic PC_SetPluginVar(m_dwPluginID, VAR_SHOW_BACKGROUND, 1); + PC_SetPluginVar(m_dwPluginID, VAR_TEXT_FILE, L""); + } // @@ -103,15 +107,17 @@ PLUGIN_EXPORT void PluginUpdateVars() (float)PC_GetPluginVarInt(m_dwPluginID, VAR_TEXT_FONT_SIZE), PC_GetPluginVarInt(m_dwPluginID, VAR_TEXT_FONT_STYLE)); + //SAFE_DELETE(pFileName); + pFileName = PC_GetPluginVarStr(m_dwPluginID, VAR_TEXT_FILE); - struct stat attrib; - stat("C:/Users/Koosemose/Desktop/Snip/Snip.txt", &attrib); - time_t modifyTime = attrib.st_mtime; - + WIN32_FILE_ATTRIBUTE_DATA attribs; + GetFileAttributesExW(pFileName, GetFileExInfoStandard, &attribs); + + FILETIME modifyTime = attribs.ftLastWriteTime; oldModifyTime = modifyTime; string line; ifstream myfile; - myfile.open("C:/Users/Koosemose/Desktop/Snip/Snip.txt"); + myfile.open(pFileName); string textContents = ""; if (myfile.is_open()) { @@ -178,14 +184,16 @@ PLUGIN_EXPORT void PluginUpdateOverlay() WCHAR s[128]; _itow_s(PC_GetConfirmedProcessID(), s, 10); - struct stat attrib; - stat("C:/Users/Koosemose/Desktop/Snip/Snip.txt", &attrib); - time_t modifyTime = attrib.st_mtime; - if (modifyTime > oldModifyTime) { + + WIN32_FILE_ATTRIBUTE_DATA attribs; + GetFileAttributesExW(pFileName, GetFileExInfoStandard, &attribs); + + FILETIME modifyTime = attribs.ftLastWriteTime; + if (CompareFileTime(&modifyTime, &oldModifyTime) >0) { oldModifyTime = modifyTime; string line; ifstream myfile; - myfile.open("C:/Users/Koosemose/Desktop/Snip/Snip.txt"); + myfile.open(pFileName); string textContents = ""; if (myfile.is_open()) { @@ -237,6 +245,7 @@ DWORD dwTextColor, dwBackgroundColor; BOOL bItalic, bBold; wstring szFontFamily; DWORD dwFontSize; +wstring szFileName; static void SetFontButtonText(HWND dlg) { @@ -250,6 +259,14 @@ static void SetFontButtonText(HWND dlg) SetWindowText(GetDlgItem(dlg, IDC_TEXT_FONT), fontstr); } +static void SetFileNameButtonText(HWND dlg) +{ + WCHAR filestr[128]; + wsprintf(filestr, L"%s", + szFileName.c_str()); + SetWindowText(GetDlgItem(dlg, IDC_TEXT_FILE), filestr); +} + static void InitSettingsDialog(HWND hwnd) { // HWND ctrl; @@ -262,9 +279,10 @@ static void InitSettingsDialog(HWND hwnd) bBold = (PC_GetPluginVarInt(m_dwPluginID, VAR_TEXT_FONT_STYLE) & 1) != 0; szFontFamily = PC_GetPluginVarStr(m_dwPluginID, VAR_TEXT_FONT_FAMILY); dwFontSize = PC_GetPluginVarInt(m_dwPluginID, VAR_TEXT_FONT_SIZE); - + szFileName = PC_GetPluginVarStr(m_dwPluginID, VAR_TEXT_FILE); Button_SetCheck(GetDlgItem(hwnd, IDC_SHOW_BACKGROUND), PC_GetPluginVarInt(m_dwPluginID, VAR_SHOW_BACKGROUND) != 0 ? BST_CHECKED : BST_UNCHECKED); SetFontButtonText(hwnd); + SetFileNameButtonText(hwnd); } static void DrawColorButton(LPDRAWITEMSTRUCT lpDIS, COLORREF clr) @@ -297,8 +315,9 @@ static INT_PTR CALLBACK DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar { PC_SetPluginVar(m_dwPluginID, VAR_TEXT_COLOR, dwTextColor); PC_SetPluginVar(m_dwPluginID, VAR_BACKGROUND_COLOR, dwBackgroundColor); - + PC_SetPluginVar(m_dwPluginID, VAR_TEXT_FILE, szFileName.c_str()); PC_SetPluginVar(m_dwPluginID, VAR_TEXT_FONT_FAMILY, szFontFamily.c_str()); + PC_SetPluginVar(m_dwPluginID, VAR_TEXT_FILE, szFileName.c_str()); PC_SetPluginVar(m_dwPluginID, VAR_TEXT_FONT_SIZE, dwFontSize); PC_SetPluginVar(m_dwPluginID, VAR_SHOW_BACKGROUND, Button_GetCheck(GetDlgItem(hwnd, IDC_SHOW_BACKGROUND)) == BST_CHECKED); int style = (bBold ? 1 : 0) | (bItalic ? 2 : 0); @@ -350,6 +369,56 @@ static INT_PTR CALLBACK DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar } ReleaseDC(hwnd, dc); + } + if (id == IDC_TEXT_FILE) { + HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | + COINIT_DISABLE_OLE1DDE); + if (SUCCEEDED(hr)) + { + IFileOpenDialog *pFileOpen; + COMDLG_FILTERSPEC rgSpec[] = + { + { L"Text Files", L"*.txt" }, + { L"All Files", L"*.*" }, + }; + // Create the FileOpenDialog object. + hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL, + IID_IFileOpenDialog, reinterpret_cast(&pFileOpen)); + + if (SUCCEEDED(hr)) + { + // Show the Open dialog box. + pFileOpen->SetFileTypes(2,rgSpec); + + hr = pFileOpen->Show(NULL); + + // Get the file name from the dialog box. + if (SUCCEEDED(hr)) + { + IShellItem *pItem; + hr = pFileOpen->GetResult(&pItem); + if (SUCCEEDED(hr)) + { + PWSTR pszFilePath; + hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath); + + // Display the file name to the user. + if (SUCCEEDED(hr)) + { + //MessageBox(NULL, pszFilePath, L"File Path", MB_OK); + //szFileName = L"CATS"; + szFileName = pszFilePath; + SetFileNameButtonText(hwnd); + CoTaskMemFree(pszFilePath); + } + pItem->Release(); + } + } + pFileOpen->Release(); + } + CoUninitialize(); + } + } break; diff --git a/Marquee Text/overlayMarqueeText.h b/Marquee Text/overlayMarqueeText.h index c04fb4f..406d871 100644 --- a/Marquee Text/overlayMarqueeText.h +++ b/Marquee Text/overlayMarqueeText.h @@ -4,4 +4,5 @@ #define VAR_TEXT_FONT_FAMILY "text_font.family" #define VAR_TEXT_FONT_SIZE "text_font.size" #define VAR_TEXT_FONT_STYLE "text_font.style" -#define VAR_SHOW_BACKGROUND "show_background" \ No newline at end of file +#define VAR_SHOW_BACKGROUND "show_background" +#define VAR_TEXT_FILE "text_file" \ No newline at end of file diff --git a/Marquee Text/overlayMarqueeText.rc b/Marquee Text/overlayMarqueeText.rc index 60db46db00fb010ca5fe8e85677bd8da2b51798a..18e66011c8a04e5e8e1d7b0f76747e76c9cc6858 100644 GIT binary patch delta 361 zcmZ3bxlDV*Hcm#)$?`nPlOJ#jF)B>{$SJF;z+lK=z+lRt!=L~q4Z$KHz9EAN11|#? z156JOy9t95NF`9GsHP`_4}&XMAHoD9pjjZDAR58~nlbqzuO`q&p2-PZY+zf3Cs%NZ zh$;Zha$+cDC;`HJhCHarbGb~Vk=#LWp+a8e z$x^&3K%;GW#pPk%04f4I#R6)81=K5ryp|A^vIvzRCu6G9=Z1I@;$@)O;xHXBZ$kA< RKF@oe*^I$-^FlsOHUQf+I`;qo delta 171 zcmZ3cy-IV#HqOcOc(f+Z8|#nf#Vhmfw)UfWeeO2aF9F3@1LP#bjn){mHXP+U~HQ{z+@MrL22mu?ppI3Zx0xt_U$YLD^u#U;6`OY(&G8k;0%g@OM021;g6#xJL diff --git a/Marquee Text/resource.h b/Marquee Text/resource.h index 2c7b01f0bd98c437016015e2204c24767f507e24..91f5a9276c27aef3a7721f2cd119ed62cc1064a5 100644 GIT binary patch delta 58 zcmeCMX7&E&+gC9c(1LtHffEYd7%~}>88U!mDnk*20z(Oqt^kpngBh6_0SQmv6#!mnmJ_Mxz diff --git a/lang/Magyar.txt b/lang/Magyar.txt index 12db107c3ccf0f2592b6e93e01305ddafc110b26..4b04e9513ba81ed605e8c12355e461a1731cc43e 100644 GIT binary patch delta 52 zcmcb|GL3aZ7Nfc+gAao%11A&~GgL8rV<=-tWk?6&Vg?05+GRtB=aYmGyVhs DN81b2 delta 11 ScmaFIvVmoT2jk>6#uoq_3Iw76 diff --git a/lang/Suomi.txt b/lang/Suomi.txt index 7626c4e6888662e3dc07a89d0bf5bd0a85854dac..c34409f5d480952f0eefcdcb2dfa140dd9ff60d6 100644 GIT binary patch delta 50 wcmdnP@{MJK6QimpgAao%11A)gFr+eMGZZtFFl2&pDnklGK11#$Ny&o&>l6 diff --git "a/lang/\320\240\321\203\321\201\321\201\320\272\320\270\320\271.txt" "b/lang/\320\240\321\203\321\201\321\201\320\272\320\270\320\271.txt" index f4a0f9b5a3118102aceee0e901e71a4ae1ab3585..aada4800f6621b25cb82878ecac6bea14b51125e 100644 GIT binary patch delta 53 zcmZ3+@_=Q78>6NtgAao%11A(Jv6!-0u{g3gvDmQ~v3RpsvM4aPuowVo>&d2!9|7*j B2&Vu5 delta 11 ScmaFBvW#Ve8{^~##s>fz@C14Q diff --git "a/lang/\346\227\245\346\234\254\350\252\236.txt" "b/lang/\346\227\245\346\234\254\350\252\236.txt" index 70a74a8c0f53d256274328c0b41e5d267423e8c5..b592c5ba8c369082350f32f7b8c4fcce047bc9aa 100644 GIT binary patch delta 41 scmaFHJcVV08KbNxgAao%11A(7Ggxb|)8K@`RfB~FOAKC5R%JX00NK3^M*si- delta 11 ScmbQj@{D#ti@&00a>L