Jump to content

EnableFlash & DisableFlash for Buttons


Recommended Posts

  • Honorable Member

First of all I know this is kind useless but for the sake of enabling and disabling the flash effect in buttons I decided to use the standard flash function because I didn't know an easier way.

 

Spoiler

EterPythonLib/PythonWindow.cpp



/// 1.
// Search
	void CButton::Flash()
	{
		m_isFlash = true;
	}

// Add below
	void CButton::EnableFlash()
	{
		m_isFlash = true;
		if (!m_overVisual.IsEmpty())
			SetCurrentVisual(&m_overVisual);
	}

	void CButton::DisableFlash()
	{
		m_isFlash = false;
		if (!m_upVisual.IsEmpty())
			SetCurrentVisual(&m_upVisual);
	}


/// 2.
// Search function
	void CButton::OnRender()

// Replace with
	void CButton::OnRender()
	{
		if (!IsShow())
			return;

		if (m_pcurVisual)
		{
			if (m_isFlash)
			{
				if (!IsIn() && !IsPressed())
				{
					if (!m_overVisual.IsEmpty())
						SetCurrentVisual(&m_overVisual);

					if (int(timeGetTime() / 500) % 2)
						return;
				}
			}

			m_pcurVisual->Render();
		}

		PyCallClassMemberFunc(m_poHandler, "OnRender", BuildEmptyTuple());
	}

EterPythonLib/PythonWindow.h



/// 1.
// Search
			void Flash();

// Add below
			void EnableFlash();
			void DisableFlash();

EterPythonLib/PythonWindowManagerModule.cpp



/// 1.
// Search
PyObject * wndButtonFlash(PyObject * poSelf, PyObject * poArgs)
{
	UI::CWindow * pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();

	((UI::CButton*)pWindow)->Flash();

	return Py_BuildNone();
}

// Add below
PyObject* wndButtonEnableFlash(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow * pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();

	((UI::CButton*)pWindow)->EnableFlash();

	return Py_BuildNone();
}

PyObject* wndButtonDisableFlash(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow * pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();

	((UI::CButton*)pWindow)->DisableFlash();

	return Py_BuildNone();
}

/// 2.
// Search
		{ "Flash",						wndButtonFlash,						METH_VARARGS },

// Add below
		{ "EnableFlash",				wndButtonEnableFlash,				METH_VARARGS },
		{ "DisableFlash",				wndButtonDisableFlash,				METH_VARARGS },

ROOT/ui.py



''' 1. '''
# Search
	def Flash(self):
		wndMgr.Flash(self.hWnd)

# Add below
	def EnableFlash(self):
		wndMgr.EnableFlash(self.hWnd)

	def DisableFlash(self):
		wndMgr.DisableFlash(self.hWnd)

 

As for an example, here is a demonstration of the flash effect.

 

255226CU52L7z-1-.gif

  • Metin2 Dev 1
  • Good 2
  • Love 7
Link to comment
Share on other sites

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.