* Rename Logger_windows -> LoggerWindows

* Add logger support for SDL base
This commit is contained in:
iProgramInCpp
2023-08-28 11:13:57 +03:00
parent 8fe86fccb5
commit 6e2fffdd68
10 changed files with 24 additions and 15 deletions

View File

@@ -24,6 +24,8 @@ void AppPlatform_sdlbase::_init(std::string storageDir, SDL_Window *window)
m_bShiftPressed[1] = false;
ensureDirectoryExists(_storageDir.c_str());
m_pLogger = new Logger;
}
void AppPlatform_sdlbase::setIcon(const Texture& icon)

View File

@@ -7,6 +7,7 @@
#include "client/player/input/Mouse.hpp"
#include "client/player/input/Keyboard.hpp"
#include "common/Logger.hpp"
class AppPlatform_sdlbase : public AppPlatform
{
@@ -48,6 +49,8 @@ private:
int xrel;
int yrel;
Logger* m_pLogger;
static SDL_Surface* getSurfaceForTexture(const Texture* const texture);
protected:

View File

@@ -12,7 +12,7 @@
#include <shlobj.h>
#include "AppPlatform_windows.hpp"
#include "Logger_windows.hpp"
#include "LoggerWindows.hpp"
#include "thirdparty/stb_image.h"
#include "thirdparty/stb_image_write.h"
@@ -35,7 +35,7 @@ AppPlatform_windows::AppPlatform_windows()
// This initializes the Logger singleton to use the Windows-specific variant
// If we didn't initialize it here, the Minecraft class would have our back
m_Logger = new Logger_windows();
m_Logger = new LoggerWindows();
}
AppPlatform_windows::~AppPlatform_windows()

View File

@@ -16,7 +16,7 @@
#include "client/player/input/Mouse.hpp"
#include "client/player/input/Keyboard.hpp"
#include "common/Utils.hpp"
#include "Logger_windows.hpp"
#include "LoggerWindows.hpp"
class AppPlatform_windows : public AppPlatform
{
@@ -78,6 +78,6 @@ private:
int m_MouseDiffX, m_MouseDiffY;
Logger_windows *m_Logger;
LoggerWindows *m_Logger;
};

View File

@@ -2,10 +2,10 @@
#include <stdarg.h>
#include <windows.h>
#include "Logger_windows.hpp"
#include "LoggerWindows.hpp"
#include "common/Util.hpp"
void Logger_windows::print(const char* const str)
void LoggerWindows::print(const char* const str)
{
Logger::print(str);
@@ -13,17 +13,17 @@ void Logger_windows::print(const char* const str)
OutputDebugStringA("\n");
}
void Logger_windows::print(std::string str)
void LoggerWindows::print(std::string str)
{
print(str.c_str());
}
void Logger_windows::vprintf(const char* const fmt, va_list argPtr)
void LoggerWindows::vprintf(const char* const fmt, va_list argPtr)
{
print(Util::vformat(fmt, argPtr));
}
void Logger_windows::printf(const char* const fmt, ...)
void LoggerWindows::printf(const char* const fmt, ...)
{
va_list argList;
va_start(argList, fmt);

View File

@@ -3,7 +3,7 @@
#include <string>
#include "common/Logger.hpp"
class Logger_windows : Logger
class LoggerWindows : Logger
{
void print(const char* const str) override;
void print(std::string str) override;

View File

@@ -391,7 +391,7 @@
<ClCompile Include="$(MC_ROOT)\platforms\windows\AppPlatform_windows.cpp" />
<ClCompile Include="$(MC_ROOT)\platforms\windows\main.cpp" />
<ClCompile Include="$(MC_ROOT)\platforms\windows\SoundSystemWindows.cpp" />
<ClInclude Include="..\Logger_windows.hpp" />
<ClInclude Include="..\LoggerWindows.hpp" />
<ClCompile Include="$(MC_ROOT)\source\App.cpp" />
<ClCompile Include="$(MC_ROOT)\source\AppPlatform.cpp" />
<ClCompile Include="$(MC_ROOT)\source\client\gui\components\AvailableGamesList.cpp" />
@@ -730,7 +730,7 @@
<ClCompile Include="$(MC_ROOT)\thirdparty\zlib\uncompr.c" />
<ClCompile Include="$(MC_ROOT)\thirdparty\zlib\zutil.c" />
<ClCompile Include="..\..\..\source\common\Logger.cpp" />
<ClCompile Include="..\Logger_windows.cpp" />
<ClCompile Include="..\LoggerWindows.cpp" />
</ItemGroup>
<ItemGroup>
<Text Include="$(MC_ROOT)\thirdparty\raknet\CMakeLists.txt" />

View File

@@ -12,6 +12,7 @@ add_library(reminecraftpe-core STATIC
common/Timer.cpp
common/CThread.cpp
common/Util.cpp
common/Logger.cpp
network/packets/UpdateBlockPacket.cpp
network/packets/RequestChunkPacket.cpp
network/packets/PlayerEquipmentPacket.cpp

View File

@@ -525,7 +525,7 @@ void GameRenderer::renderLevel(float f)
if (bAnaglyph)
glColorMask(true, true, true, false);
}
int logs = 0;
void GameRenderer::render(float f)
{
if (m_pMinecraft->m_pLocalPlayer && m_pMinecraft->m_bGrabbedMouse)
@@ -636,7 +636,7 @@ void GameRenderer::render(float f)
std::stringstream debugText;
debugText << "ReMinecraftPE " << m_pMinecraft->getVersionString();
debugText << "\n" << m_shownFPS << " fps, " << m_shownChunkUpdates << " chunk updates";
debugText << "\n" << m_shownFPS << " fps, " << m_shownChunkUpdates << " chunk updates" << " logs: " << logs;
if (m_pMinecraft->m_options.m_bDebugText)
{

View File

@@ -4,6 +4,8 @@
#include "Logger.hpp"
#include "Util.hpp"
extern int logs;
Logger* Logger::m_singleton = nullptr;
Logger* const Logger::singleton()
@@ -26,7 +28,8 @@ Logger::~Logger()
void Logger::print(const char* const str)
{
std::cout << str << std::endl;
::printf("%s\n", str);
logs++;
}
void Logger::print(std::string str)