int ApokalypseApp::run(){ LogDebug("Hallo Welt"); SDL_Surface *img = IMG_Load(TStringEntry(application->getDataConfig().getEntry("","backgroundimg")).getString().text()); screen->setBackground(img); if (!img){ LogWarning("Could not load image: %s",SDL_GetError()); }else{ SDL_FreeSurface(img); } Intro *intro = new Intro(screen); intro->run(); delete intro; MenuScreen *menu = new MenuScreen(screen); int menuresult = menu->run(); switch (menuresult){ case 0: break; default: {LogWarning("invalid menuresult, bailing out"); return 0; }break; }; delete menu; return 0; }
int main() { sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window"); sf::Clock Clock; MenuScreen Ms; // Exécution de la boucle principale while (App.IsOpened()) { // Traitement des évènements sf::Event Event; while (App.GetEvent(Event)) { // Fenêtre fermée : on quitte if (Event.Type == sf::Event::Closed) App.Close(); } sf::Randomizer::SetSeed(sf::Randomizer::Random(0,10000)); // Efface l'écran (remplissage avec du noir) App.Clear(); //App.Clear(sf::Color(sf::Randomizer::Random(0,255),sf::Randomizer::Random(0,255),sf::Randomizer::Random(0,255),255)); Ms.Draw(Clock, App); // Affichage du contenu de la fenêtre à l'écran App.Display(); } return EXIT_SUCCESS; }
static int menuScreen_construct (void) { Menu *menu = getPreferencesMenu(); if (!menu) return 0; return menuScreen.construct(menu); }
void Game::showMenu() { MenuScreen mainMenu; MenuScreen::MenuResult result = mainMenu.show(_mainWindow); switch (result) { case MenuScreen::Exit: _gameState = Game::Exiting; break; case MenuScreen::Play: _gameState = Game::Playing; break; case MenuScreen::Options: _gameState = Game::ShowingOptions; break; } }
int activateMenuScreen (void) { if (!menuScreenConstructed) { Menu *menu = getPreferencesMenu(); if (!menu) return 0; if (!menuScreen.construct(menu)) return 0; menuScreenConstructed = 1; } activateScreen(SCR_MENU); return 1; }
void ImageScreen::keyPressEvent(int keyCode) { if (strcmp(Card::ORIENTATION_LANDSCAPE, card->getOrientation().c_str()) == 0) { //if it is a landscape card, the orientation must be switched switch(keyCode) { case MAK_UP: case MAK_DOWN: keyCode = MAK_LEFT; break; case MAK_LEFT: keyCode = MAK_DOWN; break; case MAK_RIGHT: keyCode = MAK_UP; break; } } switch (keyCode) { case MAK_LEFT: case MAK_RIGHT: imge->refreshWidget(); imge->statAdded = false; currentSelectedStat = -1; flip=!flip; if (imge->getResource() != NULL) { maDestroyObject(imge->getResource()); } imge->setResource(Util::loadImageFromResource(RES_LOADING1)); imge->update(); imge->requestRepaint(); maUpdateScreen(); if (flip) { Util::retrieveBack(imge, card, height-PADDING*2, imageCacheBack); Util::retrieveFront(NULL, card, height-PADDING*2, imageCacheFront); } else { Util::retrieveFront(imge, card, height-PADDING*2, imageCacheFront); Util::retrieveBack(NULL, card, height-PADDING*2, imageCacheBack); } currentSelectedStat = -1; break; case MAK_UP: if (imge->getResource() != RES_TEMP) { if(card->getStats().size()>0){ selectStat(-1); if (currentSelectedStat == -1) { if (screenType == ST_NEW_CARD) { Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Accept":"", "Reject", "Flip", layout); } else if (screenType == Util::AT_SHARE) { Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Share":"", "Back", "Flip", layout); } else { Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Options":"", "Back", "Flip", layout); } imge->refreshWidget(); imge->statAdded = false; } else { if (screenType == ST_NEW_CARD) { Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Accept":"", "Reject", "Flip", layout); } else if (screenType == Util::AT_SHARE) { Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Share":"", "Back", "Flip", layout); } else { Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Options":"", "Back", "Flip", layout); } imge->refreshWidget(); if(flip==card->getStats()[currentSelectedStat]->getFrontOrBack()){ imge->selectStat(card->getStats()[currentSelectedStat]->getLeft(),card->getStats()[currentSelectedStat]->getTop(), card->getStats()[currentSelectedStat]->getWidth(),card->getStats()[currentSelectedStat]->getHeight(), card->getStats()[currentSelectedStat]->getColorRed(), card->getStats()[currentSelectedStat]->getColorGreen(), card->getStats()[currentSelectedStat]->getColorBlue(), MobImage::PORTRAIT); } } } } break; case MAK_DOWN: if (imge->getResource() != RES_TEMP) { if(card->getStats().size()>0){ selectStat(1); if (currentSelectedStat == -1) { if (screenType == ST_NEW_CARD) { Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Accept":"", "Reject", "Flip", layout); } else if (screenType == Util::AT_SHARE) { Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Share":"", "Back", "Flip", layout); } else { Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Options":"", "Back", "Flip", layout); } imge->refreshWidget(); imge->statAdded = false; } else { if (screenType == ST_NEW_CARD) { Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Accept":"", "Reject", "Flip", layout); } else if (screenType == Util::AT_SHARE) { Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Share":"", "Back", "Flip", layout); } else { Util::updateSoftKeyLayout((hasConnection&&canAuction)?"Options":"", "Back", "Flip", layout); } imge->refreshWidget(); if(flip==card->getStats()[currentSelectedStat]->getFrontOrBack()){ imge->selectStat(card->getStats()[currentSelectedStat]->getLeft(),card->getStats()[currentSelectedStat]->getTop(), card->getStats()[currentSelectedStat]->getWidth(),card->getStats()[currentSelectedStat]->getHeight(), card->getStats()[currentSelectedStat]->getColorRed(), card->getStats()[currentSelectedStat]->getColorGreen(), card->getStats()[currentSelectedStat]->getColorBlue(), MobImage::PORTRAIT); } else { while((flip!=card->getStats()[currentSelectedStat]->getFrontOrBack())&&(currentSelectedStat <= card->getStats().size())){ selectStat(1); } imge->selectStat(card->getStats()[currentSelectedStat]->getLeft(),card->getStats()[currentSelectedStat]->getTop(), card->getStats()[currentSelectedStat]->getWidth(),card->getStats()[currentSelectedStat]->getHeight(), card->getStats()[currentSelectedStat]->getColorRed(), card->getStats()[currentSelectedStat]->getColorGreen(), card->getStats()[currentSelectedStat]->getColorBlue(), MobImage::PORTRAIT); } } } } break; case MAK_SOFTLEFT: if (screenType == ST_NEW_CARD) { busy = true; acceptCard(); } else if (screenType == Util::AT_SHARE) { if (next != NULL) { feed->remHttp(); delete next; } next = new TradeFriendDetailScreen(this, feed, card); next->show(); } else if (screenType == ST_VIEW_CARD) { } else { if (card != NULL && hasConnection && canAuction) { if (next != NULL) { feed->remHttp(); delete next; } next = new OptionsScreen(feed, OptionsScreen::ST_CARD_OPTIONS, this, card); next->show(); } } break; case MAK_BACK: case MAK_SOFTRIGHT: if (screenType == ST_NEW_CARD) { busy = true; rejectCard(); } else { previous->show(); } break; case MAK_FIRE: if (card != NULL) { if(((flipOrSelect && tapped)&&(currentSelectedStat == -1)) || (!tapped && currentSelectedStat == -1)){ flip=!flip; imge->refreshWidget(); imge->statAdded = false; currentSelectedStat = -1; if (imge->getResource() != NULL) { maDestroyObject(imge->getResource()); } imge->setResource(Util::loadImageFromResource(RES_LOADING1)); imge->update(); imge->requestRepaint(); maUpdateScreen(); if (flip) { if ((imageCacheBack != NULL)&&(imge != NULL)) { Util::retrieveBack(imge, card, height-PADDING*2, imageCacheBack); Util::retrieveFront(NULL, card, height-PADDING*2, imageCacheFront); } } else { if ((imageCacheFront != NULL)&&(imge != NULL)) { Util::retrieveFront(imge, card, height-PADDING*2, imageCacheFront); Util::retrieveBack(NULL, card, height-PADDING*2, imageCacheBack); } } flipOrSelect=0; currentSelectedStat = -1; tapped = false; }else{ if (imge->getResource() != RES_TEMP) { if(currentSelectedStat>-1){ if(flip==card->getStats()[currentSelectedStat]->getFrontOrBack()){ imge->refreshWidget(); imge->selectStat(card->getStats()[currentSelectedStat]->getLeft(),card->getStats()[currentSelectedStat]->getTop(), card->getStats()[currentSelectedStat]->getWidth(),card->getStats()[currentSelectedStat]->getHeight(), card->getStats()[currentSelectedStat]->getColorRed(), card->getStats()[currentSelectedStat]->getColorGreen(), card->getStats()[currentSelectedStat]->getColorBlue(), MobImage::PORTRAIT); Stat *stat = card->getStats()[currentSelectedStat]; if ((strcmp(stat->getDesc().c_str(), "Mobile No") == 0)|| (strcmp(stat->getDesc().c_str(), "Tel No") == 0) ){ if (next != NULL) { feed->remHttp(); delete next; next == NULL; } next = new OptionsScreen(feed, OptionsScreen::ST_NUMBER_OPTIONS, this, card, stat->getDisplay()); next->show(); } else if (strcmp(stat->getDesc().c_str(), "Email") == 0) { String email = stat->getDisplay(); int ret = maPlatformRequest(("mailto:"+email).c_str()); if (ret < 0 ) { ret = maPlatformRequest(email.c_str()); } if (ret < 0) { MenuScreen *confirmation = new MenuScreen(RES_BLANK, "Feature currently not supported on device."); confirmation->setMenuWidth(170); confirmation->setMarginX(5); confirmation->setMarginY(5); confirmation->setDock(MenuScreen::MD_CENTER); confirmation->setListener(this); confirmation->setMenuFontSel(Util::getDefaultFont()); confirmation->setMenuFontUnsel(Util::getDefaultFont()); confirmation->setMenuSkin(Util::getSkinDropDownItem()); confirmation->addItem("Ok"); confirmation->show(); } } else if ((strcmp(stat->getDesc().c_str(), "Web Address") == 0)|| (strcmp(stat->getDesc().c_str(), "Social Media Link 1") == 0)|| (strcmp(stat->getDesc().c_str(), "Social Media Link 1") == 0)|| (strcmp(stat->getDesc().c_str(), "Social Media Link 1") == 0)|| (strcmp(stat->getDesc().c_str(), "Social Media Link 1") == 0)|| (strcmp(stat->getDesc().c_str(), "Social Media Link 1") == 0)) { String url = stat->getDisplay(); //maPlatformRequest will only work if the url starts with http:// //so we need to check for it, and add it if it isnt there if (url.find("http://") != 0) { url = "http://"+url; } int ret = maPlatformRequest(url.c_str()); if (ret < 0) { MenuScreen *confirmation = new MenuScreen(RES_BLANK, "Feature currently not supported on device."); confirmation->setMenuWidth(170); confirmation->setMarginX(5); confirmation->setMarginY(5); confirmation->setDock(MenuScreen::MD_CENTER); confirmation->setListener(this); confirmation->setMenuFontSel(Util::getDefaultFont()); confirmation->setMenuFontUnsel(Util::getDefaultFont()); confirmation->setMenuSkin(Util::getSkinDropDownItem()); confirmation->addItem("Ok"); confirmation->show(); } } } } } } } else { previous->show(); } break; } }
void destructSpecialScreens (void) { helpScreen.destruct(); menuScreen.destruct(); frozenScreen.destruct(); }