void TreadmillFB303::make_fb303( std::shared_ptr<std::thread>& server_thread, int server_port, Scheduler& scheduler) { { folly::SharedMutex::WriteHolder guard(instance_mutex); if (instance) { LOG(FATAL) << "Global Treadmill FB303 instance was already set"; } instance = std::make_shared<TreadmillFB303>(scheduler); } auto server = std::make_shared<apache::thrift::ThriftServer>(); LOG(INFO) << "FB303 running on port " << server_port; server->setPort(server_port); server->setInterface(getGlobalTreadmillFB303()); TLSConfig::applyDefaultsToThriftServer(*server); server_thread.reset( new std::thread([server]() { server->serve(); }), [server](std::thread* t) { server->stop(); t->join(); delete t; }); }
/** * Initializes all the elements in the No Containment screen. * @param game Pointer to the core game. */ NoContainmentState::NoContainmentState() { // Create objects _window = new Window(this, 320, 200, 0, 0); _btnOk = new TextButton(120, 18, 100, 174); _txtTitle = new Text(220, 64, 50, 8); // Set palette setInterface("noContainment"); add(_window, "window", "noContainment"); add(_btnOk, "button", "noContainment"); add(_txtTitle, "text", "noContainment"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&NoContainmentState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&NoContainmentState::btnOkClick, Options::keyOk); _btnOk->onKeyboardPress((ActionHandler)&NoContainmentState::btnOkClick, Options::keyCancel); _txtTitle->setText(tr("STR_ALIEN_DIES_NO_ALIEN_CONTAINMENT_FACILITY")); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setBig(); _txtTitle->setWordWrap(true); }
/** * Initializes all the elements in the Statistics window. * @param game Pointer to the core game. */ StatisticsState::StatisticsState() { // Create objects _window = new Window(this, 320, 200, 0, 0, POPUP_BOTH); _btnOk = new TextButton(50, 12, 135, 180); _txtTitle = new Text(310, 25, 5, 8); _lstStats = new TextList(280, 136, 12, 36); // Set palette setInterface("endGameStatistics"); add(_window, "window", "endGameStatistics"); add(_btnOk, "button", "endGameStatistics"); add(_txtTitle, "text", "endGameStatistics"); add(_lstStats, "list", "endGameStatistics"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getMod()->getSurface("BACK01.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&StatisticsState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&StatisticsState::btnOkClick, Options::keyOk); _txtTitle->setBig(); _txtTitle->setAlign(ALIGN_CENTER); _lstStats->setColumns(2, 200, 80); _lstStats->setDot(true); listStats(); }
//There is no answer from the PING. void ping_no_answer(uint8_t* nbNoAnswer, uint8_t interface){ int8_t neighbor = interface_neighbor(interface); //There is no neighbor, so it's logical. if(neighbor == -1 ) return; //There was someone few seconds ago, so nbNoAnswer increases. (*nbNoAnswer)++; //When we have no news for a long time, the module is gone. if((*nbNoAnswer) == NB_NO_PING){ //the first interface to have no answer will copy the interfaces. if(!awareOfMissingBlock) interfaces_copy(); setInterface(interface, -1, -1); //Throwing away the IrDA queues for this UART. irda_reset_queues(interface2uart(interface)); //Maybe he has just turned so we check... if(!ID_in_interfaces(neighbor)) { network_reset(neighbor, interface); } (*nbNoAnswer) = 0; } }
/** * Initializes all the elements in the EndResearch screen. * @param game Pointer to the core game. * @param base Pointer to the base to get info from. * @param possibilities List of newly possible ResearchProject */ NewPossibleResearchState::NewPossibleResearchState(Base * base, const std::vector<RuleResearch *> & possibilities) : _base(base) { _screen = false; // Create objects _window = new Window(this, 288, 180, 16, 10); _btnOk = new TextButton(160, 14, 80, 149); _btnResearch = new TextButton(160, 14, 80, 165); _txtTitle = new Text(288, 40, 16, 20); _lstPossibilities = new TextList(250, 96, 35, 50); // Set palette setInterface("geoResearch"); add(_window, "window", "geoResearch"); add(_btnOk, "button", "geoResearch"); add(_btnResearch, "button", "geoResearch"); add(_txtTitle, "text1", "geoResearch"); add(_lstPossibilities, "text2", "geoResearch"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getMod()->getSurface("BACK05.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&NewPossibleResearchState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&NewPossibleResearchState::btnOkClick, Options::keyCancel); _btnResearch->setText(tr("STR_ALLOCATE_RESEARCH")); _btnResearch->onMouseClick((ActionHandler)&NewPossibleResearchState::btnResearchClick); _btnResearch->onKeyboardPress((ActionHandler)&NewPossibleResearchState::btnResearchClick, Options::keyOk); _txtTitle->setBig(); _txtTitle->setAlign(ALIGN_CENTER); _lstPossibilities->setColumns(1, 250); _lstPossibilities->setBig(); _lstPossibilities->setAlign(ALIGN_CENTER); _lstPossibilities->setScrolling(true, 0); size_t tally(0); for (std::vector<RuleResearch *>::const_iterator iter = possibilities.begin(); iter != possibilities.end(); ++iter) { bool liveAlien = (*iter)->needItem() && _game->getMod()->getUnit((*iter)->getName()) != 0; if (!_game->getSavedGame()->wasResearchPopped(*iter) && (*iter)->getRequirements().empty() && !liveAlien) { _game->getSavedGame()->addPoppedResearch((*iter)); _lstPossibilities->addRow (1, tr((*iter)->getName()).c_str()); } else { tally++; } } if (!(tally == possibilities.size() || possibilities.empty())) { _txtTitle->setText(tr("STR_WE_CAN_NOW_RESEARCH")); } }
/** * Initializes all the elements in the Equip Craft screen. * @param game Pointer to the core game. * @param base Pointer to the base to get info from. */ CraftsState::CraftsState(Base *base) : _base(base) { // Create objects _window = new Window(this, 320, 200, 0, 0); _btnOk = new TextButton(288, 16, 16, 176); _txtTitle = new Text(298, 17, 16, 8); _txtBase = new Text(298, 17, 16, 24); _txtName = new Text(94, 9, 16, 40); _txtStatus = new Text(50, 9, 110, 40); _txtWeapon = new Text(50, 17, 160, 40); _txtCrew = new Text(58, 9, 210, 40); _txtHwp = new Text(46, 9, 268, 40); _lstCrafts = new TextList(288, 118, 8, 58); // Set palette setInterface("craftSelect"); add(_window, "window", "craftSelect"); add(_btnOk, "button", "craftSelect"); add(_txtTitle, "text", "craftSelect"); add(_txtBase, "text", "craftSelect"); add(_txtName, "text", "craftSelect"); add(_txtStatus, "text", "craftSelect"); add(_txtWeapon, "text", "craftSelect"); add(_txtCrew, "text", "craftSelect"); add(_txtHwp, "text", "craftSelect"); add(_lstCrafts, "list", "craftSelect"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK14.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&CraftsState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&CraftsState::btnOkClick, Options::keyCancel); _txtTitle->setBig(); _txtTitle->setText(tr("STR_INTERCEPTION_CRAFT")); _txtBase->setBig(); _txtBase->setText(tr("STR_BASE_").arg(_base->getName())); _txtName->setText(tr("STR_NAME_UC")); _txtStatus->setText(tr("STR_STATUS")); _txtWeapon->setText(tr("STR_WEAPON_SYSTEMS")); _txtWeapon->setWordWrap(true); _txtCrew->setText(tr("STR_CREW")); _txtHwp->setText(tr("STR_HWPS")); _lstCrafts->setColumns(5, 94, 68, 44, 46, 28); _lstCrafts->setSelectable(true); _lstCrafts->setBackground(_window); _lstCrafts->setMargin(8); _lstCrafts->onMouseClick((ActionHandler)&CraftsState::lstCraftsClick); }
/** * Initializes all the elements in the Promotions screen. * @param game Pointer to the core game. */ PromotionsState::PromotionsState() { // Create objects _window = new Window(this, 320, 200, 0, 0); _btnOk = new TextButton(288, 16, 16, 176); _txtTitle = new Text(300, 17, 10, 8); _txtName = new Text(114, 9, 16, 32); _txtRank = new Text(90, 9, 130, 32); _txtBase = new Text(80, 9, 220, 32); _lstSoldiers = new TextList(288, 128, 8, 40); // Set palette setInterface("promotions"); add(_window, "window", "promotions"); add(_btnOk, "button", "promotions"); add(_txtTitle, "heading", "promotions"); add(_txtName, "text", "promotions"); add(_txtRank, "text", "promotions"); add(_txtBase, "text", "promotions"); add(_lstSoldiers, "list", "promotions"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&PromotionsState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&PromotionsState::btnOkClick, Options::keyOk); _btnOk->onKeyboardPress((ActionHandler)&PromotionsState::btnOkClick, Options::keyCancel); _txtTitle->setText(tr("STR_PROMOTIONS")); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setBig(); _txtName->setText(tr("STR_NAME")); _txtRank->setText(tr("STR_NEW_RANK")); _txtBase->setText(tr("STR_BASE")); _lstSoldiers->setColumns(3, 114, 90, 84); _lstSoldiers->setSelectable(true); _lstSoldiers->setBackground(_window); _lstSoldiers->setMargin(8); for (std::vector<Base*>::iterator i = _game->getSavedGame()->getBases()->begin(); i != _game->getSavedGame()->getBases()->end(); ++i) { for (std::vector<Soldier*>::iterator j = (*i)->getSoldiers()->begin(); j != (*i)->getSoldiers()->end(); ++j) { if ((*j)->isPromoted()) { _lstSoldiers->addRow(3, (*j)->getName().c_str(), tr((*j)->getRankString()).c_str(), (*i)->getName().c_str()); } } } }
/*! \fn QServiceFilter::QServiceFilter(const QString& interfaceName, const QString& version, QServiceFilter::VersionMatchRule rule) Creates a new filter object that matches all service implementations implementing \a interfaceName that match the specified \a version using the given \a rule. */ QServiceFilter::QServiceFilter(const QString& interfaceName, const QString& version, QServiceFilter::VersionMatchRule rule) { d = new QServiceFilterPrivate(); d->majorVersion = -1; d->minorVersion = -1; d->matchingRule = QServiceFilter::MinimumVersionMatch; d->capMatchingRule = QServiceFilter::MatchMinimum; setInterface(interfaceName, version, rule); }
/** * Initializes all the elements in the Transfers window. * @param game Pointer to the core game. * @param base Pointer to the base to get info from. */ TransfersState::TransfersState(Base *base) : _base(base) { _screen = false; // Create objects _window = new Window(this, 320, 184, 0, 8, POPUP_BOTH); _btnOk = new TextButton(288, 16, 16, 166); _txtTitle = new Text(278, 17, 21, 18); _txtItem = new Text(114, 9, 16, 34); _txtQuantity = new Text(54, 9, 152, 34); _txtArrivalTime = new Text(112, 9, 212, 34); _lstTransfers = new TextList(273, 112, 14, 50); // Set palette setInterface("transferInfo"); add(_window, "window", "transferInfo"); add(_btnOk, "button", "transferInfo"); add(_txtTitle, "text", "transferInfo"); add(_txtItem, "text", "transferInfo"); add(_txtQuantity, "text", "transferInfo"); add(_txtArrivalTime, "text", "transferInfo"); add(_lstTransfers, "list", "transferInfo"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK13.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&TransfersState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&TransfersState::btnOkClick, Options::keyOk); _btnOk->onKeyboardPress((ActionHandler)&TransfersState::btnOkClick, Options::keyCancel); _txtTitle->setBig(); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setText(tr("STR_TRANSFERS")); _txtItem->setText(tr("STR_ITEM")); _txtQuantity->setText(tr("STR_QUANTITY_UC")); _txtArrivalTime->setText(tr("STR_ARRIVAL_TIME_HOURS")); _lstTransfers->setColumns(3, 155, 75, 46); _lstTransfers->setSelectable(true); _lstTransfers->setBackground(_window); _lstTransfers->setMargin(2); for (std::vector<Transfer*>::iterator i = _base->getTransfers()->begin(); i != _base->getTransfers()->end(); ++i) { std::wostringstream ss, ss2; ss << (*i)->getQuantity(); ss2 << (*i)->getHours(); _lstTransfers->addRow(3, (*i)->getName(_game->getLanguage()).c_str(), ss.str().c_str(), ss2.str().c_str()); } }
/** * Initializes all the elements in the Load Craft Loadout window. */ CraftEquipmentLoadState::CraftEquipmentLoadState(CraftEquipmentState *parent) : _parent(parent) { _screen = false; // Create objects _window = new Window(this, 240, 136, 40, 36+1, POPUP_BOTH); _txtTitle = new Text(230, 16, 45, 44+3); _lstLoadout = new TextList(208, 80, 48, 60); _btnCancel = new TextButton(120, 16, 90, 148); // Set palette setInterface("craftEquipmentLoad"); add(_window, "window", "craftEquipmentLoad"); add(_txtTitle, "text", "craftEquipmentLoad"); add(_lstLoadout, "list", "craftEquipmentLoad"); add(_btnCancel, "button", "craftEquipmentLoad"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getMod()->getSurface("BACK04.SCR")); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setText(tr("STR_LOAD_CRAFT_LOADOUT_TEMPLATE")); _lstLoadout->setColumns(1, 192); _lstLoadout->setSelectable(true); _lstLoadout->setBackground(_window); _lstLoadout->setMargin(8); _lstLoadout->onMouseClick((ActionHandler)&CraftEquipmentLoadState::lstLoadoutClick); _btnCancel->setText(tr("STR_CANCEL_UC")); _btnCancel->onMouseClick((ActionHandler)&CraftEquipmentLoadState::btnCancelClick); _btnCancel->onKeyboardPress((ActionHandler)&CraftEquipmentLoadState::btnCancelClick, Options::keyCancel); for (int i = 0; i < SavedGame::MAX_CRAFT_LOADOUT_TEMPLATES; ++i) { ItemContainer *item = _game->getSavedGame()->getGlobalCraftLoadout(i); if (item->getContents()->empty()) { _lstLoadout->addRow(1, tr("STR_EMPTY_SLOT_N").arg(i + 1).c_str()); } else { const std::wstring &itemName = _game->getSavedGame()->getGlobalCraftLoadoutName(i); if (itemName.empty()) { _lstLoadout->addRow(1, tr("STR_UNNAMED_SLOT_N").arg(i + 1).c_str()); } else { _lstLoadout->addRow(1, itemName.c_str()); } } } }
/** * Initializes all the elements in the Cannot Reequip screen. * @param game Pointer to the core game. * @param missingItems List of items still needed for reequip. */ CannotReequipState::CannotReequipState(std::vector<ReequipStat> missingItems) { // Create objects _window = new Window(this, 320, 200, 0, 0); _btnOk = new TextButton(120, 18, 100, 174); _txtTitle = new Text(220, 32, 50, 8); _txtItem = new Text(142, 9, 10, 50); _txtQuantity = new Text(88, 9, 152, 50); _txtCraft = new Text(74, 9, 218, 50); _lstItems = new TextList(288, 112, 8, 58); // Set palette setInterface("cannotReequip"); add(_window, "window", "cannotReequip"); add(_btnOk, "button", "cannotReequip"); add(_txtTitle, "heading", "cannotReequip"); add(_txtItem, "text", "cannotReequip"); add(_txtQuantity, "text", "cannotReequip"); add(_txtCraft, "text", "cannotReequip"); add(_lstItems, "list", "cannotReequip"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getMod()->getSurface("BACK01.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&CannotReequipState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&CannotReequipState::btnOkClick, Options::keyOk); _btnOk->onKeyboardPress((ActionHandler)&CannotReequipState::btnOkClick, Options::keyCancel); _txtTitle->setText(tr("STR_NOT_ENOUGH_EQUIPMENT_TO_FULLY_RE_EQUIP_SQUAD")); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setBig(); _txtTitle->setWordWrap(true); _txtItem->setText(tr("STR_ITEM")); _txtQuantity->setText(tr("STR_QUANTITY_UC")); _txtCraft->setText(tr("STR_CRAFT")); _lstItems->setColumns(3, 162, 46, 80); _lstItems->setSelectable(true); _lstItems->setBackground(_window); _lstItems->setMargin(2); for (std::vector<ReequipStat>::iterator i = missingItems.begin(); i != missingItems.end(); ++i) { std::wostringstream ss; ss << i->qty; _lstItems->addRow(3, tr(i->item).c_str(), ss.str().c_str(), i->craft.c_str()); } }
/** * Initializes all the elements in the Target Info window. * @param game Pointer to the core game. * @param target Pointer to the target to show info from. * @param globe Pointer to the Geoscape globe. */ TargetInfoState::TargetInfoState(Target *target, Globe *globe) : _target(target), _globe(globe) { _screen = false; // Create objects _window = new Window(this, 192, 120, 32, 40, POPUP_BOTH); _btnIntercept = new TextButton(160, 12, 48, 124); _btnOk = new TextButton(160, 12, 48, 140); _txtTitle = new Text(182, 32, 37, 46); _txtTargetted = new Text(182, 9, 37, 78); _txtFollowers = new Text(182, 40, 37, 88); // Set palette setInterface("targetInfo"); add(_window, "window", "targetInfo"); add(_btnIntercept, "button", "targetInfo"); add(_btnOk, "button", "targetInfo"); add(_txtTitle, "text", "targetInfo"); add(_txtTargetted, "text", "targetInfo"); add(_txtFollowers, "text", "targetInfo"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getMod()->getSurface("BACK01.SCR")); _btnIntercept->setText(tr("STR_INTERCEPT")); _btnIntercept->onMouseClick((ActionHandler)&TargetInfoState::btnInterceptClick); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&TargetInfoState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&TargetInfoState::btnOkClick, Options::keyCancel); std::wostringstream ss; _txtTitle->setBig(); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setVerticalAlign(ALIGN_MIDDLE); _txtTitle->setWordWrap(true); ss << L'\x01' << _target->getName(_game->getLanguage()); _txtTitle->setText(ss.str().c_str()); _txtTargetted->setAlign(ALIGN_CENTER); _txtTargetted->setText(tr("STR_TARGETTED_BY")); ss.str(L""); _txtFollowers->setAlign(ALIGN_CENTER); for (std::vector<Target*>::iterator i = _target->getFollowers()->begin(); i != _target->getFollowers()->end(); ++i) { ss << (*i)->getName(_game->getLanguage()) << L'\n'; } _txtFollowers->setText(ss.str()); }
JrServer::~JrServer() { _Info("Closing server."); setInterface(nullptr); auto devices = d->clients.keys(); for (auto dev : devices) { dev->close(); removeClient(dev); } delete d->transport; delete d; }
/** * Initializes all the elements in the Main Menu window. * @param game Pointer to the core game. */ MainMenuState::MainMenuState() { // Create objects _window = new Window(this, 256, 160, 32, 20, POPUP_BOTH); _btnNewGame = new TextButton(92, 20, 64, 90); _btnNewBattle = new TextButton(92, 20, 164, 90); _btnLoad = new TextButton(92, 20, 64, 118); _btnOptions = new TextButton(92, 20, 164, 118); _btnQuit = new TextButton(192, 20, 64, 146); _txtTitle = new Text(256, 30, 32, 45); // Set palette setInterface("mainMenu"); add(_window, "window", "mainMenu"); add(_btnNewGame, "button", "mainMenu"); add(_btnNewBattle, "button", "mainMenu"); add(_btnLoad, "button", "mainMenu"); add(_btnOptions, "button", "mainMenu"); add(_btnQuit, "button", "mainMenu"); add(_txtTitle, "text", "mainMenu"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); _btnNewGame->setText(tr("STR_NEW_GAME")); _btnNewGame->onMouseClick((ActionHandler)&MainMenuState::btnNewGameClick); _btnNewBattle->setText(tr("STR_NEW_BATTLE")); _btnNewBattle->onMouseClick((ActionHandler)&MainMenuState::btnNewBattleClick); _btnLoad->setText(tr("STR_LOAD_SAVED_GAME")); _btnLoad->onMouseClick((ActionHandler)&MainMenuState::btnLoadClick); _btnOptions->setText(tr("STR_OPTIONS")); _btnOptions->onMouseClick((ActionHandler)&MainMenuState::btnOptionsClick); _btnQuit->setText(tr("STR_QUIT")); _btnQuit->onMouseClick((ActionHandler)&MainMenuState::btnQuitClick); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setBig(); std::wostringstream title; title << tr("STR_OPENXCOM") << L"\x02"; title << Language::utf8ToWstr(OPENXCOM_VERSION_SHORT) << Language::utf8ToWstr(OPENXCOM_VERSION_GIT); _txtTitle->setText(title.str()); // Set music _game->getResourcePack()->playMusic("GMSTORY"); }
void Utility::unload() { if(program->active == nullptr) return; if(tracerEnable) tracerToggle(); system().unload(); path.reset(); pathname.reset(); setInterface(nullptr); video.clear(); audio.clear(); presentation->setTitle({Emulator::Name, " ", Emulator::Version}); }
/** * Initializes all the elements in the Base Defense screen. * @param game Pointer to the core game. * @param base Pointer to the base being attacked. * @param ufo Pointer to the attacking ufo. * @param state Pointer to the Geoscape. */ BaseDefenseState::BaseDefenseState(Base *base, Ufo *ufo, GeoscapeState *state) : _state(state) { _base = base; _action = BDA_NONE; _row = -1; _passes = 0; _attacks = 0; _thinkcycles = 0; _ufo = ufo; // Create objects _window = new Window(this, 320, 200, 0, 0); _txtTitle = new Text(300, 17, 16, 6); _txtInit = new Text(300, 10, 16, 24); _lstDefenses = new TextList(300, 128, 16, 40); _btnOk = new TextButton(120, 18, 100, 170); // Set palette setInterface("baseDefense"); add(_window, "window", "baseDefense"); add(_btnOk, "button", "baseDefense"); add(_txtTitle, "text", "baseDefense"); add(_txtInit, "text", "baseDefense"); add(_lstDefenses, "text", "baseDefense"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK04.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&BaseDefenseState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&BaseDefenseState::btnOkClick, Options::keyOk); _btnOk->onKeyboardPress((ActionHandler)&BaseDefenseState::btnOkClick, Options::keyCancel); _btnOk->setVisible(false); _txtTitle->setBig(); _txtTitle->setText(tr("STR_BASE_UNDER_ATTACK").arg(_base->getName())); _txtInit->setVisible(false); _txtInit->setText(tr("STR_BASE_DEFENSES_INITIATED")); _lstDefenses->setColumns(3, 134, 70, 50); _gravShields = _base->getGravShields(); _defenses = _base->getDefenses()->size(); _timer = new Timer(250); _timer->onTimer((StateHandler)&BaseDefenseState::nextStep); _timer->start(); _explosionCount = 0; }
UfopaediaStartState::UfopaediaStartState() { _screen = false; // set background window _window = new Window(this, 256, 180, 32, 10, POPUP_BOTH); // set title _txtTitle = new Text(224, 17, 48, 33); // Set palette setInterface("ufopaedia"); add(_window, "window", "ufopaedia"); add(_txtTitle, "text", "ufopaedia"); _btnOk = new TextButton(224, 12, 48, 167); add(_btnOk, "button1", "ufopaedia"); // set buttons const std::vector<std::string> &list = _game->getMod()->getUfopaediaCategoryList(); int y = 50; y -= 13 * (list.size() - 9); for (std::vector<std::string>::const_iterator i = list.begin(); i != list.end(); ++i) { TextButton *button = new TextButton(224, 12, 48, y); y += 13; add(button, "button1", "ufopaedia"); button->setText(tr(*i)); button->onMouseClick((ActionHandler)&UfopaediaStartState::btnSectionClick); _btnSections.push_back(button); } if (!_btnSections.empty()) _txtTitle->setY(_btnSections.front()->getY() - _txtTitle->getHeight()); centerAllSurfaces(); _window->setBackground(_game->getMod()->getSurface("BACK01.SCR")); _txtTitle->setBig(); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setText(tr("STR_UFOPAEDIA")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&UfopaediaStartState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&UfopaediaStartState::btnOkClick, Options::keyCancel); _btnOk->onKeyboardPress((ActionHandler)&UfopaediaStartState::btnOkClick, Options::keyGeoUfopedia); }
//load base cartridge void Utility::loadMedia(Emulator::Interface* emulator, Emulator::Interface::Media& media, string pathname) { unload(); setInterface(emulator); path(0) = program->path({media.name, ".sys/"}); path(media.id) = pathname; this->pathname.append(pathname); system().load(media.id); system().power(); presentation->setSystemName(media.name); presentation->setVisible(); load(); }
/** * Initializes all the elements in the Abandon Game screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. */ AbandonGameState::AbandonGameState(OptionsOrigin origin) : _origin(origin) { _screen = false; int x; if (_origin == OPT_GEOSCAPE) { x = 20; } else { x = 52; } // Create objects _window = new Window(this, 216, 160, x, 20, POPUP_BOTH); _btnYes = new TextButton(50, 20, x+18, 140); _btnNo = new TextButton(50, 20, x+148, 140); _txtTitle = new Text(206, 17, x+5, 70); // Set palette setInterface("geoscape", false, _origin == OPT_BATTLESCAPE); add(_window, "genericWindow", "geoscape"); add(_btnYes, "genericButton2", "geoscape"); add(_btnNo, "genericButton2", "geoscape"); add(_txtTitle, "genericText", "geoscape"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); _btnYes->setText(tr("STR_YES")); _btnYes->onMouseClick((ActionHandler)&AbandonGameState::btnYesClick); _btnYes->onKeyboardPress((ActionHandler)&AbandonGameState::btnYesClick, Options::keyOk); _btnNo->setText(tr("STR_NO")); _btnNo->onMouseClick((ActionHandler)&AbandonGameState::btnNoClick); _btnNo->onKeyboardPress((ActionHandler)&AbandonGameState::btnNoClick, Options::keyCancel); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setBig(); _txtTitle->setText(tr("STR_ABANDON_GAME_QUESTION")); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } }
void ping_new_neighbor(uint8_t block, uint8_t membersInHisNetwork, uint8_t interface, uint8_t hisInterface){ //The table wasn't in the interfaces. if(!ID_in_interfaces(block) && !ID_was_in_interfaces(block)){ //He is in the interface and we check if we need an election. setInterface(interface, block, hisInterface); ping_decision(block, membersInHisNetwork, interface); } //He was in the interfaces : maybe he turned. else{ turn_function(block, membersInHisNetwork, interface, hisInterface); } }
/** * Initializes all the elements in the Confirm Display Options screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. */ OptionsConfirmState::OptionsConfirmState(OptionsOrigin origin) : _origin(origin), _countdown(15) { _screen = false; // Create objects _window = new Window(this, 216, 100, 52, 50, POPUP_BOTH); _btnYes = new TextButton(50, 20, 70, 120); _btnNo = new TextButton(50, 20, 200, 120); _txtTitle = new Text(206, 20, 57, 70); _txtTimer = new Text(206, 20, 57, 100); _timer = new Timer(1000); // Set palette setInterface("mainMenu", false, _game->getSavedGame() ? _game->getSavedGame()->getSavedBattle() : 0); add(_window, "confirmVideo", "mainMenu"); add(_btnYes, "confirmVideo", "mainMenu"); add(_btnNo, "confirmVideo", "mainMenu"); add(_txtTitle, "confirmVideo", "mainMenu"); add(_txtTimer, "confirmVideo", "mainMenu"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); _btnYes->setText(tr("STR_YES")); _btnYes->onMouseClick((ActionHandler)&OptionsConfirmState::btnYesClick); _btnNo->setText(tr("STR_NO")); _btnNo->onMouseClick((ActionHandler)&OptionsConfirmState::btnNoClick); // no keyboard shortcuts to make sure users can see the message _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setWordWrap(true); _txtTitle->setText(tr("STR_DISPLAY_OPTIONS_CONFIRM")); _txtTimer->setAlign(ALIGN_CENTER); _txtTimer->setWordWrap(true); _txtTimer->setText(tr("STR_DISPLAY_OPTIONS_REVERT").arg(_countdown)); if (_origin == OPT_BATTLESCAPE) { applyBattlescapeTheme(); } _timer->onTimer((StateHandler)&OptionsConfirmState::countdown); _timer->start(); }
//load base cartridge void Utility::loadMedia(Emulator::Interface* emulator, Emulator::Interface::Media& media, string pathname) { unload(); setInterface(emulator); //TODO: don't hardcode this! path(0) = "/usr/share/termboy/"; //program->path({media.name, ".sys/"}); path(media.id) = pathname; this->pathname.append(pathname); system().load(media.id); system().power(); //presentation->setSystemName(media.name); //presentation->setVisible(); load(); }
ScopedServerInterfaceThread::ScopedServerInterfaceThread( shared_ptr<ServerInterface> si, const string& host, uint16_t port) { auto tm = ThreadManager::newSimpleThreadManager(1, 5, false, 50); tm->threadFactory(make_shared<PosixThreadFactory>()); tm->start(); auto ts = make_shared<ThriftServer>(); ts->setAddress(host, port); ts->setInterface(move(si)); ts->setNWorkerThreads(1); ts->setThreadManager(tm); ts_ = move(ts); sst_.start(ts_); }
/** * Initializes all the elements in the Confirm New Base window. * @param game Pointer to the core game. * @param base Pointer to the base to place. * @param globe Pointer to the Geoscape globe. */ ConfirmNewBaseState::ConfirmNewBaseState(Base *base, Globe *globe) : _base(base), _globe(globe), _cost(0) { _screen = false; // Create objects _window = new Window(this, 224, 72, 16, 64); _btnOk = new TextButton(54, 12, 68, 104); _btnCancel = new TextButton(54, 12, 138, 104); _txtCost = new Text(120, 9, 68, 80); _txtArea = new Text(120, 9, 68, 90); // Set palette setInterface("geoscape"); add(_window, "genericWindow", "geoscape"); add(_btnOk, "genericButton2", "geoscape"); add(_btnCancel, "genericButton2", "geoscape"); add(_txtCost, "genericText", "geoscape"); add(_txtArea, "genericText", "geoscape"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&ConfirmNewBaseState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&ConfirmNewBaseState::btnOkClick, Options::keyOk); _btnCancel->setText(tr("STR_CANCEL_UC")); _btnCancel->onMouseClick((ActionHandler)&ConfirmNewBaseState::btnCancelClick); _btnCancel->onKeyboardPress((ActionHandler)&ConfirmNewBaseState::btnCancelClick, Options::keyCancel); std::wstring area; for (std::vector<Region*>::iterator i = _game->getSavedGame()->getRegions()->begin(); i != _game->getSavedGame()->getRegions()->end(); ++i) { if ((*i)->getRules()->insideRegion(_base->getLongitude(), _base->getLatitude())) { _cost = (*i)->getRules()->getBaseCost(); area = tr((*i)->getRules()->getType()); break; } } _txtCost->setText(tr("STR_COST_").arg(Text::formatFunding(_cost))); _txtArea->setText(tr("STR_AREA_").arg(area)); }
/** * Initializes all the elements in the Confirm Transfer window. * @param game Pointer to the core game. * @param base Pointer to the destination base. * @param state Pointer to the Transfer state. */ TransferConfirmState::TransferConfirmState(Base *base, TransferItemsState *state) : _base(base), _state(state) { _screen = false; // Create objects _window = new Window(this, 320, 80, 0, 60); _btnCancel = new TextButton(128, 16, 176, 115); _btnOk = new TextButton(128, 16, 16, 115); _txtTitle = new Text(310, 17, 5, 75); _txtCost = new Text(60, 17, 110, 95); _txtTotal = new Text(100, 17, 170, 95); // Set palette setInterface("transferConfirm"); add(_window, "window", "transferConfirm"); add(_btnCancel, "button", "transferConfirm"); add(_btnOk, "button", "transferConfirm"); add(_txtTitle, "text", "transferConfirm"); add(_txtCost, "text", "transferConfirm"); add(_txtTotal, "text", "transferConfirm"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK13.SCR")); _btnCancel->setText(tr("STR_CANCEL_UC")); _btnCancel->onMouseClick((ActionHandler)&TransferConfirmState::btnCancelClick); _btnCancel->onKeyboardPress((ActionHandler)&TransferConfirmState::btnCancelClick, Options::keyCancel); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&TransferConfirmState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&TransferConfirmState::btnOkClick, Options::keyOk); _txtTitle->setBig(); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setText(tr("STR_TRANSFER_ITEMS_TO").arg(_base->getName())); _txtCost->setBig(); _txtCost->setText(tr("STR_COST")); std::wostringstream ss; ss << L'\x01' << Text::formatFunding(_state->getTotal()); _txtTotal->setBig(); _txtTotal->setText(ss.str().c_str()); }
/** * Initializes all the elements in the Confirm Landing window. * @param game Pointer to the core game. * @param craft Pointer to the craft to confirm. * @param texture Texture of the landing site. * @param shade Shade of the landing site. */ ConfirmLandingState::ConfirmLandingState(Craft *craft, Texture *texture, int shade) : _craft(craft), _texture(texture), _shade(shade) { _screen = false; // Create objects _window = new Window(this, 216, 160, 20, 20, POPUP_BOTH); _btnYes = new TextButton(80, 20, 40, 150); _btnNo = new TextButton(80, 20, 136, 150); _txtMessage = new Text(206, 80, 25, 40); _txtBegin = new Text(206, 17, 25, 130); // Set palette setInterface("confirmLanding"); add(_window, "window", "confirmLanding"); add(_btnYes, "button", "confirmLanding"); add(_btnNo, "button", "confirmLanding"); add(_txtMessage, "text", "confirmLanding"); add(_txtBegin, "text", "confirmLanding"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getMod()->getSurface("BACK15.SCR")); _btnYes->setText(tr("STR_YES")); _btnYes->onMouseClick((ActionHandler)&ConfirmLandingState::btnYesClick); _btnYes->onKeyboardPress((ActionHandler)&ConfirmLandingState::btnYesClick, Options::keyOk); _btnNo->setText(tr("STR_NO")); _btnNo->onMouseClick((ActionHandler)&ConfirmLandingState::btnNoClick); _btnNo->onKeyboardPress((ActionHandler)&ConfirmLandingState::btnNoClick, Options::keyCancel); _txtMessage->setBig(); _txtMessage->setAlign(ALIGN_CENTER); _txtMessage->setWordWrap(true); _txtMessage->setText(tr("STR_CRAFT_READY_TO_LAND_NEAR_DESTINATION") .arg(_craft->getName(_game->getLanguage())) .arg(_craft->getDestination()->getName(_game->getLanguage()))); _txtBegin->setBig(); _txtBegin->setAlign(ALIGN_CENTER); std::wostringstream ss; ss << L'\x01' << tr("STR_BEGIN_MISSION"); _txtBegin->setText(ss.str()); }
/** * Initializes all the elements in the Confirm Destination window. * @param game Pointer to the core game. * @param craft Pointer to the craft to retarget. * @param target Pointer to the selected target (NULL if it's just a point on the globe). */ ConfirmDestinationState::ConfirmDestinationState(Craft *craft, Target *target) : _craft(craft), _target(target) { Waypoint *w = dynamic_cast<Waypoint*>(_target); _screen = false; // Create objects _window = new Window(this, 224, 72, 16, 64); _btnOk = new TextButton(50, 12, 68, 104); _btnCancel = new TextButton(50, 12, 138, 104); _txtTarget = new Text(212, 32, 22, 72); // Set palette setInterface("confirmDestination", w != 0 && w->getId() == 0); add(_window, "window", "confirmDestination"); add(_btnOk, "button", "confirmDestination"); add(_btnCancel, "button", "confirmDestination"); add(_txtTarget, "text", "confirmDestination"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK12.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&ConfirmDestinationState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&ConfirmDestinationState::btnOkClick, Options::keyOk); _btnCancel->setText(tr("STR_CANCEL_UC")); _btnCancel->onMouseClick((ActionHandler)&ConfirmDestinationState::btnCancelClick); _btnCancel->onKeyboardPress((ActionHandler)&ConfirmDestinationState::btnCancelClick, Options::keyCancel); _txtTarget->setBig(); _txtTarget->setAlign(ALIGN_CENTER); _txtTarget->setVerticalAlign(ALIGN_MIDDLE); _txtTarget->setWordWrap(true); if (w != 0 && w->getId() == 0) { _txtTarget->setText(tr("STR_TARGET").arg(tr("STR_WAY_POINT"))); } else { _txtTarget->setText(tr("STR_TARGET").arg(_target->getName(_game->getLanguage()))); } }
/** * Initializes all the elements in a Craft Error window. * @param game Pointer to the core game. * @param state Pointer to the Geoscape state. * @param msg Error message. */ CraftErrorState::CraftErrorState(GeoscapeState *state, const std::wstring &msg) : _state(state) { _screen = false; // Create objects _window = new Window(this, 256, 160, 32, 20, POPUP_BOTH); _btnOk = new TextButton(100, 18, _state ? 48 : 110, 150); _btnOk5Secs = new TextButton(100, 18, 172, 150); _txtMessage = new Text(246, 96, 37, 42); // Set palette setInterface("craftError"); add(_window, "window", "craftError"); add(_btnOk, "button", "craftError"); add(_btnOk5Secs, "button", "craftError"); add(_txtMessage, "text1", "craftError"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getMod()->getSurface("BACK12.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&CraftErrorState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&CraftErrorState::btnOkClick, Options::keyCancel); if (!_state) { _btnOk->onKeyboardPress((ActionHandler)&CraftErrorState::btnOkClick, Options::keyOk); } _btnOk5Secs->setText(tr("STR_OK_5_SECONDS")); _btnOk5Secs->onMouseClick((ActionHandler)&CraftErrorState::btnOk5SecsClick); if (_state) { _btnOk5Secs->onKeyboardPress((ActionHandler)&CraftErrorState::btnOk5SecsClick, Options::keyOk); } _btnOk5Secs->setVisible(_state != 0); _txtMessage->setAlign(ALIGN_CENTER); _txtMessage->setVerticalAlign(ALIGN_MIDDLE); _txtMessage->setBig(); _txtMessage->setWordWrap(true); _txtMessage->setText(msg); }
/** * Initializes all the elements in the EndManufacture screen. * @param game Pointer to the core game. * @param base Pointer to the base to get info from. * @param possibilities List of newly possible ManufactureProject */ NewPossibleManufactureState::NewPossibleManufactureState(Base * base, const std::vector<RuleManufacture *> & possibilities) : _base(base) { _screen = false; // Create objects _window = new Window(this, 288, 180, 16, 10); _btnOk = new TextButton(160, 14, 80, 149); _btnManufacture = new TextButton(160, 14, 80, 165); _txtTitle = new Text(288, 40, 16, 20); _lstPossibilities = new TextList(250, 80, 35, 50); // Set palette setInterface("geoManufacture"); add(_window, "window", "geoManufacture"); add(_btnOk, "button", "geoManufacture"); add(_btnManufacture, "button", "geoManufacture"); add(_txtTitle, "text1", "geoManufacture"); add(_lstPossibilities, "text2", "geoManufacture"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getMod()->getSurface("BACK17.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&NewPossibleManufactureState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&NewPossibleManufactureState::btnOkClick, Options::keyCancel); _btnManufacture->setText(tr("STR_ALLOCATE_MANUFACTURE")); _btnManufacture->onMouseClick((ActionHandler)&NewPossibleManufactureState::btnManufactureClick); _btnManufacture->onKeyboardPress((ActionHandler)&NewPossibleManufactureState::btnManufactureClick, Options::keyOk); _txtTitle->setBig(); _txtTitle->setAlign(ALIGN_CENTER); _txtTitle->setText(tr("STR_WE_CAN_NOW_PRODUCE")); _lstPossibilities->setColumns(1, 250); _lstPossibilities->setBig(); _lstPossibilities->setAlign(ALIGN_CENTER); _lstPossibilities->setScrolling(true, 0); for (std::vector<RuleManufacture *>::const_iterator iter = possibilities.begin(); iter != possibilities.end(); ++iter) { _lstPossibilities->addRow (1, tr((*iter)->getName()).c_str()); } }
/** * Initializes all the elements in the Craft Patrol window. * @param game Pointer to the core game. * @param craft Pointer to the craft to display. * @param globe Pointer to the Geoscape globe. */ CraftPatrolState::CraftPatrolState(Craft *craft, Globe *globe) : _craft(craft), _globe(globe) { _screen = false; // Create objects _window = new Window(this, 224, 168, 16, 16, POPUP_BOTH); _btnOk = new TextButton(140, 12, 58, 144); _btnRedirect = new TextButton(140, 12, 58, 160); _txtDestination = new Text(224, 64, 16, 48); _txtPatrolling = new Text(224, 17, 16, 120); // Set palette setInterface("geoCraftScreens"); add(_window, "window", "geoCraftScreens"); add(_btnOk, "button", "geoCraftScreens"); add(_btnRedirect, "button", "geoCraftScreens"); add(_txtDestination, "text1", "geoCraftScreens"); add(_txtPatrolling, "text1", "geoCraftScreens"); centerAllSurfaces(); // Set up objects _window->setBackground(_game->getResourcePack()->getSurface("BACK12.SCR")); _btnOk->setText(tr("STR_OK")); _btnOk->onMouseClick((ActionHandler)&CraftPatrolState::btnOkClick); _btnOk->onKeyboardPress((ActionHandler)&CraftPatrolState::btnOkClick, Options::keyCancel); _btnRedirect->setText(tr("STR_REDIRECT_CRAFT")); _btnRedirect->onMouseClick((ActionHandler)&CraftPatrolState::btnRedirectClick); _btnRedirect->onKeyboardPress((ActionHandler)&CraftPatrolState::btnRedirectClick, Options::keyOk); _txtDestination->setBig(); _txtDestination->setAlign(ALIGN_CENTER); _txtDestination->setWordWrap(true); _txtDestination->setText(tr("STR_CRAFT_HAS_REACHED_DESTINATION") .arg(_craft->getName(_game->getLanguage())) .arg(_craft->getDestination()->getName(_game->getLanguage()))); _txtPatrolling->setBig(); _txtPatrolling->setAlign(ALIGN_CENTER); _txtPatrolling->setText(tr("STR_NOW_PATROLLING")); }