Пример #1
0
void moveup(int frame[][4])
{
    int i = 0;
    int j = 0;
    int k = 0;

    for (i = 0; i < FRAME_SIZE; i++) {        
        for (j = 0; j < FRAME_SIZE; j++) {
            if (frame[j][i] == 0)
            {
                for(; j < FRAME_SIZE - 1; j++)
                {
                    frame[j][i] = frame[j+1][i];
                }
                frame[j][i] = 0;
                j = 0;
            }
        }
    }
    printFrame(frame);
    for (i = 0; i < FRAME_SIZE; i++) {
        
        for (j = 0; j < FRAME_SIZE; j++) {
            if (frame[i][j] == frame[i][j + 1]) {
                frame[i][j] += frame[i][j + 1];
                for (k = j + 1; k < FRAME_SIZE - 1; k++) {
                    frame[i][k] = frame[i][k+1];
                }
            }
        }
    }
    printFrame(frame);
    return ;
}
Пример #2
0
//--------------------------------------------------------------
void gamuzaMain::keyReleased(int key){

	bool alt = gamuzaKmap.isAltDown();

	// fullscreen toggle
	if(alt && (key == 'f' || key == 'F')){
		gamuzaFullscreen();
	}

	// LIVE CODING
	if(alt && (key == 'j' || key == 'J')){
		liveCodingMode = !liveCodingMode;
	}

	// show/hide script code
	if(alt && (key == 'w' || key == 'W')){
		viewCode = !viewCode;
	}

	// open file dialog
	if(alt && (key == 'd' || key == 'D')){
		openFileDialog();
	}

	// save frame
	if(alt && (key == 'o' || key == 'O')){
		saveFrame();
	}

	// print frame
	if(alt && (key == 'p' || key == 'P')){
		printFrame();
	}

}
Пример #3
0
Файл: io.cpp Проект: kodda/24h
uint16_t IODevice::receiveFrame()
{
  _input_received_frame_is_available = false;
  _input_name=(_input_received_frame >> 2) & 0x07f;
  _input_state=_input_received_frame & 0x03;
  Serial.print("RECV frame: ");
  printFrame(_input_received_frame);
}
Пример #4
0
void CDebugHelper::printBacktrace(lua_State* pState)
{
    int depth = getStackDepth(pState);
    for (int i = 0; i < depth; ++i)
    {
        printFrame(pState, i);
    }
}
Пример #5
0
Файл: io.cpp Проект: kodda/24h
void IODevice::sendFrame(const byte address, const byte data)
{
  while(_output_state!=IDLE) {}
  _output_frame = (1 << 9) | ((uint16_t)address << 2) | ((uint16_t)data & 0x03);
  Serial.print("SENT frame: ");
  printFrame(_output_frame); 
  _output_currentBit = 9;
  _output_state = SENDING;
}
Пример #6
0
void print_filler(void)
{
	int width;
	int version = 7;
	unsigned char *frame;

	width = QRspec_getWidth(version);
	frame = FrameFiller_test(version);
	if(frame == NULL) abort();

	printFrame(width, frame);
	free(frame);
}
Пример #7
0
void print_fillerMQR(void)
{
	int width;
	int version = 3;
	unsigned char *frame;

	for(version = 1; version <= MQRSPEC_VERSION_MAX; version++) {
		width = MQRspec_getWidth(version);
		frame = FrameFiller_testMQR(version);
		if(frame == NULL) abort();

		printFrame(width, frame);
	}
}
Пример #8
0
void camping(void)
{
	char i, encre, a;
	char *ptr;
	while(1) {
		text();cls();
		ptr = (char*)0x26a; *ptr = *ptr & 254; // Vire le curseur 
		ink(eencre[ville-1]);
		printFrame(15);
		printTitle(8,2, A_BGRED, "<  ++ CAMPEMENT ++  >", 21);
		printAtXY(9,6, "1. Inspecter un heros");
		printAtXY(9,8, "2. Visualiser l'equipe");
		if (ca>20 && ca<29)
			printAtXY(9,10, "3. Ouvrir un coffre");
		printAtXY(9,12,"4. Se reposer");
		printAtXY(13,16,"5. Lever le camp");
		// affichage équipe
		printTeam();
		a = get();
		switch(a) {
			case '1':
				inspect();
				break;
			case '2':
				printTeamFull();
				break;
			case '3':
				if (ca>20 && ca<29)
					chest();
				break;
			case '4':
				sleep();
				break;
			case '5':
				cls();
				printAtXY(8,10, "Bon voyage !");
				wait(150);
				return;
				break;
			default:
				ping();
				break;	
		}
		//attribAtXY(3,0,a);
	}
	
}
void TestPlatformConfigManager()
{
	HwaPlatformConfigManager& mgr = HwaPlatformConfigManager::getManager();
	mgr.setFile("../config/framework-config.xml");
	printf("view path=%s\n", mgr.getViewConfigPath().c_str());
	printf("protocal path=%s\n", mgr.getProtocalConfigPath().c_str());
	mgr.getProjectsInfor();
	mgr.getProjectCardInfors("simulation");
	mgr.getProjectCardInfors("test");

	HwaFrameConfigManager& frameMgr = HwaFrameConfigManager::getManager();
	FrameInfor frameInfor = frameMgr.getFrameInfor("00000011111");
	printFrame(frameInfor);

	HwaString information = mgr.getHomePageDescription();
	printf("page infor=%s\n", information.c_str());
}
Пример #10
0
int main(int argc, const char * argv[])
{
    char c;
    int pos;
    int pre[FRAME_SIZE][FRAME_SIZE] = {0};
    
    /* initial data */
    //srand((int)timer(0));
    pos = rand() % FRAME_ALL;
    pre[pos/FRAME_SIZE][pos%FRAME_SIZE] = generateNum();
    
    do
    {
        printFrame(pre);
        c = getchar();
        if (c == 'w' ) {
	    printf("%c\r\n", c);
            moveup(pre);
            update(pre, UP);
        }
        else if (c == 'a') {
            moveleft(pre);
            update(pre, LEFT);
        }
        else if (c == 's') {
            movedown(pre);
            update(pre, DOWN);
        }else if (c == 'd') {
            moveright(pre);
            update(pre, RIGHT);
        }else if (c == '\n'){
	    /* do nothing */
	}else {
	    printf("%c\r\n", c);
            printf("error character\r\n");
        }
    } while (c != 'q');
        
    // insert code here...
    printf("Hello, World!\n");
    return 0;
}
Пример #11
0
int main(int argc, char *argv[]) {

  static int selret;

  unsigned int recLen;
  static char* p;
  static char filebuffer[FILESIZE];
  static char directemp[BUFSIZE];
  static char filename[BUFSIZE];
  static struct timeval time;

  static fd_set readFDS;
  static frame frameArray[MAXSEQNUM];
  static int LB = 0, RB = 0; // static
  static char ackBuffer[100];
  static ack recvAck;
  static timeStruct timesArray[SWS];
  int lastSeqNum = -1;
  double t, timeout;
  int lastFrameCount = 0;

  //check command line args.
  if(argc < 6) {
    printf("usage : %s <server> <error rate> <random seed> <send_file> <send_log> \n", argv[0]);
    exit(1);
  }

  printf("argv4: %s\n",argv[4]);

  if(strcmp(argv[4],"0")){

    strcpy(directemp,argv[4]);
    p = strtok(directemp,DELM);
      
    while(p != NULL){
      strcpy(filename,p);
      p= strtok(NULL,DELM);
    }
      
    printf("Filename: %s\n",filename);
    fp = fopen(argv[4],"r");
    if(fp == NULL){
      printf("Error opening file: %s\n",strerror(errno));
    }
     
    //strcpy(msgbuffer,filebuffer);
  }

  
  
  printf("error rate : %f\n",atof(argv[2]));
  printf("%s: sending data to '%s' \n", argv[0], argv[1]);
    

  /* Note: you must initialize the network library first before calling
     sendto_().  The arguments are the <errorrate> and <random seed> */
  init_net_lib(atof(argv[2]), atoi(argv[3]));

  /* get server IP address (input must be IP address, not DNS name) */


  //setup socket structs
  /***************************************************/
  remoteServAddr.sin_family = AF_INET;
  remoteServAddr.sin_port = htons(REMOTE_SERVER_PORT);
  inet_pton(AF_INET, argv[1], &remoteServAddr.sin_addr);
  
  cliAddr.sin_family = AF_INET;
  cliAddr.sin_addr.s_addr = htonl(INADDR_ANY);
  cliAddr.sin_port = htons(0);
  /*************************************************/



  /* socket creation */
  if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    printf("Unable to connect socket!\n");
    exit(1);
  }
  int lastFrameSent = 0;
  while(1){
	  bzero(&ackBuffer, sizeof(ackBuffer));
    
	  int moveCount = MoveForward(&LB, &RB, frameArray, MAXSEQNUM);
	  if(lastFrameSent == 0){
		  lastFrameSent = SendNextFrames(moveCount, frameArray, MAXSEQNUM, LB, &fp,
				  	  	  &sock,(struct sockaddr *) &remoteServAddr, timesArray, SWS);
	  }

/*
    if((sendto_(sock,sendFrame, strlen(sendFrame),0, (struct sockaddr *) &remoteServAddr,
		sizeof(remoteServAddr)))< 0 ){
      printf("Error Sending\n");
      perror("sendto()");
      exit(1);
    }*/

	  gettimeofday(&time,NULL);
	  t = (time.tv_sec + (time.tv_usec/1000000.0));


	  timeout = (currentDeadline(timesArray,SWS) + DELAY) - t;
	  printf("Timeout: %f\n", timeout);
	  if(timeout < 0){timeout = 0;}

    selret = ballinselect(sock,&readFDS,timeout,0);

    
    if ((selret != -1) && (selret != 0)){
      
      if(recvfrom(sock, &ackBuffer, sizeof (ackBuffer), 0,(struct sockaddr *) &recAddr, (socklen_t*) &recLen) < 0){
    	  perror("recvfrom()");
    	  exit(1);
      }

      printf("Ack Buffer: %s\n",ackBuffer);

      makeackstruct(ackBuffer, &recvAck);
      if(lastSeqNum != recvAck.seqNum){
    	  frameArray[recvAck.seqNum].ack = 1;
    	  lastSeqNum = recvAck.seqNum;

    	  printf("============================\n");
    	  printf("Received Ack!\n");
    	  printf("Ack SeqNum: %d\n", recvAck.seqNum);
    	  printf("============================\n\n\n");

    	  removefromtimearray(recvAck.seqNum, timesArray,SWS);
      }

    }
    else if (selret == 0) {
      printf("timeout\n");
      bzero(&filebuffer,sizeof(filebuffer));

      int timeoutframe = FindTimeout(timesArray,SWS);



      if(frameArray[timeoutframe].lastFrame == 1){
    	  if(frameArray[timeoutframe].ack == 1){return EXIT_SUCCESS;}
    	  if(lastFrameCount == 10){return EXIT_SUCCESS;}
    	  lastFrameCount ++;
      }

      MakePacket(filebuffer,frameArray[timeoutframe]);

      printf("\nSending Timed out Frame: \n\n");
      printFrame(frameArray[timeoutframe]);

      if((sendto_(sock,filebuffer, strlen(filebuffer),0, (struct sockaddr *) &remoteServAddr,
      		sizeof(remoteServAddr)))< 0 ){
            printf("Error Sending\n");
            perror("sendto()");
            exit(1);
      }

      /*gettimeofday(&time,NULL);
      double t2= time.tv_sec + (time.tv_usec/1000000.0);
      printf("Time Out Time time: %f\n",t2);*/
    } else if (selret < 0) {printf("select() failed\n");}
  }

  fclose(fp);
    
  return EXIT_SUCCESS;
}
Пример #12
0
void money(char p)
{
	char a,i,j;
	char titre[32];
	int somme;
	cls();
	printFrame(18);
	strcpy(titre, " < ");
	strcat(titre, characters[p].nom);
	strcat(titre, " DONNE > ");
	j = strlen(titre);
	a = (31-j)/2 + 4;
	printTitle(a,2, A_BGRED, titre, j);
	// affiche les persos
	for(i=0;i<6;i++) {
		printAtXY(5,4+i, itoa(i+1));
		printAtXY(7,4+i, characters[i].nom);
		printAtXY(19,4+i, itoa(characters[i].ri*10));
	}
	// affiche les richesses du héros sélectionné
	printAtXY(5,13, "Votre Bourse :");
	printAtXY(19,13, itoa(characters[p].ri*10));
	printAtXY(27,13, "Cerfs Ag");
	// demande la somme
	printTitle(4,14, A_BGBLUE, "COMBIEN de C.Ag ?", 17);
	somme = 0;
	while(1) {
		a = get();
		if (a == '\r' || a == '\n')
			break; // sort sur un retour chariot ou lf
		else if (a<'0' || a>'9')
			ping();
		else {
			// schéma de Horner
			somme = somme*10 + (a - '0');
			// si ça fait trop on repasse à 0 en pingant
			if (somme > characters[p].ri*10) {
				ping();
				somme = 0;
				// on efface aussi ce qu'il y avait
				printAtXY(27,14, "        ");
			}
			// on affiche la somme courante
			printAtXY(27,14, itoa(somme));
		}	
	}
	// si la somme n'est pas nulle on demande le destinataire
	if (somme != 0) {
		printTitle(4,16, A_BGBLUE, "ENRICHIR QUEL HEROS ? (0:Aucun)", 31);
		while(1) {
			a = get();
			if (a<'0' || a>'6')
				ping(); // ping si pas correct
			else
				break; // correct : on sort
		}
		i = a - '1';
		if ((i>=0) && (i!=p)) {
			// c'est correct on transfère
			characters[i].ri+=somme/10;
			characters[p].ri-=somme/10;
			ping();
		}
	}
}
Пример #13
0
void items(char p)
{
	char a,i,j, item,o;
	char titre[32];
	printTitle(4,25, A_BGBLUE, "Quel Objet ? (0:aucun) ?", 24);
	while(1) {
		a = get();
		if (a<'0' || a>'6')
			ping(); // ping si pas correct
		else {
			o = a - '1';
			if(o==-1)
				return; // on arrête tout
			item = characters[p].sad[o];
			// IF(IT>21ANDIT<27)OR(IT>33ANDIT<44)THENL=24
			if ((item<=0)||(item>21 && item<27)||(item>33 && item<44)) {
				ping();
				printAtXY(6,25, "       !IMPOSSIBLE!       ");
				wait(250);
				return;
			} else
				break; // correct : on sort
		}
	}
	// ici on a un bon objet
	cls();
	printFrame(18);
	strcpy(titre, " < ");
	strcat(titre, characters[p].nom);
	strcat(titre, " DONNE > ");
	j = strlen(titre);
	a = (31-j)/2 + 4;
	printTitle(a,2, A_BGRED, titre, j);
	strcpy(titre, textesItems[item-1]);
	j = strlen(titre);
	printTitle(5,3, A_BGMAGENTA, titre, j);
	// affiche les persos
	for(i=0;i<6;i++) {
		printAtXY(10,7+i, itoa(i+1));
		printAtXY(12,7+i, characters[i].nom);
	}
	printTitle(4,16, A_BGBLUE, "A QUEL HEROS ? (0:Aucun)", 24);
	while(1) {
		a = get();
		if (a<'0' || a>'6')
			ping(); // ping si pas correct
		else
			break; // correct : on sort
	}
	a = a - '1';
	if ((a>=0) && (a!=p)) {
		// sac à dos destination plein ?
		if (characters[a].sad[5]>0) {
			ping();
			printAtXY(6,25, "       !IMPOSSIBLE!       ");
			wait(250);
			return;
		}
		// c'est correct on transfère
		// on cherche la première place libre
		i=0; while(characters[a].sad[i]>0) i++;
		characters[a].sad[i] = characters[p].sad[o];
		characters[p].sad[o]=0;
		// compacte le sac à dos
		while(o<5) {
			characters[p].sad[o]=characters[p].sad[o+1];
			characters[p].sad[o+1]=0;
			o++;
		}
		ping();
	}
}
Пример #14
0
//--------------------------------------------------------------
void gamuzaMain::keyReleased(int key){

	bool alt = gamuzaKmap.isAltDown();

    //////////////////////////////////////////////////////////
	// LIVE CODING
    if(alt && (key == 'j' || key == 'J')){
        liveCodingMode = !liveCodingMode;
        if(liveCodingMode && isFullscreen){
            scriptScroll.reset(lcPrevX-20,1,20,lcPrevH-1);
        }else if(liveCodingMode && !isFullscreen){
            scriptScroll.reset(lcPrevX-20,1,20,lcPrevH-1);
        }
    }
    // show/hide script code
    if(alt && (key == 'w' || key == 'W')){
        viewCode = !viewCode;
    }
    // LUA
    lua.scriptKeyReleased(key);
    //////////////////////////////////////////////////////////


	// save frame
	if(alt && (key == 'o' || key == 'O')){
		saveFrame();
	}

	// print frame
	if(alt && (key == 'p' || key == 'P')){
		printFrame();
	}

    // switch between mouse/keyboard Mapping points control
    if(alt && (key == 'm' || key == 'M')){
        activateMouseMapping = !activateMouseMapping;
    }

    // TIMELINE
    if(alt && (key == 't' || key == 'T')){
        showTimeline = !showTimeline;
        if(showTimeline){
            timeline.show();
            timeline.enableMouse();
        }else{
            timeline.hide();
            timeline.disableMouse();
        }
    }
    // play/stop the timeline
    if(alt && (key == 'g' || key == 'G')){
        timeline.togglePlay();
    }

    // fullscreen toggle
	if(alt && (key == 'f' || key == 'F')){
		gamuzaFullscreen();
	}

    liveKey = key;

}
Пример #15
0
void spells(char p)
{
	char i,a,j, max;
	char titre[32];
	
	// tests
	/*
	characters[0].ok=2;
	characters[0].et=2;
	characters[1].ok=3;
	characters[1].et=2;
	characters[2].ok=4;
	characters[2].et=2;
	characters[3].ok=3;
	characters[3].et=2;
	characters[4].ni=8;
	*/
	
	cls();
	printFrame(14);
	printTitle(11,2, A_BGRED, " < * SORTS * > ", 15);
	max = characters[p].ni > 8 ? 8 : characters[p].ni; 
	for(i=0;i<max;i++) {
		printAtXY(11,4+i, itoa(i+1));
		printAtXY(14,4+i, sorts[(characters[p].cp-4)*8+i]);
		printAtXY(25,4+i, "(");
		printAtXY(27,4+i, itoa(characters[p].sp[i]));
		printAtXY(30,4+i, ")");
	}
	if (characters[p].cp!=5) {
		printTitle(14,14, A_BGRED, " <ESPACE> ", 10);
		a = get();
	} else { // mestre
		a = 'o';
		while(a == 'o' || a == 'O') {
			printTitle(7,14, A_BGRED, " Un sort de soin (O/N) ? ", 25);
			a = get();
			if (a!='o' && a!='O')
				return;
			printAtXY(6,14, "                               ");
			// affichage équipe
			printTeam();
			printAtXY(8,12, "        LEQUEL  ?      ");
			while(1) {
				a = get();
				if (a<'1' || a>'7' || a=='4' || a=='6') {
					zap(); // zap si pas correct
					printAtXY(6,12, "       !IMPOSSIBLE!       ");
					wait(250);
					printAtXY(8,12, "        LEQUEL  ?      ");
				} else {
					i = a - '1';
					if(i>=characters[p].ni) {
						zap(); // pas du bon niveau
						printAtXY(6,12, "       !IMPOSSIBLE!       ");
						wait(250);
						printAtXY(8,12, "        LEQUEL  ?      ");
					} else
						break; // correct : on sort
				}
			}		
			strcpy(titre, "Incantation de ");
			strcat(titre, sorts[(characters[p].cp-4)*8+i]);
			j = strlen(titre);
			a = (31-j)/2 + 4;
			printAtXY(a,12, titre);
			if(i==4) {
				// soigne tout le monde
				for(i=0;i<6;i++) {
					if (characters[i].ok!=4) {
						characters[i].et=characters[i].pv;
						characters[i].ok=1;
					}
				}
			} else {
				printAtXY(7,16, " SOIGNER QUI ? (0:Aucun) ");
				while(1) {
					a = get();
					if (a<'0' || a>'6')
						ping(); // ping si pas correct
					else
						break; // correct : on sort
				}
				a = a - '1';
				if (a>=0) {
					// soigne a
					// cas impossibles
					if((i==0 && characters[a].ok==4) || 
					   (i==1 && characters[a].ok!=2) ||
					   (i==2 && characters[a].ok!=3) ||
					   (i==6 && characters[a].ok!=4)) {
						zap();
						printAtXY(6,12, "       !IMPOSSIBLE!       ");
						wait(250);
						printAtXY(6,12, "                          ");
					} else {
						// ça marche
						characters[a].et=characters[a].pv;
						if(i!=0) characters[a].ok=1;
					}
				}
				printAtXY(7,16, "                         ");
			}
			printAtXY(7,12, "                         ");
			// affichage équipe
			printTeam();
			a='o';
		}
	}
}
Пример #16
0
int main(void) {
    unsigned char frameHead = 0x7e;
    unsigned char frameTail = 0xac;

    unsigned char cmd = 11;
    unsigned char mode = 1;
    unsigned char ADNumber = 1;
    int originADValue = 0x7e12ac1b;
    int originWeight = 80;
    unsigned char checksum = 0;


    // originADValue -> ADValue
    // 1. 主机序转网络序
    originADValue = htonl(originADValue);
    // 2. 转义特殊字符
    unsigned char *ADValue;
    int ADValueLen = 0;
    ADValueLen = convertValue((unsigned char *)&originADValue, sizeof(int), &ADValue);
    if (ADValueLen < 0) {
        fprintf(stderr, "Error: Convert value error!\n");
        return -1;
    }
    printf(">> ADValueLen:%d\n", ADValueLen); 

    originWeight = htonl(originWeight);
    unsigned char *weight;
    int weightLen = 0;
    weightLen = convertValue((unsigned char *)&originWeight, sizeof(int), &weight);
    if (weightLen < 0) {
        fprintf(stderr, "Error: Convert value error!\n");
        return -1;
    }

    printf(">> weightLen:%d\n", weightLen);
    printf("Convert OK!\n"); 
    
    int frameLen = 1+1+1+1+ADValueLen+weightLen+1+1;
    printf("frameLen:%d\n", frameLen);
    unsigned char *frame = malloc(frameLen);
    if (frame == NULL) {
        perror("malloc()");
        return -1;
    }

    int index = 0;
    frame[index++] = frameHead;
    frame[index++] = cmd;
    frame[index++] = mode;
    frame[index++] = ADNumber;

    printf("** index = %d\n", index);
    memcpy(&frame[index], ADValue, ADValueLen);
    index += ADValueLen;

    printf("** index = %d\n", index);
    memcpy(&frame[index], weight, weightLen);
    index += weightLen;
    
    printf("** index = %d\n", index);
    checksum = getChecksum(frame-1, frameLen-2);

    frame[index++] = checksum;

    frame[index++] = frameTail;

    printf("index: %d\t frame len: %d\n", index, frameLen);

    printFrame(frame, frameLen);

    free(ADValue);
    free(weight);
    return 0;
}
Пример #17
0
void inspect(void)
{
	char a, i, j;
	char titre[32];
	
	printTitle(8,4, A_BGRED, "INSPECTER QUEL HEROS ? ", 23);
	while(1) {
		a = get();
		if (a<'1' || a>'6')
			ping(); // ping si pas correct
		else
			break; // correct : on sort
	}
	cls();
	printFrame(23);
	i = a - '1';
	// construction du nom/titre
	strcpy(titre, " < ");
	strcat(titre, characters[i].nom);
	if(characters[i].mp != 1) {
		strcat(titre, " ");
		strcat(titre, maisons[characters[i].mp-2]);
	}
	strcat(titre, " > ");
	j = strlen(titre);
	a = (31-j)/2 + 4;
	// affichage du titre
	printTitle(a,2, A_BGRED, titre, j);
	// affichage classe, niv, xp
	printAtXY(5,  4, "Carr :");
	printAtXY(11, 4, classe[characters[i].cp-1]);
	printAtXY(22, 4, "Niv:");
	printAtXY(27, 4, itoa(characters[i].ni));
	printAtXY(29, 4, "EXP:");
	printAtXY(33, 4, itoa(characters[i].xp));
	
	// affichage santé, pv
	printAtXY(5,  6, "Sant{:");
	printAtXY(11, 6, etat[characters[i].ok-1]);
	printAtXY(22, 6, "PV :");
	printAtXY(27, 6, itoa(characters[i].et));
	printAtXY(30, 6, "/");
	printAtXY(32, 6, itoa(characters[i].pv));
	// affichage bourse
	printAtXY(5,  8, "Bourse:");
	printAtXY(13, 8, itoa(characters[i].ri*10));
	printAtXY(21, 8, "Cerfs d'Argent");
	
	// affichage de l'équipement porté
	printAtXY(5,  10, "Arme D:");
	if (characters[i].wr != 0)
		printAtXY(13, 10, textesItems[characters[i].wr-1]);

	printAtXY(5,  11, "Arme G:");
	if (characters[i].wl != 0)
		printAtXY(13, 11, textesItems[characters[i].wl-1]);
	
	printAtXY(5,  12, "Animal:");
	if (characters[i].bt != 0)
		printAtXY(13, 12, textesItems[characters[i].bt-1]);

	printAtXY(5,  13, "Armure:");
	if (characters[i].pt != 0)
		printAtXY(13, 13, textesItems[characters[i].pt-1]);
	printAtXY(29, 13, "CA:");
	printAtXY(33, 13, itoa(characters[i].ca));
	
	// affiche les caracs
	printTitle(4,15, A_BGRED, "CC  CT  Fo  Ag  In  FM ", 23);
	printAtXY(7,16, itoa(characters[i].cc));
	printAtXY(11,16, itoa(characters[i].ct));
	printAtXY(15,16, itoa(characters[i].fo));
	printAtXY(19,16, itoa(characters[i].ag));
	printAtXY(23,16, itoa(characters[i].in));
	printAtXY(27,16, itoa(characters[i].fm));
	// affichage du sac à dos
	for(j=0;j<6;j++) {
		printAtXY(5,18+j, itoa(j+1));
		if (characters[i].sad[j]!=0) {
			if (characters[i].sad[j]-1<nbTextes)
			    printAtXY(8,18+j, textesItems[characters[i].sad[j]-1]);
			else
				printAtXY(8,18+j, "objet bugge");
		} else {
			printAtXY(8,18+j, "..............");
		}
	}
	// les morts et les paralysés ne peuvent pas lancer de sorts!
	if (characters[i].cp>3 && characters[i].ok<3)
		printTitle(10,25, A_BGRED, " <ESPACE> : SORTS ", 18);
	else
		printTitle(10,25, A_BGRED, " <ESPACE> : RETOUR", 18);
	printTitle(4,26, A_BGBLUE, " DONNER :  ", 11);
	printTitle(16,26, A_BGRED, " A)rgent O)bjet ? ", 17);
	while(1) {
		a = get();
		if (a=='A') {
			money(i);
			break;
		} else if (a=='O') {
			items(i);
			break;
		} else if (a==' ') {
			if (characters[i].cp>3 && characters[i].ok<3)
				spells(i);
			break;
		} else
			ping();
	}
}
Пример #18
0
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
    m_contextMenuHitResult = page()->mainFrame()->hitTestContent(event->pos());

    if (m_contextMenuHitResult.isContentEditable())
    {
        // Check to see if handled by speller
        if (popupSpellMenu(event))
            return;
    }

    WebWindow *webwin = m_parentTab->webWindow();
    
    KMenu menu(this);

    KAction *sendByMailAction = new KAction(&menu);
    sendByMailAction->setIcon(KIcon("mail-send"));
    connect(sendByMailAction, SIGNAL(triggered(bool)), this, SLOT(sendByMail()));

    // Choose right context
    int resultHit = 0;
    if (m_contextMenuHitResult.linkUrl().isEmpty())
        resultHit = WebView::EmptySelection;
    else
        resultHit = WebView::LinkSelection;

    if (!m_contextMenuHitResult.pixmap().isNull())
        resultHit |= WebView::ImageSelection;

    if (m_contextMenuHitResult.isContentSelected())
        resultHit = WebView::TextSelection;

    // --------------------------------------------------------------------------------
    // Ok, let's start filling up the menu...

    // is content editable? Add PASTE
    if (m_contextMenuHitResult.isContentEditable())
    {
        menu.addAction(pageAction(KWebPage::Paste));
        menu.addSeparator();
    }

    QAction *a;

    // EMPTY PAGE ACTIONS -------------------------------------------------------------
    if (resultHit == WebView::EmptySelection)
    {
        // send by mail: page url
        sendByMailAction->setData(page()->currentFrame()->url());
        sendByMailAction->setText(i18n("Share page URL"));

        // navigation
        QWebHistory *history = page()->history();
        if (history->canGoBack())
        {
            menu.addAction(pageAction(KWebPage::Back));
        }

        if (history->canGoForward())
        {
            menu.addAction(pageAction(KWebPage::Forward));
        }

        menu.addAction(pageAction(KWebPage::Reload));

        menu.addSeparator();

        // Frame
        KActionMenu *frameMenu = new KActionMenu(i18n("Current Frame"), &menu);
        frameMenu->addAction(pageAction(KWebPage::OpenFrameInNewWindow));

        a = new KAction(KIcon("document-print-frame"), i18n("Print Frame"), &menu);
        connect(a, SIGNAL(triggered()), m_parentTab, SLOT(printFrame()));
        frameMenu->addAction(a);

        menu.addAction(frameMenu);

        menu.addSeparator();

        // Page Actions
        menu.addAction(pageAction(KWebPage::SelectAll));

        if (webwin)
            menu.addAction(webwin->actionByName(KStandardAction::name(KStandardAction::Save)));

        if (!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetList())
        {
            a = new KAction(KIcon("kget"), i18n("List All Links"), &menu);
            connect(a, SIGNAL(triggered(bool)), page(), SLOT(downloadAllContentsWithKGet()));
            menu.addAction(a);
        }

        if (webwin)
        {
            menu.addAction(webwin->actionByName("page_source"));
            menu.addAction(webwin->actionByName("web_inspector"));
        }
    }

    // LINK ACTIONS -------------------------------------------------------------------
    if (resultHit & WebView::LinkSelection)
    {
        // send by mail: link url
        sendByMailAction->setData(m_contextMenuHitResult.linkUrl());
        sendByMailAction->setText(i18n("Share link"));

        a = new KAction(KIcon("tab-new"), i18n("Open in New &Tab"), &menu);
        a->setData(m_contextMenuHitResult.linkUrl());
        connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewTab()));
        menu.addAction(a);

        a = new KAction(KIcon("window-new"), i18n("Open in New &Window"), &menu);
        a->setData(m_contextMenuHitResult.linkUrl());
        connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewWindow()));
        menu.addAction(a);

        if (!m_parentTab->isWebApp())
        {
            a = new KAction(KIcon("view-media-artist"), i18n("Open in Private &Window"), &menu);
            a->setData(m_contextMenuHitResult.linkUrl());
            connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInPrivateWindow()));
            menu.addAction(a);
        }
Пример #19
0
/*!
  \brief Paint the plot into a given rectangle.
  Paint the contents of a QwtPlot instance into a given rectangle (Qwt modified code).

  \param painter Painter
  \param plotRect Bounding rectangle
  \param pfilter Print filter
*/
void Plot::print(QPainter *painter, const QRect &plotRect,
        const QwtPlotPrintFilter &pfilter)
{
    int axisId;

    if ( painter == 0 || !painter->isActive() ||
            !plotRect.isValid() || size().isNull() )
       return;

    QwtText t = title();
	printFrame(painter, plotRect);

    painter->save();

    // All paint operations need to be scaled according to
    // the paint device metrics.

    QwtPainter::setMetricsMap(this, painter->device());
    const QwtMetricsMap &metricsMap = QwtPainter::metricsMap();

    // It is almost impossible to integrate into the Qt layout
    // framework, when using different fonts for printing
    // and screen. To avoid writing different and Qt unconform
    // layout engines we change the widget attributes, print and
    // reset the widget attributes again. This way we produce a lot of
    // useless layout events ...

    pfilter.apply((QwtPlot *)this);

    int baseLineDists[QwtPlot::axisCnt];
    if ( !(pfilter.options() & QwtPlotPrintFilter::PrintCanvasBackground) ){
        // In case of no background we set the backbone of
        // the scale on the frame of the canvas.

        for (axisId = 0; axisId < QwtPlot::axisCnt; axisId++ ){
            QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(axisId);
            if ( scaleWidget ){
                baseLineDists[axisId] = scaleWidget->margin();
                scaleWidget->setMargin(0);
            }
        }
    }
    // Calculate the layout for the print.

    int layoutOptions = QwtPlotLayout::IgnoreScrollbars
        | QwtPlotLayout::IgnoreFrames;
    if ( !(pfilter.options() & QwtPlotPrintFilter::PrintMargin) )
        layoutOptions |= QwtPlotLayout::IgnoreMargin;
    if ( !(pfilter.options() & QwtPlotPrintFilter::PrintLegend) )
        layoutOptions |= QwtPlotLayout::IgnoreLegend;

    ((QwtPlot *)this)->plotLayout()->activate(this,
        QwtPainter::metricsMap().deviceToLayout(plotRect),
        layoutOptions);

    if ((pfilter.options() & QwtPlotPrintFilter::PrintTitle)
        && (!titleLabel()->text().isEmpty())){
        printTitle(painter, plotLayout()->titleRect());
    }

    QRect canvasRect = plotLayout()->canvasRect();

    for ( axisId = 0; axisId < QwtPlot::axisCnt; axisId++ ){
        QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(axisId);
        if (scaleWidget){
            int baseDist = scaleWidget->margin();

            int startDist, endDist;
            scaleWidget->getBorderDistHint(startDist, endDist);

            QRect scaleRect = plotLayout()->scaleRect(axisId);
            if (!scaleWidget->margin()){
                switch(axisId){
                    case xBottom:
                        scaleRect.translate(0, canvasRect.bottom() - scaleRect.top());
                    break;
                    case xTop:
                        scaleRect.translate(0, canvasRect.top() - scaleRect.bottom());
                    break;
                    case yLeft:
                        scaleRect.translate(canvasRect.left() - scaleRect.right(), 0);
                    break;
                    case yRight:
                        scaleRect.translate(canvasRect.right() - scaleRect.left(), 0);
                    break;
                }
            }
            printScale(painter, axisId, startDist, endDist, baseDist, scaleRect);
        }
    }

    if ( !(pfilter.options() & QwtPlotPrintFilter::PrintCanvasBackground) )
    {
        QRect boundingRect(
            canvasRect.left() - 1, canvasRect.top() - 1,
            canvasRect.width() + 2, canvasRect.height() + 2);
        boundingRect = metricsMap.layoutToDevice(boundingRect);
        boundingRect.setWidth(boundingRect.width() - 1);
        boundingRect.setHeight(boundingRect.height() - 1);

        painter->setPen(QPen(Qt::black));
        painter->setBrush(QBrush(Qt::NoBrush));
        painter->drawRect(boundingRect);
    }

    canvasRect = metricsMap.layoutToDevice(canvasRect);

    // When using QwtPainter all sizes where computed in pixel
    // coordinates and scaled by QwtPainter later. This limits
    // the precision to screen resolution. A much better solution
    // is to scale the maps and print in unlimited resolution.

    QwtScaleMap map[axisCnt];
    for (axisId = 0; axisId < axisCnt; axisId++){
        map[axisId].setTransformation(axisScaleEngine(axisId)->transformation());

        const QwtScaleDiv &scaleDiv = *axisScaleDiv(axisId);
        map[axisId].setScaleInterval(scaleDiv.lBound(), scaleDiv.hBound());

        double from, to;
        if ( axisEnabled(axisId) ){
            const int sDist = axisWidget(axisId)->startBorderDist();
            const int eDist = axisWidget(axisId)->endBorderDist();
            const QRect &scaleRect = plotLayout()->scaleRect(axisId);

            if ( axisId == xTop || axisId == xBottom ){
                from = metricsMap.layoutToDeviceX(scaleRect.left() + sDist);
                to = metricsMap.layoutToDeviceX(scaleRect.right() + 1 - eDist);
            } else {
                from = metricsMap.layoutToDeviceY(scaleRect.bottom() + 1 - eDist );
                to = metricsMap.layoutToDeviceY(scaleRect.top() + sDist);
            }
        } else {
            const int margin = plotLayout()->canvasMargin(axisId);
            if ( axisId == yLeft || axisId == yRight ){
                from = metricsMap.layoutToDeviceX(canvasRect.bottom() - margin);
                to = metricsMap.layoutToDeviceX(canvasRect.top() + margin);
            } else {
                from = metricsMap.layoutToDeviceY(canvasRect.left() + margin);
                to = metricsMap.layoutToDeviceY(canvasRect.right() - margin);
            }
        }
        map[axisId].setPaintXInterval(from, to);
    }

    // The canvas maps are already scaled.
    QwtPainter::setMetricsMap(painter->device(), painter->device());
    printCanvas(painter, canvasRect, map, pfilter);
    QwtPainter::resetMetricsMap();

    ((QwtPlot *)this)->plotLayout()->invalidate();

    // reset all widgets with their original attributes.
    if ( !(pfilter.options() & QwtPlotPrintFilter::PrintCanvasBackground) ){
        // restore the previous base line dists
        for (axisId = 0; axisId < QwtPlot::axisCnt; axisId++ ){
            QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(axisId);
            if ( scaleWidget  )
                scaleWidget->setMargin(baseLineDists[axisId]);
        }
    }

    pfilter.reset((QwtPlot *)this);
    painter->restore();
    setTitle(t);//hack used to avoid bug in Qwt::printTitle(): the title attributes are overwritten
}
Пример #20
0
void Plot::print(QPainter *painter, const QRect &plotRect,
        const QwtPlotPrintFilter &pfilter) const
{
printFrame(painter, plotRect);
QwtPlot::print(painter, plotRect, pfilter);
}
void CANGenPlugin::errorFrameReceived(const can_frame& frame)
{
    LOG_INFO("CANPlugin::errorFrameReceived()");
    printFrame(frame);
}
Пример #22
0
void CDebugHelper::run(lua_State* pState)
{
    char buffer[1024];

    char sep[] = " \t\n";
    char* next = NULL;
    char* last = NULL;
    char* cmd = NULL;

    m_curFrame = 0;

    while(true)
    {
        printf("(db): ");
        fgets(buffer, 1024, stdin);

        if(buffer[0] == '\0')
        {
            if(m_lastCmd[0] == '\0')
            {
                continue;
            }
            else
            {
                strcpy(buffer, m_lastCmd);
            }
        }
        else
        {
            strcpy(m_lastCmd, buffer);
        }

        next = strtok_r(buffer, sep, &last);
        cmd = next;

        for(char* p = cmd; *p; ++p)
        {
            *p = tolower(*p);
        }        

        if(strcmp(cmd, "h") == 0 || strcmp(cmd, "help") == 0)
        {
            help();
            continue;
        }
        else if(strcmp(cmd, "c") == 0 || strcmp(cmd, "continue") == 0)
        {
            setNoneHook(pState);
            return;
        }
        else if(strcmp(cmd, "bt") == 0)
        {
            printBacktrace(pState);
            continue;
        }
        else if(strcmp(cmd, "l") == 0 || strcmp(cmd, "list") == 0)
        {
            int beginLine = 0;
            int endLine = 0;
            next = strtok_r(NULL, sep, &last);
            if (next)
            {
                beginLine = atoi(next);
                next = strtok_r(NULL, sep, &last);
                if (next)
                {
                    endLine = atoi(next);
                }
            }

            printSource(pState, beginLine, endLine);
        }
        else if(strcmp(cmd, "f") == 0 || strcmp(cmd, "frame") == 0)
        {
            next = strtok_r(NULL, sep, &last);
            if(next)
            {
                m_curFrame = atoi(next);
            }
            printFrame(pState, m_curFrame);    
            continue;
        }
        else if(strcmp(cmd, "p") == 0 || strcmp(cmd, "print") == 0)
        {
            next = strtok_r(NULL, sep, &last);
            if (next)
            {
                printValue(pState, next);
            }

            continue;
        }
        else if(strcmp(cmd, "n") == 0 || strcmp(cmd, "next") == 0)
        {
            setNextHook(pState);
            return;
        }
        else if(strcmp(cmd, "s") == 0 || strcmp(cmd, "step") == 0)
        {
            setStepHook(pState);
            return;
        }
        else if(strcmp(cmd, "return") == 0)
        {
            setReturnHook(pState);
            return;
        }           
    }
}
Пример #23
0
/**
 * Parser function for the manual state.
 *
 * This is used in manual mode.
 *
 * \param m The received message.
 */
void parse_manual(tExtendedCAN *m) {

	uint16_t tmp = 0;
	uint16_t tmp2 = 0;
	uint8_t i;
	char str[30];
	bool ending = false;

	//dribbling
	if (m->data[0] == 'd') {
		tmp = atoi(m->data+1);
		char* pos = strchr(m->data,',');
		if (pos != NULL) {
		  tmp2 = atoi(pos+1);
		}
		
		sprintf(str, "Dribbling set : %d %d \n", tmp, tmp2);
		debug(str);
		ballhandler_set(tmp, tmp2);
	}
	// stop ball mechanism
	else if (m->data[0] == 's') {
		for (i = 1; i < m->header.length; i++) {
			if (m->data[i] >= 0x30 && m->data[i] <= 0x39) {
				tmp = tmp * 10 + (m->data[i] - 0x30);
				if (tmp > 254) {
					error("ERR DATE");
					return;
				}
			}
			else {
				error("ERR NAN");
				return;
			}
		}
		sprintf(str, "Stopping set : %d\n", tmp);
		debug(str);
		stop_set(tmp);
	}
	//servo set
	else if (m->data[0] == 'k') {
		for (i = 1; i < m->header.length; i++) {
			if (m->data[i] >= 0x30 && m->data[i] <= 0x39) {
				tmp = tmp * 10 + (m->data[i] - 0x30);
				if (tmp > 254) {
					error("ERR DATE");
					return;
				}
			}
			else {
				error("ERR NAN");
				return;
			}
		}
		sprintf(str, "Kicker set : %d \n", tmp);
		debug(str);
		servo_set(tmp);
	}
	// switch back to AUTOMATIC MODE
	// (without the driver the rekick driver
	// (the one in c#), the system goes into standby mode)
	else if (m->data[0] == 'a') {
		debug("auto");
		parse_data = parse_default;
		manual_mode = false;
	}
	else if (m->data[0] == 'l') {
		if( !light )
		{
			RESET(OF_LED);
			light = true;
		}
		else
		{
			SET(OF_LED);
			light = false;
		}
		debug("toggle light");
	}
	else if (m->data[0] == 'i') {
		getFrameBurst(img);
		debug("save image");
	}
	else if (m->data[0] == 't') {
        	for(int i=0; i<1536; i++)
        	{
                	img[i] = 100;
        	}
		printFrame(img);
		debug("test image");
	}
	else if (m->data[0] == 'p') {
		printFrame(img);
		debug("image printed!");
	}
	else if (m->data[0] == 'f') {
		if( debugOF == 1 )
		{
			debugOF = 0;
		}
		else
		{
			debugOF = 1;
		}
		debug("toggle flow!");
	}
	else {
		error("ERR IMPL");
	}

	return;
}