Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- -----------------------------------------
- * Game hacking QTS ( Quickie Tip Series )
- * no. 26 - Input box
- -----------------------------------------
- * Author: SEGnosis - GHAnon.net
- * Thanks to:
- * bitterbanana - No known site
- * Drunken Cheetah - No known site
- * fatboy88 - No known site
- * Geek4Ever - No known site
- * learn_more - www.uc-forum.com
- * Novocaine - http://ilsken.net/blog/?page_id=64
- * Philly0494 - No known site
- * Roverturbo - www.uc-forum.com
- * SilentKarma - www.halocoders.com - offline
- * Strife - www.uc-forum.com
- * Wieter20 - No known site
- */
- class C_InputBox
- {
- public:
- void Load()
- {
- m_szInputQueue[ 0 ] = 0;
- SetRect( &m_rtClient, 0, 0, 300, 200 );
- SetRect( &m_rtInput, 0, 0, 150, CDraw.m_iListBoxFontHeight + 2 );
- SetRect( &m_rtButton, 0, 0, CDraw.m_iListBoxFontWidth * 4, CDraw.m_iListBoxFontHeight + 2 );
- }
- void Input( UINT uiMessage, WPARAM wParam, LPARAM lParam );
- void DrawDialog();
- void Move();
- bool GetCurrentInput( char* szpQueue )
- {
- if( m_bActive)
- strcpy( szpQueue, m_szInputQueue );
- return false;
- }
- private:
- char m_szInputQueue[ 24 ];
- bool m_bActive;
- RECT m_rtClient,
- m_rtInput,
- m_rtButton;
- }CInputBox;
- void C_InputBox::Input( UINT uiMessage, WPARAM wParam, LPARAM lParam )
- {
- switch( uiMessage )
- {
- case WM_LBUTTONDOWN:
- {
- POINT ptCursor;
- GetCursorPos( &ptCursor );
- ScreenToClient( g_hWnd, &ptCursor );
- if( CDraw.IsPointInRect( ptCursor, m_rtButton, true ) )
- m_bActive = false;
- }
- break;
- case WM_CHAR:
- switch( wParam )
- {
- case VK_BACK:
- m_szInputQueue[ max( strlen( m_szInputQueue ) - 1, 0 ) ] = 0;
- break;
- case VK_RETURN:
- m_bActive = false;
- break;
- case VK_TAB:
- if( !m_bActive )
- {
- m_bActive = true;
- m_szInputQueue[ 0 ] = 0;
- }
- break;
- default:
- {
- static char szInput[ 2 ] = { 0 };
- szInput[ 0 ] = ( char )wParam;
- if( strlen( m_szInputQueue ) < 23 && ( isalnum( szInput[ 0 ] ) || szInput[ 0 ] == VK_SPACE ) )
- strcat( m_szInputQueue, szInput );
- }
- break;
- }
- break;
- }
- }
- void C_InputBox::Move()
- {
- SetRect( &m_rtClient, g_rtClient.right/2 - m_rtClient.right/2, g_rtClient.bottom/2 - m_rtClient.bottom/2, m_rtClient.right, m_rtClient.bottom );
- SetRect( &m_rtInput, m_rtClient.left + 75, m_rtClient.top + 50, m_rtInput.right, m_rtInput.bottom );
- SetRect( &m_rtButton, m_rtClient.left + m_rtClient.right/2 - m_rtButton.right/2, m_rtClient.top + m_rtClient.bottom - m_rtButton.bottom - 10, m_rtButton.right, m_rtButton.bottom );
- }
- void C_InputBox::DrawDialog()
- {
- if( !m_bActive )
- return;
- Move();
- const D3DCOLOR coLightGray = D3DCOLOR_XRGB( 150, 150, 150 );
- const D3DCOLOR coMocha = D3DCOLOR_XRGB( 63, 41, 4 );
- const D3DCOLOR coMochaBorder= D3DCOLOR_XRGB( 27, 27, 27 );
- CDraw.GradientRect( D3DXVECTOR2( m_rtClient.left, m_rtClient.top ), m_rtClient.right, m_rtClient.bottom, CDraw.m_coWhite, coLightGray );
- CDraw.Rect( m_rtInput.left, m_rtInput.top, m_rtInput.right, m_rtInput.bottom, coMocha );
- CDraw.LineRect( m_rtInput.left, m_rtInput.top, m_rtInput.right, m_rtInput.bottom, coMochaBorder );
- CDraw.Rect( m_rtButton.left, m_rtButton.top, m_rtButton.right, m_rtButton.bottom, coMocha );
- CDraw.LineRect( m_rtButton.left, m_rtButton.top, m_rtButton.right, m_rtButton.bottom, coMochaBorder );
- CDraw.String( m_rtButton.left + CDraw.m_iListBoxFontWidth, m_rtButton.top + 1, CDraw.m_coWhite, FF_DEFAULT, "Ok" );
- CDraw.String( m_rtInput.left + 5, m_rtInput.top + 1, CDraw.m_coWhite, FF_DEFAULT, m_szInputQueue );
- }
- CInputBox.Load(); // once
- CInputBox.DrawDialog(); // in endscene
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement