diff --git a/.gitignore b/.gitignore index 27a1cc6..a3f37de 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,6 @@ Thumbs.db # 资源文件 *.res -*.ico \ No newline at end of file +*.ico + +# 打包文件 diff --git a/installer.nsi b/installer/installer.nsi similarity index 68% rename from installer.nsi rename to installer/installer.nsi index d723b92..4bc22eb 100644 --- a/installer.nsi +++ b/installer/installer.nsi @@ -3,7 +3,7 @@ ; Basic Information Name "Gobang Game" -OutFile "Gobang_Setup.exe" +OutFile "..\\Gobang_Setup.exe" InstallDir "$PROGRAMFILES\Gobang" RequestExecutionLevel admin @@ -22,41 +22,13 @@ RequestExecutionLevel admin Section "Main" SetOutPath "$INSTDIR" - ; Copy all C source files - File "ai.c" - File "config.c" - File "game_mode.c" - File "globals.c" - File "gobang.c" - File "init_board.c" - File "main.c" - File "network.c" - File "record.c" - File "ui.c" - - ; Copy all header files - File "ai.h" - File "config.h" - File "game_mode.h" - File "globals.h" - File "gobang.h" - File "init_board.h" - File "network.h" - File "record.h" - File "type.h" - File "ui.h" - ; Copy configuration and documentation files - File "gobang_config.ini" - File "README.md" - - ; Copy directories - File /r "MD" - File /r "TXT" + File "..\\gobang_config.ini" + File "..\\README.md" ; Copy executable file if exists - IfFileExists "gobang.exe" 0 +2 - File "gobang.exe" + IfFileExists "..\\gobang.exe" 0 +2 + File "..\\gobang.exe" ; Create program group directory CreateDirectory "$SMPROGRAMS\Gobang" @@ -80,4 +52,4 @@ Section "Uninstall" Delete "$DESKTOP\Gobang.lnk" RMDir /r "$SMPROGRAMS\Gobang" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Gobang" -SectionEnd \ No newline at end of file +SectionEnd diff --git a/installer/setup.iss b/installer/setup.iss new file mode 100644 index 0000000..0d86414 --- /dev/null +++ b/installer/setup.iss @@ -0,0 +1,57 @@ +; Inno Setup Script for Gobang Game +; Generated by Inno Setup Script Wizard + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +AppId={{A92AAE42-5C7E-4C8E-9F2B-8D4E5F6A7B8C} +AppName=Gobang Game +AppVersion=1.0 +AppPublisher=Gobang Game Developer +DefaultDirName={autopf}\Gobang +DefaultGroupName=Gobang Game +AllowNoIcons=yes +OutputDir=.. +OutputBaseFilename=Gobang_Setup +SetupIconFile=compiler:SetupClassicIcon.ico +Compression=lzma +SolidCompression=yes +WizardStyle=modern + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" +Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +; 可执行文件 +Source: "..\\gobang.exe"; DestDir: "{app}"; Flags: ignoreversion + +; 配置文件 +Source: "..\\gobang_config.ini"; DestDir: "{app}"; Flags: ignoreversion + +; 指定的TXT文件 +Source: "..\\TXT\\*"; DestDir: "{app}\TXT"; Flags: ignoreversion + +; 文档文件 +Source: "..\\README.md"; DestDir: "{app}"; Flags: ignoreversion + +[Dirs] +; 创建空的records目录(不包含存档文件) +Name: "{app}\records" + +[Icons] +Name: "{group}\Gobang Game"; Filename: "{app}\gobang.exe"; Check: FileExists(ExpandConstant('{app}\gobang.exe')) +Name: "{group}\{cm:UninstallProgram,Gobang Game}"; Filename: "{uninstallexe}" +Name: "{autodesktop}\Gobang Game"; Filename: "{app}\gobang.exe"; Tasks: desktopicon; Check: FileExists(ExpandConstant('{app}\gobang.exe')) + +[Run] +Filename: "{app}\gobang.exe"; Description: "{cm:LaunchProgram,Gobang Game}"; Flags: nowait postinstall skipifsilent; Check: FileExists(ExpandConstant('{app}\gobang.exe')) + +[Code] +function FileExists(const FileName: string): Boolean; +begin + Result := FileExists(FileName); +end; diff --git a/main.c b/main.c index 03604ae..e76ae62 100644 --- a/main.c +++ b/main.c @@ -8,8 +8,8 @@ * @detail gcc 为编译器,添加了-lws2_32链接Windows网络库 * @detail 编译指令:gcc -std=c17 -o gobang.exe *.c -lws2_32 * @detail 运行指令:.\gobang.exe - * @brief & "D:\Program Files (x86)\NSIS\makensis.exe" "d:\Code\doing_exercises\gobang\installer.nsi" - * @detail 安装指令:makensis installer.nsi + * @brief & "D:\Program Files (x86)\NSIS\makensis.exe" "installer\\installer.nsi" + * @brief & "D:\Program Files (x86)\Inno Setup 6\iscc.exe" installer\\setup.iss */ #include "game_mode.h" @@ -88,4 +88,4 @@ int main(int argc, char *argv[]) } return 0; -} \ No newline at end of file +}