123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- #define LOGISTICSMECHDISPLAY_CPP
- /*************************************************************************************************\
- LogisticsMechDisplay.cpp : Implementation of the LogisticsMechDisplay component.
- //---------------------------------------------------------------------------//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- \*************************************************************************************************/
- #include "LogisticsMechDisplay.h"
- #include "LogisticsMech.h"
- #include "mclib.h"
- #include "..\resource.h"
- #include "Prefs.h"
- LogisticsMechDisplay::LogisticsMechDisplay( )
- {
- pCurMech = NULL;
- helpTextArrayID = 7;
- }
- //-------------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------
- void LogisticsMechDisplay::update()
- {
- componentListBox.update();
- LogisticsScreen::update();
- mechCamera.update();
- }
- //-------------------------------------------------------------------------------------------------
- LogisticsMechDisplay::~LogisticsMechDisplay()
- {
- }
- //-------------------------------------------------------------------------------------------------
- void LogisticsMechDisplay::render(int xOffset, int yOffset)
- {
- componentListBox.move(xOffset, yOffset);
- componentListBox.render();
- componentListBox.move(-xOffset, -yOffset);
- if ( xOffset == 0 && yOffset == 0 ) // don't draw until we're done animating in or out
- mechCamera.render();
- for ( int i = 0; i < 3; i++ )
- {
- attributeMeters[i].render( xOffset, yOffset );
- }
-
- LogisticsScreen::render( xOffset, yOffset );
- }
- //-------------------------------------------------------------------------------------------------
- int LogisticsMechDisplay::init( )
- {
- FitIniFile file;
- FullPathFileName path;
- path.init( artPath, "mcl_mechinfo", ".fit" );
- if ( NO_ERR != file.open( path ) )
- {
- Assert( 0, 0, "Couldn't open mcl_mechinfo.fit" );
- return 0;
- }
- LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" );
-
- mechCamera.init( rects[1].left(), rects[2].top(),
- rects[2].left(), rects[2].bottom() );
- char blockName[64];
- for ( int i = 0; i < 3; i++ )
- {
- sprintf( blockName, "AttributeMeter%ld", i );
- attributeMeters[i].init( &file, blockName );
- }
-
- componentListBox.init( rects[0].left(), rects[0].top(),
- rects[0].width(), rects[0].height() );
- return 1;
- }
- //-------------------------------------------------------------------------------------------------
- void LogisticsMechDisplay::setMech( LogisticsMech* pMech, bool bFromLB )
- {
- if ( pMech != pCurMech )
- {
- pCurMech = pMech;
- if ( pCurMech )
- {
- textObjects[0].setText( pCurMech->getChassisName() );
- textObjects[1].setText( pCurMech->getName() );
- char text[64];
- char tmpStr[64];
- cLoadString( IDS_MB_MECH_WEIGHT, tmpStr, 63 );
- sprintf( text, tmpStr, pCurMech->getMaxWeight(), (const char*)pCurMech->getMechClass() );
- textObjects[3].setText( text );
-
- long tmpColor;
- textObjects[2].setText( pCurMech->getVariant()->getOptimalRangeString( tmpColor ) );
- textObjects[2].setColor( tmpColor );
- sprintf( text, "%ld", pCurMech->getArmor() );
- textObjects[4].setText( text );
- sprintf( text, "%ld", pCurMech->getDisplaySpeed() );
- textObjects[5].setText( text );
- sprintf( text, "%ld", pCurMech->getJumpRange() * 25);
- textObjects[6].setText( text );
- attributeMeters[0].setValue( pCurMech->getArmor()/MAX_ARMOR_RANGE);
- attributeMeters[1].setValue( pCurMech->getSpeed()/MAX_SPEED_RANGE);
- attributeMeters[2].setValue( pCurMech->getJumpRange() * 25 / MAX_JUMP_RANGE);
-
- EString fileName = pMech->getFileName();
- int index = fileName.Find( '.' );
- fileName = fileName.Left( index );
- index = fileName.ReverseFind( '\\' );
- fileName = fileName.Right( fileName.Length() - index - 1 );
- mechCamera.setMech( fileName, prefs.baseColor, prefs.highlightColor, prefs.highlightColor );
- mechCamera.setScale( pMech->getVariant()->getChassis()->getScale() );
-
- componentListBox.setMech( pCurMech->getVariant() );
- }
- else
- {
- for ( int i = 0; i < 6; i++ )
- textObjects[i].setText( "" );
- attributeMeters[0].setValue( 0 );
- attributeMeters[1].setValue( 0 );
- attributeMeters[2].setValue( 0 );
- componentListBox.setMech( 0 );
- mechCamera.setMech( NULL );
- }
- }
- }
- //*************************************************************************************************
- // end of file ( LogisticsMechDisplay.cpp )
|