Skip to content

Commit 2052cb5

Browse files
author
Leviscus Tempris
committed
Package project #38
1 parent f9ac94d commit 2052cb5

19 files changed

+234
-125
lines changed

Content/Image/Brand/Icon16.png

982 Bytes
Loading

Icon.ico

159 KB
Binary file not shown.

LICENSE.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2024 James Steele Seeley
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Script/Package/Win64/T_Side.bmp

151 KB
Binary file not shown.

Script/Package/Win64/T_Side.pdn

112 KB
Binary file not shown.

Script/Package/Win64/install.nsi

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
; Include Modern UI 2
2+
!include MUI2.nsh
3+
4+
; Define name
5+
!define PROJECT_NAME_FULL "Tic-Tac-Gone"
6+
!define PROJECT_NAME_SHORT "TicTacGone"
7+
!define PUBLISHER_NAME_FULL "James Steele Seeley"
8+
!define COPYRIGHT_YEAR "2024"
9+
!define PROJECT_ROOT "..\..\..\"
10+
11+
; Define project version number
12+
!define PROJECT_VERSION_SHORT "2.0"
13+
!define PROJECT_VERSION_FULL "2.0.0.0"
14+
15+
; Define installer version number
16+
!define INSTALLER_VERSION "2.0.0.0"
17+
18+
!define INSTALLER_FILENAME "${PROJECT_NAME_SHORT}_${PROJECT_VERSION_SHORT}_Win64_Install.exe"
19+
20+
Name "${PROJECT_NAME_FULL} ${PROJECT_VERSION_SHORT}"
21+
OutFile "${PROJECT_ROOT}Release/${INSTALLER_FILENAME}"
22+
23+
InstallDir "$PROGRAMFILES64\${PROJECT_NAME_FULL}"
24+
InstallDirRegKey HKLM "Software\${PROJECT_NAME_SHORT}" "Install_Dir"
25+
26+
SetCompressor /SOLID lzma
27+
XPStyle on
28+
29+
; MUI settings
30+
!define MUI_ABORTWARNING
31+
!define MUI_ICON "${PROJECT_ROOT}Icon.ico"
32+
!define MUI_UNICON "${PROJECT_ROOT}Icon.ico"
33+
34+
; Custom image for the installer
35+
!define MUI_WELCOMEFINISHPAGE_BITMAP "T_Side.bmp"
36+
37+
; Welcome page
38+
!insertmacro MUI_PAGE_WELCOME
39+
40+
; License page
41+
!insertmacro MUI_PAGE_LICENSE "${PROJECT_ROOT}LICENSE.txt"
42+
43+
; Components page
44+
!insertmacro MUI_PAGE_COMPONENTS
45+
46+
; Directory page
47+
!insertmacro MUI_PAGE_DIRECTORY
48+
49+
; Instfiles page
50+
!insertmacro MUI_PAGE_INSTFILES
51+
52+
; Finish page
53+
!insertmacro MUI_PAGE_FINISH
54+
55+
; Uninstaller pages
56+
!insertmacro MUI_UNPAGE_CONFIRM
57+
!insertmacro MUI_UNPAGE_INSTFILES
58+
59+
; Language files
60+
!insertmacro MUI_LANGUAGE "English"
61+
62+
; Installer properties
63+
VIProductVersion "${INSTALLER_VERSION}"
64+
VIAddVersionKey /LANG=1033 "ProductName" "${PROJECT_NAME_FULL}"
65+
VIAddVersionKey /LANG=1033 "FileDescription" "${PROJECT_NAME_FULL} Installer"
66+
VIAddVersionKey /LANG=1033 "CompanyName" "${PUBLISHER_NAME_FULL}"
67+
VIAddVersionKey /LANG=1033 "LegalCopyright" "(c) ${COPYRIGHT_YEAR} ${PUBLISHER_NAME_FULL}"
68+
VIAddVersionKey /LANG=1033 "FileVersion" "${INSTALLER_VERSION}"
69+
VIAddVersionKey /LANG=1033 "ProductVersion" "${PROJECT_VERSION_FULL}"
70+
VIAddVersionKey /LANG=1033 "OriginalFilename" "${INSTALLER_FILENAME}"
71+
VIAddVersionKey /LANG=1033 "InternalName" "${PROJECT_NAME_SHORT}_Installer"
72+
73+
Section "${PROJECT_NAME_FULL} (required)" SecMain
74+
SectionIn RO
75+
76+
SetOutPath $INSTDIR
77+
78+
File /r "${PROJECT_ROOT}x64\Release\*.*"
79+
File "${PROJECT_ROOT}LICENSE.txt"
80+
File "${PROJECT_ROOT}Icon.ico"
81+
82+
WriteRegStr HKLM "SOFTWARE\${PROJECT_NAME_SHORT}" "Install_Dir" "$INSTDIR"
83+
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROJECT_NAME_SHORT}" "DisplayName" "${PROJECT_NAME_FULL}"
84+
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROJECT_NAME_SHORT}" "DisplayVersion" "${PROJECT_VERSION_SHORT}"
85+
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROJECT_NAME_SHORT}" "Publisher" "${PUBLISHER_NAME_FULL}"
86+
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROJECT_NAME_SHORT}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
87+
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROJECT_NAME_SHORT}" "DisplayIcon" "$INSTDIR\Icon.ico"
88+
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROJECT_NAME_SHORT}" "NoModify" 1
89+
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROJECT_NAME_SHORT}" "NoRepair" 1
90+
91+
WriteUninstaller "uninstall.exe"
92+
SectionEnd
93+
94+
Section "Start Menu Shortcuts" SecShortcutsStart
95+
CreateDirectory "$SMPROGRAMS\${PROJECT_NAME_FULL}"
96+
97+
SetOutPath "$INSTDIR"
98+
99+
; Add the start menu shortcuts
100+
CreateShortCut "$SMPROGRAMS\${PROJECT_NAME_FULL}\${PROJECT_NAME_FULL}.lnk" "$INSTDIR\${PROJECT_NAME_SHORT}.exe" "" "$INSTDIR\${PROJECT_NAME_SHORT}.exe" 0 SW_SHOWMINIMIZED
101+
CreateShortCut "$SMPROGRAMS\${PROJECT_NAME_FULL}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
102+
SectionEnd
103+
104+
Section "Desktop Shortcut" SecShortcutsDesktop
105+
CreateShortCut "$DESKTOP\${PROJECT_NAME_FULL}.lnk" "$INSTDIR\${PROJECT_NAME_SHORT}.exe" "" "$INSTDIR\${PROJECT_NAME_SHORT}.exe" 0
106+
SectionEnd
107+
108+
; Component descriptions
109+
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
110+
!insertmacro MUI_DESCRIPTION_TEXT ${SecMain} "Main installation of ${PROJECT_NAME_FULL}"
111+
!insertmacro MUI_DESCRIPTION_TEXT ${SecShortcutsStart} "Create Start Menu shortcuts"
112+
!insertmacro MUI_DESCRIPTION_TEXT ${SecShortcutsDesktop} "Create Desktop shortcut"
113+
!insertmacro MUI_FUNCTION_DESCRIPTION_END
114+
115+
Section "Uninstall"
116+
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROJECT_NAME_SHORT}"
117+
DeleteRegKey HKLM "SOFTWARE\${PROJECT_NAME_SHORT}"
118+
119+
RMDir /r "$SMPROGRAMS\${PROJECT_NAME_FULL}"
120+
RMDir /r "$INSTDIR"
121+
Delete "$DESKTOP\${PROJECT_NAME_FULL}.lnk"
122+
SectionEnd

_Develop/Image/Brand/PNGToICO.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from PIL import Image
2+
3+
def create_multi_layer_ico(input_png_path, output_ico_path, icon_sizes=(256, 128, 64, 48, 32, 16)):
4+
# Load the original PNG image
5+
image = Image.open(input_png_path)
6+
7+
# Create a list to hold the icon images
8+
icon_images = []
9+
10+
# Generate the different sizes for the icon
11+
for size in icon_sizes:
12+
# Resize the image to the current size using the LANCZOS resampling algorithm
13+
icon_image = image.resize((size, size), Image.Resampling.LANCZOS)
14+
icon_images.append(icon_image)
15+
16+
# Save the icon images as a single ICO file
17+
icon_images[0].save(output_ico_path, format='ICO', sizes=[(img.width, img.height) for img in icon_images])
18+
19+
# Usage
20+
create_multi_layer_ico('Icon.png', 'Icon.ico')

game-tic-tac-gone.rc

3.19 KB
Binary file not shown.

game-tic-tac-toe-bananza.vcxproj

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<ProjectGuid>{cba5b4aa-4dd8-4459-8aed-4cb719321ea1}</ProjectGuid>
2525
<RootNamespace>gametictactoebananza</RootNamespace>
2626
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
<ProjectName>game-tic-tac-gone</ProjectName>
2728
</PropertyGroup>
2829
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2930
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -146,6 +147,7 @@
146147
<ClCompile Include="src\Window.cpp" />
147148
</ItemGroup>
148149
<ItemGroup>
150+
<ClInclude Include="resource.h" />
149151
<ClInclude Include="src\AI.h" />
150152
<ClInclude Include="src\Button.h" />
151153
<ClInclude Include="src\IAI.h" />
@@ -161,6 +163,12 @@
161163
<ClInclude Include="src\UI.h" />
162164
<ClInclude Include="src\Window.h" />
163165
</ItemGroup>
166+
<ItemGroup>
167+
<ResourceCompile Include="game-tic-tac-gone.rc" />
168+
</ItemGroup>
169+
<ItemGroup>
170+
<Image Include="Icon.ico" />
171+
</ItemGroup>
164172
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
165173
<ImportGroup Label="ExtensionTargets">
166174
</ImportGroup>

game-tic-tac-toe-bananza.vcxproj.filters

+13
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,18 @@
9797
<ClInclude Include="src\IGrid.h">
9898
<Filter>src</Filter>
9999
</ClInclude>
100+
<ClInclude Include="resource.h">
101+
<Filter>Header Files</Filter>
102+
</ClInclude>
103+
</ItemGroup>
104+
<ItemGroup>
105+
<ResourceCompile Include="game-tic-tac-gone.rc">
106+
<Filter>Resource Files</Filter>
107+
</ResourceCompile>
108+
</ItemGroup>
109+
<ItemGroup>
110+
<Image Include="Icon.ico">
111+
<Filter>Resource Files</Filter>
112+
</Image>
100113
</ItemGroup>
101114
</Project>

resource.h

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//{{NO_DEPENDENCIES}}
2+
// Microsoft Visual C++ generated include file.
3+
// Used by game-tic-tac-gone.rc
4+
//
5+
#define IDI_ICON1 101
6+
7+
// Next default values for new objects
8+
//
9+
#ifdef APSTUDIO_INVOKED
10+
#ifndef APSTUDIO_READONLY_SYMBOLS
11+
#define _APS_NEXT_RESOURCE_VALUE 102
12+
#define _APS_NEXT_COMMAND_VALUE 40001
13+
#define _APS_NEXT_CONTROL_VALUE 1001
14+
#define _APS_NEXT_SYMED_VALUE 101
15+
#endif
16+
#endif

src/Grid.cpp

+26-65
Original file line numberDiff line numberDiff line change
@@ -179,76 +179,37 @@ void Grid::draw(sf::RenderWindow& window, bool canHover) const {
179179
line.setSize(sf::Vector2f(cellSize * gridSize, 8)); // Reset size for horizontal lines
180180
}
181181

182-
bool drawText = false;
183-
184-
if (drawText) {
185-
sf::Text text;
186-
text.setFont(Resource::getInstance().getFont());
187-
text.setCharacterSize(static_cast<unsigned int>(cellSize * 0.8f));
188-
for (int i = 0; i < gridSize; ++i) {
189-
for (int j = 0; j < gridSize; ++j) {
190-
PlayerType cell = getCell(i, j);
191-
if (cell != PlayerType::None) {
192-
text.setString(cell == PlayerType::Player1 ? "X" : "O");
193-
194-
auto& playerDeque = (cell == PlayerType::Player1) ? lastThreeCellsPlayer1 : lastThreeCellsPlayer2;
195-
if (playerDeque.size() == 3 && playerDeque.front().first == i && playerDeque.front().second == j) {
196-
// Apply half brightness to the third oldest cell
197-
text.setFillColor((cell == PlayerType::Player1 ? sf::Color(255, 0, 0, 128) : sf::Color(0, 0, 255, 128)));
198-
}
199-
else {
200-
// Full brightness for other cells
201-
text.setFillColor(cell == PlayerType::Player1 ? sf::Color::Red : sf::Color::Blue);
202-
}
203-
204-
// Calculate the bounding box of the text
205-
sf::FloatRect textRect = text.getLocalBounds();
206-
text.setOrigin(textRect.left + textRect.width * 0.5f, textRect.top + textRect.height * 0.5f);
207-
208-
// Set the position of the text to be centered in the cell
209-
text.setPosition(
210-
offsetX + j * cellSize + cellSize * 0.5f,
211-
offsetY + i * cellSize + cellSize * 0.5f
212-
);
213-
214-
window.draw(text);
182+
sf::Sprite sprite;
183+
float padding = 30.0f; // Padding of 30 pixels on each side
184+
for (int i = 0; i < gridSize; ++i) {
185+
for (int j = 0; j < gridSize; ++j) {
186+
PlayerType cell = getCell(i, j);
187+
if (cell != PlayerType::None) {
188+
if (cell == PlayerType::Player1) {
189+
sprite.setTexture(Resource::getInstance().getXTexture());
190+
}
191+
else if (cell == PlayerType::Player2) {
192+
sprite.setTexture(Resource::getInstance().getOTexture());
215193
}
216-
}
217-
}
218-
}
219-
else {
220-
sf::Sprite sprite;
221-
float padding = 30.0f; // Padding of 30 pixels on each side
222-
for (int i = 0; i < gridSize; ++i) {
223-
for (int j = 0; j < gridSize; ++j) {
224-
PlayerType cell = getCell(i, j);
225-
if (cell != PlayerType::None) {
226-
if (cell == PlayerType::Player1) {
227-
sprite.setTexture(Resource::getInstance().getXTexture());
228-
}
229-
else if (cell == PlayerType::Player2) {
230-
sprite.setTexture(Resource::getInstance().getOTexture());
231-
}
232194

233-
// Set half transparency for the third oldest cell
234-
auto& playerDeque = (cell == PlayerType::Player1) ? lastThreeCellsPlayer1 : lastThreeCellsPlayer2;
235-
if (!classic && playerDeque.size() == 3 && std::make_pair(i, j) == playerDeque.front()) {
236-
sprite.setColor(sf::Color(255, 255, 255, 128)); // Half transparent
237-
}
238-
else {
239-
sprite.setColor(sf::Color(255, 255, 255, 255)); // Fully opaque
240-
}
195+
// Set half transparency for the third oldest cell
196+
auto& playerDeque = (cell == PlayerType::Player1) ? lastThreeCellsPlayer1 : lastThreeCellsPlayer2;
197+
if (!classic && playerDeque.size() == 3 && std::make_pair(i, j) == playerDeque.front()) {
198+
sprite.setColor(sf::Color(255, 255, 255, 128)); // Half transparent
199+
}
200+
else {
201+
sprite.setColor(sf::Color(255, 255, 255, 255)); // Fully opaque
202+
}
241203

242-
// Adjust position and scale for padding
243-
float paddedPositionX = offsetX + j * cellSize + padding / 2;
244-
float paddedPositionY = offsetY + i * cellSize + padding / 2;
245-
float paddedCellSize = cellSize - padding; // Reduce cell size by padding on both sides
204+
// Adjust position and scale for padding
205+
float paddedPositionX = offsetX + j * cellSize + padding / 2;
206+
float paddedPositionY = offsetY + i * cellSize + padding / 2;
207+
float paddedCellSize = cellSize - padding; // Reduce cell size by padding on both sides
246208

247-
sprite.setPosition(paddedPositionX, paddedPositionY);
248-
sprite.setScale(paddedCellSize / sprite.getLocalBounds().width, paddedCellSize / sprite.getLocalBounds().height);
209+
sprite.setPosition(paddedPositionX, paddedPositionY);
210+
sprite.setScale(paddedCellSize / sprite.getLocalBounds().width, paddedCellSize / sprite.getLocalBounds().height);
249211

250-
window.draw(sprite);
251-
}
212+
window.draw(sprite);
252213
}
253214
}
254215
}

0 commit comments

Comments
 (0)