Example #1
0
    void Render( int realX, int realY, bool highlighted, bool clicked )
    {
        Image *img = g_resource->GetImage( "gui/tick.bmp" );
        
        Vote *vote = g_app->GetWorld()->m_votingSystem.LookupVote(m_voteId);
        if( vote && vote->m_result == Vote::VoteUnknown )
        {   
            Team *myTeam = g_app->GetWorld()->GetMyTeam();
            if( vote->GetRequiredAllianceId() == myTeam->m_allianceId )
            {       
                g_renderer->SetBlendMode( Renderer::BlendModeAdditive );

                g_renderer->RectFill( realX, realY, m_w, m_h, Colour(100,100,100,50) );

                if( highlighted || clicked )
                {
                    g_renderer->RectFill( realX, realY, m_w, m_h, Colour(100,100,100,150) );
                    g_renderer->Blit( img, realX+8, realY+2, 15, 15, Colour(255,255,255,20) );
                }

                if( vote->GetCurrentVote( myTeam->m_teamId ) == m_vote )
                {
                    g_renderer->RectFill( realX, realY, m_w, m_h, Colour(100,100,100,150) );
                    g_renderer->Blit( img, realX+8, realY+2, 15, 15, White );
                }

                g_renderer->Rect( realX, realY, m_w, m_h, Colour(100,100,100,100) );

                g_renderer->SetBlendMode( Renderer::BlendModeNormal );
            }
        }
    }
Example #2
0
void VotingSystem::Update()
{
    if( g_app->GetGame()->m_winner != -1 ) 
    {
        return;
    }

    m_updateTimer += SERVER_ADVANCE_PERIOD;
    if( m_updateTimer >= 1 )
    {
        m_updateTimer = 0;

        for( int i = 0; i < m_votes.Size(); ++i )
        {
            if( m_votes.ValidIndex(i) )
            {
                Vote *vote = m_votes[i];
                if( vote->m_result == Vote::VoteUnknown )
                {
                    vote->m_timer -= 1;
                    int required = vote->GetVotesRequired();
                    int yes, no, abstain;
                    vote->GetCurrentVote( &yes, &no, &abstain );
                
                    if( yes >= required )
                    {
                        vote->Finish( Vote::VoteYes );
                    }
                    else if( no >= required || abstain == 0 || vote->m_timer <= 0 )
                    {
                        vote->Finish( Vote::VoteNo );
                    }
                }                
            }
        }
    }
}
Example #3
0
    void Render( int realX, int realY, bool highlighted, bool clicked )
    {
        AlliancesWindow *parent = (AlliancesWindow *)m_parent;
        int voteId = parent->m_votes[m_voteIndex];
        
        Vote *vote = g_app->GetWorld()->m_votingSystem.LookupVote( voteId );
        Team *myTeam = g_app->GetWorld()->GetMyTeam();
        
        if( vote )
        {
            g_renderer->RectFill( realX, realY, m_w, m_h, Colour(10,10,50,200) );
            
            Colour borderCol(255,255,255,100);
            if( highlighted || clicked ) 
            {
                borderCol.m_a = 255;
                g_renderer->RectFill( realX, realY, m_w, m_h, Colour(100,100,150,100) );
            }
            g_renderer->Rect( realX, realY, m_w, m_h, borderCol );

            switch( vote->m_voteType )
            {
                case Vote::VoteTypeJoinAlliance:
                    if( myTeam->m_teamId == vote->m_createTeamId )
                    {
                        char *allianceName = g_app->GetWorld()->GetAllianceName(vote->m_voteData);
                        g_renderer->TextSimple( realX+10, realY+5, White, 14, LANGUAGEPHRASE("dialog_you_requested_alliance_1") );
						char caption[512];
						sprintf( caption, LANGUAGEPHRASE("dialog_you_requested_alliance_2") );
						LPREPLACESTRINGFLAG( 'A', allianceName, caption );
                        g_renderer->TextSimple( realX+10, realY+20, White, 14, caption );
                    }
                    else 
                    {
                        Team *team = g_app->GetWorld()->GetTeam( vote->m_createTeamId );
						char caption[512];
						sprintf( caption, LANGUAGEPHRASE("dialog_requested_alliance_1") );
						LPREPLACESTRINGFLAG( 'T', team->m_name, caption );
                        g_renderer->TextSimple( realX+10, realY+5, White, 15, caption );
                        g_renderer->TextSimple( realX+10, realY+20, White, 15, LANGUAGEPHRASE("dialog_requested_alliance_2") );
                    }
                    break;

                case Vote::VoteTypeKickPlayer:
                {
                    Team *kickTeam = g_app->GetWorld()->GetTeam(vote->m_voteData);
                    if( myTeam->m_teamId == vote->m_createTeamId )
                    {
                        g_renderer->TextSimple( realX+10, realY+5, White, 15, LANGUAGEPHRASE("dialog_you_requested_kick_1") );
						char caption[512];
						sprintf( caption, LANGUAGEPHRASE("dialog_you_requested_kick_2") );
						LPREPLACESTRINGFLAG( 'T', kickTeam->m_name, caption );
                        g_renderer->TextSimple( realX+10, realY+20, White, 15, caption );
                    }
                    else
                    {
                        Team *team = g_app->GetWorld()->GetTeam( vote->m_createTeamId );
						char caption[512];
						sprintf( caption, LANGUAGEPHRASE("dialog_requested_kick_1") );
						LPREPLACESTRINGFLAG( 'T', team->m_name, caption );
                        g_renderer->TextSimple( realX+10, realY+5, White, 15, caption );
						sprintf( caption, LANGUAGEPHRASE("dialog_requested_kick_2") );
						LPREPLACESTRINGFLAG( 'T', kickTeam->m_name, caption );
                        g_renderer->TextSimple( realX+10, realY+20, White, 15, caption );
                    }
                    break;
                }
            }

            int yes, no, abstain;
            vote->GetCurrentVote( &yes, &no, &abstain );

            g_renderer->Text( realX + 190, realY + 12, White, 17, "%ds", int(vote->m_timer) );
            
            g_renderer->TextSimple( realX + m_w - 70, realY + 5, White, 10,  LANGUAGEPHRASE("dialog_vote_yes") );
            g_renderer->TextSimple( realX + m_w - 70, realY + 15, White, 10, LANGUAGEPHRASE("dialog_vote_no") );
            g_renderer->TextSimple( realX + m_w - 70, realY + 25, White, 10, LANGUAGEPHRASE("dialog_vote_abstain") );

            g_renderer->Text( realX + m_w - 20, realY + 5, White, 10,  "%d", yes );
            g_renderer->Text( realX + m_w - 20, realY + 15, White, 10, "%d", no );
            g_renderer->Text( realX + m_w - 20, realY + 25, White, 10, "%d", abstain );
        }
    }
Example #4
0
void VotingWindow::Render( bool _hasFocus )
{
    InterfaceWindow::Render( _hasFocus );

    Vote *vote = g_app->GetWorld()->m_votingSystem.LookupVote(m_voteId);
    if( vote )
    {   
        Team *myTeam = g_app->GetWorld()->GetMyTeam();

        switch( vote->m_voteType )
        {
            case Vote::VoteTypeJoinAlliance:
                if( myTeam->m_teamId == vote->m_createTeamId )
                {
                    char *allianceName = g_app->GetWorld()->GetAllianceName(vote->m_voteData);
                    g_renderer->TextCentreSimple( m_x+m_w/2, m_y+30, White, 20, LANGUAGEPHRASE("dialog_you_requested_alliance_1") );
					char caption[512];
					sprintf( caption, LANGUAGEPHRASE("dialog_you_requested_alliance_2") );
					LPREPLACESTRINGFLAG( 'A', allianceName, caption );
                    g_renderer->TextCentreSimple( m_x+m_w/2, m_y+50, White, 20, caption );
                }
                else if( myTeam->m_allianceId == vote->m_voteData )
                {
                    Team *team = g_app->GetWorld()->GetTeam( vote->m_createTeamId );
					char caption[512];
					sprintf( caption, LANGUAGEPHRASE("dialog_requested_alliance_1") );
					LPREPLACESTRINGFLAG( 'T', team->m_name, caption );
					g_renderer->TextCentreSimple( m_x+m_w/2, m_y+30, White, 20, caption );
                    g_renderer->TextCentreSimple( m_x+m_w/2, m_y+50, White, 20, LANGUAGEPHRASE("dialog_requested_alliance_2") );
                }
                break;

            case Vote::VoteTypeKickPlayer:
            {
                Team *kickTeam = g_app->GetWorld()->GetTeam(vote->m_voteData);
                if( myTeam->m_teamId == vote->m_createTeamId )
                {
                    g_renderer->TextCentreSimple( m_x+m_w/2, m_y+30, White, 20, LANGUAGEPHRASE("dialog_you_requested_kick_1") );
					char caption[512];
					sprintf( caption, LANGUAGEPHRASE("dialog_you_requested_kick_2") );
					LPREPLACESTRINGFLAG( 'T', kickTeam->m_name, caption );
                    g_renderer->TextCentreSimple( m_x+m_w/2, m_y+50, White, 20, caption );
                }
                else if( myTeam->m_allianceId == kickTeam->m_allianceId &&
                         myTeam->m_teamId != kickTeam->m_teamId )
                {
                    Team *team = g_app->GetWorld()->GetTeam( vote->m_createTeamId );
					char caption[512];
					sprintf( caption, LANGUAGEPHRASE("dialog_requested_kick_1") );
					LPREPLACESTRINGFLAG( 'T', team->m_name, caption );
                    g_renderer->TextCentreSimple( m_x+m_w/2, m_y+30, White, 20, caption );
					sprintf( caption, LANGUAGEPHRASE("dialog_requested_kick_2") );
					LPREPLACESTRINGFLAG( 'T', kickTeam->m_name, caption );
                    g_renderer->TextCentreSimple( m_x+m_w/2, m_y+50, White, 20, caption );
                }
                break;
            }
        }


        g_renderer->SetFont( "kremlin" );
        g_renderer->TextCentreSimple( m_x + m_w/2, m_y + 90, White, 20, LANGUAGEPHRASE("dialog_vote_yes") );
        g_renderer->TextCentreSimple( m_x + m_w/2, m_y + 120, White, 20, LANGUAGEPHRASE("dialog_vote_no") );
        g_renderer->TextCentreSimple( m_x + m_w/2, m_y + 150, White, 20, LANGUAGEPHRASE("dialog_vote_abstain") );
        g_renderer->SetFont();

        int yes, no, abstain;
        vote->GetCurrentVote( &yes, &no, &abstain );

        g_renderer->Text( m_x + m_w - 40, m_y + 90, White, 20, "%d", yes );
        g_renderer->Text( m_x + m_w - 40, m_y + 120, White, 20, "%d", no );
        g_renderer->Text( m_x + m_w - 40, m_y + 150, White, 20, "%d", abstain );

        if( vote->m_result == Vote::VoteUnknown )
        {
			char caption[512];
			sprintf( caption, LANGUAGEPHRASE("dialog_vote_seconds_to_vote") );
			LPREPLACEINTEGERFLAG( 'S', (int) vote->m_timer, caption );
            g_renderer->TextCentreSimple( m_x + m_w/2, m_y + m_h - 70, White, 15, caption );
            
            int votesRequired = vote->GetVotesRequired();
			sprintf( caption, LANGUAGEPHRASE("dialog_vote_number_votes_required") );
			LPREPLACEINTEGERFLAG( 'V', votesRequired, caption );
            g_renderer->TextCentreSimple( m_x+m_w/2, m_y + m_h - 50, White, 15, caption );
        }
        else if( vote->m_result == Vote::VoteYes )
        {
            g_renderer->SetFont( "kremlin" );
            g_renderer->TextCentreSimple( m_x+m_w/2, m_y + m_h - 70, White, 30, LANGUAGEPHRASE("dialog_vote_succeeded") );
            g_renderer->SetFont();
        }
        else if( vote->m_result == Vote::VoteNo )
        {
            g_renderer->SetFont( "kremlin" );
            g_renderer->TextCentreSimple( m_x+m_w/2, m_y + m_h - 70, White, 30, LANGUAGEPHRASE("dialog_vote_failed") );
            g_renderer->SetFont();
        }
    }       
}