forked from cafeberry/cafeberry
feat: Fullscreen, fix sending input when window not focused, fix iggy lib not being copied & request dedicated GPU
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <shellapi.h>
|
||||
#include "GameConfig\Minecraft.spa.h"
|
||||
#include "..\MinecraftServer.h"
|
||||
#include "..\LocalPlayer.h"
|
||||
@@ -24,10 +25,6 @@
|
||||
#include "..\..\Minecraft.World\ThreadName.h"
|
||||
#include "..\..\Minecraft.Client\StatsCounter.h"
|
||||
#include "..\ConnectScreen.h"
|
||||
//#include "Social\SocialManager.h"
|
||||
//#include "Leaderboards\LeaderboardManager.h"
|
||||
//#include "XUI\XUI_Scene_Container.h"
|
||||
//#include "NetworkManager.h"
|
||||
#include "..\..\Minecraft.Client\Tesselator.h"
|
||||
#include "..\..\Minecraft.Client\Options.h"
|
||||
#include "Sentient\SentientManager.h"
|
||||
@@ -42,12 +39,11 @@
|
||||
|
||||
HINSTANCE hMyInst;
|
||||
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
|
||||
|
||||
char chGlobalText[256];
|
||||
uint16_t ui16GlobalText[256];
|
||||
|
||||
#define THEME_NAME "584111F70AAAAAAA"
|
||||
#define THEME_FILESIZE 2797568
|
||||
|
||||
//#define THREE_MB 3145728 // minimum save size (checking for this on a selected device)
|
||||
//#define FIVE_MB 5242880 // minimum save size (checking for this on a selected device)
|
||||
//#define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR space required for a save (checking for this on a selected device)
|
||||
@@ -58,29 +54,51 @@ uint16_t ui16GlobalText[256];
|
||||
#define NUM_PROFILE_SETTINGS 4
|
||||
DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
|
||||
{
|
||||
#ifdef _XBOX
|
||||
XPROFILE_OPTION_CONTROLLER_VIBRATION,
|
||||
XPROFILE_GAMER_YAXIS_INVERSION,
|
||||
XPROFILE_GAMER_CONTROL_SENSITIVITY,
|
||||
XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL,
|
||||
XPROFILE_TITLE_SPECIFIC1,
|
||||
#else
|
||||
0,0,0,0,0
|
||||
#endif
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Time Since fAppTime is a float, we need to keep the quadword app time
|
||||
// as a LARGE_INTEGER so that we don't lose precision after running
|
||||
// for a long time.
|
||||
//-------------------------------------------------------------------------------------
|
||||
//str1k3r - request dedicated GPU from AMD and NVIDIA drivers
|
||||
extern "C"
|
||||
{
|
||||
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
|
||||
__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
|
||||
}
|
||||
|
||||
BOOL g_isFullscreen = FALSE;
|
||||
BOOL g_bWidescreen = TRUE;
|
||||
BOOL g_bResolutionSetByCMD = FALSE;
|
||||
|
||||
int g_iScreenWidth = 1920;
|
||||
int g_iScreenHeight = 1080;
|
||||
|
||||
static Windows64LaunchArgs ParseLaunchArgs()
|
||||
{
|
||||
Windows64LaunchArgs args = {};
|
||||
args.resolution = 0;
|
||||
|
||||
int argc = 0;
|
||||
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
if (argv == nullptr)
|
||||
return args;
|
||||
|
||||
if (argc > 1 && lstrlenW(argv[1]) == 1)
|
||||
{
|
||||
if (argv[1][0] >= L'1' && argv[1][0] <= L'6')
|
||||
args.resolution = argv[1][0] - L'0';
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
if (_wcsicmp(argv[i], L"-fullscreen") == 0)
|
||||
{
|
||||
args.fullscreen = true;
|
||||
}
|
||||
}
|
||||
|
||||
LocalFree(argv);
|
||||
return args;
|
||||
}
|
||||
|
||||
void DefineActions(void)
|
||||
{
|
||||
// The app needs to define the actions required, and the possible mappings for these
|
||||
@@ -624,6 +642,39 @@ void Render()
|
||||
g_pSwapChain->Present( 0, 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Toggle borderless fullscreen
|
||||
// Credits to the smartCMD repo for this
|
||||
// This is the proper way to do this therefore we just took it
|
||||
//--------------------------------------------------------------------------------------
|
||||
void ToggleFullscreen()
|
||||
{
|
||||
const DWORD dwStyle = GetWindowLong(g_hWnd, GWL_STYLE);
|
||||
if (!g_isFullscreen)
|
||||
{
|
||||
MONITORINFO mi = { sizeof(mi) };
|
||||
if (GetWindowPlacement(g_hWnd, &g_wpPrev) &&
|
||||
GetMonitorInfo(MonitorFromWindow(g_hWnd, MONITOR_DEFAULTTOPRIMARY), &mi))
|
||||
{
|
||||
SetWindowLong(g_hWnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
|
||||
SetWindowPos(g_hWnd, HWND_TOP,
|
||||
mi.rcMonitor.left, mi.rcMonitor.top,
|
||||
mi.rcMonitor.right - mi.rcMonitor.left,
|
||||
mi.rcMonitor.bottom - mi.rcMonitor.top,
|
||||
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetWindowLong(g_hWnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW);
|
||||
SetWindowPlacement(g_hWnd, &g_wpPrev);
|
||||
SetWindowPos(g_hWnd, nullptr, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
g_isFullscreen = !g_isFullscreen;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Clean up the objects we've created
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -637,8 +688,6 @@ void CleanupDevice()
|
||||
if( g_pd3dDevice ) g_pd3dDevice->Release();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPTSTR lpCmdLine,
|
||||
@@ -647,44 +696,46 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
if(lpCmdLine)
|
||||
Windows64LaunchArgs launchArgs = ParseLaunchArgs();
|
||||
|
||||
if(launchArgs.resolution != 0)
|
||||
{
|
||||
if(lpCmdLine[0] == '1')
|
||||
if(launchArgs.resolution == 1)
|
||||
{
|
||||
// 2160p
|
||||
g_iScreenWidth = 3840;
|
||||
g_iScreenHeight = 2160;
|
||||
g_bResolutionSetByCMD = TRUE;
|
||||
}
|
||||
else if(lpCmdLine[0] == '2')
|
||||
else if(launchArgs.resolution == 2)
|
||||
{
|
||||
// 1440p
|
||||
g_iScreenWidth = 2560;
|
||||
g_iScreenHeight = 1440;
|
||||
g_bResolutionSetByCMD = TRUE;
|
||||
}
|
||||
else if (lpCmdLine[0] == '3')
|
||||
else if (launchArgs.resolution == 3)
|
||||
{
|
||||
// 1080p
|
||||
g_iScreenWidth = 1920;
|
||||
g_iScreenHeight = 1080;
|
||||
g_bResolutionSetByCMD = TRUE;
|
||||
}
|
||||
else if(lpCmdLine[0] == '4')
|
||||
else if(launchArgs.resolution == 4)
|
||||
{
|
||||
// 720p
|
||||
g_iScreenWidth = 1280;
|
||||
g_iScreenHeight = 720;
|
||||
g_bResolutionSetByCMD = TRUE;
|
||||
}
|
||||
else if(lpCmdLine[0] == '5')
|
||||
else if(launchArgs.resolution == 5)
|
||||
{
|
||||
// 480p
|
||||
g_iScreenWidth = 640;
|
||||
g_iScreenHeight = 480;
|
||||
g_bResolutionSetByCMD = TRUE;
|
||||
}
|
||||
else if(lpCmdLine[0] == '6')
|
||||
else if(launchArgs.resolution == 6)
|
||||
{
|
||||
// Vita Native, 544p
|
||||
g_iScreenWidth = 960;
|
||||
@@ -693,7 +744,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Initialize global strings
|
||||
MyRegisterClass(hInstance);
|
||||
|
||||
@@ -711,6 +761,11 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(launchArgs.fullscreen)
|
||||
{
|
||||
ToggleFullscreen();
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Main message loop
|
||||
MSG msg = {0};
|
||||
@@ -1001,7 +1056,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
|
||||
app.UpdateTime();
|
||||
PIXBeginNamedEvent(0,"Input manager tick");
|
||||
InputManager.Tick();
|
||||
if (GetFocus())
|
||||
{
|
||||
InputManager.Tick();
|
||||
}
|
||||
PIXEndNamedEvent();
|
||||
PIXBeginNamedEvent(0,"Profile manager tick");
|
||||
// ProfileManager.Tick();
|
||||
@@ -1192,6 +1250,18 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
#if 0
|
||||
PIXEndNamedEvent();
|
||||
#endif
|
||||
isF11Pressed = (GetAsyncKeyState(VK_F11) & 0x8000) != 0;
|
||||
|
||||
if(isF11Pressed && !wasF11Pressed && GetFocus())
|
||||
{
|
||||
ToggleFullscreen();
|
||||
}
|
||||
else if(isF11Pressed && !wasF11Pressed && GetFocus())
|
||||
{
|
||||
ToggleFullscreen();
|
||||
}
|
||||
|
||||
wasF11Pressed = isF11Pressed;
|
||||
|
||||
// 4J-PB - Update the trial timer display if we are in the trial version
|
||||
if(!ProfileManager.IsFullVersion())
|
||||
|
||||
Reference in New Issue
Block a user