Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/EterLib/GrpDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ DWORD GetMaxTextureHeight()
return s_MaxTextureHeight;
}

#ifdef ENABLE_WINDOW_RESIZE
void CGraphicDevice::SetNewSize(int width, int height)
{
ms_iWidth = width;
ms_iHeight = height;

SetViewport(0.0f, 0.0f, (float)width, (float)height, 0, 1);
}
#endif
int CGraphicDevice::Create(HWND hWnd, int iHres, int iVres, bool Windowed, int /*iBit*/, int iReflashRate)
{
int iRet = CREATE_OK;
Expand Down
3 changes: 3 additions & 0 deletions src/EterLib/GrpDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class CGraphicDevice : public CGraphicBase

void Destroy();
int Create(HWND hWnd, int hres, int vres, bool Windowed = true, int bit = 32, int ReflashRate = 0);
#ifdef ENABLE_WINDOW_RESIZE
void SetNewSize(int width, int height);
#endif

EDeviceState GetDeviceState();
bool Reset();
Expand Down
23 changes: 23 additions & 0 deletions src/EterPythonLib/PythonWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,29 @@ namespace UI
PyCallClassMemberFunc(m_poHandler, "OnRender", BuildEmptyTuple());
}

#ifdef ENABLE_WINDOW_RESIZE
void CWindow::Resize(CWindow* rootWindow)
{
OnResize();

m_isUpdatingChildren = TRUE;

for (auto& Child : m_pChildList)
Child->Resize(rootWindow);

m_isUpdatingChildren = FALSE;
}

void CWindow::OnResize()
{
if (!m_poHandler)
return;

static PyObject* poFuncName_OnUpdate = PyString_InternFromString("OnResize");
PyCallClassMemberFunc_ByPyString(m_poHandler, poFuncName_OnUpdate, BuildEmptyTuple());
UpdateRect();
}
#endif
void CWindow::SetName(const char * c_szName)
{
m_strName = c_szName;
Expand Down
8 changes: 8 additions & 0 deletions src/EterPythonLib/PythonWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ namespace UI
void DestroyHandle();
void Update();
void Render();
#ifdef ENABLE_WINDOW_RESIZE
void Resize(CWindow* rootWindow);
#endif



void SetName(const char * c_szName);
const char * GetName() { return m_strName.c_str(); }
Expand Down Expand Up @@ -109,6 +114,9 @@ namespace UI

virtual void OnRender();
virtual void OnUpdate();
#ifdef ENABLE_WINDOW_RESIZE
virtual void OnResize();
#endif
virtual void OnChangePosition(){}

virtual void OnSetFocus();
Expand Down
8 changes: 8 additions & 0 deletions src/EterPythonLib/PythonWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,14 @@ namespace UI
m_pRootWindow->Render();
}

#ifdef ENABLE_WINDOW_RESIZE
void CWindowManager::Resize(int width, int height)
{
SetResolution(width, height);
SetScreenSize(width, height);
m_pRootWindow->Resize(m_pRootWindow);
}
#endif
CWindow * CWindowManager::__PickWindow(long x, long y)
{
if (m_pLockWindow)
Expand Down
3 changes: 3 additions & 0 deletions src/EterPythonLib/PythonWindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ namespace UI

void Update();
void Render();
#ifdef ENABLE_WINDOW_RESIZE
void Resize(int width, int height);
#endif

void RunMouseMove(long x, long y);
void RunMouseLeftButtonDown(long x, long y);
Expand Down
2 changes: 2 additions & 0 deletions src/UserInterface/Locale_inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
#define ENABLE_NEW_EQUIPMENT_SYSTEM
#define ENABLE_ATLAS_SCALE
//#define ENABLE_DISCORD_RPC

#define ENABLE_WINDOW_RESIZE
14 changes: 14 additions & 0 deletions src/UserInterface/PythonApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ m_IsMovingMainWindow(false)

ms_pInstance = this;
m_isWindowFullScreenEnable = FALSE;
#ifdef ENABLE_WINDOW_RESIZE
m_isResizing = false;
#endif

m_v3CenterPosition = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
m_dwStartLocalTime = ELTimer_GetMSec();
Expand Down Expand Up @@ -591,6 +594,13 @@ int CPythonApplication::CheckDeviceState()
return DEVICE_STATE_OK;
}

#ifdef ENABLE_WINDOW_RESIZE
void CPythonApplication::ChangeDeviceSize(int width, int height)
{
m_grpDevice.SetNewSize(width, height);
}
#endif

bool CPythonApplication::CreateDevice(int width, int height, int Windowed, int bit, int frequency)
{
int iRet;
Expand Down Expand Up @@ -776,7 +786,11 @@ bool LoadLocaleData(const char* localePath)
unsigned __GetWindowMode(bool windowed)
{
if (windowed)
#ifdef ENABLE_WINDOW_RESIZE
return WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_TILEDWINDOW;
#else
return WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
#endif

return WS_POPUP;
}
Expand Down
6 changes: 6 additions & 0 deletions src/UserInterface/PythonApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ class CPythonApplication : public CMSApplication, public CInputKeyboard, public
void OnIMEKeyDown(int iIndex);

int CheckDeviceState();
#ifdef ENABLE_WINDOW_RESIZE
void ChangeDeviceSize(int width, int height);
#endif

BOOL __IsContinuousChangeTypeCursor(int iCursorNum);

Expand Down Expand Up @@ -432,6 +435,9 @@ class CPythonApplication : public CMSApplication, public CInputKeyboard, public
bool m_isMinimizedWnd;
bool m_isActivateWnd;
BOOL m_isWindowFullScreenEnable;
#ifdef ENABLE_WINDOW_RESIZE
bool m_isResizing;
#endif

DWORD m_dwStickyKeysFlag;
int m_iForceSightRange;
Expand Down
19 changes: 18 additions & 1 deletion src/UserInterface/PythonApplicationEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,24 @@ void CPythonApplication::OnUIRender()
}

void CPythonApplication::OnSizeChange(int width, int height)
{
{
#ifdef ENABLE_WINDOW_RESIZE
if (width <= 0 || height <= 0)
return;

if (m_dwWidth != width || m_dwHeight != height)
{
m_dwWidth = width;
m_dwHeight = height;

SetRect(&m_rect, 0, 0, width, height);
AdjustWindowRectEx(&m_rect, GetWindowStyle(m_hWnd), GetMenu(m_hWnd) != NULL, GetWindowExStyle(m_hWnd));

ChangeDeviceSize(width, height);
UI::CWindowManager::Instance().Resize(width, height);
CPythonNetworkStream::Instance().ResizeUI();
}
#endif
}

void CPythonApplication::OnMouseMiddleButtonDown(int x, int y)
Expand Down
5 changes: 5 additions & 0 deletions src/UserInterface/PythonApplicationModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,11 @@ void initapp()
PyModule_AddIntConstant(poModule, "CAMERA_TO_POSITIVE", CPythonApplication::CAMERA_TO_POSITIVE);
PyModule_AddIntConstant(poModule, "CAMERA_TO_NEGATIVE", CPythonApplication::CAMERA_TO_NEGITIVE);
PyModule_AddIntConstant(poModule, "CAMERA_STOP", CPythonApplication::CAMERA_STOP);
#ifdef ENABLE_WINDOW_RESIZE
PyModule_AddIntConstant(poModule, "ENABLE_WINDOW_RESIZE", 1);
#else
PyModule_AddIntConstant(poModule, "ENABLE_WINDOW_RESIZE", 0);
#endif

#ifdef ENABLE_COSTUME_SYSTEM
PyModule_AddIntConstant(poModule, "ENABLE_COSTUME_SYSTEM", 1);
Expand Down
30 changes: 30 additions & 0 deletions src/UserInterface/PythonApplicationProcedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,27 @@ LRESULT CPythonApplication::WindowProcedure(HWND hWnd, UINT uiMsg, WPARAM wParam
RECT rcWnd;
GetClientRect(&rcWnd);

#ifdef ENABLE_WINDOW_RESIZE
m_isResizing = false;
UINT uWidth = rcWnd.right - rcWnd.left;
UINT uHeight = rcWnd.bottom - rcWnd.top;
m_grpDevice.ResizeBackBuffer(uWidth, uHeight);
OnSizeChange(uWidth, uHeight);
#else
UINT uWidth=rcWnd.right-rcWnd.left;
UINT uHeight=rcWnd.bottom-rcWnd.left;
m_grpDevice.ResizeBackBuffer(uWidth, uHeight);
OnSizeChange(short(LOWORD(lParam)), short(HIWORD(lParam)));
#endif
}
break;
case WM_NCLBUTTONDOWN:
{
switch (wParam)
{
case HTMAXBUTTON:
ShowWindow(hWnd, IsZoomed(hWnd) ? SW_RESTORE : SW_MAXIMIZE);
return 0;
case HTSYSMENU:
return 0;
case HTMINBUTTON:
Expand Down Expand Up @@ -274,6 +284,22 @@ LRESULT CPythonApplication::WindowProcedure(HWND hWnd, UINT uiMsg, WPARAM wParam
if (wParam == SC_KEYMENU)
return 0;
break;
#ifdef ENABLE_WINDOW_RESIZE
case WM_ENTERSIZEMOVE:
m_isResizing = true;
break;

case WM_GETMINMAXINFO:
{
MINMAXINFO* pMMI = (MINMAXINFO*)lParam;
RECT rcMinClient = { 0, 0, 800, 600 };
AdjustWindowRectEx(&rcMinClient, GetWindowStyle(m_hWnd), GetMenu(m_hWnd) != NULL, GetWindowExStyle(m_hWnd));
pMMI->ptMinTrackSize.x = rcMinClient.right - rcMinClient.left;
pMMI->ptMinTrackSize.y = rcMinClient.bottom - rcMinClient.top;
break;
}
#endif

case WM_SYSKEYDOWN:
switch (LOWORD(wParam))
{
Expand All @@ -294,7 +320,11 @@ LRESULT CPythonApplication::WindowProcedure(HWND hWnd, UINT uiMsg, WPARAM wParam
break;

case WM_SETCURSOR:
#ifdef ENABLE_WINDOW_RESIZE
if (LOWORD(lParam) == HTCLIENT && IsActive())
#else
if (IsActive())
#endif
{
if (m_bCursorVisible && CURSOR_MODE_HARDWARE == m_iCursorMode)
{
Expand Down
10 changes: 10 additions & 0 deletions src/UserInterface/PythonNetworkStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ bool CPythonNetworkStream::IsSelectedEmpire()
return false;
}

#ifdef ENABLE_WINDOW_RESIZE
void CPythonNetworkStream::ResizeUI()
{
if ("Game" != m_strPhase)
return;

PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "BINARY_UpdateUI", Py_BuildValue("()"));
}
#endif

UINT CPythonNetworkStream::GetAccountCharacterSlotDatau(UINT iSlot, UINT eType)
{
if (iSlot >= PLAYER_PER_ACCOUNT4)
Expand Down
3 changes: 3 additions & 0 deletions src/UserInterface/PythonNetworkStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class CPythonNetworkStream : public CNetworkStream, public CSingleton<CPythonNet
// END_OF_SUPPORT_BGM

bool IsSelectedEmpire();
#ifdef ENABLE_WINDOW_RESIZE
void ResizeUI();
#endif

void ToggleGameDebugInfo();

Expand Down