chore: port more cafeberry fixes
This commit is contained in:
1 parent
533640cafd
commit
7d592c43ca
6 files changed
+350
-152
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <shellapi.h>
|
||||
#include "GameConfig\Minecraft.spa.h"
|
||||
#include "..\MinecraftServer.h"
|
||||
#include "..\LocalPlayer.h"
|
||||
@@ -37,6 +38,7 @@
|
||||
#include "..\..\Minecraft.World\compression.h"
|
||||
#include "..\..\Minecraft.World\OldChunkStorage.h"
|
||||
|
||||
#include "Windows64_Minecraft.h"
|
||||
#include "Xbox/resource.h"
|
||||
|
||||
HINSTANCE hMyInst;
|
||||
@@ -68,17 +70,54 @@ DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
|
||||
#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_bWidescreen = TRUE;
|
||||
BOOL g_isFullscreen = FALSE;
|
||||
BOOL g_bResolutionSetByCMD = FALSE;
|
||||
|
||||
int g_iScreenWidth = 1920;
|
||||
int g_iScreenHeight = 1080;
|
||||
|
||||
static LaunchArgs ParseLaunchArgs()
|
||||
{
|
||||
LaunchArgs 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;
|
||||
}
|
||||
else if (_wcsicmp(argv[i], L"-resolution") == 0)
|
||||
{
|
||||
if (i + 1 < argc && argv[i + 1][0] >= L'1' && argv[i + 1][0] <= L'6')
|
||||
{
|
||||
args.resolution = argv[++i][0] - L'0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LocalFree(argv);
|
||||
return args;
|
||||
}
|
||||
|
||||
void DefineActions(void)
|
||||
{
|
||||
// The app needs to define the actions required, and the possible mappings for these
|
||||
@@ -115,8 +154,8 @@ void DefineActions(void)
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_DOWN);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_UP);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_LT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_RT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_RB);
|
||||
@@ -164,8 +203,8 @@ void DefineActions(void)
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_DOWN);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_UP);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_RT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_LT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_DPAD_RIGHT);
|
||||
@@ -205,8 +244,8 @@ void DefineActions(void)
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_DOWN);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_UP);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_RT);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_A);
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_DPAD_RIGHT);
|
||||
@@ -311,30 +350,41 @@ ID3D11Texture2D* g_pDepthStencilBuffer = NULL;
|
||||
//
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int wmId, wmEvent;
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
wmId = LOWORD(wParam);
|
||||
wmEvent = HIWORD(wParam);
|
||||
// Parse the menu selections:
|
||||
switch (wmId)
|
||||
{
|
||||
case IDM_EXIT:
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
case WM_ENTERMENULOOP:
|
||||
case WM_ENTERSIZEMOVE:
|
||||
SetTimer(hWnd, 1, USER_TIMER_MINIMUM, NULL);
|
||||
break;
|
||||
case WM_EXITMENULOOP:
|
||||
case WM_EXITSIZEMOVE:
|
||||
KillTimer(hWnd, 1);
|
||||
break;
|
||||
case WM_ERASEBKGND:
|
||||
return 1;
|
||||
case WM_TIMER:
|
||||
if (wParam == 1)
|
||||
{
|
||||
// Tick UI
|
||||
ui.tick();
|
||||
ui.render();
|
||||
RenderManager.Present();
|
||||
ui.CheckMenuDisplayed();
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
break;
|
||||
case WM_PAINT:
|
||||
hdc = BeginPaint(hWnd, &ps);
|
||||
// TODO: Add any drawing code here...
|
||||
EndPaint(hWnd, &ps);
|
||||
// Tick Managers
|
||||
app.UpdateTime();
|
||||
InputManager.Tick();
|
||||
StorageManager.Tick();
|
||||
RenderManager.Tick();
|
||||
|
||||
// Tick Music
|
||||
Minecraft *pMinecraft=Minecraft::GetInstance();
|
||||
pMinecraft->soundEngine->tick(NULL, 0.0f);
|
||||
pMinecraft->soundEngine->playMusicTick();
|
||||
}
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
app.ExitGame();
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
@@ -342,7 +392,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -405,7 +455,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ShowWindow(g_hWnd, nCmdShow);
|
||||
ShowWindow(g_hWnd, SW_SHOWMAXIMIZED);
|
||||
UpdateWindow(g_hWnd);
|
||||
|
||||
return TRUE;
|
||||
@@ -466,17 +516,30 @@ HRESULT InitDevice()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
RECT rc;
|
||||
GetClientRect( g_hWnd, &rc );
|
||||
UINT width = rc.right - rc.left;
|
||||
UINT height = rc.bottom - rc.top;
|
||||
//app.DebugPrintf("width: %d, height: %d\n", width, height);
|
||||
width = g_iScreenWidth;
|
||||
height = g_iScreenHeight;
|
||||
app.DebugPrintf("width: %d, height: %d\n", width, height);
|
||||
//str1k3r - use screen size instead of window size & detect if its widescreen or not
|
||||
if (!g_bResolutionSetByCMD)
|
||||
{
|
||||
HMONITOR hMonitor = MonitorFromWindow(g_hWnd, MONITOR_DEFAULTTONEAREST);
|
||||
MONITORINFO monitorInfo = { sizeof(MONITORINFO) };
|
||||
if (GetMonitorInfo(hMonitor, &monitorInfo))
|
||||
{
|
||||
g_iScreenWidth = monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left;
|
||||
g_iScreenHeight = monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
g_iScreenHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
//str1k3r - stop hardcoding size and just use the screens actual size
|
||||
UINT width = g_iScreenWidth;
|
||||
UINT height = g_iScreenHeight;
|
||||
|
||||
UINT createDeviceFlags = 0;
|
||||
#ifdef _DEBUG
|
||||
app.DebugPrintf("Screen Width: %d, Screen Height: %d\n", width, height);
|
||||
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||
#endif
|
||||
|
||||
@@ -484,7 +547,9 @@ app.DebugPrintf("width: %d, height: %d\n", width, height);
|
||||
{
|
||||
D3D_DRIVER_TYPE_HARDWARE,
|
||||
D3D_DRIVER_TYPE_WARP,
|
||||
#ifdef _DEBUG //str1k3r - using this can actually SLOW stuff down, as its ran on the CPU instead of the GPU also only intended for debugging
|
||||
D3D_DRIVER_TYPE_REFERENCE,
|
||||
#endif
|
||||
};
|
||||
UINT numDriverTypes = ARRAYSIZE( driverTypes );
|
||||
|
||||
@@ -544,6 +609,7 @@ app.DebugPrintf("width: %d, height: %d\n", width, height);
|
||||
hr = g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencilBuffer);
|
||||
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC descDSView;
|
||||
ZeroMemory(&descDSView, sizeof(descDSView));
|
||||
descDSView.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
descDSView.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
descDSView.Texture2D.MipSlice = 0;
|
||||
@@ -567,8 +633,6 @@ app.DebugPrintf("width: %d, height: %d\n", width, height);
|
||||
vp.TopLeftY = 0;
|
||||
g_pImmediateContext->RSSetViewports( 1, &vp );
|
||||
|
||||
RenderManager.Initialise(g_pd3dDevice, g_pSwapChain);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -607,27 +671,54 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
if(lpCmdLine)
|
||||
//str1k3r - tell windows that we are aware of high DPI displays
|
||||
SetProcessDPIAware();
|
||||
|
||||
LaunchArgs 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(launchArgs.resolution == 2)
|
||||
{
|
||||
// 1440p
|
||||
g_iScreenWidth = 2560;
|
||||
g_iScreenHeight = 1440;
|
||||
g_bResolutionSetByCMD = TRUE;
|
||||
}
|
||||
else if (launchArgs.resolution == 3)
|
||||
{
|
||||
// 1080p
|
||||
g_iScreenWidth = 1920;
|
||||
g_iScreenHeight = 1080;
|
||||
g_bResolutionSetByCMD = TRUE;
|
||||
}
|
||||
else if(launchArgs.resolution == 4)
|
||||
{
|
||||
// 720p
|
||||
g_iScreenWidth = 1280;
|
||||
g_iScreenHeight = 720;
|
||||
g_bResolutionSetByCMD = TRUE;
|
||||
}
|
||||
else if(lpCmdLine[0] == '2')
|
||||
else if(launchArgs.resolution == 5)
|
||||
{
|
||||
// 480p
|
||||
g_iScreenWidth = 640;
|
||||
g_iScreenHeight = 480;
|
||||
g_bResolutionSetByCMD = TRUE;
|
||||
}
|
||||
else if(lpCmdLine[0] == '3')
|
||||
else if(launchArgs.resolution == 6)
|
||||
{
|
||||
// Vita
|
||||
g_iScreenWidth = 720;
|
||||
g_iScreenHeight = 408;
|
||||
|
||||
// Vita native
|
||||
//g_iScreenWidth = 960;
|
||||
//g_iScreenHeight = 544;
|
||||
// Vita Native, 544p
|
||||
g_iScreenWidth = 960;
|
||||
g_iScreenHeight = 544;
|
||||
g_bResolutionSetByCMD = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user