Jump to content
Sign in to follow this  
Owsap

c++ [C++] EnableFlash & DisableFlash for Buttons

Recommended Posts

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.

CU52L7z.gif

  • Love 7

Share this post


Link to post

Very nice thank you

 

could you please also show how you did the flash effect on the pet System ? :) 

Share this post


Link to post
Acum 3 ore, Syriza a spus:

Very nice thank you

 

could you please also show how you did the flash effect on the pet System ? :) 

Carefully.

  • Love 1

Share this post


Link to post
Il y a 4 heures, Syriza a dit :

Very nice thank you

 

could you please also show how you did the flash effect on the pet System ? :) 

HjHVFFn.jpg

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • 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.