/** * Adds a new child surface for the state to take care of, * giving it the game's display palette. Once associated, * the state handles all of the surface's behaviour * and management automatically. * @param surface Child surface. * @note Since visible elements can overlap one another, * they have to be added in ascending Z-Order to be blitted * correctly onto the screen. */ void State::add(Surface *surface) { // Set palette surface->setPalette(_game->getScreen()->getPalette()); // Set default fonts Text *t = dynamic_cast<Text*>(surface); TextButton *tb = dynamic_cast<TextButton*>(surface); TextEdit *te = dynamic_cast<TextEdit*>(surface); TextList *tl = dynamic_cast<TextList*>(surface); if (t) { t->setFonts(_game->getResourcePack()->getFont("BIGLETS.DAT"), _game->getResourcePack()->getFont("SMALLSET.DAT")); } else if (tb) { tb->setFonts(_game->getResourcePack()->getFont("BIGLETS.DAT"), _game->getResourcePack()->getFont("SMALLSET.DAT")); } else if (te) { te->setFonts(_game->getResourcePack()->getFont("BIGLETS.DAT"), _game->getResourcePack()->getFont("SMALLSET.DAT")); } else if (tl) { tl->setFonts(_game->getResourcePack()->getFont("BIGLETS.DAT"), _game->getResourcePack()->getFont("SMALLSET.DAT")); } _surfaces.push_back(surface); }
/** * Adds a new child surface for the state to take care of, * giving it the game's display palette. Once associated, * the state handles all of the surface's behaviour * and management automatically. * @param surface Child surface. * @note Since visible elements can overlap one another, * they have to be added in ascending Z-Order to be blitted * correctly onto the screen. */ void State::add(Surface *surface) { // Set palette surface->setPalette(_game->getScreen()->getPalette()); // Set default fonts Text *t = dynamic_cast<Text*>(surface); TextButton *tb = dynamic_cast<TextButton*>(surface); TextEdit *te = dynamic_cast<TextEdit*>(surface); TextList *tl = dynamic_cast<TextList*>(surface); WarningMessage *wm = dynamic_cast<WarningMessage*>(surface); BaseView *bv = dynamic_cast<BaseView*>(surface); if (t) { t->setFonts(_game->getResourcePack()->getFont("Big.fnt"), _game->getResourcePack()->getFont("Small.fnt")); } else if (tb) { tb->setFonts(_game->getResourcePack()->getFont("Big.fnt"), _game->getResourcePack()->getFont("Small.fnt")); } else if (te) { te->setFonts(_game->getResourcePack()->getFont("Big.fnt"), _game->getResourcePack()->getFont("Small.fnt")); } else if (tl) { tl->setFonts(_game->getResourcePack()->getFont("Big.fnt"), _game->getResourcePack()->getFont("Small.fnt")); } else if (bv) { bv->setFonts(_game->getResourcePack()->getFont("Big.fnt"), _game->getResourcePack()->getFont("Small.fnt")); } else if (wm) { wm->setFonts(_game->getResourcePack()->getFont("Big.fnt"), _game->getResourcePack()->getFont("Small.fnt")); } _surfaces.push_back(surface); }