Skip to content

Commit df39a6c

Browse files
committed
-WIP achievements and stats
-Now, the touchscreen controls will be tied to the gui scale -Now, the touchscreen texture will fit better with the other gui elements -Fixed `Material::m_bTranslucent` not being initialized -Fixed BlockRegionUpdatePacket causing crashes between platforms
1 parent 09488e6 commit df39a6c

32 files changed

Lines changed: 521 additions & 105 deletions

game/assets/gui/touchscreen.png

-5.86 KB
Loading

platforms/windows/minecraftcpp.sln

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 18
4-
VisualStudioVersion = 18.1.11312.151 d18.0
4+
VisualStudioVersion = 18.1.11312.151
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZLib", "projects\ZLib\ZLib.vcxproj", "{5DA292FD-FA40-45D8-900A-6652C9662913}"
77
EndProject
@@ -17,6 +17,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "World", "projects\World\Wor
1717
EndProject
1818
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Client", "projects\Client\Client.vcxproj", "{A6E03DCA-99F6-45B8-800D-73060AE407FC}"
1919
EndProject
20+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Stats", "projects\Stats\Stats.vcxproj", "{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}"
21+
EndProject
2022
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinecraftClient.Win32", "projects\MinecraftClient.Win32\MinecraftClient.Win32.vcxproj", "{FF5A623D-03C2-4967-8E78-CB021114A501}"
2123
EndProject
2224
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinecraftClient.SDL2", "projects\MinecraftClient.SDL2\MinecraftClient.SDL2.vcxproj", "{5C1CE194-2DC6-441D-96F5-9780D0A10AAB}"
@@ -137,6 +139,22 @@ Global
137139
{A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release|x64.Build.0 = Release|x64
138140
{A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release|x86.ActiveCfg = Release|Win32
139141
{A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release|x86.Build.0 = Release|Win32
142+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Debug_SDL2|x64.ActiveCfg = Debug|x64
143+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Debug_SDL2|x64.Build.0 = Debug|x64
144+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Debug_SDL2|x86.ActiveCfg = Debug|Win32
145+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Debug_SDL2|x86.Build.0 = Debug|Win32
146+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Debug|x64.ActiveCfg = Debug|x64
147+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Debug|x64.Build.0 = Debug|x64
148+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Debug|x86.ActiveCfg = Debug|Win32
149+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Debug|x86.Build.0 = Debug|Win32
150+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Release_SDL2|x64.ActiveCfg = Release|x64
151+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Release_SDL2|x64.Build.0 = Release|x64
152+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Release_SDL2|x86.ActiveCfg = Release|Win32
153+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Release_SDL2|x86.Build.0 = Release|Win32
154+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Release|x64.ActiveCfg = Release|x64
155+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Release|x64.Build.0 = Release|x64
156+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Release|x86.ActiveCfg = Release|Win32
157+
{73E3C8DC-6660-4F24-9CE6-35C4ABA3FA5E}.Release|x86.Build.0 = Release|Win32
140158
{FF5A623D-03C2-4967-8E78-CB021114A501}.Debug_SDL2|x64.ActiveCfg = Debug|x64
141159
{FF5A623D-03C2-4967-8E78-CB021114A501}.Debug_SDL2|x86.ActiveCfg = Debug|Win32
142160
{FF5A623D-03C2-4967-8E78-CB021114A501}.Debug|x64.ActiveCfg = Debug|x64

platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
<ProjectReference Include="..\Client\Client.vcxproj">
8181
<Project>{a6e03dca-99f6-45b8-800d-73060ae407fc}</Project>
8282
</ProjectReference>
83+
<ProjectReference Include="..\Stats\Stats.vcxproj">
84+
<Project>{73e3c8dc-6660-4f24-9ce6-35c4aba3fa5e}</Project>
85+
</ProjectReference>
8386
<ProjectReference Include="..\Common\Common.vcxproj">
8487
<Project>{71774270-fd1b-4269-bd8f-f75a52d43eb6}</Project>
8588
</ProjectReference>

platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585
<ProjectReference Include="..\Client\Client.vcxproj">
8686
<Project>{a6e03dca-99f6-45b8-800d-73060ae407fc}</Project>
8787
</ProjectReference>
88+
<ProjectReference Include="..\Stats\Stats.vcxproj">
89+
<Project>{73e3c8dc-6660-4f24-9ce6-35c4aba3fa5e}</Project>
90+
</ProjectReference>
8891
<ProjectReference Include="..\Common\Common.vcxproj">
8992
<Project>{71774270-fd1b-4269-bd8f-f75a52d43eb6}</Project>
9093
</ProjectReference>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<ItemGroup>
22+
<ClInclude Include="$(MC_ROOT)\source\stats\Achievement.hpp" />
23+
<ClInclude Include="$(MC_ROOT)\source\stats\Achievements.hpp" />
24+
<ClInclude Include="$(MC_ROOT)\source\stats\Stat.hpp" />
25+
<ClInclude Include="$(MC_ROOT)\source\stats\StatFormatter.hpp" />
26+
</ItemGroup>
27+
<ItemGroup>
28+
<ClCompile Include="$(MC_ROOT)\source\stats\Achievement.cpp" />
29+
<ClCompile Include="$(MC_ROOT)\source\stats\Achievements.cpp" />
30+
<ClCompile Include="$(MC_ROOT)\source\stats\Stat.cpp" />
31+
<ClCompile Include="$(MC_ROOT)\source\stats\StatFormatter.cpp" />
32+
</ItemGroup>
33+
<PropertyGroup Label="Globals">
34+
<VCProjectVersion>17.0</VCProjectVersion>
35+
<Keyword>Win32Proj</Keyword>
36+
<ProjectGuid>{73e3c8dc-6660-4f24-9ce6-35c4aba3fa5e}</ProjectGuid>
37+
<RootNamespace>Stats</RootNamespace>
38+
<ProjectName>Stats</ProjectName>
39+
<ConfigurationType>StaticLibrary</ConfigurationType>
40+
</PropertyGroup>
41+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
42+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
43+
<ImportGroup Label="ExtensionSettings">
44+
</ImportGroup>
45+
<ImportGroup Label="Shared">
46+
</ImportGroup>
47+
<ImportGroup Label="Minecraft">
48+
<Import Project="../Directory.Build.props" Condition="'$(MC_GLOBAL_PROPS)'==''" />
49+
</ImportGroup>
50+
<PropertyGroup Label="UserMacros" />
51+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
52+
<ImportGroup Label="ExtensionTargets">
53+
</ImportGroup>
54+
</Project>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
</Filter>
7+
<Filter Include="Header Files">
8+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
9+
</Filter>
10+
</ItemGroup>
11+
<ItemGroup>
12+
<ClInclude Include="$(MC_ROOT)\source\stats\Achievement.hpp">
13+
<Filter>Header Files</Filter>
14+
</ClInclude>
15+
<ClInclude Include="$(MC_ROOT)\source\stats\Achievements.hpp">
16+
<Filter>Header Files</Filter>
17+
</ClInclude>
18+
<ClInclude Include="$(MC_ROOT)\source\stats\Stat.hpp">
19+
<Filter>Header Files</Filter>
20+
</ClInclude>
21+
<ClInclude Include="$(MC_ROOT)\source\stats\StatFormatter.hpp">
22+
<Filter>Header Files</Filter>
23+
</ClInclude>
24+
</ItemGroup>
25+
<ItemGroup>
26+
<ClCompile Include="$(MC_ROOT)\source\stats\Achievement.cpp">
27+
<Filter>Source Files</Filter>
28+
</ClCompile>
29+
<ClCompile Include="$(MC_ROOT)\source\stats\Achievements.cpp">
30+
<Filter>Source Files</Filter>
31+
</ClCompile>
32+
<ClCompile Include="$(MC_ROOT)\source\stats\Stat.cpp">
33+
<Filter>Source Files</Filter>
34+
</ClCompile>
35+
<ClCompile Include="$(MC_ROOT)\source\stats\StatFormatter.cpp">
36+
<Filter>Source Files</Filter>
37+
</ClCompile>
38+
</ItemGroup>
39+
</Project>

source/client/app/Minecraft.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Minecraft::Minecraft() :
7878
m_pUser = nullptr;
7979
m_pLevel = nullptr;
8080
m_pPlayer = nullptr;
81-
m_pMobPersp = nullptr; // why is there a duplicate? (this is used for the camera)
81+
m_pCameraEntity = nullptr; // why is there a duplicate? (this is used for the camera)
8282
field_D0C = 0;
8383
m_pScreen = nullptr;
8484
field_D18 = 10;
@@ -246,7 +246,7 @@ bool Minecraft::isTouchscreen() const
246246

247247
bool Minecraft::useSplitControls() const
248248
{
249-
return !m_bIsTouchscreen || m_options->m_bSplitControls;
249+
return !m_bIsTouchscreen || m_options->m_splitControls.get();
250250
}
251251

252252
bool Minecraft::useController() const
@@ -723,8 +723,8 @@ void Minecraft::tick()
723723
m_pParticleEngine->tick();
724724

725725
#ifndef ORIGINAL_CODE
726-
if (m_pMobPersp)
727-
m_pSoundEngine->update(m_pMobPersp.get(), m_timer.m_renderTicks);
726+
if (m_pCameraEntity)
727+
m_pSoundEngine->update(m_pCameraEntity.get(), m_timer.m_renderTicks);
728728
#endif
729729
}
730730

@@ -989,7 +989,7 @@ void Minecraft::setLevel(Level* pLevel, const std::string& text, std::shared_ptr
989989
{
990990
m_progress.progressStart(text);
991991
m_progress.progressStage(Util::EMPTY_STRING);
992-
m_pMobPersp = nullptr;
992+
m_pCameraEntity = nullptr;
993993
m_pSoundEngine->playStreaming(Util::EMPTY_STRING);
994994

995995
if (pLevel)
@@ -1036,7 +1036,7 @@ void Minecraft::setLevel(Level* pLevel, const std::string& text, std::shared_ptr
10361036
if (pLevel->m_bIsNew)
10371037
m_pLevel->save(true, m_progress);
10381038

1039-
m_pMobPersp = m_pPlayer;
1039+
m_pCameraEntity = m_pPlayer;
10401040

10411041
if (m_pMinecraftServer)
10421042
m_pMinecraftServer->manageLevels(m_progress);

source/client/app/Minecraft.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class Minecraft : public App
169169
Level* m_pLevel;
170170
MinecraftServer* m_pMinecraftServer;
171171
std::shared_ptr<LocalPlayer> m_pPlayer;
172-
std::shared_ptr<Mob> m_pMobPersp;
172+
std::shared_ptr<Mob> m_pCameraEntity;
173173
Gui m_gui;
174174
int field_D0C;
175175
std::vector<std::function<void()>> m_delayed;

source/client/app/NinecraftApp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "client/gui/screens/StartMenuScreen.hpp"
1414
#include "world/entity/EntityType.hpp"
1515
#include "world/tile/entity/TileEntityType.hpp"
16+
#include "stats/Achievements.hpp"
1617

1718
#ifdef DEMO
1819
#include "world/level/storage/MemoryLevelStorageSource.hpp"
@@ -79,6 +80,7 @@ void NinecraftApp::init()
7980
Item::initItems();
8081
Biome::initBiomes();
8182
TileEntityType::initTypes();
83+
Achievements::initAchievements();
8284
}
8385

8486
initGLStates();

source/client/gui/Gui.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
239239
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
240240

241241
// note: scale starts from 4.0f
242-
float halfWidth = (40.0f * breakProgress + 48.0f) / 2.0f;
242+
int halfWidth = (40.0f * breakProgress + 48.0f) / 2.0f;
243243

244-
blit(InvGuiScale * xPos - halfWidth, InvGuiScale * yPos - halfWidth, 88, 88, halfWidth * 2, halfWidth * 2, 352, 352);
244+
blit(InvGuiScale * xPos - halfWidth, InvGuiScale * yPos - halfWidth, 88 + 44 - halfWidth, 88 + 44 - halfWidth, halfWidth * 2, halfWidth * 2, 352, 352);
245245

246246
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
247247
//glDisable(GL_BLEND);

0 commit comments

Comments
 (0)