Jump to content

[Request] Function "SetPercentageWithScale"


Recommended Posts

  • Honorable Member
#ui.py
	def SetPercentageWithScale(self, curValue, maxValue):
		wndMgr.SetRenderingRectWithScale(self.hWnd, 0.0, 0.0, -1.0 + float(curValue) / float(maxValue), 0.0)
// EterPythonLib/PythonWindowManagerModule.cpp
PyObject * wndImageSetRenderingRectWithScale(PyObject * poSelf, PyObject * poArgs)
{
	UI::CWindow * pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();
	float fLeft;
	if (!PyTuple_GetFloat(poArgs, 1, &fLeft))
		return Py_BuildException();
	float fTop;
	if (!PyTuple_GetFloat(poArgs, 2, &fTop))
		return Py_BuildException();
	float fRight;
	if (!PyTuple_GetFloat(poArgs, 3, &fRight))
		return Py_BuildException();
	float fBottom;
	if (!PyTuple_GetFloat(poArgs, 4, &fBottom))
		return Py_BuildException();

	if (pWindow->IsType(UI::CExpandedImageBox::Type()))
		((UI::CExpandedImageBox*)pWindow)->SetRenderingRectWithScale(fLeft, fTop, fRight, fBottom);
	else if (pWindow->IsType(UI::CAniImageBox::Type()))
		((UI::CAniImageBox*)pWindow)->SetRenderingRectWithScale(fLeft, fTop, fRight, fBottom);

	return Py_BuildNone();
}

// Bottom of the file where is the functionlist:
		{ "SetRenderingRectWithScale",	wndImageSetRenderingRectWithScale,	METH_VARARGS },
// EterPythonLib/PythonWindow.h
// class CExpandedImageBox --> Public function definition:
			void SetRenderingRectWithScale(float fLeft, float fTop, float fRight, float fBottom);

// class CAniImageBox --> Public function definition:
			void SetRenderingRectWithScale(float fLeft, float fTop, float fRight, float fBottom);
// EterPythonLib/PythonWindow.cpp
// Add this near to the CExcpandedImageBox functions
	void CExpandedImageBox::SetRenderingRectWithScale(float fLeft, float fTop, float fRight, float fBottom)
	{
		if (!m_pImageInstance)
			return;

		((CGraphicExpandedImageInstance*)m_pImageInstance)->SetRenderingRectWithScale(fLeft, fTop, fRight, fBottom);
	}

// Add this near to the CAniImageBox functions
	struct FSetRenderingRectWithScale
	{
		float fLeft, fTop, fRight, fBottom;
		void operator () (CGraphicExpandedImageInstance * pInstance)
		{
			pInstance->SetRenderingRectWithScale(fLeft, fTop, fRight, fBottom);
		}
	};
	void CAniImageBox::SetRenderingRectWithScale(float fLeft, float fTop, float fRight, float fBottom)
	{
		FSetRenderingRectWithScale setRenderingRect;
		setRenderingRect.fLeft = fLeft;
		setRenderingRect.fTop = fTop;
		setRenderingRect.fRight = fRight;
		setRenderingRect.fBottom = fBottom;
		for_each(m_ImageVector.begin(), m_ImageVector.end(), setRenderingRect);
	}
// EterLib/GrpExpandedImageInstance.h
// class CGraphicExpandedImageInstance --> Public function definition:
		void SetRenderingRectWithScale(float fLeft, float fTop, float fRight, float fBottom);
// EterLib/GrpExpandedImageInstance.cpp
void CGraphicExpandedImageInstance::SetRenderingRectWithScale(float fLeft, float fTop, float fRight, float fBottom)
{
	if (IsEmpty())
		return;

	float fWidth = float(GetWidth() * m_v2Scale.x);
	float fHeight = float(GetHeight() * m_v2Scale.y);

	m_RenderingRect.left = fWidth * fLeft;
	m_RenderingRect.top = fHeight * fTop;
	m_RenderingRect.right = fWidth * fRight;
	m_RenderingRect.bottom = fHeight * fBottom;
}

 

A couple of minutes of RE :)

  • Metin2 Dev 1
  • Love 4
Link to comment
Share on other sites

2 hours ago, xP3NG3Rx said:

#ui.py
	def SetPercentageWithScale(self, curValue, maxValue):
		wndMgr.SetRenderingRectWithScale(self.hWnd, 0.0, 0.0, -1.0 + float(curValue) / float(maxValue), 0.0)

// EterPythonLib/PythonWindowManagerModule.cpp
PyObject * wndImageSetRenderingRectWithScale(PyObject * poSelf, PyObject * poArgs)
{
	UI::CWindow * pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();
	float fLeft;
	if (!PyTuple_GetFloat(poArgs, 1, &fLeft))
		return Py_BuildException();
	float fTop;
	if (!PyTuple_GetFloat(poArgs, 2, &fTop))
		return Py_BuildException();
	float fRight;
	if (!PyTuple_GetFloat(poArgs, 3, &fRight))
		return Py_BuildException();
	float fBottom;
	if (!PyTuple_GetFloat(poArgs, 4, &fBottom))
		return Py_BuildException();

	if (pWindow->IsType(UI::CExpandedImageBox::Type()))
		((UI::CExpandedImageBox*)pWindow)->SetRenderingRectWithScale(fLeft, fTop, fRight, fBottom);
	else if (pWindow->IsType(UI::CAniImageBox::Type()))
		((UI::CAniImageBox*)pWindow)->SetRenderingRectWithScale(fLeft, fTop, fRight, fBottom);

	return Py_BuildNone();
}

// Bottom of the file where is the functionlist:
		{ "SetRenderingRectWithScale",	wndImageSetRenderingRectWithScale,	METH_VARARGS },

// EterPythonLib/PythonWindow.h
// class CExpandedImageBox --> Public function definition:
			void SetRenderingRectWithScale(float fLeft, float fTop, float fRight, float fBottom);

// class CAniImageBox --> Public function definition:
			void SetRenderingRectWithScale(float fLeft, float fTop, float fRight, float fBottom);

// EterPythonLib/PythonWindow.cpp
// Add this near to the CExcpandedImageBox functions
	void CExpandedImageBox::SetRenderingRectWithScale(float fLeft, float fTop, float fRight, float fBottom)
	{
		if (!m_pImageInstance)
			return;

		((CGraphicExpandedImageInstance*)m_pImageInstance)->SetRenderingRectWithScale(fLeft, fTop, fRight, fBottom);
	}

// Add this near to the CAniImageBox functions
	struct FSetRenderingRectWithScale
	{
		float fLeft, fTop, fRight, fBottom;
		void operator () (CGraphicExpandedImageInstance * pInstance)
		{
			pInstance->SetRenderingRectWithScale(fLeft, fTop, fRight, fBottom);
		}
	};
	void CAniImageBox::SetRenderingRectWithScale(float fLeft, float fTop, float fRight, float fBottom)
	{
		FSetRenderingRectWithScale setRenderingRect;
		setRenderingRect.fLeft = fLeft;
		setRenderingRect.fTop = fTop;
		setRenderingRect.fRight = fRight;
		setRenderingRect.fBottom = fBottom;
		for_each(m_ImageVector.begin(), m_ImageVector.end(), setRenderingRect);
	}

// EterLib/GrpExpandedImageInstance.h
// class CGraphicExpandedImageInstance --> Public function definition:
		void SetRenderingRectWithScale(float fLeft, float fTop, float fRight, float fBottom);

// EterLib/GrpExpandedImageInstance.cpp
void CGraphicExpandedImageInstance::SetRenderingRectWithScale(float fLeft, float fTop, float fRight, float fBottom)
{
	if (IsEmpty())
		return;

	float fWidth = float(GetWidth() * m_v2Scale.x);
	float fHeight = float(GetHeight() * m_v2Scale.y);

	m_RenderingRect.left = fWidth * fLeft;
	m_RenderingRect.top = fHeight * fTop;
	m_RenderingRect.right = fWidth * fRight;
	m_RenderingRect.bottom = fHeight * fBottom;
}

 

A couple of minutes of RE :)


Thank you bro, you god.

Link to comment
Share on other sites

  • Honorable Member

Actually this is the same as the normal just with scale, I cannot understand ymir why did it this way.
I mean if you don't change the scale, it is in standard case 1.0 so basically the new functions are not necessary.
Just enough to multiply the sizes with the scales.

  • Good 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.