bool CFullTestIOInWindow::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::MouseButtonPress) { for(int i=0;i<_vec32IO.size();i++) { if(obj == _vec32IO[i]) { //***PLC PLCCommandFrame_0x80 c={0}; ((CApp*)qApp)->_tjob->initFrame80(&c); //***仪表 hardwareTestFrame_0x30 b={_METER_FRAME_HARDWARE_TEST_,0x00}; QByteArray tmp1=QByteArray::fromRawData((const char*)&b,sizeof(b)); ((CApp*)qApp)->_tjob->sendTestData232(tmp1); if(property("in").toInt()) { setProperty("in",0); setMap(&c,0,i); c.ifeedback = _bReadCurrent->isChecked()?0x1:0x0; QByteArray tmp2=QByteArray::fromRawData((const char*)&c,sizeof(c)); ((CApp*)qApp)->_tjob->sendTestData485(tmp2); _statusLabel->setText(tr("请观察低电平有效的IO量是否变红,同时观察相应的激励电流(mA)。")); _statusLabel_1->setText(tr("当前电平:低电平,当前IO通道:")+ QString::number(i)); } else { setProperty("in",1); setMap(&c,1,i); c.ifeedback = _bReadCurrent->isChecked()?0x1:0x0; QByteArray tmp2=QByteArray::fromRawData((const char*)&c,sizeof(c)); ((CApp*)qApp)->_tjob->sendTestData485(tmp2); _statusLabel->setText(tr("请观察高电平有效的IO量是否变红。")); _statusLabel_1->setText(tr("当前电平:高电平,当前IO通道:")+ QString::number(i)); } break; } } return true; } return QWidget::eventFilter(obj, event); }
int main(void){ char* map = initMap(); banner(map); int input = 0; int turn; for(turn=5; turn != 0; turn-- ){ printf("Dein Zug: "); if(scanf("%d", &input) <= 0){ printf("\nFehler bei der Eingabe!\n"); while(getchar() != '\n'); turn++; continue; } if(setMap(map, input) == 0){ if(check(map) != 0) break; outMap(map); printf("Gegner ist am Zug:\n"); setNPC(map); outMap(map); if(check(map) != 0) break; } else{ turn++; } } printf("Der Sieger ist...\n"); //Das kann man bestimmt auch besser machen.. int result = check(map); if(result == 0) printf("Niemand\n"); else if(result == 1) printf("Der Spieler\n"); else if(result == 2) printf("Der Computer\n"); free(map); writeRecord(result); return 0; }
ObjectEditor::ObjectEditor(QString *patchProject,ELanguage *lan, QWidget *parent): SpaceEngine() { SpaceEngineEvents->setParent(parent); addCamera(); pack=new EResursePack(); camera=getCamersList()->front(); // camera->setLineWidth(5); connect(camera,SIGNAL(MouseClikedEvent(EMouseEvent*)),SLOT(cameraClick(EMouseEvent*))); connect(camera,SIGNAL(scrollEnd(EKord&)),this,SLOT(cameraSizeChanged(EKord&))); setCameraVirtual(camera,EKord(0.70,0.88),EKord(0,0.1)); Projectpatch=patchProject; lang=lan; log=new ELoadScreen(); addMap(); ObjectRender=NULL; setMap(getMapsList()->front(),camera); createVerticalMenu(); createHorizontalMenu(); addQtWidget(log,EKord(0),EKord(1,0.1)); log->setHidden(true); ugol=lastX=0; connect(getMain(),SIGNAL(EmouseMoveEvent(QMouseEvent*)),SLOT(MouseMove(QMouseEvent*))); connect(getMain(),SIGNAL(EkeyPressEvent(QKeyEvent*)),SLOT(press(QKeyEvent*))); connect(getMain(),SIGNAL(EkeyReleaseEvent(QKeyEvent*)),SLOT(release(QKeyEvent*))); alt=ShiftPressd=ctrlPresed=false; }
void CFunctionTestSpeedTableWindow::timerUpdate() { //***PLC if(_cur>=cf->_function_tpoint["meter_speed"].size()) _cur=0; int val = cf->_function_tpoint["meter_speed"][_cur]; if(val<=cf->_function_param["low_speed"]) { _signOutLabel->setStyleSheet("border-radius:15px;background:red;border:1px solid #666;"); _statusLabel->setStyleSheet("font:bold 16px;color:red;max-height:50px;min-height:26px;background:#CCFF99;"); _statusLabel->setText(tr("请观察速度表,现在的值应该是 ") + QString::number(val) + tr(" km/h,\n高低档切换指示灯点亮!")); } else { _signOutLabel->setStyleSheet("border-radius:15px;background:#fff;border:1px solid #666;"); _statusLabel->setStyleSheet("font:bold 16px;color:#0099FF;max-height:50px;min-height:26px;background:#CCFF99;"); _statusLabel->setText(tr("请观察速度表,现在的值应该是 ") + QString::number(val) + tr(" km/h,\n高低档切换指示灯熄灭!")); } _currentValue->setValue(val); PLCCommandFrame_0x80 c={0}; ((CApp*)qApp)->_tjob->initFrame80(&c); QByteArray tb = arrangeByte( (double)val*((double)cf->_function_param["speed_pulse"]/3600.0),4); c.freqout[0] = tb[0]; c.freqout[1] = tb[1]; c.freqout[2] = tb[2]; c.freqout[3] = tb[3]; //***取力开关量置低位 setMap(&c,2,0); QByteArray tmp2=QByteArray::fromRawData((const char*)&c,sizeof(c)); ((CApp*)qApp)->_tjob->sendTestData485(tmp2); _cur++; }
void TclTextInterp::initialize_structure_cb(int molid, int code) { char molstr[30]; sprintf(molstr, "%d", molid); char codestr[30]; sprintf(codestr, "%d", code); setMap("vmd_initialize_structure", molstr, codestr); }
inline void StructureTransitionTable::add(JSGlobalData& globalData, Structure* structure) { if (isUsingSingleSlot()) { Structure* existingTransition = singleTransition(); // This handles the first transition being added. if (!existingTransition) { setSingleTransition(globalData, structure); return; } // This handles the second transition being added // (or the first transition being despecified!) setMap(new TransitionMap()); add(globalData, existingTransition); } // Add the structure to the map. // Newer versions of the STL have an std::make_pair function that takes rvalue references. // When either of the parameters are bitfields, the C++ compiler will try to bind them as lvalues, which is invalid. To work around this, use unary "+" to make the parameter an rvalue. // See https://bugs.webkit.org/show_bug.cgi?id=59261 for more details std::pair<TransitionMap::iterator, bool> result = map()->add(globalData, make_pair(structure->m_nameInPrevious, +structure->m_attributesInPrevious), structure); if (!result.second) { // There already is an entry! - we should only hit this when despecifying. ASSERT(result.first.get().second->m_specificValueInPrevious); ASSERT(!structure->m_specificValueInPrevious); map()->set(result.first, structure); } }
static void setWholeVeCmd(float value) { scheduleMsg(&logger, "Setting whole VE map to %f", value); if (engineConfiguration->algorithm != LM_SPEED_DENSITY) { scheduleMsg(&logger, "WARNING: setting VE map not in SD mode is pointless"); } setMap(config->veTable, value); }
void TclTextInterp::molecule_changed_cb(int molid, int code) { char molstr[30]; sprintf(molstr, "%d", molid); char codestr[30]; sprintf(codestr, "%d", code); setMap("vmd_molecule", molstr, codestr); }
void TclTextInterp::timestep_cb(int molid, int frame) { char mol[10]; char n[10]; sprintf(mol, "%d", molid); sprintf(n, "%d", frame); setMap("vmd_timestep", mol, n); }
void Map::initMap(bool const obstacles) { int count = 0; int rand_x; int rand_y; this->obstacles = obstacles; for(int y = 0 ; y != this->height ; y++) { for(int x = 0 ; x != this->width ; x++) { if (y == 0 || y == (this->height - 1) || x == 0 || x == this->width -1) this->MapSnake[y][x] = WALL; else this->MapSnake[y][x] = EMPTY; } } this->printSnakeOnMap(); this->addFood(FOOD); if (this->obstacles == true) { while (count != NB_WALL) { rand_x = rand() % this->width; rand_y = rand() % this->height; if (this->MapSnake[rand_y][rand_x] == EMPTY && rand_x > 0 && rand_y > 0) { setMap(rand_x, rand_y, WALL); count++; } } } }
void FloorItem::postInit(Map *const map, int subX, int subY) { setMap(map); const ItemInfo &info = ItemDB::get(mItemId); if (map) { const int max = info.getMaxFloorOffset(); if (subX > max) subX = max; else if (subX < -max) subX = -max; if (subY > max) subY = max; else if (subY < -max) subY = -max; mPos.x = static_cast<float>(mX * map->getTileWidth() + subX + mapTileSize / 2 - 8); mPos.y = static_cast<float>(mY * map->getTileHeight() + subY + mapTileSize - 8); } else { mPos.x = 0; mPos.y = 0; } mCursor = info.getPickupCursor(); setupSpriteDisplay(info.getDisplay(), true, 1, info.getDyeColorsString(mColor)); mYDiff = 31; }
bool Map::push (int _x, int _y) { assert (!badCoords (xpos_, ypos_)); assert (empty (xpos_, ypos_)); int xd=0, yd=0; if (_x < xpos_) xd = -1; if (_x > xpos_) xd = 1; if (_y < ypos_) yd = -1; if (_y > ypos_) yd = 1; if (badDelta (xd, yd) || badCoords (_x+xd, _y+yd)) return false; int x=xpos_+xd, y=ypos_+yd; if (!object (x, y)) return false; if (!empty (_x+xd, _y+yd)) return false; while (!(x==_x && y==_y)) { x += xd; y += yd; if (!empty (x, y)) return false; } clearMap (xpos_+xd, ypos_+yd, OBJECT); setMap (_x+xd, _y+yd, OBJECT); xpos_ = _x; ypos_ = _y; return true; }
BaseCreatureEntity::BaseCreatureEntity(sf::Texture* image, float x = 0.0f, float y = 0.0f, int spriteWidth = -1, int spriteHeight = -1) : CollidingSpriteEntity (image, x, y, spriteWidth, spriteHeight ) { hurting = false; hurtingType = ShotTypeStandard; shadowFrame = -1; setMap(game().getCurrentMap(), TILE_WIDTH, TILE_HEIGHT, OFFSET_X, OFFSET_Y); hpDisplay = 0; armor = 0.0f; movingStyle = movWalking; for (int i = 0; i < NB_SPECIAL_STATES; i++) { specialState[i].type = (enumSpecialState)i; specialState[i].active = false; specialState[i].timer = 0.0f; specialState[i].param1 = 0.0f; specialState[i].param2 = 0.0f; } for (int i = 0; i < NB_RESISTANCES; i++) { resistance[i] = ResistanceStandard; } recoil.active = false; facingDirection = 2; }
bool LuaScript::resume() { assert(nbArgs >= 0); assert(mCurrentThread); setMap(mCurrentThread->mMap); const int tmpNbArgs = nbArgs; nbArgs = -1; int result = lua_resume(mCurrentState, tmpNbArgs); setMap(0); if (result == 0) // Thread is done { if (lua_gettop(mCurrentState) > 0) LOG_WARN("Ignoring values returned by script thread!"); } else if (result == LUA_YIELD) // Thread has yielded { if (lua_gettop(mCurrentState) > 0) LOG_WARN("Ignoring values passed to yield!"); } else // Thread encountered an error { // Make a traceback using the debug.traceback function lua_getglobal(mCurrentState, "debug"); lua_getfield(mCurrentState, -1, "traceback"); lua_pushvalue(mCurrentState, -3); // error string as first parameter lua_pcall(mCurrentState, 1, 1, 0); LOG_WARN("Lua Script Error:" << std::endl << lua_tostring(mCurrentState, -1)); } lua_settop(mCurrentState, 0); const bool done = result != LUA_YIELD; if (done) { // Clean up the current thread (not sure if this is the best place) delete mCurrentThread; } mCurrentThread = 0; mCurrentState = mRootState; return done; }
void cGRID::checkCollision(std::shared_ptr<cGAME_OBJECT>& obj, cSCENE_MAIN* scene) { if (current_map_data_.data_grid[obj->getCellPos().y][obj->getCellPos().x] == 'l') { map_data_index_ = current_map_data_.potal_L_filename; int y = obj->getCellPos().y; obj->setCellPos({ current_map_[map_data_index_].count_x - 2, y }); setMap(obj); } if (current_map_data_.data_grid[obj->getCellPos().y][obj->getCellPos().x] == 't') { map_data_index_ = current_map_data_.potal_T_filename; int x = obj->getCellPos().x; obj->setCellPos({ x, current_map_[map_data_index_].count_y - 2 }); setMap(obj); } if (current_map_data_.data_grid[obj->getCellPos().y][obj->getCellPos().x] == 'r') { map_data_index_ = current_map_data_.potal_R_filename; int y = obj->getCellPos().y; obj->setCellPos({ 1, y }); setMap(obj); } if (current_map_data_.data_grid[obj->getCellPos().y][obj->getCellPos().x] == 'b') { map_data_index_ = current_map_data_.potal_B_filename; int x = obj->getCellPos().x; obj->setCellPos({ x, 1 }); setMap(obj); } if (current_map_data_.data_grid[obj->getCellPos().y][obj->getCellPos().x] == 'd') { scene->changeSceneState(eSCENE_STATE::SELECT); int x = obj->getCellPos().x - 1; int y = obj->getCellPos().y; obj->setCellPos({ x, y }); obj->setPos({ x* current_map_data_.width, y * current_map_data_.height }); } if (current_map_data_.data_grid[obj->getCellPos().y][obj->getCellPos().x] == 'x') { //map_data_index_ = current_map_data_.potal_R_filename; int y = obj->getCellPos().y; obj->setCellPos({ 1, y }); setMap(obj); } }
PrefSelectionWidget::PrefSelectionWidget (QWidget *parent, PreferenceValue *pref) : QWidget (parent) { QSettings s; setupUi (this); label->setText (pref->help ()); setMap (pref->data ().toMap (), s.value (pref->key (), pref->defval ()).toString ()); }
QMap<QString, QVariant> Settings::map(QString key, QMap<QString, QVariant> default_value) { QMap<QString, QVariant> value = valueWithFallback(key, default_value).toMap(); if (value==default_value) { setMap(key, default_value); } return value; }
void App::updateMetadata() { if(bNewData) { metadata.update(json_data); bNewData = false; bConnected = true; setMap(); } }
MapSearchable::MapSearchable(Map map, Position start, Location goal) { setMap(map); this->start = map.getGridPosition(start); this->goal = map.getGridLocation(goal); this->startState = State(map.getWorldLocation(this->start.getLocation()), 0, this->operator()(this->start.getLocation()), airDistance(this->start.getLocation(), this->goal)); this->goalState = State(map.getWorldLocation(this->goal)); }
void kgeography::openMap() { mapChooser mp(this); if (mp.exec() == mapChooser::Accepted) { showResultsDialog(); setMap(mp.getMap()); resizeMainWindow(); } }
MapView::MapView(Model::Map * m) : QGraphicsScene() { gridStrategy = NULL; displayStrategy = NULL; paintStrategy = NULL; setMap(m); initCursor(); modified = false; }
void MapDrawer::updateData(const LCreal dt) { // Update our baseclass BaseClass::updateData(dt); // Set our map if we don't have one if (myMap == 0) { CadrgMap* map = dynamic_cast<CadrgMap*>(findContainerByType(typeid(CadrgMap))); if (map != 0) setMap(map); } }
ActorSprite::~ActorSprite() { setMap(NULL); mUsedTargetCursor = NULL; // Notify listeners of the destruction. Event event(Event::Destroyed); event.setActor("source", this); event.trigger(Event::ActorSpriteChannel); }
bool JoystickMapper::setValue(string name, string value) { if (name == "inputDevice") inputDevice = value; else if (name == "deviceId") deviceId = getOEInt(value); else if (name.substr(0, 4) == "axis") setMap(JOYSTICK_AXIS1 + getOEInt(name.substr(4)), value); else if (name.substr(0, 6) == "button") setMap(JOYSTICK_BUTTON1 + getOEInt(name.substr(6)), value); else if (name.substr(0, 15) == "sensitivityAxis") setSensitivity(JOYSTICK_AXIS1 + getOEInt(name.substr(15)), getFloat(value)); else if (name.substr(0, 11) == "reverseAxis") setReverse(JOYSTICK_AXIS1 + getOEInt(name.substr(11)), getOEInt(value)); else if (name.substr(0, 3) == "map") inputDeviceMap[name.substr(3)] = value; else return false; return true; }
Being::~Being() { mUsedTargetCursor = NULL; delete_all(mSprites); if (player_node && player_node->getTarget() == this) player_node->setTarget(NULL); setMap(NULL); delete mSpeechBubble; delete mText; }
ImageParticle::~ImageParticle() { if (mImage) { std::string name = mImage->getIdPath(); if (ImageParticle::imageParticleCountByName[name] > 0) ImageParticle::imageParticleCountByName[name] --; mImage->decRef(); mImage = nullptr; } setMap(nullptr); }
// --- void SabreWulfScene::initialize () { setMap (__SABREWULFMAP__); QGAMES::Scene::initialize (); setMazePlaceNumber (__FIRSTMAZEPLACE__); // The basic data... _locations = Locations (); // ...and the buffer... _allLocations.clear (); _allLocations.resize (__NUMBEROFMAZEPLACES__); for (int i = 0; i < __NUMBEROFMAZEPLACES__; i++) _allLocations [i] = Locations (); }
ChestEntity::ChestEntity(float x, float y, int chestType, bool isOpen) : CollidingSpriteEntity(ImageManager::getInstance().getImage(IMAGE_CHEST), x, y, 48, 48) { type = ENTITY_CHEST; imagesProLine = 2; this->isOpen = isOpen; this->chestType = chestType; frame = chestType * 2; if (chestType > CHEST_FAIRY) frame = CHEST_FAIRY * 2; frame += (isOpen ? 1 : 0); setMap(game().getCurrentMap(), TILE_WIDTH, TILE_HEIGHT, OFFSET_X, OFFSET_Y); timer = -1.0f; }
void MenuDeathmatchMaps::handlerCheckMap(AG_Event * event){ std::string filename( AG_STRING(1) ); try { TiXmlDocument doc; // nacteni XML souboru TiXmlRootElement(doc, filename, "map", true); if(setMap(filename)) handlerBack(); } catch(int val){ if(val==1) AG_TextError("%s:\n%s", filename.c_str(), "File does not represent Bombic map."); } }
void FloorItem::postInit(Map *const map, int subX, int subY) { setMap(map); const ItemInfo &info = ItemDB::get(mItemId); if (map) { const int maxX = info.getMaxFloorOffsetX(); const int maxY = info.getMaxFloorOffsetY(); if (!serverFeatures->haveExtendedDropsPosition()) { if (subX > maxX) subX = maxX; else if (subX < -maxX) subX = -maxX; if (subY > maxY) subY = maxY; else if (subY < -maxY) subY = -maxY; subX -= 8; subY -= 8; } mHeightPosDiff = map->getHeightOffset(mX, mY) * 16; mPixelX = mX * map->getTileWidth() + subX + mapTileSize / 2; mPixelY = mY * map->getTileHeight() + subY + mapTileSize - mHeightPosDiff; mPos.x = static_cast<float>(mPixelX); mPos.y = static_cast<float>(mPixelY); mYDiff = 31 - mHeightPosDiff; } else { mPixelX = 0; mPixelY = 0; mPos.x = 0; mPos.y = 0; mYDiff = 31; } mCursor = info.getPickupCursor(); setupSpriteDisplay(info.getDisplay(), ForceDisplay_true, 1, info.getDyeIconColorsString(mColor)); }