diff --git a/ConsoleAlarm/1.txt b/1.txt similarity index 100% rename from ConsoleAlarm/1.txt rename to 1.txt diff --git a/ConsoleAlarm.sdf b/ConsoleAlarm.sdf deleted file mode 100644 index db64ca6..0000000 Binary files a/ConsoleAlarm.sdf and /dev/null differ diff --git a/ConsoleAlarm.sln b/ConsoleAlarm.sln deleted file mode 100644 index 2bb1b39..0000000 --- a/ConsoleAlarm.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleAlarm", "ConsoleAlarm\ConsoleAlarm.vcxproj", "{12348AEF-F571-4661-8CA5-8E4BB622ABF4}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {12348AEF-F571-4661-8CA5-8E4BB622ABF4}.Debug|Win32.ActiveCfg = Debug|Win32 - {12348AEF-F571-4661-8CA5-8E4BB622ABF4}.Debug|Win32.Build.0 = Debug|Win32 - {12348AEF-F571-4661-8CA5-8E4BB622ABF4}.Release|Win32.ActiveCfg = Release|Win32 - {12348AEF-F571-4661-8CA5-8E4BB622ABF4}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/ConsoleAlarm.v12.suo b/ConsoleAlarm.v12.suo deleted file mode 100644 index b72db06..0000000 Binary files a/ConsoleAlarm.v12.suo and /dev/null differ diff --git a/ConsoleAlarm/ConsoleAlarm.vcxproj b/ConsoleAlarm/ConsoleAlarm.vcxproj deleted file mode 100644 index 02e91a2..0000000 --- a/ConsoleAlarm/ConsoleAlarm.vcxproj +++ /dev/null @@ -1,84 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {12348AEF-F571-4661-8CA5-8E4BB622ABF4} - Win32Proj - ConsoleAlarm - - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - true - - - false - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/ConsoleAlarm/ConsoleAlarm.vcxproj.filters b/ConsoleAlarm/ConsoleAlarm.vcxproj.filters deleted file mode 100644 index 203a71c..0000000 --- a/ConsoleAlarm/ConsoleAlarm.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - 源文件 - - - \ No newline at end of file diff --git a/ConsoleAlarm/Debug/ConsoleAlarm.log b/ConsoleAlarm/Debug/ConsoleAlarm.log deleted file mode 100644 index a78c432..0000000 --- a/ConsoleAlarm/Debug/ConsoleAlarm.log +++ /dev/null @@ -1,26 +0,0 @@ -生成启动时间为 2020/4/27 星期一 9:45:57。 - 1>项目“C:\Users\Admin\documents\visual studio 2013\Projects\ConsoleAlarm\ConsoleAlarm\ConsoleAlarm.vcxproj”在节点 2 上(Build 个目标)。 - 1>ClCompile: - D:\EDownload\Visual Studio 2013 Ultimate\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt main.cpp - main.cpp - 1>c:\users\admin\documents\visual studio 2013\projects\consolealarm\consolealarm\main.cpp(97): warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details. - d:\edownload\visual studio 2013 ultimate\vc\include\conio.h(131) : 参见“getch”的声明 - 1>c:\users\admin\documents\visual studio 2013\projects\consolealarm\consolealarm\main.cpp(137): warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details. - d:\edownload\visual studio 2013 ultimate\vc\include\conio.h(131) : 参见“getch”的声明 - 1>c:\users\admin\documents\visual studio 2013\projects\consolealarm\consolealarm\main.cpp(144): warning C4129: “s”: 不可识别的字符转义序列 - 1>c:\users\admin\documents\visual studio 2013\projects\consolealarm\consolealarm\main.cpp(251): warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details. - d:\edownload\visual studio 2013 ultimate\vc\include\conio.h(131) : 参见“getch”的声明 - 1>c:\users\admin\documents\visual studio 2013\projects\consolealarm\consolealarm\main.cpp(280): warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details. - d:\edownload\visual studio 2013 ultimate\vc\include\conio.h(131) : 参见“getch”的声明 - 1>c:\users\admin\documents\visual studio 2013\projects\consolealarm\consolealarm\main.cpp(335): warning C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. - d:\edownload\visual studio 2013 ultimate\vc\include\time.inl(112) : 参见“localtime”的声明 - 1>c:\users\admin\documents\visual studio 2013\projects\consolealarm\consolealarm\main.cpp(411): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. - d:\edownload\visual studio 2013 ultimate\vc\include\stdio.h(283) : 参见“scanf”的声明 - Link: - D:\EDownload\Visual Studio 2013 Ultimate\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\Admin\documents\visual studio 2013\Projects\ConsoleAlarm\Debug\ConsoleAlarm.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\Users\Admin\documents\visual studio 2013\Projects\ConsoleAlarm\Debug\ConsoleAlarm.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\Admin\documents\visual studio 2013\Projects\ConsoleAlarm\Debug\ConsoleAlarm.lib" /MACHINE:X86 Debug\main.obj - ConsoleAlarm.vcxproj -> C:\Users\Admin\documents\visual studio 2013\Projects\ConsoleAlarm\Debug\ConsoleAlarm.exe - 1>已完成生成项目“C:\Users\Admin\documents\visual studio 2013\Projects\ConsoleAlarm\ConsoleAlarm\ConsoleAlarm.vcxproj”(Build 个目标)的操作。 - -生成成功。 - -已用时间 00:00:02.44 diff --git a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/CL.read.1.tlog b/ConsoleAlarm/Debug/ConsoleAlarm.tlog/CL.read.1.tlog deleted file mode 100644 index 1e53b08..0000000 Binary files a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/CL.read.1.tlog and /dev/null differ diff --git a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/CL.write.1.tlog b/ConsoleAlarm/Debug/ConsoleAlarm.tlog/CL.write.1.tlog deleted file mode 100644 index 2d8d980..0000000 Binary files a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/CL.write.1.tlog and /dev/null differ diff --git a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/ConsoleAlarm.lastbuildstate b/ConsoleAlarm/Debug/ConsoleAlarm.tlog/ConsoleAlarm.lastbuildstate deleted file mode 100644 index 6e702df..0000000 --- a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/ConsoleAlarm.lastbuildstate +++ /dev/null @@ -1,2 +0,0 @@ -#TargetFrameworkVersion=v4.0:PlatformToolSet=v120:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit -Debug|Win32|C:\Users\Admin\documents\visual studio 2013\Projects\ConsoleAlarm\| diff --git a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/cl.command.1.tlog b/ConsoleAlarm/Debug/ConsoleAlarm.tlog/cl.command.1.tlog deleted file mode 100644 index 54afbd7..0000000 Binary files a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/cl.command.1.tlog and /dev/null differ diff --git a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/link.command.1.tlog b/ConsoleAlarm/Debug/ConsoleAlarm.tlog/link.command.1.tlog deleted file mode 100644 index 0120163..0000000 Binary files a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/link.command.1.tlog and /dev/null differ diff --git a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/link.read.1.tlog b/ConsoleAlarm/Debug/ConsoleAlarm.tlog/link.read.1.tlog deleted file mode 100644 index 1e72588..0000000 Binary files a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/link.read.1.tlog and /dev/null differ diff --git a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/link.write.1.tlog b/ConsoleAlarm/Debug/ConsoleAlarm.tlog/link.write.1.tlog deleted file mode 100644 index 570791b..0000000 Binary files a/ConsoleAlarm/Debug/ConsoleAlarm.tlog/link.write.1.tlog and /dev/null differ diff --git a/ConsoleAlarm/Debug/main.obj b/ConsoleAlarm/Debug/main.obj deleted file mode 100644 index 382bcc3..0000000 Binary files a/ConsoleAlarm/Debug/main.obj and /dev/null differ diff --git a/ConsoleAlarm/Debug/vc120.idb b/ConsoleAlarm/Debug/vc120.idb deleted file mode 100644 index 2d5cf4e..0000000 Binary files a/ConsoleAlarm/Debug/vc120.idb and /dev/null differ diff --git a/ConsoleAlarm/Debug/vc120.pdb b/ConsoleAlarm/Debug/vc120.pdb deleted file mode 100644 index 0a4e3dc..0000000 Binary files a/ConsoleAlarm/Debug/vc120.pdb and /dev/null differ diff --git a/Debug/1.txt b/Debug/1.txt deleted file mode 100644 index e69de29..0000000 diff --git a/Debug/ConsoleAlarm.exe b/Debug/ConsoleAlarm.exe deleted file mode 100644 index 73c3786..0000000 Binary files a/Debug/ConsoleAlarm.exe and /dev/null differ diff --git a/Debug/ConsoleAlarm.ilk b/Debug/ConsoleAlarm.ilk deleted file mode 100644 index c9b3c65..0000000 Binary files a/Debug/ConsoleAlarm.ilk and /dev/null differ diff --git a/Debug/ConsoleAlarm.pdb b/Debug/ConsoleAlarm.pdb deleted file mode 100644 index 4732e72..0000000 Binary files a/Debug/ConsoleAlarm.pdb and /dev/null differ diff --git a/Debug/sth2.mp3 b/Debug/sth2.mp3 deleted file mode 100644 index 95abfc6..0000000 Binary files a/Debug/sth2.mp3 and /dev/null differ diff --git a/README.md b/README.md index 8065695..a022cd4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # Alarmcpp 闲着没事的时候做的C++控制台闹钟 +\fork者的愿望:实现多个铃声的读取,并将1.txt改为1.json diff --git a/ConsoleAlarm/main.cpp b/main.cpp similarity index 80% rename from ConsoleAlarm/main.cpp rename to main.cpp index 7997993..daa9e23 100644 --- a/ConsoleAlarm/main.cpp +++ b/main.cpp @@ -10,30 +10,33 @@ #include #pragma comment(lib,"winmm.lib") /* -еûд -кܶطдIJǺܺ -ӢдװX +fork者留言:我会尽力完善这个项目 +*/ +/* +这是我闲的没事乱写的 +有很多地方还写的不是很好 +用英语写纯属装X by Reiz VERSION:1.0 */ using namespace std; const char _space = ' '; -string filename;//ļ -string mpath;//ʾ· -int timeh;//ʱ -int timem;// -string atype;// -string msg1;//תʾϢ -wchar_t* msg2;//ʾ +string filename;//保存的文件名 +string mpath;//提示音路径 +int timeh;//时 +int timem;//分 +string atype;//闹钟类型 +string msg1;//待转换的提示信息 +wchar_t* msg2;//闹钟提示 -void hideCur()//ع +void hideCur()//隐藏光标 { CONSOLE_CURSOR_INFO cursor_info = { 1, 0 }; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info); } -void showCur()//ʾ +void showCur()//显示光标 { HANDLE h_GAME = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_CURSOR_INFO cursor_info; @@ -51,7 +54,7 @@ void SelectAlarm(); void SaveAlarm(); void selmenuref(); -wchar_t* mwstr;//bgm·תwchar_t* +wchar_t* mwstr;//bgm路径转换wchar_t*后变量 int main() { system("color f"); @@ -63,7 +66,7 @@ int main() return 0; } -void HomePage()//ҳ +void HomePage()//主页 { hideCur(); UseAlarm(); @@ -72,7 +75,7 @@ void HomePage()// char* mp2 = const_cast (mp1); size_t len = strlen(mp2) + 1; size_t converted = 0; - mwstr = (wchar_t*)malloc(len * sizeof(wchar_t));//string=> const char*=> char*=>wchar_t* + mwstr = (wchar_t*)malloc(len * sizeof(wchar_t));//这是string=> const char*=> char*=>wchar_t*了 mbstowcs_s(&converted, mwstr, len, mp2, _TRUNCATE); const char* temp = msg1.c_str(); @@ -84,7 +87,7 @@ void HomePage()// system("cls"); system("color a"); - char ch;//µļ + char ch;//按下的键 printf("\n\n%35cWelcome to use the Console Alarm\n",_space); printf("%35cWhat are You going to do?\n",_space); //system("pause"); @@ -94,7 +97,7 @@ void HomePage()// printf("\n%35c[E] Exit\n",_space); while (1) { - ch = getch();//ж + ch = getch();//判断输入 if (ch == 'c') { printf("Create a Alarm\n"); @@ -119,7 +122,7 @@ void HomePage()// } } -void CreateAlarm()// +void CreateAlarm()//创建闹钟 { char chh; int IsLoop = 1; @@ -135,13 +138,13 @@ void CreateAlarm()// while (IsLoop) { chh = getch(); - if (chh == 'm')//ӵBGM + if (chh == 'm')//闹钟的BGM { IsLoop = 0; system("cls"); //char path[100]; showCur(); - printf("Please Type Your WAV music path here(type 'back' can back)\nlike this d:\\\\\sth2.wav\nType the path:"); + printf("Please Type Your WAV music path here(type 'back' can back)\nlike this “d:\\\\\sth2.wav”\nType the path:"); cin >> mpath; if (mpath == "") @@ -171,7 +174,7 @@ void CreateAlarm()// } - else if (chh == 't')//ʱ + else if (chh == 't')//设置闹钟时间 { IsLoop = 0; system("cls"); @@ -186,7 +189,7 @@ void CreateAlarm()// Sleep(1000); CreateAlarm(); } - else if (chh == 's')// + else if (chh == 's')//设置闹钟类型 { IsLoop = 0; showCur(); @@ -207,7 +210,7 @@ void CreateAlarm()// } } - else if (chh == 'o')// + else if (chh == 'o')//保存 { IsLoop = 0; SaveAlarm(); @@ -216,7 +219,7 @@ void CreateAlarm()// Sleep(1000); HomePage(); } - else if (chh == 'e')//ʾϢ + else if (chh == 'e')//设置提示信息 { showCur(); system("cls"); @@ -232,7 +235,7 @@ void CreateAlarm()// CreateAlarm(); } - else if (chh == 'b')//ҳ + else if (chh == 'b')//返回主页 { IsLoop = 0; HomePage(); @@ -241,7 +244,7 @@ void CreateAlarm()// } } -void DelAlarm()//ɾ +void DelAlarm()//删除 { char ch; system("cls"); @@ -268,7 +271,7 @@ void DelAlarm()//ɾ } } -void SelectAlarm()//ѡӵIJ˵ +void SelectAlarm()//选择闹钟的菜单 { char ch; system("cls"); @@ -305,10 +308,10 @@ void SelectAlarm()//ѡ } } -void UseAlarm()//ȡ +void UseAlarm()//读取闹钟 { fstream fs; - fs.open("1.txt", ios::in);//1 + fs.open("1.txt", ios::in);//打开1 if (fs.fail()) { ofstream txt("1.txt"); @@ -316,23 +319,23 @@ void UseAlarm()// } string th; string tm; - getline(fs, mpath);//ȡļ music path line:1 - getline(fs, atype);// alarm typeӸʽ line:2 - getline(fs,th = to_string (timeh));//ʱ hour line:3 - getline(fs,tm = to_string(timem));// ʱ minutes line:4 - timeh = atoi(th.c_str());//string ת char*תint + getline(fs, mpath);//读取文件 music path line:1 + getline(fs, atype);// alarm type闹钟格式 line:2 + getline(fs,th = to_string (timeh));//时间 hour line:3 + getline(fs,tm = to_string(timem));// 时间 minutes line:4 + timeh = atoi(th.c_str());//string 转 char*再转换int timem = atoi(tm.c_str()); fs.close(); } -void StartA()//ʼӵBGM͵ +void StartA()//开始播放闹钟的BGM和弹出窗口 { - time_t t; //ʱ - tm* local; //ʱ + time_t t; //秒时间 + tm* local; //本地时间 char buf[128] = { 0 }; - t = time(NULL); //ȡĿǰʱ - local = localtime(&t); //תΪʱ + t = time(NULL); //获取目前秒时间 + local = localtime(&t); //转为本地时间 strftime(buf, 64, "%Y-%m-%d %H:%M:%S", local); system("cls&&color a"); @@ -377,7 +380,7 @@ void StartA()// } } -void SaveAlarm()// +void SaveAlarm()//保存闹钟 { fstream fst; fst.open("1.txt",ios::out); @@ -385,11 +388,11 @@ void SaveAlarm()// system("cls"); if (!fst) { - printf("ļʧܣ\n"); + printf("文件打开失败!\n"); } else { - //line:1 mpath + //line:1 mpath变量保存 fst << mpath << endl; //line:2 atype fst << atype << endl; @@ -401,7 +404,7 @@ void SaveAlarm()// } -void selmenuref()//ѡѡж +void selmenuref()//选择闹钟选项判断 { showCur(); int input = 1; @@ -430,4 +433,4 @@ void selmenuref()//ѡ printf("Type ERROR!\n"); } } -} \ No newline at end of file +} diff --git a/ConsoleAlarm/sth2.mp3 b/sth2.mp3 similarity index 100% rename from ConsoleAlarm/sth2.mp3 rename to sth2.mp3