本文整理汇总了C++中GfxEngine类的典型用法代码示例。如果您正苦于以下问题:C++ GfxEngine类的具体用法?C++ GfxEngine怎么用?C++ GfxEngine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GfxEngine类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
void ScreenWait::initialize( GfxEngine& engine, GuiEnv& gui )
{
_d->engine = &engine;
_d->gui = &gui;
_d->bgPicture = Picture::load("c3title", 1);
// center the bgPicture on the screen
int x = (engine.getScreenWidth() - _d->bgPicture.getWidth()) / 2;
int y = (engine.getScreenHeight() - _d->bgPicture.getHeight()) / 2;
_d->bgPicture.setOffset(x, -y);
}
示例2: draw
void AdvisorFinanceWindow::draw( GfxEngine& painter )
{
if( !isVisible() )
return;
painter.drawPicture( *_d->background, getScreenLeft(), getScreenTop() );
Widget::draw( painter );
}
示例3: draw
void AdvisorsWindow::draw( GfxEngine& engine )
{
if( !isVisible() )
return;
engine.drawPicture( *_d->background, Point( 0, 0 ) );
Widget::draw( engine );
}
示例4: draw
void PopupMessageBox::draw( GfxEngine& painter )
{
if( !isVisible() )
return;
painter.drawPicture( *_d->background, getScreenLeft(), getScreenTop() );
Widget::draw( painter );
}
示例5: draw
//! draws the element and its children
void GroupBox::draw( GfxEngine& painter )
{
if (!isVisible())
return;
painter.drawPicture( *_d->texture, getScreenLeft(), getScreenTop(), &getAbsoluteClippingRectRef() );
Widget::draw( painter );
}
示例6: draw
//! draws the element and its children
void ScrollBar::draw( GfxEngine& painter )
{
if (!isVisible())
return;
//draw background
if( _d->texture.isValid() )
{
painter.drawPicture( _d->texture, getAbsoluteRect().UpperLeftCorner );
}
//draw slider
if( _d->sliderTexture.isValid() )
{
painter.drawPicture( _d->sliderTexture, _d->sliderRect.UpperLeftCorner );
}
// draw buttons
Widget::draw( painter );
}
示例7: draw
void Minimap::draw(GfxEngine& painter)
{
if( !isVisible() )
return;
if( DateTime::getElapsedTime() - _d->lastTimeUpdate > 500 )
{
_d->updateImage();
_d->lastTimeUpdate = DateTime::getElapsedTime();
}
painter.drawPicture( *_d->minimap, getScreenLeft(), getScreenTop() ); // 152, 145
Widget::draw( painter );
}
示例8: draw
void SenatePopupInfo::draw( GfxEngine& painter )
{
Point cursorPos = getEnvironment()->getCursorPos();
Tile* tile = _d->mapRenderer->getTile( cursorPos, false );
if( tile )
{
SmartPtr< Senate > senate = tile->getOverlay().as< Senate >();
if( senate.isValid() )
{
if( DateTime::getElapsedTime() - _d->lastUpdateTime > 2000 )
{
_d->updateRatings();
}
painter.drawPicture( *_d->background, cursorPos );
}
}
}
示例9: loadArchive
void PictureBank::loadArchive( const std::string &filename, GfxEngine& engine )
{
std::cout << "reading image archive: " << filename << std::endl;
struct archive *a;
struct archive_entry *entry;
int rc;
a = archive_read_new();
archive_read_support_compression_all(a);
archive_read_support_format_all(a);
rc = archive_read_open_filename(a, filename.c_str(), 16384); // block size
if (rc != ARCHIVE_OK)
{
THROW("Cannot open archive " << filename);
}
SDL_Surface *surface;
SDL_RWops *rw;
const Uint32 bufferSize = 10000000; // allocated buffer
std::auto_ptr< Uint8 > buffer( new Uint8[ bufferSize ] );
if( buffer.get() == 0 )
THROW("Memory error, cannot allocate buffer size " << bufferSize);
std::string entryname;
Picture tmpPicture;
while( archive_read_next_header(a, &entry) == ARCHIVE_OK )
{
// for all entries in archive
entryname = archive_entry_pathname(entry);
if ((archive_entry_stat(entry)->st_mode & S_IFREG) == 0)
{
// not a regular file (maybe a directory). skip it.
continue;
}
if (archive_entry_stat(entry)->st_size >= bufferSize)
{
THROW("Cannot load archive: file is too big " << entryname << " in archive " << filename);
}
int size = archive_read_data(a, buffer.get(), bufferSize); // read data into buffer
rw = SDL_RWFromMem(buffer.get(), size);
surface = IMG_Load_RW(rw, 0);
SDL_SetAlpha( surface, 0, 0 );
tmpPicture.init( surface, Point() );
engine.loadPicture( tmpPicture );
setPicture( entryname, tmpPicture );
SDL_FreeRW(rw);
}
rc = archive_read_finish(a);
if (rc != ARCHIVE_OK)
{
THROW("Error while reading archive " << filename);
}
}
示例10: initialize
void ScreenGame::initialize( GfxEngine& engine, GuiEnv& gui )
{
_d->gui = &gui;
_d->engine = &engine;
_d->infoBoxMgr = InfoBoxManager::create( &gui );
CityPtr city = _d->scenario->getCity();
_d->gui->clear();
/*new PopupMessageBox( _d->gui->getRootWidget(), "Test title", "This is test string for popup message box",
"Sen 351 BC", "For New player" ); */
const int topMenuHeight = 23;
const Picture& rPanelPic = Picture::load( ResourceGroup::panelBackground, 14 );
Rect rPanelRect( engine.getScreenWidth() - rPanelPic.getWidth(), topMenuHeight,
engine.getScreenWidth(), engine.getScreenHeight() );
_d->rightPanel = MenuRigthPanel::create( gui.getRootWidget(), rPanelRect, rPanelPic);
_d->topMenu = TopMenu::create( gui.getRootWidget(), topMenuHeight );
_d->topMenu->setPopulation( city->getPopulation() );
_d->topMenu->setFunds( city->getFunds().getValue() );
_d->topMenu->setDate( GameDate::current() );
_d->menu = Menu::create( gui.getRootWidget(), -1, _d->scenario->getCity() );
_d->menu->setPosition( Point( engine.getScreenWidth() - _d->menu->getWidth() - _d->rightPanel->getWidth(),
_d->topMenu->getHeight() ) );
_d->extMenu = ExtentMenu::create( gui.getRootWidget(), _d->mapRenderer, -1, _d->scenario->getCity() );
_d->extMenu->setPosition( Point( engine.getScreenWidth() - _d->extMenu->getWidth() - _d->rightPanel->getWidth(),
_d->topMenu->getHeight() ) );
_d->wndStackMsgs = WindowMessageStack::create( gui.getRootWidget(), -1 );
_d->wndStackMsgs->setPosition( Point( gui.getRootWidget()->getWidth() / 4, 33 ) );
_d->wndStackMsgs->sendToBack();
_d->rightPanel->bringToFront();
// 8*30: used for high buildings (granary...), visible even when not in tilemap_area.
getMapArea().setViewSize( engine.getScreenSize() + Size( 180 ) );
// here move camera to start position of map
getMapArea().setCenterIJ( _d->scenario->getCity()->getCameraPos() );
new SenatePopupInfo( _d->gui->getRootWidget(), _d->mapRenderer );
//connect elements
CONNECT( _d->topMenu, onSave(), _d.data(), Impl::showSaveDialog );
CONNECT( _d->topMenu, onExit(), this, ScreenGame::resolveExitGame );
CONNECT( _d->topMenu, onEnd(), this, ScreenGame::resolveEndGame );
CONNECT( _d->topMenu, onRequestAdvisor(), _d.data(), Impl::showAdvisorsWindow );
CONNECT( _d->menu, onCreateConstruction(), _d.data(), Impl::resolveCreateConstruction );
CONNECT( _d->menu, onRemoveTool(), _d.data(), Impl::resolveRemoveTool );
CONNECT( _d->menu, onMaximize(), _d->extMenu, ExtentMenu::maximize );
CONNECT( _d->extMenu, onCreateConstruction(), _d.data(), Impl::resolveCreateConstruction );
CONNECT( _d->extMenu, onRemoveTool(), _d.data(), Impl::resolveRemoveTool );
CONNECT( city, onPopulationChanged(), _d->topMenu, TopMenu::setPopulation );
CONNECT( city, onFundsChanged(), _d->topMenu, TopMenu::setFunds );
CONNECT( &GameDate::instance(), onMonthChanged(), _d->topMenu, TopMenu::setDate );
CONNECT( &_d->mapRenderer, onShowTileInfo(), _d.data(), Impl::showTileInfo );
CONNECT( city, onWarningMessage(), _d->wndStackMsgs, WindowMessageStack::addMessage );
CONNECT( &_d->mapRenderer, onWarningMessage(), _d->wndStackMsgs, WindowMessageStack::addMessage );
CONNECT( _d->extMenu, onSelectOverlayType(), _d.data(), Impl::resolveSelectOverlayView );
CONNECT( _d->extMenu, onEmpireMapShow(), _d.data(), Impl::showEmpireMapWindow );
CONNECT( _d->extMenu, onAdvisorsWindowShow(), _d.data(), Impl::showAdvisorsWindow );
CONNECT( _d->extMenu, onMissionTargetsWindowShow(), _d.data(), Impl::showMissionTaretsWindow );
CONNECT( city, onDisasterEvent(), &_d->alarmsHolder, AlarmEventHolder::add );
CONNECT( _d->extMenu, onSwitchAlarm(), &_d->alarmsHolder, AlarmEventHolder::next );
CONNECT( &_d->alarmsHolder, onMoveToAlarm(), &_d->mapArea, TilemapArea::setCenterIJ );
CONNECT( &_d->alarmsHolder, onAlarmChange(), _d->extMenu, ExtentMenu::setAlarmEnabled );
}
示例11: drawTile
void LayerHealth::drawTile(GfxEngine& engine, Tile& tile, Point offset)
{
Point screenPos = tile.getXY() + offset;
tile.setWasDrawn();
bool needDrawAnimations = false;
if( tile.getOverlay().isNull() )
{
//draw background
engine.drawPicture( tile.getPicture(), screenPos );
}
else
{
TileOverlayPtr overlay = tile.getOverlay();
int healthLevel = -1;
switch( overlay->getType() )
{
//fire buildings and roads
case construction::road:
case construction::B_PLAZA:
needDrawAnimations = true;
engine.drawPicture( tile.getPicture(), screenPos );
break;
case building::B_DOCTOR:
case building::B_HOSPITAL:
case building::B_BARBER:
case building::B_BATHS:
needDrawAnimations = _flags.count( overlay->getType() );
if( needDrawAnimations )
{
engine.drawPicture( tile.getPicture(), screenPos );
}
else
{
CityHelper helper( _city );
drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
break;
//houses
case building::house:
{
HousePtr house = overlay.as< House >();
if( _flags.count( building::B_DOCTOR ) ) { healthLevel = house->getHealthLevel(); }
else if( _flags.count( building::B_HOSPITAL ) ) { healthLevel = house->getServiceValue( Service::hospital ); }
else if( _flags.count( building::B_BARBER ) ) { healthLevel = house->getServiceValue( Service::barber ); }
else if( _flags.count( building::B_BATHS ) ) { healthLevel = house->getServiceValue( Service::baths ); }
needDrawAnimations = (house->getSpec().getLevel() == 1) && (house->getHabitants().size() == 0);
CityHelper helper( _city );
drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
}
break;
//other buildings
default:
{
CityHelper helper( _city );
drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
break;
}
if( needDrawAnimations )
{
_renderer->registerTileForRendering( tile );
}
else if( healthLevel > 0 )
{
drawColumn( engine, screenPos, 9, healthLevel );
}
}
}
示例12: draw
void GuiInfoBox::draw( GfxEngine& engine )
{
engine.drawPicture( getBgPicture(), getScreenLeft(), getScreenTop() );
Widget::draw( engine );
}
示例13: draw
void BaseSpecialOrdersWindow::draw( GfxEngine& engine )
{
engine.drawPicture( *_d->bgPicture, getScreenLeft(), getScreenTop() );
Widget::draw( engine );
}