StackHandler *loadStackRef(Common::SeekableReadStream *stream) { StackHandler *nsh; if (stream->readByte()) { // It's one we've loaded already... nsh = getStackFromLibrary(stream->readUint16BE()); nsh->timesUsed++; } else { // Load the new stack nsh = new StackHandler; if (!checkNew(nsh)) return NULL; nsh->last = NULL; nsh->first = loadStack(stream, &nsh->last); nsh->timesUsed = 1; // Add it to the library of loaded stacks stackLibrary *s = new stackLibrary; if (!checkNew(s)) return NULL; s->stack = nsh; s->next = stackLib; stackLib = s; stackLibTotal++; } return nsh; }
bool ZStackDocReader::readFile(const QString &filePath) { m_filePath = filePath; switch (ZFileType::fileType(filePath.toStdString())) { case ZFileType::SWC_FILE: loadSwc(filePath); break; case ZFileType::LOCSEG_CHAIN_FILE: loadLocsegChain(filePath); break; case ZFileType::SWC_NETWORK_FILE: loadSwcNetwork(filePath); break; case ZFileType::OBJECT_SCAN_FILE: case ZFileType::TIFF_FILE: case ZFileType::V3D_PBD_FILE: case ZFileType::LSM_FILE: case ZFileType::V3D_RAW_FILE: case ZFileType::MC_STACK_RAW_FILE: case ZFileType::DVID_OBJECT_FILE: loadStack(filePath); break; case ZFileType::V3D_APO_FILE: case ZFileType::V3D_MARKER_FILE: case ZFileType::RAVELER_BOOKMARK: loadPuncta(filePath); break; default: return false; break; } return true; }
int Battle::hKeyZ(){ if(processStat == BattleMenu){ switch(battleMenuCurrentPos){ case 0://Attack processStat = MonsterMenu; break; case 1: engine->engineCall(loadStack(svc::loadSkillMenu, 1, _currentChara)); engine->engineCall(loadStack(svc::setStat, Stats::inSkillMenu)); if(varMap["SkillMenuCurPos"].get<unsigned int>() != 0xffffffff){ Skill tmp = (*team)[team->getNameList()[_currentChara]].getSkillList()[varMap["SkillMenuCurPos"].get<unsigned int>()]; if(tmp.geteTarget() != 0){ processStat = PlayerSkill; }else{ processStat = skillMonsterMenu; } } break; case 2: engine->engineCall(loadStack(svc::loadInvMenu, 0)); engine->engineCall(loadStack(svc::setStat, Stats::inInvMenu)); processStat = process::PostPlayer; break; case 3: int p = rand() % 100; if(p - _chance < 0){ engine->engineCall(loadStack(svc::loadPrompt, UTF8_to_WChar("You Successfully Escaped!"), UTF8_to_WChar("System"))); engine->engineCall(loadStack(svc::restoreStat)); }else{ engine->engineCall(loadStack(svc::loadPrompt, UTF8_to_WChar("You Failed to Escape!"), UTF8_to_WChar("System"))); processStat = process::PostPlayer; } break; } }else if(processStat == MonsterMenu){ int atk = (*team)[team->getNameList()[_currentChara]].getAttack(); float rng = (rand() % 6) / 10 + 0.75; int dmg = (-1) * (rng) * (atk + charaAttackBuff[_currentChara]) + _monsters[MonsterMenuCurrentPos].getDefense(); _monsters[MonsterMenuCurrentPos].varHP(dmg); char kk[100]; if(_monsters[MonsterMenuCurrentPos].isDead()){ sprintf(kk, "%s is Dead!", _monsters[MonsterMenuCurrentPos].getName().c_str()); _monsters.erase(_monsters.begin() + MonsterMenuCurrentPos); }else{ sprintf(kk, "%s received %d point of damage!", _monsters[MonsterMenuCurrentPos].getName().c_str(), (-1)*dmg); } engine->engineCall(loadStack(svc::loadPrompt, UTF8_to_WChar(kk), UTF8_to_WChar("System"))); processStat = PostPlayer; }else if(processStat == skillMonsterMenu){ processStat = PlayerSkill; } return 0; }
void Command::operator()(const std::string& args) { mArgs = args; sCommand = *this; if(mOptions & LOAD_STACK) { loadStack(cmdStackLoaded); } else { sCommand.mProc = NULL; mProc(args); } }
QgsEffectStackPropertiesWidget::QgsEffectStackPropertiesWidget( QgsEffectStack *stack, QWidget *parent ) : QgsPanelWidget( parent ) , mStack( stack ) , mPreviewPicture( nullptr ) { // TODO #ifdef Q_OS_MAC //setWindowModality( Qt::WindowModal ); #endif mPresentWidget = nullptr; setupUi( this ); mAddButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.svg" ) ) ); mRemoveButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.svg" ) ) ); mUpButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.svg" ) ) ); mDownButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.svg" ) ) ); mModel = new QStandardItemModel(); // Set the effect mEffectsList->setModel( mModel ); QItemSelectionModel* selModel = mEffectsList->selectionModel(); connect( selModel, SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( effectChanged() ) ); loadStack( stack ); updatePreview(); connect( mUpButton, SIGNAL( clicked() ), this, SLOT( moveEffectUp() ) ); connect( mDownButton, SIGNAL( clicked() ), this, SLOT( moveEffectDown() ) ); connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addEffect() ) ); connect( mRemoveButton, SIGNAL( clicked() ), this, SLOT( removeEffect() ) ); updateUi(); // set first selected effect as active item in the tree int initialRow = 0; for ( int i = 0; i < stack->count(); ++i ) { // list shows effects in opposite order to stack if ( stack->effect( stack->count() - i - 1 )->enabled() ) { initialRow = i; break; } } QModelIndex newIndex = mEffectsList->model()->index( initialRow, 0 ); mEffectsList->setCurrentIndex( newIndex ); setPanelTitle( tr( "Effects Properties" ) ); }
QgsEffectStackPropertiesWidget::QgsEffectStackPropertiesWidget( QgsEffectStack *stack, QWidget *parent ) : QWidget( parent ) , mStack( stack ) , mPreviewPicture( 0 ) { // TODO #ifdef Q_OS_MAC //setWindowModality( Qt::WindowModal ); #endif mPresentWidget = NULL; setupUi( this ); mAddButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.svg" ) ) ); mRemoveButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.svg" ) ) ); mUpButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.svg" ) ) ); mDownButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.svg" ) ) ); mModel = new QStandardItemModel(); // Set the effect mEffectsList->setModel( mModel ); QItemSelectionModel* selModel = mEffectsList->selectionModel(); connect( selModel, SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( effectChanged() ) ); loadStack( stack ); updatePreview(); connect( mUpButton, SIGNAL( clicked() ), this, SLOT( moveEffectUp() ) ); connect( mDownButton, SIGNAL( clicked() ), this, SLOT( moveEffectDown() ) ); connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addEffect() ) ); connect( mRemoveButton, SIGNAL( clicked() ), this, SLOT( removeEffect() ) ); updateUi(); // set effect as active item in the tree QModelIndex newIndex = mEffectsList->model()->index( 0, 0 ); mEffectsList->setCurrentIndex( newIndex ); }
bool Test::test2() { Stack<int> s2; std::vector<int> t2 = {2, 8, 3, 5, 6}; loadStack(s2, t2); s2.popUntil(99); std::vector<int> r2; std::cerr << "Test 2: pop until when value not in stack : "; while (!s2.isEmpty()) { r2.push_back(s2.peek()); s2.pop(); } bool PASS = (r2.size()==0); if (PASS) std::cout << "PASS\n"; else std::cout << "FAILED\n"; return(PASS); }
bool Test::test1() { // test 1 Stack<int> s1; std::vector<int> t1 = {2, 8, 3, 5, 6}; loadStack(s1, t1); s1.popUntil(8); std::vector<int> r1; std::cerr << "Test 1: pop until on a populated stack : "; while (!s1.isEmpty()) { r1.push_back(s1.peek()); s1.pop(); } bool PASS = (r1.size()==2) && (r1[0]==8) && (r1[1]==2); if (PASS) std::cout << "PASS\n"; else std::cout << "FAILED\n"; return(PASS); }
LoadedFunction *loadFunction(Common::SeekableReadStream *stream) { int a; // Reserve memory... LoadedFunction *buildFunc = new LoadedFunction; if (!checkNew(buildFunc)) return NULL; // See what it was called by and load if we need to... buildFunc->originalNumber = stream->readUint16BE(); buildFunc->calledBy = NULL; if (stream->readByte()) { buildFunc->calledBy = loadFunction(stream); if (!buildFunc->calledBy) return NULL; } buildFunc->timeLeft = stream->readUint32LE(); buildFunc->runThisLine = stream->readUint16BE(); buildFunc->freezerLevel = 0; buildFunc->cancelMe = stream->readByte(); buildFunc->returnSomething = stream->readByte(); buildFunc->isSpeech = stream->readByte(); loadVariable(&(buildFunc->reg), stream); loadFunctionCode(buildFunc); buildFunc->stack = loadStack(stream, NULL); for (a = 0; a < buildFunc->numLocals; a++) { loadVariable(&(buildFunc->localVars[a]), stream); } return buildFunc; }
void QgsEffectStackPropertiesWidget::loadStack() { mModel->clear(); loadStack( mStack ); }
int Battle::hDoEvent(){ if(processStat == prePlayer){ if((*team)[team->getNameList()[_currentChara]].isDead()) processStat = PostPlayer; else processStat = BattleMenu; }else if(processStat == PlayerSkill){ Skill tmp = (*team)[team->getNameList()[_currentChara]].getSkillList()[varMap["SkillMenuCurPos"].get<unsigned int>()]; if(tmp.getfTarget() == 0){ engine->engineCall(loadStack(svc::loadTeamMenu, 1)); engine->engineCall(loadStack(svc::setStat, Stats::inTeamMenu)); if(varMap["TeamMenuCurPos"].get<unsigned int>() == 0xffffffff){ processStat = process::BattleMenu; return -1; } } int p = engine->engineCall(loadStack(svc::useSkill, _currentChara, varMap["SkillMenuCurPos"].get<unsigned int>(), MonsterMenuCurrentPos, varMap["TeamMenuCurPos"].get<unsigned int>())).get<int>(); if(!p){ engine->engineCall(loadStack(svc::loadPrompt, UTF8_to_WChar("Not Enough Mana!"), UTF8_to_WChar("System"))); processStat = BattleMenu; }else{ processStat = PostPlayer; } }else if(processStat == PostPlayer){ if(isMonsterWipeOut()){ processStat = process::PostBattle; }else{ _currentChara++; if(_currentChara >= _memberCount){ engine->engineCall(loadStack(svc::loadPrompt, UTF8_to_WChar("It's Now Monster's Turn"), UTF8_to_WChar("System"))); processStat = process::MonsterTurn; }else{ processStat = process::prePlayer; } } }else if(processStat == MonsterTurn){ for(unsigned int i = 0; i < _monsters.size(); i++){ if(_monsters[i].isDead()) continue; int us = rand() % _monsters[i].getSkillList().size() + 1; if(us == 0){//Normal Attack int target = rand() % _memberCount; float rng = (rand() % 6) / 10 + 0.75; int tardef = (*team)[team->getNameList()[target]].getDefense(); engine->engineCall(loadStack(svc::varHP, target, ((-1) * (rng) * _monsters[i].getAttack() + tardef + charaDefenseBuff[target]))); }else{//Skills Skill tmp = _monsters[i].getSkillList()[us - 1]; if(tmp.getfTarget() == 0){ _monsters[i].varHP(tmp.getfHPv()); _monsters[i].varMP(tmp.getfMPv()); }else if(tmp.getfTarget() == 1){ for(unsigned int m = 0; m < _monsters.size(); m++){ _monsters[m].varHP(tmp.getfHPv()); _monsters[m].varMP(tmp.getfMPv()); } } if(tmp.geteTarget() == 0){ unsigned int target = rand() % _memberCount; engine->engineCall(loadStack(svc::varHP, target, tmp.geteHPv())); engine->engineCall(loadStack(svc::varMP, target, tmp.geteMPv())); }else if(tmp.geteTarget() == 1){ for(unsigned int m = 0; m < _memberCount; m++){ engine->engineCall(loadStack(svc::varHP, m, tmp.geteHPv())); engine->engineCall(loadStack(svc::varMP, m, tmp.geteMPv())); } } } usleep(1000000); } if(engine->engineCall(loadStack(svc::isTeamWipeOut)).get<int>()){ engine->engineCall(loadStack(svc::gameOver)); }else{ engine->engineCall(loadStack(svc::loadPrompt, UTF8_to_WChar("It's Now your Turn"), UTF8_to_WChar("System"))); _currentChara = 0; processStat = process::prePlayer; } }else if(processStat == process::PostBattle){ for(unsigned int i = 0; i < _monstersBak.size(); i++){ for(unsigned int j = 0; j < _memberCount; j++){ engine->engineCall(loadStack(svc::varExp, j, _monstersBak[i].getExp())).get<int>(); } } engine->engineCall(loadStack(svc::restoreStat)); } return 0; }
int Battle::hKeyQ(){ engine->engineCall(loadStack(svc::loadMainMenu)); engine->engineCall(loadStack(svc::setStat, Stats::inMainMenu)); return 0; }
int HelpMenu::hKeyX(){ engine->engineCall(loadStack(svc::restoreStat)); return 0; }