void service::recreate(bool updating) { if (updating) utils_docker::pullImage(mParams, mSettings, getImageName()); try { // nuke any existing dService files on host (but preserve volume containers!). if (utils::fileexists(getPath())) utils::deltree(getPath(), mParams); // notice for hostVolumes. if (utils::fileexists(getPathHostVolume())) logmsg(kLINFO, "A drunner hostVolume already exists for " + getName() + ", reusing it."); // create the basic directories. ensureDirectoriesExist(); // copy files to service directory on host. std::string op; int r = utils::bashcommand("docker run --rm -i -v " + getPathdRunner() + ":/tempcopy " + getImageName() + " /bin/bash -c \"cp -r /drunner/* /tempcopy/ && chmod a+rx /tempcopy/*\"", op); if (r != 0) logmsg(kLERROR, "Couldn't copy the service files. You will need to reinstall the service."); // write out variables.sh for the dService. drunnerCompose drc(*this, mParams); if (drc.readOkay()==kRError) fatal("Unexpected error - docker-compose.yml is broken."); // write out servicevars.sh for ourselves. sh_servicevars svcvars(getPath()); svcvars.create(getImageName()); if (!svcvars.write()) fatal("Unexpected error - couldn't write out servicevars.sh."); // make sure we have the latest of all exra containers. for (const auto & entry : drc.getServicesInfo()) if (entry.mImageName != getImageName()) // don't pull main image again. utils_docker::pullImage(mParams, mSettings, entry.mImageName); // create the utils.sh file for the dService. generate_utils_sh(getPathdRunner(), mParams); // create launch script createLaunchScript(); // create volumes createVolumes(&drc); } catch (const eExit & e) { // tidy up. if (utils::fileexists(getPath())) utils::deltree(getPath(), mParams); throw (e); } }
//-------------------------------- // //-------------------------------- bool AflMapData::saveMap(LPCSTR pFileName) { int i,j,k; FILE* pFile; pFile = fopen(pFileName,TEXT("wb")); if(!pFile) return false; m_strFileName = pFileName; setRelativePath(); fwrite(m_strMapHeader[MAP_BINHEADER],strlen(m_strMapHeader[MAP_BINHEADER])+1,1,pFile); //----------------------------- writeHeader(pFile,m_strMapHeader[MAP_VERSION],getVersion()); writeHeader(pFile,m_strMapHeader[MAP_MAPNAME],getMapName()); writeHeader(pFile,m_strMapHeader[MAP_BITMAP],getImageName(0)); writeHeader(pFile,m_strMapHeader[MAP_SPRITE],getImageName(1)); writeHeader(pFile,m_strMapHeader[MAP_WIDTH],getMapWidth()); writeHeader(pFile,m_strMapHeader[MAP_HEIGHT],getMapHeight()); writeHeader(pFile,m_strMapHeader[MAP_OPATTERN],getOutTipIndex()); writeHeader(pFile,m_strMapHeader[MAP_PARTSWIDTH],getTipWidth()); writeHeader(pFile,m_strMapHeader[MAP_PARTSHEIGHT],getTipHeight()); writeHeader(pFile,m_strMapHeader[MAP_OBJECT],getObjectFileName()); //----------------------------- //マップデータ for(k=0;k<4;k++) { if(!isZero(k)) { PSHORT pData = m_ptrData[k].get(); writeHeader(pFile,m_strMapHeader[MAP_MAPDATA0+k], pData,getMapWidth()*getMapHeight()*sizeof(short)); } } //----------------------------- //パーツ接触フラグ for(j=0;j<5;j++) { int nCollide; for(nCollide=i=0;i<0xffff/8;i++) if(m_byCollide[j][i]) nCollide = i+1; writeHeader(pFile,m_strMapHeader[MAP_PAERSCOLLIDE0+j],m_byCollide,nCollide); } //----------------------------- //----------------------------- //マップ個別フラグ writeHeader(pFile,m_strMapHeader[MAP_MAPFLAG0],getMapFlag(),getMapWidth()*getMapHeight()); //----------------------------- fclose(pFile); return true; }
void Drawable::draw(const Cairo::RefPtr<Cairo::Context>& context, ImageBuffer& buff) { context->save(); // std::cout << getImageName() << std::endl; auto image = buff.getImage(getImageName(), flipped_, scaleX, scaleY); // int width = image->get_width(); // int height = image->get_height(); proto::Position pos = getPosition(); int x = c_.scaleWidth(pos.x); int y = c_.scaleHeight(pos.y); // Gdk::Cairo::set_source_pixbuf(context, image, pos.x + width / 2, // pos.y - height / 2); Gdk::Cairo::set_source_pixbuf(context, image, x, offset_ + y); context->paint(); // context->set_source_rgb(0.8, 0.0, 0.0); // context->move_to(pos.x, pos.y); // context->line_to(pos.x + width / 2, pos.y - height / 2); // context->line_to(pos.x + width / 2, pos.y + height / 2); // context->line_to(pos.x - width / 2, pos.y + height / 2); // context->line_to(pos.x - width / 2, pos.y - height / 2); // context->line_to(pos.x + width / 2, pos.y - height / 2); // context->stroke(); context->restore(); }
bool CSeparateImageFontWriter::write( const SFontInfo& fnt ) { if (fnt.images.size() == 0) { cerr << "No image data to write, aborting." << endl; return false; } for (u32 i = 0; i < fnt.images.size(); ++i) { std::string imageFileName = getImageName(i); const char* fname = imageFileName.c_str(); if (!driver->writeImageToFile(fnt.images[i], fname)) { cerr << "Writting image: " << fname << " failed" << endl; return false; } else { cout << fname << " saved" << endl; } } return onWriteFontFile(fnt); }
void MainWindow::selectBoardPosition( int boardPositionId ) { if ( isHumanTurnToPutPiece ) { isHumanTurnToPutPiece = false; // allow the user to choose a piece isHumanTurnToChoose = true; // updating current board position id currentBoardPositionId = boardPositionId; // update board QPiece *piece = boardPieces[ currentBoardPositionId ]; piece->setImage( getImageName( currentPieceId ) ); piece->updateImage(); // update pieces used piece = pieces[ currentPieceId ]; piece->setImage( ":/images/p00.jpg" ); piece->updateImage(); // update current piece selected QPixmap pixMap( "" ); selectedPiece->setPixmap( pixMap ); // emit signal to indicate the human just played emit humanPlayed( currentPieceId, currentBoardPositionId ); } }
// virtual LLXMLNodePtr LLIconCtrl::getXML(bool save_children) const { LLXMLNodePtr node = LLUICtrl::getXML(); node->setName(LL_ICON_CTRL_TAG); if (!getImageName().empty()) { node->createChild("image_name", TRUE)->setStringValue(getImageName()); } if (mMinWidth) node->createChild("min_width", true)->setIntValue(mMinWidth); if (mMinHeight) node->createChild("min_height", true)->setIntValue(mMinHeight); node->createChild("color", TRUE)->setFloatValue(4, mColor.mV); return node; }
void service::install() { logmsg(kLDEBUG, "Installing " + getName() + " at " + getPath() + ", using image " + getImageName()); if (utils::fileexists(getPath())) logmsg(kLERROR, "Service already exists. Try: drunner update " + getName()); // make sure we have the latest version of the service. utils_docker::pullImage(mParams, mSettings, getImageName()); logmsg(kLDEBUG, "Attempting to validate " + getImageName()); validateImage(mParams,mSettings,getImageName()); recreate(false); servicehook hook(this, "install", mParams); hook.endhook(); logmsg(kLINFO, "Installation complete - try running " + getName()+ " now!"); }
void MainWindow::humanPieceSelect( int pieceId ) { currentPieceId = pieceId; string imageName = getImageName( pieceId ); QPixmap pixMap( imageName.c_str() ); selectedPiece->setPixmap( pixMap ); isHumanTurnToPutPiece = true; }
void Node::loadPicture() { QPixmap pix(getImageName()); const size_t offset = 0; //picturePadding; qDebug() << pix.width() << "x" << pix.height(); setPixmap(pix.scaled(QSize(diameter + offset, diameter + offset))); setFlags(QGraphicsPixmapItem::flags() | QGraphicsItem::ItemClipsToShape); }
void Renderable::draw(const Matrix& mat, double wdt, double hgt) const { SphericalCoordinate sc = (mat * m_Position).toSphericalCoordinate(); if(sc.distance < 10.0) return; // "clipping" Gosu::Image& im = getImage(getImageName()); Gosu::ImageData& imdata = im.getData(); Quaternion quat = Quaternion::fromAxisAngle(Vector::RIGHT, -sc.inclination-Gosu::pi/2)*Quaternion::fromAxisAngle(Vector::UP, -sc.azimuth-Gosu::pi/2); Matrix mat2 = quat.inverted().toMatrix(); double dist = sc.distance; if (dist > m_FixedSizeDistance) { dist = m_FixedSizeDistance; } Vector vn = mat2 * Vector(-double(im.width())/2*m_Scale, -double(im.height())/2*m_Scale, -dist); Vector vp = mat2 * Vector(double(im.width())/2*m_Scale, double(im.height())/2*m_Scale, -dist); SphericalCoordinate n = vn.toSphericalCoordinate(); SphericalCoordinate p = vp.toSphericalCoordinate(); auto drawfun = [m_Color, dist, &imdata](double nx, double ny, double px, double py) { imdata.draw(nx, ny, m_Color, px, ny, m_Color, px, py, m_Color, nx, py, m_Color, -dist, Gosu::amDefault); }; double nx = screenX(n, wdt); double px = screenX(p, wdt); double ny = screenY(n, hgt); double py = screenY(p, hgt); if (nx > px) { if (ny > py) { drawfun(nx - wdt, ny - hgt, px, py); drawfun(nx - wdt, ny, px, py + hgt); drawfun(nx, ny - hgt, px + wdt, py); drawfun(nx, ny, px + wdt, py + hgt); } else { drawfun(nx - wdt, ny, px, py); drawfun(nx, ny, px + wdt, py); } } else { if (ny > py) { drawfun(nx, ny - hgt, px, py); drawfun(nx, ny, px, py + hgt); } else { drawfun(nx, ny, px, py); } } }
void MainWindow::computerPlay( int pieceId, int boardPositionId ) { if ( ( pieceId < boardPieces.size() ) && ( boardPositionId < pieces.size() ) ) { QPiece *piece = boardPieces[ boardPositionId ]; piece->setImage( getImageName( pieceId ) ); piece->updateImage(); piece = pieces[ pieceId ]; piece->setImage( ":/images/p00.jpg" ); piece->updateImage(); QPixmap pixMap( "" ); selectedPiece->setPixmap( pixMap ); } }
QImage *LH_DataViewerImage::render_qimage(int w, int h) { delete image_; if( setup_file_->value().isFile() ) { QString folderPath = setup_file_->value().dir().path() + "/"; QString imageName = getImageName(); if (imageName=="") { uchar *data = new uchar[4]; data[0] = 255; data[1] = 0; data[2] = 0; data[3] = 0; image_ = new QImage(data,1,1,QImage::Format_ARGB32); } else image_ = new QImage(folderPath + imageName); } else image_ = new QImage(w,h,QImage::Format_Invalid); return image_; }
void MainWindow::selectPiece( int pieceId ) { if ( isHumanTurnToChoose ) { isHumanTurnToChoose = false; // update current piece selected id currentPieceId = pieceId; // update pieces used QPiece *piece = pieces[ pieceId ]; piece->setImage( ":/images/p00.jpg" ); piece->updateImage(); // previsualize selected piece string imageName = getImageName( pieceId ); QPixmap pixMap( imageName.c_str() ); selectedPiece->setPixmap( pixMap ); // emit signal to allow the computer play emit computerPieceSelected( pieceId ); } }
void CStrengthenItem::addTableCell(unsigned int uIdx, CTableViewCell * pCell) { CLayout *lay = UICloneMgr::cloneLayout(m_cell); CItem &item = *(m_itemList.at(uIdx));// m_itemData.itemList.at(uIdx); pCell->setTag(uIdx); const ItemData * itemData = DataCenter::sharedData()->getItemDesc()->getCfg(item.itemId); for (int i = 1; i <=11; i++) { CCNode *child = lay->getChildByTag(i); if (!child) continue; lay->removeChild(child); pCell->addChild(child); if (i==1) { CImageView *bgImg = (CImageView*)child; if (m_toHero>0) { if (!item.canUse&&item.armor.hero!=m_toHero) { CColorView *colorView = CColorView::create(ccc4(0,0,0,100)); colorView->setContentSize(bgImg->getContentSize()); colorView->setPosition(bgImg->getPosition()); pCell->addChild(colorView,1); } if(item.armor.hero<=0) { //记录库存 m_iCountEquipStock++; } } bgImg->setTouchEnabled(true); bgImg->setUserData(m_itemList.at(uIdx)); bgImg->setOnClickListener(this,ccw_click_selector(CStrengthenItem::onTouchItem)); } else if (i==2) { ((CButton*)child)->setEnabled(false); CCSprite *mask = CCSprite::createWithTexture(setItemQualityTexture(item.quality)); mask->setPosition(ccp(child->getContentSize().width/2,child->getContentSize().height/2)); child->addChild(mask, 10); CCSprite *prop = CCSprite::create(GetImageName(1, item.quality, item.iconId).c_str()); if (!prop) { prop = CImageView::create("prop/32003.png"); } prop->setPosition(ccp(child->getContentSize().width/2,child->getContentSize().height/2)); child->addChild(prop); //添加星星 CLayout* pStarLayout = getStarLayout(item.iStar); child->addChild(pStarLayout, 10); } else if (i==3) { CLabel *label = (CLabel*)child; if(itemData) { label->setString(itemData->itemName.c_str()); } } else if (i==4) { CLabel *label = (CLabel*)child; if (item.itemLevel==0) { label->removeFromParent(); } else { label->setString(CCString::createWithFormat("+%d",item.itemLevel)->getCString()); label->setPositionX(pCell->getChildByTag(3)->getPositionX()+pCell->getChildByTag(3)->getContentSize().width+10); } } else if (i==5) { CLabel *label = (CLabel*)child; if (item.itemLevel==0) { label->setVisible(false); } else { label->setVisible(true); //if (item.itemLevel==item.armor.strenLv) //{ // label->setString(CCString::createWithFormat("Lv.%s",GETLANGSTR(229))->getCString()); //} //else //{ // label->setString(CCString::createWithFormat("Lv.%d",item.itemLevel)->getCString()); //} label->setString(CCString::createWithFormat("+%d",item.itemLevel)->getCString()); } } else if (i==6) { CCSprite *head = (CCSprite*)child; if (item.armor.hero>0) { CCSprite *img = CCSprite::create(getImageName(&item.armor).c_str()); if(!img) { img = CCSprite::create("headIcon/101.png"); CCLOG("ERROR CStrengthenItem::addTableCell"); } CCSprite *mask = (CCSprite*) lay->getChildByTag(7); lay->removeChild(mask); pCell->addChild(mask); img->setScale(0.53f); img->setPosition(ccp(head->getContentSize().width/2,head->getContentSize().height/2+14)); head->addChild(img); } else { pCell->removeChild(child); } } else if (i==7) { pCell->removeChild(child); } else if (i==8) { child->setVisible(item.stren); } else if(i==9) { if (item.itemLevel==0) { child->setVisible(false); } else { child->setVisible(true); } } else if( i ==10) { CCNode* pCombatTip = (CCNode*)child; pCombatTip->setVisible(item.armor.armorType != 5); } else if (i==11) { CLabelAtlas* pLabel = (CLabelAtlas*)child; pLabel->setAnchorPoint(ccp(0, 0.5f)); pLabel->setString(ToString(item.armor.combat)); pLabel->setVisible(item.armor.armorType != 5); } } }
double Renderable::getRadius() const { Gosu::Image& i = getImage(getImageName()); return double(std::min(i.width(), i.height()))*0.5*m_Scale; }
extern void setSystemData(struct SystemData *sd) { struct SystemCounts2 sc; int size, totalSize, i, reflashes; dumpSystemDataToLog(sd); sd->structType = NOR_STRUCT_ID_SYSTEM; reflashes = getReflashCount(); if (!sd->countReflashes) sd->countReflashes = reflashes + 1; if (!sd->serialNumber[0]) { strcpy(sd->serialNumber,getSerialNumber()); if (!sd->serialNumber[0]) { strcpy(sd->serialNumber,(char *)"UNKNOWN"); } } if (!sd->location[0]) { strcpy(sd->location,getLocation()); if (!sd->location[0]) { strcpy(sd->location,(char *)"UNKNOWN"); } } if (!sd->imageName[0]) { strcpy(sd->imageName,getImageName()); if (!sd->imageName[0]) { strcpy(sd->imageName,(char *)"UNKNOWN"); } } if (!sd->updateNumber[0]) strcpy(sd->updateNumber,getUpdateNumber()); if (!sd->monthLastUpdated) sd->monthLastUpdated = getUpdateMonth(); if (!sd->dateLastUpdated) sd->dateLastUpdated = getUpdateDate(); if (!sd->yearLastUpdated) sd->yearLastUpdated = getUpdateYear(); dumpSystemDataToLog(sd); systemCounts.monthday = sd->dateLastUpdated; systemCounts.month = sd->monthLastUpdated; systemCounts.year = sd->yearLastUpdated; sc.structType = NOR_STRUCT_ID_COUNTS; sc.period = 0; sc.cumulativeDays = 0; sc.corruptionDay = 0; sc.powerups = 0; sc.lastInitVoltage = 0; sc.rotations[0].structType = NOR_STRUCT_ID_ROTATION; sc.rotations[0].rotationNumber = 0; sc.rotations[0].periodNumber = 0; sc.rotations[0].hoursAfterLastUpdate = 0; checkVoltage(); sc.rotations[0].initVoltage = vCur_1; for (i=1; i< MAX_ROTATIONS; i++) { sc.rotations[i].structType = -2; // -1 is bad since FF is unwritten memory } // startup() assumes that struct SystemData is written first at TB_SERIAL_NUMBER_ADDR totalSize = 0; size = sizeof(struct SystemData); // round up # of words write_app_flash((int *)sd, size, totalSize); totalSize += size; ptrsCounts.systemData = (struct SystemData *)(TB_SERIAL_NUMBER_ADDR); size = sizeof(struct SystemCounts2); // round up # of words write_app_flash((int *)&sc, size, totalSize); ptrsCounts.systemCounts = (struct SystemCounts2 *)(TB_SERIAL_NUMBER_ADDR + totalSize); ptrsCounts.period = NULL; ptrsCounts.cumulativeDays = NULL; ptrsCounts.powerups = NULL; ptrsCounts.corruptionDay = NULL; ptrsCounts.latestRotation = NULL; }