#include #include #include #include #include #include #include #include #include #include #include #include #include"bass.h" #pragma comment(lib, "bass.lib") #pragma comment(lib, "urlmon.lib") enum TEST_MODE { NORMAL, BLACKLIST, RANGE }; #ifndef __DEBUG inline std::wstring s2ws(const std::string& s) { int len; int slength = (int)s.length() + 1; len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0); std::wstring r(len, L'\0'); MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, &r[0], len); return r; } #endif void Quit() { BASS_Free(); CoUninitialize(); std::cout<<"Nacisnij przycisk, aby zakonczyc dzialanie programu!"<& WordsEng, std::vector& WordsPol, std::deque& isSound, std::deque& blackList) { if (nIndex < nAmount) { WordsEng.erase(WordsEng.begin() + nIndex); WordsPol.erase(WordsPol.begin() + nIndex); isSound.erase(isSound.begin() + nIndex); blackList.erase(blackList.begin() + nIndex); --nAmount; } else std::cout<<">>Nie ma slowka z takim numerem!"<& isSound) { FuckS(sWord); std::string sUrl = "http://www.diki.pl/images/en/mp3/"+ sWord + ".mp3"; std::string sDest = "Sounds/"+ sWord + ".mp3"; HRESULT result = URLDownloadToFile(NULL, s2ws(sUrl).c_str(), s2ws(sDest).c_str(), 0, NULL ); //HRESULT result = URLDownloadToFile(NULL, sUrl.c_str(), sDest.c_str(), 0, NULL); if (sFunc == "AddW") isSound.push_back(result == S_OK); } void PlayS(std::string sWord) { FuckS(sWord); std::string sPath = "Sounds/"+ sWord + ".mp3"; HSTREAM stream = BASS_StreamCreateFile(FALSE, sPath.c_str(), 0, 0, 0); BASS_ChannelPlay(stream, FALSE); Sleep(1500); BASS_StreamFree(stream); } void AddW(const std::string& sWordEng, const std::string& sWordPol, void (*pfDownloadS)(std::string, std::string, std::deque&), unsigned& nAmount, std::vector& WordsEng, std::vector& WordsPol, std::deque& isSound, std::deque& blackList) { ++nAmount; WordsEng.push_back(sWordEng); WordsPol.push_back(sWordPol); blackList.push_back(false); pfDownloadS(sWordEng, __FUNCTION__, isSound); } void LoadW(unsigned& nAmount, std::vector& WordsEng, std::vector& WordsPol, std::deque& isSound, std::deque& blackList, void(*pfQuit)()) { std::fstream file; std::string sTemp = ""; file.open("vocabulary.txt", std::ios::in); while (!file.eof()) { std::getline(file, sTemp); ++nAmount; if (sTemp == "") { --nAmount; continue; } else if (!(nAmount%2==0)) WordsEng.push_back(sTemp); else WordsPol.push_back(sTemp); } nAmount /= 2; file.close(); file.clear(); file.open("sounds.txt", std::ios::in); while (!file.eof()) { std::getline(file, sTemp); if (sTemp == "") continue; isSound.push_back(sTemp != "0"); } file.close(); file.clear(); file.open("blacklist.txt", std::ios::in); while (!file.eof()) { std::getline(file, sTemp); if (sTemp == "") continue; blackList.push_back(sTemp != "0"); } file.close(); file.clear(); if (WordsEng.size() != nAmount) { std::cout<<">>UWAGA! BLEDNA ILOSC SLOWEK (ENG)!"<>UWAGA! BLEDNA ILOSC SLOWEK (POL)!"<>UWAGA! BLEDNA ILOSC DZWIEKOW!"<>UWAGA! BLEDNA ILOSC SLOWEK (BL)!"<& WordsEng, std::vector& WordsPol, std::deque& isSound, std::deque& blackList) { std::ofstream file; file.open("vocabulary.txt"); for (unsigned i = 0; i& WordsEng, std::vector& WordsPol, std::deque& isSound, std::deque& blackList) { std::string sWord; unsigned nMode = 0, nGood = 0, nCount = 0, nCountT = 0; std::vector vuIndex; if (nAmountOfWords == 0 ) nCount = nAmount; else nCount = nAmountOfWords; nCountT = nCount; for (unsigned i = nRangeFrom; i>Co oznacza: "<>Test przerwany!"<>Bardzo dobrze!"<>Zle! To slowko oznacza: "<>Podaj angielskie slowko oznaczajace: "<>Test przerwany!"<>Bardzo dobrze!"<>Zle! Chodzilo mi o slowko: "<>Jakie slowko slyszysz?"<>Test przerwany!"<>Bardzo dobrze!"<>Zle!"<>Jakie slowko slyszysz?"<>Test przerwany!"<>Bardzo dobrze!"<>Zle!"<>A co oznacza to slowko po polsku?"<>Test przerwany!"<>Bardzo dobrze!"<>Zle!"<>Jakie slowko slyszysz?"<>Test przerwany!"<>Bardzo dobrze!"<>Zle!"<>Nie ma takiego trybu!"<>Wynik testu: "<(time(NULL))); DeleteMenu(GetSystemMenu(GetConsoleWindow(), FALSE), 6, MF_BYPOSITION); BASS_Init(-1, 44100, 0, GetConsoleWindow(), NULL); CoInitializeEx(0, NULL); std::vector WordsEng, WordsPol; std::deque isSound, blackList; unsigned nAmount; WordsEng.clear(); WordsPol.clear(); isSound.clear(); nAmount = 0; LoadW(nAmount, WordsEng, WordsPol, isSound, blackList, Quit); char cChoice; std::string sWordEng = "", sWordPol = "", sInput = ""; TEST_MODE eType; unsigned nRangeFrom, nRangeTo, nAmountOfWords, nIndex; for (;;) { std::cout <<"=============================="<>cChoice; std::cin.ignore(); switch (cChoice) { case '1': std::cout<<">>Wpisz x aby przerwac!"<>Wpisz slowko: "; std::getline(std::cin, sWordEng); DownloadS(sWordEng, __FUNCTION__, isSound); PlayS(sWordEng); break; case '3': std::cout <<">>Wybierz zrodlo slownictwa:"<>cChoice; std::cin.ignore(); switch(cChoice) { case '1': std::cout<<">>Ilosc slowek: "; std::getline(std::cin, sInput); nAmountOfWords = Numberize(sInput); if(nAmountOfWords == -1) continue; nRangeFrom = 0; nRangeTo = nAmount; if (nAmountOfWords > nAmount) { std::cout<<">>Blad! Nie ma tylu slowek w bazie!"<>Zakres..."<>Blad! Ujemna ilosc slowek!"< nAmount || nRangeTo > nAmount) { std::cout<<">>Blad! Nie ma slowek o takich indeksach!"<>Blad!"<>Wybierz forme testu:"< pol"< ang"< ang"< ang -> pol"< pol"<>cChoice; std::cin.ignore(); std::cout<>cChoice; std::cin.ignore(); switch (cChoice) { case '1': std::cout<<">>Ktore slowko chcesz usunac? "; std::getline(std::cin, sInput); nIndex = Numberize(sInput); RemoveW(nIndex-1, nAmount, WordsEng, WordsPol, isSound, blackList); break; case '2': break; default: std::cout<<">>Nie ma takiej opcji!"<