Exemplo n.º 1
0
void GLESettings::writeAll()
{
	// Store the application settings
	settingStore->setValue("application/position", position());
	settingStore->setValue("application/size", size());
	settingStore->setValue("application/mainstate", mainWindowState());
	settingStore->setValue("application/drawingsize", drawingAreaSize());
	settingStore->setValue("application/storeSize", storeSize());
	settingStore->setValue("application/storeDirectory", storeDirectory());
	settingStore->setValue("application/saveOnPreview", saveOnPreview());
	settingStore->setValue("application/autoScaleOnOpen", autoScaleOnOpen());
	settingStore->setValue("application/libGSLocation", getLibGSLocation());
	settingStore->setValue("application/editorLocation", editorLocation());
	settingStore->setValue("application/resolution", dpi());
	settingStore->setValue("application/monitorOpenFile", monitorOpenFile());
	settingStore->setValue("application/monitorAutoReload", monitorAutoReloadFile());
	settingStore->setValue("application/askAboutKeepingObjects", askAboutObjects());
	settingStore->setValue("application/splitterSizes", splitterPosition());
	settingStore->setValue("application/consoleAutoShowSize", getConsoleWindowAutoShowSize());
	settingStore->setValue("application/emulateGLEVersion", getEmulateGLEVersion());
	settingStore->setValue("application/exportFormat", getExportFormat());
	settingStore->setValue("application/exportPageSize", getExportPageSize());
	settingStore->setValue("application/previewPageSize", getPreviewPageSize());
	settingStore->setValue("application/openExportedFigure", isOpenExportedFigure());
	settingStore->setValue("application/exportGrayScale", isExportGrayScale());
	settingStore->setValue("application/exportTransparent", isExportTransparent());
	settingStore->setValue("application/exportBitmapResolution", getExportBitmapResolution());
	settingStore->setValue("application/exportVectorResolution", getExportVectorResolution());
	settingStore->setValue("application/renderUsingCairo", isRenderUsingCairo());

	if (storeDirectory())
		settingStore->setValue("application/workingDirectory", pwd());

	// Store the server settings
	settingStore->setValue("server/portNumber", port());
	settingStore->setValue("server/autoStart", autoStartServer());

	// Store the drawing settings
	settingStore->setValue("drawing/gridX", grid().x());
	settingStore->setValue("drawing/gridY", grid().y());
	settingStore->setValue("drawing/equalGrid", equalGrid());

	settingStore->setValue("drawing/polarSnapStartAngle", polarSnapStartAngle());
	settingStore->setValue("drawing/polarSnapIncAngle", polarSnapIncAngle());
	settingStore->setValue("drawing/osnapOnStart", osnapOnStart());
	settingStore->setValue("drawing/orthoSnapOnStart", orthoSnapOnStart());
	settingStore->setValue("drawing/polarSnapOnStart", polarSnapOnStart());
	settingStore->setValue("drawing/polarTrackOnStart", polarSnapOnStart());
	settingStore->setValue("drawing/gridSnapOnStart", gridSnapOnStart());
}
Exemplo n.º 2
0
void display() {
/*
	This function is used to display the content on to the screen...
	This is not important for the participant... He can skip it
*/
	int gridDup[6][7],moveDup=move,endGameFlagDup,rowNum;
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	drawGrid(grid);
	if(animate) {
		drawPiece(result,displacement,move);
		if(stopAnimate(grid,result,displacement)) {
			animate=0;
			if(!errorFlag) {
				rowNum=updateGrid(move,grid,result);			//	update the grid implying the move has been made
				drawGrid(grid);
				if(checkWinOrLose(grid,result,rowNum)) {		//	check for win condition
					win=move;					//	win will contain which bot has won
					endGameFlag=1;
				}
				else if(checkDraw(grid)) {				//	check for draw condition
					win=0;						//	win=0 implies draw
					endGameFlag=1;
				}
				move*=-1;						//	toggle between plaper 1 and player 2
			}
		}
	}
	if(errorFlag)									//	If error occurs
		text(displayStr,-1.5,-1.8,font3);
	if(endGameFlag) {								//	If game ends
		if(win>0)				//	player 1 wins
			strcpy(displayStr,"Bot 1 wins!!!");
		else if(win<0)				//	player 2 wins
			strcpy(displayStr,"Bot 2 wins!!!");
		else					//	draw
			strcpy(displayStr,"Game drawn!!!");
		text(displayStr,-1.5,-1.8,font3);
		printf("\n\n\t%s\n\n\t\tgrid content : \n\n",displayStr);
		displayStatus(grid);
	}
	glFlush();
	glutSwapBuffers();
	if(animate)
		displacement+=0.005;
	if(!endGameFlag && !errorFlag && !animate) {
		copyGrid(grid,gridDup);
		moveDup=move;
		endGameFlagDup=endGameFlag;
		if(move>0)
			result=bot1(grid,move);
		else
			result=bot2(grid,move);
		if(!(equalGrid(grid,gridDup) && move==moveDup && endGameFlagDup==endGameFlag)) {	//	grid() and move variables should not be changed
			sprintf(displayStr,"Bot %d error : Grid or move is modified!!!",move);
			errorFlag=1;
		}
		checkForErrors(result,move,grid);			//	errors like result should be within the 0 to 6 range, etc...
		animate=1;
		displacement=0;
	}
}