Пример #1
0
int localGame() {
    system("cls");
    char winner = 0;
    TILE board[121];
    memset(&board, 0, sizeof board);
    initBoard(board);
    char currentPlayer = 1;
    TILE t = {0,0,0,0}, g;
    do {
        jumpTo(0,0);
        printf("%s, make a move!\n", currentPlayer==1?"Attacker":"Defender");
        printBoard(board);
        int r;
        t = selectPiece(board, currentPlayer, t);
        if (tileEmpty(t)) return 0;
        printIntense(t);
        g = selectNewPosition(board, t, &r);
        if (tileEmpty(g)) return 0;
        if (r) continue;
        makeMove(t, g, board);
        winner = hasWinner(board, board[getIndex(g)]);
        currentPlayer = currentPlayer % 2 + 1;
        t = g;
    } while (!winner);
    
    // reblit board to capture last move
    jumpTo(0,1);
    printBoard(board);
    return winner;
}
Пример #2
0
/** 
 * writeOutput	-	write the processed result
 *
 */
void VideoProcessor::writeOutput()
{
    cv::Mat input;

    // if no capture device has been set
    if (!isOpened() || !writer.isOpened())
        return;

    // save the current position
    long pos = curPos;
    
    // jump to the first frame
    jumpTo(0);

    while (getNextFrame(input)) {

        // write output sequence
        if (outputFile.length()!=0)
            writeNextFrame(input);
    }

    // set the modify flag to false
    modify = false;

    // release the writer
    writer.release();

    // jump back to the original position
    jumpTo(pos);
}
Пример #3
0
void printErrorString(int errorCode) {
    int oldx = getXPos(), oldy = getYPos();
    jumpTo(0, 15);
    for (int i = 0; i < 79; i++) printf(" "); // clear line
    jumpTo(0, 15);
    switch (errorCode) {
        case 1:
            // note: N/A
            printf("You can't move to the tile you're already on!");
            break;
        case 2:
            printf("You can only move to tiles directly in line with your current tile.");
            break;
        case 3:
            printf("This tile is already occupied.");
            break;
        case 4:
            printf("Only the king can move to this tile.");
            break;
        case 5:
            printf("The path to this tile is blocked by a different piece.");
            break;
        case 6:
            printf("You must select one of your own pieces.");
            break;
        case 7:
            printf("Abort game? (Y/N)");
            break;
        case 8:
            printf("You are not allowed to select this tile.\n");
    }
    jumpTo(oldx, oldy);
}
Пример #4
0
void Letterbox::printStudy()
{
	pause(true);

	QString filename = QFileDialog::getSaveFileName(this, tr("Choose file to which to save study sheet"), m_filename + "-study");

	if (filename.isEmpty())
		return;

	QFile file(filename);
	 
	if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
	{        
		QMessageBox::critical(this, tr("Error Writing File - Quackle Letterbox"), tr("Could not open %1 for writing.").arg(filename));        
		return;    
	}

	bool wasModified = m_modified;
	int previousNumber = m_numberIterator;
	statusBar()->showMessage(tr("Generating study sheet..."));
	jumpTo(m_clueResults.size() - 1);

	QTextStream stream(&file);
	stream << generateStudySheet(m_answers.begin(), m_answers.end()) << "\n";

	file.close();

	jumpTo(previousNumber);
	setModified(wasModified);

	statusBar()->showMessage(tr("%1 written.").arg(filename));
}
Пример #5
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    left_panel=new FilePanel(ui->centralWidget);
    right_panel=new FilePanel(ui->centralWidget);
    currentPanel=left_panel;
    menu=new QMenu;

    ui->gridLayout->addWidget(left_panel->layoutWidget,1,0,1,1);
    ui->gridLayout->addWidget(right_panel->layoutWidget,1,1,1,1);


    connect(left_panel,SIGNAL(tryOpen(QModelIndex)),this,SLOT(open(QModelIndex)));
    connect(left_panel,SIGNAL(tryJump(QString)),this,SLOT(jumpTo(QString)));
    connect(left_panel,SIGNAL(panelActivated(FilePanel*)),this,SLOT(setCurrentPanel(FilePanel*)));
    connect(left_panel,SIGNAL(tryDelete()),this,SLOT(start_del()));

    connect(right_panel,SIGNAL(tryOpen(QModelIndex)),this,SLOT(open(QModelIndex)));
    connect(right_panel,SIGNAL(tryJump(QString)),this,SLOT(jumpTo(QString)));
    connect(right_panel,SIGNAL(panelActivated(FilePanel*)),this,SLOT(setCurrentPanel(FilePanel*)));
    connect(right_panel,SIGNAL(tryDelete()),this,SLOT(start_del()));

    initDrives();

    connect(right_panel,SIGNAL(tryMount(QString)),this,SLOT(mountDrive(QString)));
    connect(left_panel,SIGNAL(tryMount(QString)),this,SLOT(mountDrive(QString)));

    left_panel->setModel(new fileModel);
    right_panel->setModel(new fileModel);
    setup_contextMenu();
    left_panel->setPopupMenu(menu);
    right_panel->setPopupMenu(menu);

    setup_toolbar();
    setup_favoritiesPath();

    left_panel->loadSettings("Left");
    right_panel->loadSettings("Right");

    connect(left_panel,SIGNAL(tryDrop(QList<QUrl>,QString,Qt::DropAction)),this,SLOT(drop(QList<QUrl>,QString,Qt::DropAction)));
    connect(right_panel,SIGNAL(tryDrop(QList<QUrl>,QString,Qt::DropAction)),this,SLOT(drop(QList<QUrl>,QString,Qt::DropAction)));

    connect(left_panel,SIGNAL(moveChecked(bool)),right_panel,SLOT(checkMove(bool)));
    connect(right_panel,SIGNAL(moveChecked(bool)),left_panel,SLOT(checkMove(bool)));

    QFileSystemWatcher *watcher=new QFileSystemWatcher;
    watcher->addPath("/dev/disk/by-uuid");
    connect(watcher,SIGNAL(directoryChanged(QString)),this,SLOT(drivesChanged(QString)));

}
Пример #6
0
int csFindCommon(commands_e command, bool error)
{
	char	word[100] = {0};
	int		refs = 0;

	if (!projectOpened) {
		::MessageBox(NULL, TEXT("Project Not opened"), TEXT("SourceNav"), MB_OK);
		return refs;
	}

	getCurrentWord(word, sizeof(word));
	exec_command(command, word);
	refs = buildCrossRefs();
	if (refs) {

		if (refs > 1) {
			pushHistory();
			csOutputDiag(refs);
		}
		else  {
			/* Jump to file and line number */
			pushHistory();
			jumpTo (refInfo[0].filename, refInfo[0].lineno - 1);
		}
	}
	else {
		if (error)
			::MessageBox(NULL, TEXT("No references found"), TEXT("SourceNav"), MB_OK);
	}
	//gCommand = command_none;
	return refs;
}
Пример #7
0
void csPrevious()
{
	if (pop_history (&his)) {
		jumpTo(his.filename, his.lineno);
	}
	return;
}
Пример #8
0
void csGooo (TCHAR *text)
{
	int		refs = 0;
	char word[100];

	if (!projectOpened) {
		::MessageBox(NULL, TEXT("Project Not opened"), TEXT("SourceNav"), MB_OK);
	}

	wcstombs(word, text, wcslen(text) + 1);
	exec_command(gCommand, word);
	refs = buildCrossRefs();
	if (refs) {

		if (refs > 1) {
			pushHistory();
			csOutputDiag(refs);
		}
		else  {
			/* Jump to file and line number */
			pushHistory();
			jumpTo (refInfo[0].filename, refInfo[0].lineno - 1);
		}
	}
	else {
		::MessageBox(NULL, TEXT("No references found"), TEXT("SourceNav"), MB_OK);
	}
	//gCommand = command_none;
	gCommand = command_none;
}
void cMapCamera::centerAndJumpViewPortToCell(int cell) {
	// fix any boundaries
	if (cell < 0) cell = 0;
	if (cell >= MAX_CELLS) cell = (MAX_CELLS-1);

	int cellX = cellCalculator->getX(cell);
	int cellY = cellCalculator->getY(cell);

	// determine the half of our screen
	int width = mapCamera->getViewportWidth();
	int height = mapCamera->getViewportHeight();

	// Half ...
	int iHalfX = width/2;
	int iHalfY = height/2;

	// determine the new X and Y position
	int newViewPortX = cellX - iHalfX;
	int newViewPortY = cellY - iHalfY;

	// now make sure the bottom right does not reach outside the map borders.
	// first jump to the new coordinates
	jumpTo(newViewPortX, newViewPortY);

	int diffX = getEndX() - (game.map_width - 1);
	int diffY = getEndY() - (game.map_height - 1);

	// when > 0 then it has overlapped, and should be substracted to the original X
	if (diffX > 0) {
		newViewPortX -= diffX;
	}

	if (diffY > 0) {
		newViewPortY -= diffY;
	}

	if (newViewPortX < 1) {
		newViewPortX = 1;
	}

	if (newViewPortY < 1) {
		newViewPortY = 1;
	}

	// now the final 'jump' to the correct positions
	jumpTo(newViewPortX, newViewPortY);
}
Пример #10
0
/** 
 * revertVideo	-	revert playing
 *
 */
void VideoProcessor::revertVideo()
{
    // pause the video
    jumpTo(0);    
    curPos = 0;
    pauseIt();
    emit updateProgressBar();
}
Пример #11
0
  void SICGenHelper::memOop_prologue(mapOop receiverMapOop,
                                     char* missHandler) {
    //   andcc rr, Mem_Tag, g0
    //   bne,a _check_receiver_map
    //   load rr, map_offset - Mem_Tag, t3
    // _miss:
    //   sethi missHandler, t3
    //   jmpl t3, missHandler, g0
    // _check_receiver_map:
    //   <loadImmediateOop receiver_map, t4>
    //   subcc t3, t4, g0
    //   bne  _miss
    //   nop
    // _cache_hit:

    if (FastMapTest) {
      a->LoadI(LReceiverReg, map_offset(), Temp1);   // load map
      loadImmediateOop(receiverMapOop, Temp2);   // load customization map
      a->SubCCR(Temp1, Temp2, G0);      // compare against actual map
      Label* ok = a->BeqForward(false); // jump to body of nmethod
      jumpTo(missHandler, Temp2, G0);
      if (SICCountTypeTests) {
        a->endTypeTest();
      } else {
        a->Nop();       // must be here in case next instr is a save
      }
      ok->define();
    } else {
      Label* checkMap = NULL;
      a->AndCCI(LReceiverReg, Mem_Tag, G0);  // test for mem tag
      checkMap = a->BneForward(true);       // branch if receiver is a mem oop
      a->LoadI(LReceiverReg, map_offset(), Temp1);   // load map in delay slot
      DefinedLabel miss(a->printing);
      jumpTo(missHandler, Temp2, G0);
      if (checkMap) checkMap->define();
      loadImmediateOop(receiverMapOop, Temp2);   // load customization map
      a->SubCCR(Temp1, Temp2, G0);      // compare against actual map
      a->Bne(&miss, false);             // jump to miss if no match
      if (SICCountTypeTests) {
        a->endTypeTest();
      } else {
        a->Nop();       // must be here in case next instr is a save
      }
    }
  }
Пример #12
0
void PlaybackController::prevSequence()
{
	if(!m_indexloader) {
		qWarning("prevSequence: index not loaded!");
		return;
	}
	const Index &index = m_indexloader->index();
	jumpTo(index.entry(index.findPreviousStop(m_reader->currentIndex())).index);
}
Пример #13
0
void Map::Impl::onStyleLoaded() {
    if (!cameraMutated) {
        jumpTo(style->getDefaultCamera());
    }
    if (LayerManager::annotationsEnabled) {
        annotationManager.onStyleLoaded();
    }
    observer.onDidFinishLoadingStyle();
}
Пример #14
0
void PlaybackController::nextMarker()
{
	if(!m_indexloader)
		return;
	recording::MarkerEntry e = m_indexloader->index().nextMarker(qMax(0, m_reader->currentIndex()));
	if(e.pos>0) {
		jumpTo(e.pos);
	}
}
Пример #15
0
  void CodeGen::memOop_prologue(pc_t missHandler) {
    //   andcc rr, Mem_Tag, g0
    //   bne,a _check_receiver_map
    //   load rr, map_offset - Mem_Tag, t3
    // _miss:
    //   sethi missHandler, t3
    //   jmpl t3, missHandler, g0
    // _check_receiver_map:
    //   <loadOop receiver_map, t4>
    //   subcc t3, t4, g0
    //   bne  _miss
    //   nop
    // _cache_hit:

    if (FastMapTest) {
      a.LoadI(ReceiverReg, map_offset(), Temp1);  // load map
      loadOop(Temp2, L->receiverMapOop());        // load customization map
      a.SubCCR(Temp1, Temp2, G0);                 // compare against actual map
      Label* ok = a.BeqForward(false);            // jump to body of nmethod
      jumpTo(missHandler, Temp2, G0);
      if (SICCountTypeTests) {
        a.endTypeTest();
      } else {
        a.Nop();
      }
      ok->define();
    } else {
      a.AndCCI(ReceiverReg, Mem_Tag, G0);         // test for mem tag
      Label* checkMap = a.BneForward(true);       // branch if rcvr is mem oop
      a.LoadI(ReceiverReg, map_offset(), Temp1);  // load map in delay slot
      DefinedLabel miss(a.printing);
      jumpTo(missHandler, Temp2, G0);
      checkMap->define();
      loadOop(Temp2, L->receiverMapOop());      // load customized map
      a.SubCCR(Temp1, Temp2, G0);               // compare against actual map
      a.Bne(&miss, false);                      // jump to miss if no match
      if (SICCountTypeTests) {
        a.endTypeTest();
      } else {
        a.Nop();
      }
    }
  }
Пример #16
0
/** 
 * prevFrame	-	display the prev frame of the sequence
 *
 */
void VideoProcessor::prevFrame()
{
    if(isStop())
        pauseIt();
    if (curPos >= 0){
        curPos -= 1;
        jumpTo(curPos);
    }
    emit updateProgressBar();
}
Пример #17
0
/** 
 * nextFrame	-	display the next frame of the sequence
 *
 */
void VideoProcessor::nextFrame()
{
    if(isStop())
        pauseIt();
    curPos += 1;
    if (curPos <= length){
        curPos += 1;
        jumpTo(curPos);
    }
    emit updateProgressBar();
}
Пример #18
0
void setup(void) {
    DDRA = 0x07;
    DDRC = 0x3F;
    fading = 0;
    jumpTo(0,0,0,0,0,0,0,0,0);
    PORTA = (PORTA&0xF8)|0x03;
    PORTC = (PORTC&0xC0)|0x3f;
    timer = 20000;
    TCCR0A = 0x02;

}
Пример #19
0
void Functions::actionJumpToLocation(Aurora::NWScript::FunctionContext &ctx) {
	NWN::Object   *object = NWN::ObjectContainer::toObject(ctx.getCaller());
	NWN::Location *moveTo = NWN::ObjectContainer::toLocation(ctx.getParams()[0].getEngineType());

	if (!object || !moveTo)
		return;

	float x, y, z;
	moveTo->getPosition(x, y, z);

	jumpTo(object, moveTo->getArea(), x, y, z);
}
Пример #20
0
void PlaybackController::jumpToMarker(int index)
{
	if(!m_indexloader)
		return;

	const QVector<MarkerEntry> &markers = m_indexloader->index().markers();
	if(index<0 || index >= markers.size()) {
		qWarning("markers()[%d] does not exist", index);
		return;
	}

	jumpTo(markers.at(index).pos);
}
Пример #21
0
void Functions::actionMoveToObject(Aurora::NWScript::FunctionContext &ctx) {
	NWN::Object *object = NWN::ObjectContainer::toObject(ctx.getCaller());
	NWN::Object *moveTo = NWN::ObjectContainer::toObject(getParamObject(ctx, 0));

	if (!object || !moveTo)
		return;

	float x, y, z;
	moveTo->getPosition(x, y, z);

	jumpTo(object, moveTo->getArea(), x, y, z);

	unimplementedFunction(ctx);
}
Пример #22
0
void Letterbox::increment()
{
	jumpTo(m_numberIterator + 1);

    if (m_numberIterator >= m_clueResults.size())
    { 
		updateViews();
        listFinished();
		m_timer->stop();
        return;
    }

    prepareQuiz();
}   
Пример #23
0
void Letterbox::jumpTo()
{
	pause(true);

	bool ok;
	int index = QInputDialog::getInteger(this, tr("Jump to word - Quackle Letterbox"), tr("Index to which to jump:"), m_numberIterator + 1, 1, m_clueResults.count(), 1, &ok);
	if (ok)
	{
		jumpTo(index);
	}

	prepareQuiz();
	pause(true);
}
Пример #24
0
QVariant Jump::getProperty(P_ID propertyId) const
      {
      switch (propertyId) {
            case P_ID::JUMP_TO:
                  return jumpTo();
            case P_ID::PLAY_UNTIL:
                  return playUntil();
            case P_ID::CONTINUE_AT:
                  return continueAt();
            default:
                  break;
            }
      return Text::getProperty(propertyId);
      }
Пример #25
0
bool appl::TextPluginCtags::onReceiveShortCut(appl::TextViewer& _textDrawer,
                                              const std::string& _shortCutName) {
	if (isEnable() == false) {
		return false;
	}
	if (_shortCutName == "appl::TextPluginCtags::OpenCtagsFile") {
		APPL_INFO("Request opening ctag file");
		ememory::SharedPtr<ewol::widget::FileChooser> tmpWidget = ewol::widget::FileChooser::create();
		if (tmpWidget == nullptr) {
			APPL_ERROR("Can not allocate widget  == > display might be in error");
			return true;
		}
		tmpWidget->propertyLabelTitle.set("Open Exuberant Ctags file");
		tmpWidget->propertyLabelValidate.set("Open");
		// try to get the current folder :
		std::string path = _textDrawer.getBufferPath();
		APPL_ERROR("get path : '" << path << "'");
		if (path != "") {
			tmpWidget->propertyPath.set(path);
		}
		ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget);
		tmpWidget->signalValidate.connect(sharedFromThis(), &appl::TextPluginCtags::onCallbackOpenCtagsOpenFileReturn);
		return true;
	} else if (_shortCutName == "appl::TextPluginCtags::JumpDestination") {
		if (_textDrawer.hasBuffer() == false) {
			return false;
		}
		std::string textToSearch;
		if (_textDrawer.hasTextSelected() == true) {
			_textDrawer.copy(textToSearch, _textDrawer.selectStart(), _textDrawer.selectStop() );
		} else {
			appl::Buffer::Iterator _beginPos;
			appl::Buffer::Iterator _endPos;
			if (_textDrawer.getPosAround(_textDrawer.cursor(), _beginPos, _endPos) == false) {
				APPL_WARNING("Can not get data around...");
				return true;
			}
			_textDrawer.copy(textToSearch, _beginPos, _endPos);
		}
		jumpTo(textToSearch);
		return true;
	} else if (_shortCutName == "appl::TextPluginCtags::JumpBack") {
		if (_textDrawer.hasBuffer() == false) {
			return false;
		}
		return true;
	}
	return false;
}
Пример #26
0
void Letterbox::print()
{
	pause(true);

	QString filename = QFileDialog::getSaveFileName(this, tr("Choose HTML file to which to save pretty word list"), m_filename + ".html", "*.html");

	if (filename.isEmpty())
		return;

	QFile file(filename);
	 
	if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
	{        
		QMessageBox::critical(this, tr("Error Writing File - Quackle Letterbox"), tr("Could not open %1 for writing.").arg(filename));        
		return;    
	}

	HTMLRepresentation printer;

	bool wasModified = m_modified;
	int previousNumber = m_numberIterator;
	statusBar()->showMessage(tr("Generating HTML..."));
	jumpTo(m_clueResults.size() - 1);

	printer.setWords(m_answers.begin(), m_answers.end());

	jumpTo(previousNumber);
	setModified(wasModified);

	QTextStream stream(&file);
	stream << printer.html() << "\n";

	file.close();

	statusBar()->showMessage(tr("%1 written.").arg(filename));
}
Пример #27
0
void Functions::actionJumpToObject(Aurora::NWScript::FunctionContext &ctx) {
	// TODO: walkStraightLineToPoint
	// bool walkStraightLineToPoint = ctx.getParams()[1].getInt() != 0;

	Jade::Object *object = Jade::ObjectContainer::toObject(ctx.getCaller());
	Jade::Object *moveTo = Jade::ObjectContainer::toObject(getParamObject(ctx, 0));

	if (!object || !moveTo)
		return;

	float x, y, z;
	moveTo->getPosition(x, y, z);

	jumpTo(object, moveTo->getArea(), x, y, z);
}
Пример #28
0
QVariant Jump::getProperty(Pid propertyId) const
      {
      switch (propertyId) {
            case Pid::JUMP_TO:
                  return jumpTo();
            case Pid::PLAY_UNTIL:
                  return playUntil();
            case Pid::CONTINUE_AT:
                  return continueAt();
            case Pid::PLAY_REPEATS:
                  return playRepeats();
            default:
                  break;
            }
      return TextBase::getProperty(propertyId);
      }
Пример #29
0
TILE selectTile(TILE board[], TILE last) {
    int cmd;
    int x = last.x, y = last.y;
    do {
        jumpTo(xsp(x), ysp(y));
        cmd = getch();
        switch (cmd) {
            case 'w':
                y -= y > 0 ? 1 : -10;
                break;
            case 's':
                y += y < 10 ? 1 : -10;
                break;
            case 'a':
                x -= x > 0 ? 1 : -10;
                break;
            case 'd':
                x += x < 10 ? 1 : -10;
                break;
            case 224: // arrow key may have been pressed
                switch (getch()) {
                    case UPKEYCODE:
                        y -= y > 0 ? 1 : -10;
                        break;
                    case DOWNKEYCODE:
                        y += y < 10 ? 1 : -10;
                        break;
                    case LEFTKEYCODE:
                        x -= x > 0 ? 1 : -10;
                        break;
                    case RIGHTKEYCODE:
                        x += x < 10 ? 1 : -10;
                        break;
                }
                break;
            case 27: // escape
                printErrorString(7); // Abort game? (Y/N)
                if (getYesNo()) {
                    memset(&last, 0, sizeof last);
                    return last;
                }
                printErrorString(0); // clear "Abort game?"-prompt
                break;
        }
    } while (! (cmd == 13 || cmd == ' ')); // return key or space can be used to select tile
    return board[y*11+x];
}
Пример #30
0
 void SICGenHelper::checkOop(Label& general, oop what, Location reg) {
   // test for inline cache hit (selector, delegatee)
   assert(Temp1 != PerformSelectorLoc && Temp1 != PerformDelegateeLoc,
          "wrong register setup");
   loadImmediateOop(what, Temp1);              // load hard-wired value
   a->SubCCR(reg, Temp1, G0);                  // compare against actual value
   if (general.isDefined()) {
     a->Bne(&general, false);                  // reuse miss handler
     a->Nop();
   } else {
     Label* hit = a->BeqForward(false);
     general.define();
     jumpTo(Memory->code->trapdoors->SendMessage_stub_td(), Temp1, G0);
     a->Nop();
     hit->define();
   }
 }