Revert "Revert "Win64: configurable username (username.txt) and persistent ga…" (#235)
This reverts commit 7f7d99501c.
This commit is contained in:
@@ -760,6 +760,43 @@ bool CMinecraftApp::LoadBeaconMenu(int iPad ,shared_ptr<Inventory> inventory, sh
|
|||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
// GAME SETTINGS
|
// GAME SETTINGS
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
static void Win64_GetSettingsPath(char *outPath, DWORD size)
|
||||||
|
{
|
||||||
|
GetModuleFileNameA(NULL, outPath, size);
|
||||||
|
char *lastSlash = strrchr(outPath, '\\');
|
||||||
|
if (lastSlash) *(lastSlash + 1) = '\0';
|
||||||
|
strncat_s(outPath, size, "settings.dat", _TRUNCATE);
|
||||||
|
}
|
||||||
|
static void Win64_SaveSettings(GAME_SETTINGS *gs)
|
||||||
|
{
|
||||||
|
if (!gs) return;
|
||||||
|
char filePath[MAX_PATH] = {};
|
||||||
|
Win64_GetSettingsPath(filePath, MAX_PATH);
|
||||||
|
FILE *f = NULL;
|
||||||
|
if (fopen_s(&f, filePath, "wb") == 0 && f)
|
||||||
|
{
|
||||||
|
fwrite(gs, sizeof(GAME_SETTINGS), 1, f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void Win64_LoadSettings(GAME_SETTINGS *gs)
|
||||||
|
{
|
||||||
|
if (!gs) return;
|
||||||
|
char filePath[MAX_PATH] = {};
|
||||||
|
Win64_GetSettingsPath(filePath, MAX_PATH);
|
||||||
|
FILE *f = NULL;
|
||||||
|
if (fopen_s(&f, filePath, "rb") == 0 && f)
|
||||||
|
{
|
||||||
|
GAME_SETTINGS temp = {};
|
||||||
|
if (fread(&temp, sizeof(GAME_SETTINGS), 1, f) == 1)
|
||||||
|
memcpy(gs, &temp, sizeof(GAME_SETTINGS));
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void CMinecraftApp::InitGameSettings()
|
void CMinecraftApp::InitGameSettings()
|
||||||
{
|
{
|
||||||
for(int i=0;i<XUSER_MAX_COUNT;i++)
|
for(int i=0;i<XUSER_MAX_COUNT;i++)
|
||||||
@@ -780,6 +817,8 @@ void CMinecraftApp::InitGameSettings()
|
|||||||
// clear this for now - it will come from reading the system values
|
// clear this for now - it will come from reading the system values
|
||||||
memset(pProfileSettings,0,sizeof(C_4JProfile::PROFILESETTINGS));
|
memset(pProfileSettings,0,sizeof(C_4JProfile::PROFILESETTINGS));
|
||||||
SetDefaultOptions(pProfileSettings,i);
|
SetDefaultOptions(pProfileSettings,i);
|
||||||
|
Win64_LoadSettings(GameSettingsA[i]);
|
||||||
|
ApplyGameSettingsChanged(i);
|
||||||
#elif defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__
|
#elif defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__
|
||||||
C4JStorage::PROFILESETTINGS *pProfileSettings=StorageManager.GetDashboardProfileSettings(i);
|
C4JStorage::PROFILESETTINGS *pProfileSettings=StorageManager.GetDashboardProfileSettings(i);
|
||||||
// 4J-PB - don't cause an options write to happen here
|
// 4J-PB - don't cause an options write to happen here
|
||||||
@@ -2372,6 +2411,9 @@ void CMinecraftApp::CheckGameSettingsChanged(bool bOverride5MinuteTimer, int iPa
|
|||||||
StorageManager.WriteToProfile(i,true, bOverride5MinuteTimer);
|
StorageManager.WriteToProfile(i,true, bOverride5MinuteTimer);
|
||||||
#else
|
#else
|
||||||
ProfileManager.WriteToProfile(i,true, bOverride5MinuteTimer);
|
ProfileManager.WriteToProfile(i,true, bOverride5MinuteTimer);
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
Win64_SaveSettings(GameSettingsA[i]);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
GameSettingsA[i]->bSettingsChanged=false;
|
GameSettingsA[i]->bSettingsChanged=false;
|
||||||
}
|
}
|
||||||
@@ -2385,6 +2427,9 @@ void CMinecraftApp::CheckGameSettingsChanged(bool bOverride5MinuteTimer, int iPa
|
|||||||
StorageManager.WriteToProfile(iPad,true, bOverride5MinuteTimer);
|
StorageManager.WriteToProfile(iPad,true, bOverride5MinuteTimer);
|
||||||
#else
|
#else
|
||||||
ProfileManager.WriteToProfile(iPad,true, bOverride5MinuteTimer);
|
ProfileManager.WriteToProfile(iPad,true, bOverride5MinuteTimer);
|
||||||
|
#ifdef _WINDOWS64
|
||||||
|
Win64_SaveSettings(GameSettingsA[iPad]);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
GameSettingsA[iPad]->bSettingsChanged=false;
|
GameSettingsA[iPad]->bSettingsChanged=false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,10 +199,11 @@ DWORD IQNetPlayer::GetSendQueueSize(IQNetPlayer * player, DWORD dwFlags) { retur
|
|||||||
DWORD IQNetPlayer::GetCurrentRtt() { return 0; }
|
DWORD IQNetPlayer::GetCurrentRtt() { return 0; }
|
||||||
bool IQNetPlayer::IsHost() { return m_isHostPlayer; }
|
bool IQNetPlayer::IsHost() { return m_isHostPlayer; }
|
||||||
bool IQNetPlayer::IsGuest() { return false; }
|
bool IQNetPlayer::IsGuest() { return false; }
|
||||||
bool IQNetPlayer::IsLocal() { return !m_isRemote; }
|
bool IQNetPlayer::IsLocal() { return true; }
|
||||||
PlayerUID IQNetPlayer::GetXuid() { return (PlayerUID)(0xe000d45248242f2e + m_smallId); }
|
PlayerUID IQNetPlayer::GetXuid() { return INVALID_XUID; }
|
||||||
LPCWSTR IQNetPlayer::GetGamertag() { return m_gamertag; }
|
extern wstring g_playerName;
|
||||||
int IQNetPlayer::GetSessionIndex() { return m_smallId; }
|
LPCWSTR IQNetPlayer::GetGamertag() { return g_playerName.empty() ? L"Windows" : g_playerName.c_str(); }
|
||||||
|
int IQNetPlayer::GetSessionIndex() { return 0; }
|
||||||
bool IQNetPlayer::IsTalking() { return false; }
|
bool IQNetPlayer::IsTalking() { return false; }
|
||||||
bool IQNetPlayer::IsMutedByLocalUser(DWORD dwUserIndex) { return false; }
|
bool IQNetPlayer::IsMutedByLocalUser(DWORD dwUserIndex) { return false; }
|
||||||
bool IQNetPlayer::HasVoice() { return false; }
|
bool IQNetPlayer::HasVoice() { return false; }
|
||||||
|
|||||||
@@ -10,11 +10,46 @@
|
|||||||
#include "..\..\Minecraft.World\BiomeSource.h"
|
#include "..\..\Minecraft.World\BiomeSource.h"
|
||||||
#include "..\..\Minecraft.World\LevelType.h"
|
#include "..\..\Minecraft.World\LevelType.h"
|
||||||
|
|
||||||
|
wstring g_playerName;
|
||||||
|
|
||||||
CConsoleMinecraftApp app;
|
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()
|
CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp()
|
||||||
{
|
{
|
||||||
m_bShutdown = false;
|
m_bShutdown = false;
|
||||||
|
LoadPlayerName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId)
|
void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId)
|
||||||
@@ -35,9 +70,27 @@ void CConsoleMinecraftApp::FatalLoadError()
|
|||||||
|
|
||||||
void CConsoleMinecraftApp::CaptureSaveThumbnail()
|
void CConsoleMinecraftApp::CaptureSaveThumbnail()
|
||||||
{
|
{
|
||||||
|
RenderManager.CaptureThumbnail(&m_ThumbnailBuffer);
|
||||||
}
|
}
|
||||||
void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *pbData,DWORD *pdwSize)
|
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()
|
void CConsoleMinecraftApp::ReleaseSaveThumbnail()
|
||||||
{
|
{
|
||||||
@@ -57,8 +110,8 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
|
|||||||
Minecraft *pMinecraft=Minecraft::GetInstance();
|
Minecraft *pMinecraft=Minecraft::GetInstance();
|
||||||
app.ReleaseSaveThumbnail();
|
app.ReleaseSaveThumbnail();
|
||||||
ProfileManager.SetLockedProfile(0);
|
ProfileManager.SetLockedProfile(0);
|
||||||
extern wchar_t g_Win64UsernameW[17];
|
LoadPlayerName();
|
||||||
pMinecraft->user->name = g_Win64UsernameW;
|
pMinecraft->user->name = g_playerName;
|
||||||
app.ApplyGameSettingsChanged(0);
|
app.ApplyGameSettingsChanged(0);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameJoinLoad::OnInit
|
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameJoinLoad::OnInit
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "4JLibs\inc\4J_Render.h"
|
||||||
|
|
||||||
class CConsoleMinecraftApp : public CMinecraftApp
|
class CConsoleMinecraftApp : public CMinecraftApp
|
||||||
{
|
{
|
||||||
|
ImageFileBuffer m_ThumbnailBuffer;
|
||||||
public:
|
public:
|
||||||
CConsoleMinecraftApp();
|
CConsoleMinecraftApp();
|
||||||
|
|
||||||
|
|||||||
@@ -729,7 +729,16 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
|||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
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_iScreenWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||||
g_iScreenHeight = GetSystemMetrics(SM_CYSCREEN);
|
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))
|
if (KMInput.IsKeyPressed(VK_F11))
|
||||||
{
|
{
|
||||||
ToggleFullscreen();
|
ToggleFullscreen();
|
||||||
|
|||||||
Reference in New Issue
Block a user