void		LogisticsDialog::update()
{
	enterAnim.update();
	exitAnim.update();

	if ( exitAnim.isDone() )
			bDone = true;

	// hack for some reason we don't get here from the zone
	userInput->mouseOn();
	userInput->setMouseCursor( mState_NORMAL );

	bool bFocus = 0;
	for ( int i = 0; i < editCount; i++ )
	{
		if ( edits[i].hasFocus() )
			bFocus = true;
	}


	if ( enterAnim.isDone() )
		LogisticsScreen::update();

	if ( userInput->leftMouseReleased() 
		&& enterAnim.isDone()
		&& !inside( userInput->getMouseX(), userInput->getMouseY() )
		&& !inside( userInput->getMouseDragX(), userInput->getMouseDragY() ) )
	{
		handleMessage( 0, NO );
	}

	
	if ( !bFocus && enterAnim.isDone() )
	{
		if ( gos_GetKeyStatus( KEY_RETURN ) == KEY_RELEASED )
		{
			if ( getButton( YES ) )
			{
				if ( getButton( YES )->isEnabled() )
					handleMessage( aMSG_LEFTMOUSEDOWN, YES );

			}
			else
				handleMessage( aMSG_LEFTMOUSEDOWN, YES );
			
		}
	}
	if ( gos_GetKeyStatus( KEY_ESCAPE ) == KEY_RELEASED )
		{
			if ( getButton( NO /*MB_MSG_MAINMENU*/ ) )
			{
				if ( getButton( NO )->isEnabled() )
					handleMessage( aMSG_LEFTMOUSEDOWN, NO );
			}

		}
	


}
Exemple #2
0
void ScrollX::update()
{
	long mouseX = userInput->getMouseX();
	long mouseY = userInput->getMouseY();

		if ( userInput->isLeftDrag() && lastX ) // dragging the little tab
		{
			float delta = (float)mouseX - (buttons[0]->globalX() + buttons[0]->width() );
			// figure out what this translates to
			float physicalRange = width() - buttons[0]->width() - buttons[1]->width() - buttons[2]->width();
			float RealRange = scrollMax;
			if ( !physicalRange )
				physicalRange = RealRange;
			float newScrollPos = .5 + (delta)*RealRange/physicalRange;
			if ( newScrollPos < 0 )
				newScrollPos = 0;
			if ( newScrollPos > scrollMax )
				newScrollPos = scrollMax;
			getParent()->handleMessage( aMSG_SCROLLTO, newScrollPos );


			SetScrollPos( newScrollPos );

		}
		else if ( pointInside( mouseX, mouseY ) )
		{
	
			if ( userInput->isLeftClick() || gos_GetKeyStatus(KEY_LMOUSE) == KEY_HELD )
			{
				lastX = 0;
				if ( buttons[2]->pointInside( mouseX, mouseY ) && 
					buttons[2]->pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() ) )
					lastX = mouseX;
				else if ( getParent() )
				{
					buttons[2]->press( 0 );
					if ( !buttons[0]->pointInside( mouseX, mouseY )
						&& !buttons[1]->pointInside( mouseX, mouseY )
						&& pointInside(userInput->getMouseDragX(), userInput->getMouseDragY()) )
					{
						float physicalRange = width() - buttons[0]->width() - buttons[1]->width() - buttons[2]->width();
						float RealRange = scrollMax;
						float delta = (float)mouseX - (buttons[0]->globalX() + buttons[0]->width());
				
						// if above the thumb, page up, otherwise page down
						if ( mouseY < buttons[2]->top() )
						{
							float newScrollPos = (delta)*RealRange/physicalRange;
							if ( scrollPos - newScrollPos > pageInc )
							{
								newScrollPos = scrollPos - pageInc;
							}
							getParent()->handleMessage( aMSG_SCROLLTO, newScrollPos );
							SetScrollPos( newScrollPos );
						}
						else
						{
							float newScrollPos = (delta)*RealRange/physicalRange;
							if (  newScrollPos - scrollPos > pageInc )
							{
								newScrollPos = scrollPos + pageInc;
							}
							getParent()->handleMessage( aMSG_SCROLLTO, newScrollPos );
							SetScrollPos( newScrollPos );
						}
					}
					
				}
			}
			else
				buttons[2]->press( 0 );

		}
		else 
			buttons[2]->press( 0 );

		if ( userInput->leftMouseReleased() )
			lastX = 0;
		
	
	aObject::update();
}
Exemple #3
0
void aTcpipPanel::update()
{
	long retVal = 0;

	if ( bConnectingDlg || bErrorDlg )
	{
		LogisticsOneButtonDialog::instance()->update();
		if ( LogisticsOneButtonDialog::instance()->isDone()  )
		{
			if ( !bErrorDlg )
			{
				if ( bFoundConnection )
				{
					long sessionCount;
					MC2Session* pSessions =  MPlayer->getSessions( sessionCount );
					if ( sessionCount )
					{
						bConnectingDlg = 0;
						retVal = MPlayer->joinSession( &pSessions[0], prefs.playerName[0] );
						if ( !retVal )
						{
							pParentScreen->handleMessage( 1, TCPIP_PANEL_FIRST_BUTTON_ID );
							MPlayer->endSessionScan();
							EString ipAddress;
							comboBox.EditBox().getEntry( ipAddress );
							prefs.setNewIP( ipAddress );
							prefs.save();
							connectingTime = 0.f;

						}
					}

					bFoundConnection = 0;
					bConnectingDlg = 0;

				}
				//they cancelled
				MPlayer->endSessionScan();
				bConnectingDlg = 0;
			}
			else
			{
				LogisticsOneButtonDialog::instance()->end();
				bErrorDlg = 0;
			}

		}
		else  if ( !bErrorDlg && !bFoundConnection )
		{
			connectingTime += frameLength;

			long sessionCount;
			MC2Session* pSessions =  MPlayer->getSessions( sessionCount );
			if ( sessionCount )
			{
				bFoundConnection = true;
				LogisticsOneButtonDialog::instance()->end();
			}
			else
			{
				bFoundConnection = false;
				if ( connectingTime > 20 )
				{
					retVal = MPLAYER_ERR_NO_CONNECTION;
					connectingTime = 0.f;
				}
			}

		}	

		if ( retVal )
		{
			int errorID =  IDS_MP_CONNECT_NO_SESSION;
			int fontID = IDS_MP_CONNECT_ERROR_NO_SESSION_FONT;
			// display a dialog about why this can't happen....
			switch ( retVal )
			{
			case MPLAYER_ERR_HOST_NOT_FOUND:
				errorID = IDS_MP_CONNECT_ERROR_NO_HOST;
				fontID = IDS_MP_CONNECT_ERROR_NO_HOST_FONT;									
				break;

			case MPLAYER_ERR_NO_CONNECTION:
				errorID = IDS_MP_CONNECT_ERROR_NO_CONNECTION;
				fontID = IDS_MP_CONNECT_ERROR_NO_CONNECTION_FONT;									
				break;

			case MPLAYER_ERR_SESSION_IN_PROGRESS:
				errorID = IDS_MP_CONNECT_ERROR_IN_PROGRESS;
				fontID = IDS_MP_CONNECT_ERROR_IN_PROGRESS_FONT;									
				break;

			case MPLAYER_ERR_SESSION_LOCKED:
				errorID = IDS_MP_CONNECT_ERROR_LOCKED;
				fontID = IDS_MP_CONNECT_ERROR_LOCKED_FONT;									
				break;

			case MPLAYER_ERR_BAD_VERSION:
				errorID = IDS_MP_CONNECTION_ERROR_WRONG_VERSION;
				fontID = IDS_MP_CONNECTION_ERROR_WRONG_VERSION_FONT;
				break;

			case MPLAYER_ERR_SESSION_FULL:
				errorID = IDS_MP_CONNECTION_ERROR_FULL;
				fontID = IDS_MP_CONNECTION_ERROR_FULL_FONT;
					break;

			}
			LogisticsOneButtonDialog::instance()->end();
			LogisticsOneButtonDialog::instance()->setText( errorID, IDS_DIALOG_OK, IDS_DIALOG_OK  );
			LogisticsOneButtonDialog::instance()->setFont( fontID );
			LogisticsOneButtonDialog::instance()->begin();
			bConnectingDlg = 0;
			bErrorDlg = 1;
		}
		return;
	}
	
	if ( comboBox.ListBox().isShowing() )
	{
		bExpanded = true;
		comboBox.update();
	}
	else
	{
		if ( !bExpanded )
			aObject::update();
		if ( userInput->leftMouseReleased() )
			bExpanded = 0;
	}


	// grey out button if inavlid...
	EString str;
	comboBox.EditBox().getEntry(str);
	bool bValid = 1;

	if ( str.Length() )
	{
		// now look for 3 periods
		int dotIndex[5];
		for ( int i = 0; i < 5; i++ )
			dotIndex[i] = -1;

		dotIndex[4] = str.Length();

		int tmp = -1;
		while ( tmp )
		{
			tmp = str.Find( '.', tmp+1 );
			if ( tmp == -1 )
			{
				break;
			}
			else
			{
				for ( i = 0; i < 3; i++ )
				{
					if ( dotIndex[i+1] == -1 )
					{
						dotIndex[i+1] = tmp;
						break;
					}
				}
				if ( i == 3 ) // to many decimals
				{
					bValid = 0;
					break;
				}
			}
		}
		if ( dotIndex[3] == -1 || !bValid )
			bValid = 0;
		else if ( dotIndex[3] < str.Length() - 1 )
		{
			bValid = 1;
			char tmp[256];
			strcpy( tmp, str );
			for ( int i = 0; i < 4; i++ )
			{
				long num = getNum( tmp, dotIndex[i]+1, dotIndex[i+1] );
				if ( num < 0 || num > 255 )
				{
					bValid = 0;
				}
			}

			
		}
		else
			bValid = 0;
	}
	else
		bValid = 0;

	if ( bValid )
	{
		button0.disable( 0 );
	} 
	else
		button0.disable( 1 );

	if ( bValid && 	gos_GetKeyStatus( KEY_RETURN ) == KEY_RELEASED )
	{
		handleMessage( TCPIP_PANEL_FIRST_BUTTON_ID, TCPIP_PANEL_FIRST_BUTTON_ID);
	}

	
}
void PauseWindow::update()
{
    if ( bPromptToQuit || bPromptToAbort )
    {
        LogisticsOKDialog::instance()->update();
        if ( LogisticsOKDialog::instance()->getStatus() == LogisticsScreen::YES )
        {
            if ( bPromptToQuit )
                gos_TerminateApplication();
            else {
                //if (MPlayer) {
                //	MPlayer->leaveSession();
                //	}
                //else
                scenarioResult = mis_PLAYER_LOST_BIG;
                aborted = true;
            }

            bPromptToQuit = bPromptToAbort = 0;
        }
        else if ( LogisticsOKDialog::instance()->getStatus() == LogisticsScreen::NO )
        {
            if ( LogisticsOKDialog::instance()->isDone() )
                bPromptToQuit = bPromptToAbort = 0;
        }

    }

    long mouseX = userInput->getMouseX();
    long mouseY = userInput->getMouseY();

    gosEnum_KeyIndex key;
    bool bShift, bCtrl, bAlt;
    MissionInterfaceManager::instance()->getHotKey( OBJECTVIES_COMMAND_KEY, key, bShift, bCtrl, bAlt );


    // hack, mission gui message isn't getting here...
    if ( gos_GetKeyStatus( key ) != KEY_HELD
            && gos_GetKeyStatus( key ) == KEY_PRESSED )
    {
        buttons[OBJECTIVES].toggle(); // big big hack.
    }


    if ( currentTime != 0 )
    {
        currentTime += frameLength;
        float p0 = 0.f;
        float p1 = 0.f;
        float t0 = 0.f;
        float t1 = 0.f;
        // figure out position based on time
        for ( int j = 0; j < 7; j++ )
        {
            if ( moveInfo[j].time <= currentTime && moveInfo[j+1].time > currentTime )
            {
                t0 = moveInfo[j].time;
                t1 = moveInfo[j + 1].time;
                //p0 = -(800.f - moveInfo[j].position)  + ((float)Environment.screenWidth);
                //p1 = -(800.f - moveInfo[j + 1].position) + ((float)Environment.screenWidth);
                //magic 05032012 begin
                p0 = -(850.f - moveInfo[j].position)  + ((float)Environment.screenWidth);
                p1 = -(850.f - moveInfo[j + 1].position) + ((float)Environment.screenWidth);
                //magic 05032012 end
                break;
            }
        }
        if ( p1 )
        {
            float dT = currentTime - t0;
            float currentPosition = p0 + dT * ( (p1 - p0)/(t1 -t0) );
            float delta = currentPosition - currentPos;
            currentPos += delta;

            for ( int i = 0; i < buttonCount; i++ )
            {
                buttons[i].move( delta, 0 );
            }

            for ( i = 0; i < staticCount; i++ )
            {
                statics[i].move( delta, 0 );
            }


            for ( i = 0; i < 2; i++ )
            {
                float dif = backgrounds[i].right - backgrounds[i].left;
                backgrounds[i].left = .5 + currentPos;
                backgrounds[i].right = .5 + currentPos + dif;
            }
        }
    }



    for ( int i = 0; i < buttonCount; i++ )
    {
        if ( buttons[i].location[0].x <= mouseX && mouseX <= buttons[i].location[2].x
                && mouseY >= buttons[i].location[0].y && mouseY <= buttons[i].location[1].y  )
        {
            if ( buttons[i].isEnabled() )
            {
                helpTextHeaderID = buttonData[i].helpTextHeader;
                helpTextID = buttonData[i].helpTextID;

                long lastX = mouseX - userInput->getMouseXDelta();
                long lastY = mouseY - userInput->getMouseYDelta();

                if ( buttons[i].location[0].x >= lastX || lastX >= buttons[i].location[2].x
                        || lastY <= buttons[i].location[0].y || lastY >= buttons[i].location[1].y )
                {
                    soundSystem->playDigitalSample( LOG_HIGHLIGHTBUTTONS );
                }

                if ( buttons[i].state != ControlButton::PRESSED )
                    buttons[i].makeAmbiguous( true );
            }
            else
            {
                helpTextHeaderID = 0;
                helpTextID = 0;
                continue;
            }

            if ( userInput->leftMouseReleased() && !wasDragging )
            {
                {
                    handleClick( buttons[i].ID );
                }
            }
        }
        else if ( buttons[i].isEnabled() && buttons[i].state != ControlButton::PRESSED  )
            buttons[i].makeAmbiguous( 0 );
    }

    if ( currentTime == 0 )
    {
        currentTime = .0001f;
        currentPos = -(800 - PauseWindow::moveInfo[0].position) + ((float)Environment.screenWidth);
        float delta = backgrounds[0].left - currentPos;

        for ( int i = 0; i < buttonCount; i++ )
        {
            for ( int j = 0; j < 4; j++ )
            {
                buttons[i].location[j].x -= delta;
            }
        }

        for ( i = 0; i < staticCount; i++ )
        {
            for ( int j = 0; j < 4; j++ )
            {
                statics[i].location[j].x -= delta;
            }
        }


        for ( i = 0; i < 2; i++ )
        {
            float dif = backgrounds[i].right - backgrounds[i].left;
            backgrounds[i].left = .5 + currentPos;
            backgrounds[i].right = .5 + currentPos + dif;
        }


    }

    wasDragging = userInput->wasLeftDrag();

    const char * campaignName = LogisticsData::instance->getCampaignName().Data();
    char campName[1024];
    _splitpath(campaignName,NULL,NULL,campName,NULL);
    if ( MPlayer ||
            LogisticsData::instance->isSingleMission() ||
            (stricmp("tutorial",campName) == 0))
    {
        buttons[ SAVE ].disable( true );
        buttons[ LOAD ].disable( true );
    }
    if ( MPlayer )
    {
        buttons[OPTIONS].disable( true );
    }

}
Exemple #5
0
void aScrollBar::update()
{
	long mouseX = userInput->getMouseX();
	long mouseY = userInput->getMouseY();

		if ( userInput->isLeftDrag() && lastY ) // dragging the little tab
		{
			int tmpLastY = mouseY; 
			tmpLastY -= userInput->getMouseDragY();
			tmpLastY += lastY;

			float finalPos = (float)tmpLastY;
			// figure out what this translates to
			float physicalRange = height() - topButton.height() - bottomButton.height() - scrollTab.height() -  2.f;
			float RealRange = scrollMax;
			if ( !physicalRange )
				physicalRange = RealRange;

			//Check for what if both of the above are zero.  Probably nothing to scroll to, eh?
			if ((fabs(physicalRange) > Stuff::SMALL) && (fabs(RealRange) > Stuff::SMALL))
			{
				float newScrollPos = .5 + (finalPos)*RealRange/physicalRange;
				if ( newScrollPos < 0 )
					newScrollPos = 0;
				if ( newScrollPos > scrollMax )
					newScrollPos = scrollMax;
				SetScroll( newScrollPos );
				scrollTab.press( true );
			}
		}
		else if ( pointInside( mouseX, mouseY ) )
		{
	
		
				
			if ( userInput->isLeftClick() || gos_GetKeyStatus(KEY_LMOUSE) == KEY_HELD
				|| userInput->leftMouseReleased() )
			{
				lastY = 0;
				if ( scrollTab.pointInside( mouseX, mouseY ) && !userInput->leftMouseReleased()  )
					lastY = scrollTab.top() - topButton.bottom();
				else if ( getParent() )
				{
					if ( !topButton.pointInside( mouseX, mouseY )
						&& !bottomButton.pointInside( mouseX, mouseY )
						&& !topButton.pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() )
						&& !bottomButton.pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() )
						&& mouseY > topButton.globalBottom() 
						&& mouseY < bottomButton.globalY()
						&& pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() )
						&& !scrollTab.pointInside( mouseX, mouseY )
						&& ( userInput->leftMouseReleased() || userInput->getMouseLeftHeld() > .5 ) )
					{
					//	float physicalRange = height() - topButton.height() - bottomButton.height() - scrollTab.height();
					//	float RealRange = scrollMax;
					//	float delta = (float)mouseY - (topButton.globalY() + topButton.height());
				
						float newScrollPos = scrollPos;
						// if above the thumb, page up, otherwise page down
						if ( mouseY < scrollTab.globalY() )
						{
								newScrollPos = scrollPos - pageInc;
						}
						else if ( mouseY > scrollTab.globalBottom() )
						{
								newScrollPos = scrollPos + pageInc;
						}

						if( newScrollPos < 0 )
								newScrollPos = 0;

						if( newScrollPos > scrollMax )
							newScrollPos = scrollMax;

						
					
						getParent()->handleMessage( aMSG_SCROLLTO, newScrollPos );
						SetScrollPos( newScrollPos );

					}

					scrollTab.press( 0 );
					
				}
			}
		}

		if ( userInput->leftMouseReleased() )
			lastY = 0;
		
	
	aObject::update();
}