Beispiel #1
0
void EclRemoveAllWindows()
{
    while( windows.ValidIndex(0) )
    {
        EclRemoveWindow( windows[0]->m_name );
    }
}
void NewsScreenInterface::ClickNewsButton ( Button *button )
{

	int index;
	sscanf ( button->name, "news_story %d", &index );

	index += baseoffset;

	// Dirty the old button

	char oldname [128];
	UplinkSnprintf ( oldname, sizeof ( oldname ), "news_story %d", currentselect - baseoffset );
	EclDirtyButton ( oldname );

	CompanyUplink *cu = (CompanyUplink *) game->GetWorld ()->GetCompany ( "Uplink" );
	UplinkAssert ( cu );

	if ( cu->GetNews (index) ) {

		currentselect = index;
        
	    // Reset the offset so the player can read it from line 1
        ScrollBox *scrollBox = ScrollBox::GetScrollBox( "news_details" );
        if ( scrollBox ) {
            scrollBox->SetCurrentIndex( 0 );

            char *newDetails = cu->GetNews (index)->GetDetails();
            Button *detailsButton = EclGetButton ( "news_details box" );
            UplinkAssert (detailsButton);
        	LList <char *> *wrappedtext = wordwraptext ( newDetails, detailsButton->width );
			if ( wrappedtext ) {
				scrollBox->SetNumItems( wrappedtext->Size() );
				if ( wrappedtext->ValidIndex (0) && wrappedtext->GetData (0) )
					delete [] wrappedtext->GetData(0);
				delete wrappedtext;
			}
			else {
				scrollBox->SetNumItems( 0 );
			}
        }

		EclRegisterCaptionChange ( "news_details box", cu->GetNews (index)->GetDetails (), 2000 );

	}
	
}
Beispiel #3
0
void EclRemoveAllWindowsExclude( char *exclude){
	while( windows.ValidIndex(0) )
    {
        EclRemoveWindow( windows[0]->m_name );
    }
}
void NewsScreenInterface::DrawDetails ( Button *button, bool highlighted, bool clicked )
{

	UplinkAssert (button);

	int screenheight = app->GetOptions ()->GetOptionValue ( "graphics_screenheight" );
	glScissor ( button->x, screenheight - (button->y + button->height), button->width, button->height );	
	glEnable ( GL_SCISSOR_TEST );

	// Get the offset

	char name_base [128];
	sscanf ( button->name, "%s", name_base );
    ScrollBox *scrollBox = ScrollBox::GetScrollBox( name_base );
    if ( !scrollBox ) return;
    int offset = scrollBox->currentIndex;
	
	// Draw the button

	glBegin ( GL_QUADS );
		SetColour ( "PanelBackgroundA" );       glVertex2i ( button->x, button->y + button->height );
		SetColour ( "PanelBackgroundB" );       glVertex2i ( button->x, button->y );
		SetColour ( "PanelBackgroundA" );       glVertex2i ( button->x + button->width, button->y );
		SetColour ( "PanelBackgroundB" );       glVertex2i ( button->x + button->width, button->y + button->height );
	glEnd ();

	SetColour ( "PanelBorder" );
	border_draw ( button );


	// Draw the text

	int maxnumlines = (button->height - 10 ) / 15;

	SetColour ( "DefaultText" );

	LList <char *> *wrappedtext = wordwraptext ( button->caption, button->width );

	if ( wrappedtext ) {

		for ( int i = offset; i < wrappedtext->Size (); ++i ) {

			if ( i > maxnumlines + offset )
				break;

			int xpos = button->x + 10;
			int	ypos = button->y + 10 + (i-offset) * 15;

			GciDrawText ( xpos, ypos, wrappedtext->GetData (i), HELVETICA_10 );

		}

		//DeleteLListData ( wrappedtext );							// Only delete first entry - since there is only one string really
		if ( wrappedtext->ValidIndex (0) && wrappedtext->GetData (0) )
			delete [] wrappedtext->GetData (0);
		delete wrappedtext;

	}

	glDisable ( GL_SCISSOR_TEST );
	
}