예제 #1
0
파일: facility.cpp 프로젝트: HexTools/one
void Facility::drawSymbol( wxDC* hdc, int lft, int top, int rgt, int bot )
{
	wxPen hpen( *wxBLACK, 2, wxSOLID );
	wxBrush bgbr( *wxWHITE, wxSOLID ), oldbr;
	wxMemoryDC memdc;

	// Draw background box, and switch to foreground GDI objects
	hdc->SetPen( *wxBLACK_PEN );
	hdc->SetBrush( bgbr );  // background brush
#if 0
	Rectangle( hdc, lft, top, rgt, bot );       // Draw rectangle
#endif
	// draw:
	hdc->SetPen( hpen );
	int mid = ( lft + rgt ) / 2 - 1;
	int x = lft, y = top;
	switch ( type_ )
	{
		case Facility::FIELDWORKS:
			memdc.SelectObject( *hbmFieldWorks );
			hdc->Blit( x + 2, y + 1, 19, 19, &memdc, 0, 0 );
			break;
		case Facility::ENTRENCHMENT:
			memdc.SelectObject( *hbmEntrenchent );
			hdc->Blit( x + 2, y + 1, 19, 19, &memdc, 0, 0 );
			break;
		case Facility::IMPR_FORT:
			memdc.SelectObject( *hbmImpFort );
			hdc->Blit( x + 2, y + 1, 19, 19, &memdc, 0, 0 );
			break;
		case Facility::ZEP_BASE:
			memdc.SelectObject( *hbmZepBase );
			hdc->Blit( x + 2, y + 1, 19, 19, &memdc, 0, 0 );
			break;
		case Facility::FORT:
			hdc->DrawLine( mid, top + 2, rgt - 7, top + 6 );
			hdc->DrawLine( rgt - 7, top + 6, rgt - 7, bot - 7 );
			hdc->DrawLine( rgt - 7, bot - 7, mid, bot - 3 );
			hdc->DrawLine( mid, bot - 3, lft + 6, bot - 7 );
			hdc->DrawLine( lft + 6, bot - 7, lft + 6, top + 6 );
			hdc->DrawLine( lft + 6, top + 6, mid, top + 2 );
			break;
		case Facility::PERMAF3:
		case Facility::PERMAF6:
		case Facility::PERMAF9:
		case Facility::PERMAF12:
			hdc->DrawLine( rgt - 6, top + 5, rgt - 6, bot - 1 );
			hdc->DrawLine( rgt - 5, top + 6, lft + 8, bot - 1 );
			hdc->DrawLine( rgt - 4, bot - 3, lft + 7, bot - 3 );
			// draw box for capacity
			hdc->SetPen( *wxBLACK_PEN );
			hdc->SetBrush( *wxWHITE_BRUSH );
			hdc->SetFont( fnt );
			hdc->DrawRectangle( x, y, 11, 11 );
			hdc->SetTextForeground( *wxBLACK );
			hdc->SetTextBackground( *wxWHITE );

			if ( type_ == Facility::PERMAF3 )
				drawStr( hdc, x + 4, y + 2, const_cast<char*>( "3" ) );
			else if ( type_ == Facility::PERMAF6 )
				drawStr( hdc, x + 4, y + 2, const_cast<char*>( "6" ) );
			else if ( type_ == Facility::PERMAF9 )
				drawStr( hdc, x + 4, y + 2, const_cast<char*>( "9" ) );
			else if ( type_ == Facility::PERMAF12 )
				drawStr( hdc, x + 2, y + 2, const_cast<char*>( "12" ) );
			break;
		case Facility::TEMPAF:
			hdc->DrawLine( rgt - 8, top + 3, rgt - 8, bot - 3 );
			hdc->DrawLine( rgt - 6, top + 5, lft + 6, bot - 3 );
			break;
		case Facility::MULBERRY:
			memdc.SelectObject( *hbmMulberry );
			hdc->Blit( x + 2, y + 4, 19, 16, &memdc, 0, 0 );
			break;
		case Facility::BALLOON:
			memdc.SelectObject( *hbmBalloons );
			hdc->Blit( x + 2, y + 1, 19, 19, &memdc, 0, 0 );
			break;
		case Facility::CONTEST:
			memdc.SelectObject( *hbmContested );
			hdc->Blit( x + 2, y + 1, 19, 19, &memdc, 0, 0 );
			break;
	}
}
예제 #2
0
파일: navalunit.cpp 프로젝트: HexTools/one
void NavalUnit::drawCounter( wxDC* dc, int x, int y, bool border /* = true */ )
{
	wxColor bgnd = _naval_armed_force[getSide( )][getSubType( )].crBg;
	wxColor fgnd = _naval_armed_force[getSide( )][getSubType( )].crFg;
	wxColor bgndtop = *wxWHITE;
	dc->SetFont( fnt );
	// draw counter
#if 0
	dc->SetPen( *wxBLACK_PEN );
	dc->SetBrush( wxBrush( bgnd, wxSOLID ) );
	dc->DrawRectangle( x, y, 28, 27 );
#endif
	if ( border )
	{
		wxBrush bgnd_brush( bgnd, wxSOLID );
		dc->SetPen( *wxBLACK_PEN );  // always black border on counter
		dc->SetBrush( bgnd_brush );
		dc->DrawRectangle( x, y, 28, 27 );
	}
	else
	{
		wxPen bgnd_pen( bgnd, 1, wxSOLID );
		// EJW (new): top 2/3 is white
		wxBrush bgnd_brushtop( bgndtop, wxSOLID );
		dc->SetPen( bgnd_pen );      // no border
		dc->SetBrush( bgnd_brushtop );
		dc->DrawRectangle( x + 1, y + 1, 26, 18 );
		// EJW: bottom 1/3 is background color
		wxBrush bgnd_brush( bgnd, wxSOLID );
		dc->SetPen( bgnd_pen );      // no border
		dc->SetBrush( bgnd_brush );
		dc->DrawRectangle( x + 1, y + 18, 26, 9 );
	}

	char str[10];

	// AA in similar way in both types
	// EJW: AA drawn first, same color as symbol
	dc->SetTextForeground( fgnd );
	sprintf( str, "%d", aa_ );
	drawStr( dc, x + 2, y + 2, str );
#if 0
	dc->SetTextForeground( *wxBLACK );
#endif
	// draw symbol
	// old style (separate capital ships)
	if ( type_ < NavalUnitType::FIRST_FLEET )
	{
		wxBitmap bmp( 20, 20 );

#if 0
		dc.SetBkMode( OPAQUE );
#endif
		wxMemoryDC mem2dc;
		mem2dc.SelectObject( bmp );  // mem2dc = counter's color (16 bit)
		mem2dc.SetBrush( wxBrush( fgnd, wxSOLID ) );
		mem2dc.SetPen( wxPen( fgnd, 1, wxSOLID ) );
		mem2dc.DrawRectangle( 0, 0, 20, 20 );
#if 0
		mem2dc.FillRect( 0, 0, 20, 20, TBrush( TColor( 0, 255, 0 ) ) );
#endif
		wxMemoryDC memdc;
		switch ( getShipType( ) )
		{
			case NavalUnitType::Ship::V:
			case NavalUnitType::Ship::VE:
			case NavalUnitType::Ship::VL:
			case NavalUnitType::Ship::VS:
				memdc.SelectObject( *hbmCarrier );
				break;
			case NavalUnitType::Ship::B:
			case NavalUnitType::Ship::BB:
			case NavalUnitType::Ship::BC:
			case NavalUnitType::Ship::BD:
			case NavalUnitType::Ship::BP:
				memdc.SelectObject( *hbmWarShip );
				break;
			case NavalUnitType::Ship::CA:
			case NavalUnitType::Ship::CC:
			case NavalUnitType::Ship::CD:
			case NavalUnitType::Ship::CL:
				memdc.SelectObject( *hbmCruiser );
				break;
			case NavalUnitType::Ship::DA:
			case NavalUnitType::Ship::DC:
			case NavalUnitType::Ship::DD:
			case NavalUnitType::Ship::DE:
			case NavalUnitType::Ship::DT:
				memdc.SelectObject( *hbmDestroyer );
				break;
			case NavalUnitType::Ship::SC:
			case NavalUnitType::Ship::SS:
			case NavalUnitType::Ship::SO:
				memdc.SelectObject( *hbmSubmarine );
				break;
			case NavalUnitType::Ship::LC:
				memdc.SelectObject( *hbmLC );
				break;
			case NavalUnitType::Ship::NT:
				memdc.SelectObject( *hbmCargoShip );
				break;
			default:
				memdc.SelectObject( *hbmAuxShip );
				break;
		}
		dc->Blit( x + 7, y + 6, 17, 10, &mem2dc, 0, 0, wxXOR );  // don't draw borders
		dc->Blit( x + 7, y + 6, 17, 10, &memdc, 0, 0, wxAND );
		dc->Blit( x + 7, y + 6, 17, 10, &mem2dc, 0, 0, wxXOR );

		dc->SetTextBackground( bgnd );
		dc->SetTextForeground( fgnd );
		dc->SetFont( fnt );

		// write str
		if ( getShipType( ) != NavalUnitType::Ship::NT && getShipType( ) != NavalUnitType::Ship::LC )
		{
			sprintf( str, "%d-%d-%d", pri_, sec_, ter_ );
			int szx = strLen( str );
			int x_pos = x + 14 - ( szx / 2 );
			drawStr( dc, x_pos, y + 17, str );
		}
	}
	// new style task forces
	else
	{
		// name
		dc->SetFont( fnt2 );

#if 0
		sprintf( str, "%s", FleetTypes[GetShipType( ) - NavalUnitType::FIRST_FLEET] );
#endif
		sprintf( str, "%s", name_ );
		wxString ws = wxS( str );

		int szx, szy;
		dc->GetTextExtent( ws, &szx, &szy );

		dc->SetTextForeground( fgnd );
		dc->SetTextBackground( bgnd );

		int x_pos = x + 14 - ( szx / 2 );  // width=28 -> 14 = halfway
		dc->DrawText( ws, x_pos, y + 9 );
		// EJW: switch to white for the type and strength on background color
		dc->SetTextForeground( *wxWHITE );
		// str
		if ( type_ == NavalUnitType::Fleet::TF )
			sprintf( str, "%d", getStrength( ) );
		else if ( type_ == NavalUnitType::Fleet::CG )
			sprintf( str, "(%d)", getStrength( ) );
		else if ( type_ == NavalUnitType::Fleet::SS )
			sprintf( str, "S%d", getStrength( ) );
		else if ( type_ == NavalUnitType::Fleet::RF )
			sprintf( str, "RF%d", getStrength( ) );
		else if ( type_ == NavalUnitType::Fleet::LC || type_ == NavalUnitType::Fleet::NTP )
			sprintf( str, "C%d", getStrength( ) );
		else // SOS type:
			sprintf( str, "%s%d", _fleet_type[type_ - NavalUnitType::FIRST_FLEET], getStrength( ) );

		szx = strLen( str );
		x_pos = x + 14 - ( szx / 2 );
		drawStr( dc, x_pos, y + 19, str );
	}
}