aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Windows64
diff options
context:
space:
mode:
authorvoid_17 <61356189+void2012@users.noreply.github.com>2026-03-03 10:31:09 +0700
committerGitHub <noreply@github.com>2026-03-03 10:31:09 +0700
commitb42a4a4e4d72f6dea0a243c77247f7b9e739f5eb (patch)
tree7827677a557888188ee7adf82a3380361c02395f /Minecraft.Client/Windows64
parent7f7d99501cf87fcc234a5d3af453e7e0642f96a3 (diff)
Revert "Revert "Win64: configurable username (username.txt) and persistent ga…" (#235)
This reverts commit 7f7d99501cf87fcc234a5d3af453e7e0642f96a3.
Diffstat (limited to 'Minecraft.Client/Windows64')
-rw-r--r--Minecraft.Client/Windows64/Windows64_App.cpp57
-rw-r--r--Minecraft.Client/Windows64/Windows64_App.h2
-rw-r--r--Minecraft.Client/Windows64/Windows64_Minecraft.cpp27
3 files changed, 82 insertions, 4 deletions
diff --git a/Minecraft.Client/Windows64/Windows64_App.cpp b/Minecraft.Client/Windows64/Windows64_App.cpp
index dbc1bfc5..461e8c34 100644
--- a/Minecraft.Client/Windows64/Windows64_App.cpp
+++ b/Minecraft.Client/Windows64/Windows64_App.cpp
@@ -10,11 +10,46 @@
#include "..\..\Minecraft.World\BiomeSource.h"
#include "..\..\Minecraft.World\LevelType.h"
+wstring g_playerName;
+
CConsoleMinecraftApp app;
+static void LoadPlayerName()
+{
+ if (!g_playerName.empty()) return;
+ g_playerName = L"Windows";
+
+ char exePath[MAX_PATH] = {};
+ GetModuleFileNameA(NULL, exePath, MAX_PATH);
+ char *lastSlash = strrchr(exePath, '\\');
+ if (lastSlash) *(lastSlash + 1) = '\0';
+ char filePath[MAX_PATH] = {};
+ _snprintf_s(filePath, sizeof(filePath), _TRUNCATE, "%susername.txt", exePath);
+
+ FILE *f = NULL;
+ if (fopen_s(&f, filePath, "r") == 0 && f)
+ {
+ char buf[128] = {};
+ if (fgets(buf, sizeof(buf), f))
+ {
+ int len = (int)strlen(buf);
+ while (len > 0 && (buf[len-1] == '\n' || buf[len-1] == '\r' || buf[len-1] == ' '))
+ buf[--len] = '\0';
+ if (len > 0)
+ {
+ wchar_t wbuf[128] = {};
+ mbstowcs(wbuf, buf, 127);
+ g_playerName = wbuf;
+ }
+ }
+ fclose(f);
+ }
+}
+
CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp()
{
m_bShutdown = false;
+ LoadPlayerName();
}
void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId)
@@ -35,9 +70,27 @@ void CConsoleMinecraftApp::FatalLoadError()
void CConsoleMinecraftApp::CaptureSaveThumbnail()
{
+ RenderManager.CaptureThumbnail(&m_ThumbnailBuffer);
}
void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *pbData,DWORD *pdwSize)
{
+ // On a save caused by a create world, the thumbnail capture won't have happened
+ if (m_ThumbnailBuffer.Allocated())
+ {
+ if (pbData)
+ {
+ *pbData = new BYTE[m_ThumbnailBuffer.GetBufferSize()];
+ *pdwSize = m_ThumbnailBuffer.GetBufferSize();
+ memcpy(*pbData, m_ThumbnailBuffer.GetBufferPointer(), *pdwSize);
+ }
+ m_ThumbnailBuffer.Release();
+ }
+ else
+ {
+ // No capture happened (e.g. first save on world creation) leave thumbnail as NULL
+ if (pbData) *pbData = NULL;
+ if (pdwSize) *pdwSize = 0;
+ }
}
void CConsoleMinecraftApp::ReleaseSaveThumbnail()
{
@@ -57,8 +110,8 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
Minecraft *pMinecraft=Minecraft::GetInstance();
app.ReleaseSaveThumbnail();
ProfileManager.SetLockedProfile(0);
- extern wchar_t g_Win64UsernameW[17];
- pMinecraft->user->name = g_Win64UsernameW;
+ LoadPlayerName();
+ pMinecraft->user->name = g_playerName;
app.ApplyGameSettingsChanged(0);
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameJoinLoad::OnInit
diff --git a/Minecraft.Client/Windows64/Windows64_App.h b/Minecraft.Client/Windows64/Windows64_App.h
index de8f6d85..bff916ec 100644
--- a/Minecraft.Client/Windows64/Windows64_App.h
+++ b/Minecraft.Client/Windows64/Windows64_App.h
@@ -1,7 +1,9 @@
#pragma once
+#include "4JLibs\inc\4J_Render.h"
class CConsoleMinecraftApp : public CMinecraftApp
{
+ ImageFileBuffer m_ThumbnailBuffer;
public:
CConsoleMinecraftApp();
diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp
index 272b29bf..48040c66 100644
--- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp
+++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp
@@ -729,7 +729,16 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
- dyn_SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
+ // 4J-Win64: set CWD to exe dir so asset paths resolve correctly
+ {
+ char szExeDir[MAX_PATH] = {};
+ GetModuleFileNameA(NULL, szExeDir, MAX_PATH);
+ char *pSlash = strrchr(szExeDir, '\\');
+ if (pSlash) { *(pSlash + 1) = '\0'; SetCurrentDirectoryA(szExeDir); }
+ }
+
+ // Declare DPI awareness so GetSystemMetrics returns physical pixels
+ SetProcessDPIAware();
g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN);
g_iScreenHeight = GetSystemMetrics(SM_CYSCREEN);
@@ -1263,7 +1272,21 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
}
}
- // F11 toggles fullscreen
+ // F3 toggles the debug console overlay, F11 toggles fullscreen
+ if (KMInput.IsKeyPressed(VK_F3))
+ {
+ static bool s_debugConsole = false;
+ s_debugConsole = !s_debugConsole;
+ ui.ShowUIDebugConsole(s_debugConsole);
+ }
+
+#ifdef _DEBUG_MENUS_ENABLED
+ if (KMInput.IsKeyPressed(VK_F4))
+ {
+ ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_DebugOverlay, NULL, eUILayer_Debug);
+ }
+#endif
+
if (KMInput.IsKeyPressed(VK_F11))
{
ToggleFullscreen();