// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    // super init first
    if ( !Layer::init() ) return false;
    
    visibleSize = Director::getInstance()->getVisibleSize();
    origin = Director::getInstance()->getVisibleOrigin();

    //add background sound
    playBackgroundSound();

    //add background stars
    createStarsBackground("Pictures/bigStar.png",20);
    createStarsBackground("Pictures/smallStar.png",50);

    //add sprite with spaceCastle in the right side of the screen
    createSpaceCastle("Pictures/spaceCastle.png");

    //add a menu with a button which closes the game
    exitMenu();

    //add label with the title of the game in the top of the screen
    createTitleLabel("Physica");

    //add Points Label
    createScoreLabel();

    //add game menu
    createGameMenu();
    return true;
}
Beispiel #2
0
void Render()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glColor3d(7, 7, 7);
	
  glBindTexture(GL_TEXTURE_2D, texture[0]);    
  glBegin(GL_QUADS);		                
    
  glTexCoord2f(0.0f, 0.0f); glVertex3f(-17.0f, -11.0f,  1.0f);	// Bottom Left Of The Texture and Quad
  glTexCoord2f(1.0f, 0.0f); glVertex3f( 10.0f, -11.0f,  1.0f);	// Bottom Right Of The Texture and Quad
  glTexCoord2f(1.0f, 1.0f); glVertex3f( 10.0f,  11.0f,  1.0f);	// Top Right Of The Texture and Quad
  glTexCoord2f(0.0f, 1.0f); glVertex3f(-17.0f,  11.0f,  1.0f);	// Top Left Of The Texture and Quad

  glEnd();  
  		
  printMenu();
  if (enterBool == 1)  // if enter is pressed
  {
    switch (optionTargeted)  // calls the functions for play, options, high scores and exit
    {
      case 0 :  exitMenu();
		printGl("Imagine the game starts now...", 8, -5);
	break;
      case 1 :  exitMenu();
		printGl("You are in options now, believe me!", 8, -5);
	break;
      case 2 :  exitMenu();
		printGl("You are the best, don't worry.", 8, -5);
	break;
      case 3 : exit(0);
	break;
    }
  }
  
  glutSwapBuffers(); 
  glutPostRedisplay();
}
Beispiel #3
0
/*------------------------------------------------------------------------------------------------------------------
 --       FUNCTION:                  main
 --
 --       DATE:                      April 16, 2009
 --
 --       REVISIONS:
 --
 --       DESIGNER:                  Alin Albu
 --
 --       PROGRAMMER:                Alin Albu
 --
 --       INTERFACE:                 main(int argc, char* args[])
 --
 --       RETURNS:                   0 on success
 --
 --       NOTES:
 --
     This function is the main entry point for the "TuxBomber" application. It starts by loading
     the paths for the menus background and player models form the config.txb file. It then
     will initialize all the SDL modules needed for the game. If all is succesfult it creates the
     menu objects and loads the main menu.If the user select Player Options it loads the options menu
     If game options is selected a text box appears and the user can input the server IP address.
     Start game will call the start() function that will connect to the server and start the game.
 ---------------------------------------------------------------------------------------------------------------------*/
int
main(int argc, char* args[])
{
  int xMenuH; //exit menu height
  char *arg[2]; // arguments to be passed to start()
   int mmresult, ocresult; //MainMenu result and OkCancel menu result
  bool fulls = false, exitGame = false;  //full screen and exit selected flags
  std::string ip; //server ip
  Uint32 countStart, fps, frame; // time when load menu started, num of frames per sec, current frame
  FILE * fp; // config.txb file pointer
  SDL_Event event;
  SDL_Surface *screen;
  std::string mainOpts[MainMenu2::num_options_];  //main menu backgrounds paths
  std::string models[POptMenu::num_models_]; //models paths
  std::string game_models[POptMenu::num_models_]; //game models paths
  std::string playaOpts[POptMenu::num_options_]; // player options backgrounds paths
  std::string exitOpts[3]; //exit dialog backgrounds paths
  int stat;
  arg[0] = (char *) malloc(17);
  arg[1] = (char *) malloc(17);

  fp = fopen(CONFIG);
  if(fp == NULL){
    perror("Make sure that config.txb is in the root folder.");
    exit(1);
  }
  //get paths from file
  getMenuItems(models, fp, "menu_models\n", POptMenu::num_models_);
  getMenuItems(game_models, fp, "game_models\n", POptMenu::num_models_);
  getMenuItems(mainOpts, fp, "main_menu\n", MainMenu2::num_options_);
  getMenuItems(exitOpts, fp, "exit_menu\n", 3);
  getMenuItems(playaOpts, fp, "options_menu\n", POptMenu::num_options_);

  //init SDL

  if (!init_everything(&screen))
    {
      return 1;
    }
  //done SDL_init

  printf("Done init all Loading main...\n");

  //create main menu and exit dialog
  MainMenu2 main(mainOpts, ASOUND, BSOUND, screen);
  OkCancel exitMenu(exitOpts, BSOUND, screen);
  InputOkCancel *ip_dialog = new InputOkCancel(exitOpts, BSOUND, screen, 20);
  POptMenu pMenu(models, playaOpts, ASOUND, BSOUND, screen);

  mmresult = 0;
  ocresult = 0;
  exitGame = false;
  //start main loop
  while (!exitGame)
    {
      mmresult = main.start(event);
      switch (mmresult)
        {
      case 0: //error
        exitGame = true;
        break;
      case 1:    //load EXIT  ok_cancel dialog
        fps = 50;
        xMenuH = exitMenu.getBackground(0)->h;
        for (frame = 0; frame < fps; frame++)
          {
            countStart = SDL_GetTicks();
            if (SDL_GetTicks() - countStart < 1000 / fps)
              SDL_Delay((1000 / fps) - (SDL_GetTicks() - countStart));
            main.move(0, 0);
            exitMenu.move(0, ((250 + xMenuH) * frame / (int) fps) - xMenuH);
            SDL_Flip(screen);
            countStart = SDL_GetTicks();
          }
        main.move(0, 0);
        ocresult = exitMenu.start(event);
        switch (ocresult)
          {
        case 1: //exit game selected
          exitGame = true;
          break;
        case 2: //cancel exit selected
          for (frame = 0; frame < fps; frame++)
            {
              countStart = SDL_GetTicks();
              if (SDL_GetTicks() - countStart < 1000 / fps)
                SDL_Delay((1000 / fps) - (SDL_GetTicks() - countStart));
              main.move(0, 0);
              exitMenu.move(0, ((250 + xMenuH) * (fps - frame) / (int) fps)
                  - xMenuH);
              SDL_Flip(screen);
              countStart = SDL_GetTicks();
            }
          exitGame = false;
          break;
        default:
          break;
          }
        break;
      case 2:   //load player options
        main.setLoaded(0);
        main.showLoaded();
        pMenu.setLoaded(0);
        fps = 60;
        for (frame = 0; frame < fps; frame++)
          {
            countStart = SDL_GetTicks();
            if (SDL_GetTicks() - countStart < 1000 / fps)
              SDL_Delay((1000 / fps) - (SDL_GetTicks() - countStart));
            main.move(0 - (frame * 10), 0);
             pMenu.move(600 - (frame * 10), 0);
            SDL_Flip(screen);
            countStart = SDL_GetTicks();
          }

        pMenu.start();

        main.setLoaded(0);
        fps = 60;
        for (frame = 0; frame < fps; frame++)
          {
            countStart = SDL_GetTicks();
            if (SDL_GetTicks() - countStart < 1000 / fps)
              SDL_Delay((1000 / fps) - (SDL_GetTicks() - countStart));
            pMenu.move(0 + (frame * 10), 0);
            main.move(-600 + (frame * 10), 0);
            SDL_Flip(screen);
            countStart = SDL_GetTicks();
          }
        break;
      case 3: //load start game
        memcpy(arg[0], "gameStart", 10);
        memcpy(arg[1], ip.c_str(), 17);

        if (fulls)
          {
            start(3, arg, screen, &exitMenu); //start full screen
          }
        else
          {
            start(2, arg, screen, &exitMenu);//start in window
          }
	exitGame = true;
        /*screen = fulls ? SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32,
            SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN) : SDL_SetVideoMode(
            SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_SWSURFACE | SDL_DOUBLEBUF);*/
        SDL_Flip(screen);
        break;
      case 4: //load game options
        ip = ip_dialog->start(event);
        break;
      case 'f': //full screen
        fulls = !fulls;
        screen = fulls ? SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32,
            SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN) : SDL_SetVideoMode(
            SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_SWSURFACE | SDL_DOUBLEBUF);
        break;
        }
    }

  SDL_FreeSurface(screen);
  TTF_Quit();
  fclose(fp);
  free(arg[0]);
  free(arg[1]);
  //SDL_Quit();      ***** CAUSES AN ERROR?! **** WORKS FINE WITHOUT CALLING THIS

  printf("Done\n");
  return 0;
}
Beispiel #4
0
void AGOSEngine_FeebleDemo::mainMenu() {
    for (int i = 1; i <= 6; i++)
        enableBox(i);

    for (int i = 11; i <= 19; i++)
        disableBox(i);

    playVideo("mmfadein.smk", true);

    startInteractiveVideo("mainmenu.smk");

    HitArea *ha = 0;
    do {
        _lastHitArea = NULL;
        _lastHitArea3 = NULL;

        while (_lastHitArea3 == 0) {
            if (shouldQuit())
                return;
            handleText();
            delay(1);
        }

        ha = _lastHitArea;
    } while (ha == NULL || !(ha->id >= 1 && ha->id <= 6));

    if (shouldQuit())
        return;

    stopInteractiveVideo();

    if (ha->id == 1) {
        // Feeble Files Data
        playVideo("ffade5.smk");
        playVideo("ftext0.smk");
        playVideo("ftext1.smk", true);
        waitForSpace();
        playVideo("ftext2.smk", true);
        waitForSpace();
        playVideo("ftext3.smk", true);
        waitForSpace();
        playVideo("ftext4.smk", true);
        waitForSpace();
        playVideo("ftext5.smk", true);
        waitForSpace();
    } else if (ha->id == 2) {
        // Opening Sequence
        playVideo("ffade1.smk");
        playVideo("musosp1.smk");
        playVideo("newcred.smk");
        playVideo("fasall.smk");
        playVideo("mus5p2.smk");
        playVideo("coach.smk");
        playVideo("outmin.smk");
    } else if (ha->id == 3) {
        // Technical Information
        playVideo("ffade3.smk");
        playVideo("idfx4a.smk");
        playVideo("idfx4b.smk");
        playVideo("idfx4c.smk");
        playVideo("idfx4d.smk");
        playVideo("idfx4e.smk");
        playVideo("idfx4f.smk");
        playVideo("idfx4g.smk");
    } else if (ha->id == 4) {
        // About AdventureSoft
        playVideo("ffade2.smk");
        playVideo("fscene3b.smk");
        playVideo("fscene3a.smk");
        playVideo("fscene3c.smk");
        playVideo("fscene3g.smk");
    } else if (ha->id == 5) {
        // Video Clips
        playVideo("ffade4.smk");
        filmMenu();
    } else if (ha->id == 6) {
        // Exit InfoDisk
        playVideo("ffade6.smk");
        exitMenu();
    }
}
Beispiel #5
0
void handleMainMenu(void)
{

	BOOL isSelected = FALSE;
	int menuOption = 0;
		
	textClear();
	gp2x_video_RGB_setscaling(320, 240);
	while(!isSelected) {
		unsigned long pad = gp2x_joystick_read(0);
		printMenuOptions();
		gp2x_printf(0, 170, 1, "MenuOption = %d",menuOption);

		gp2x_printf(0, 0, (31 + (menuOption*8)), "->");

		gp2x_video_RGB_flip(0);

		if(pad & GP2X_RIGHT) {
			if((menuOption == MMOPTION_SAVESTATE) || (menuOption == MMOPTION_LOADSTATE))
				saveSlot++;
		}
			
		if(pad & GP2X_LEFT) {
			if((menuOption == MMOPTION_SAVESTATE) || (menuOption == MMOPTION_LOADSTATE))
				saveSlot--;
		}
			
		if(pad & GP2X_DOWN) {
			menuOption++;
			textClear();
		}
			
		if(pad & GP2X_UP) {
			menuOption--;
			textClear();
		}

		if(pad & GP2X_VOL_DOWN) if(pad & GP2X_START)
			exitMenu();
			
		if(pad & GP2X_X) {
			switch(menuOption){
			  case MMOPTION_CONTINUE: RESIZE(); textClear(); return;
			  case MMOPTION_RESTART: RESIZE(); supervision_reset(); textClear(); return;
			  case MMOPTION_SELECTOR: handleFileMenu(); return;
			  case MMOPTION_OPTIONS: handleOptionsMenu(); textClear(); return;
			  case MMOPTION_SAVESTATE: sv_saveState(romname,saveSlot); textClear();return;
			  case MMOPTION_LOADSTATE: sv_loadState(romname,saveSlot); textClear();return;
			  case MMOPTION_EXIT: exitMenu(); break;
			  default: return;
			}
		}

		/*if(pad & GP2X_B) {
			textClear(); 
			return;
		}*/
		
		if(menuOption < 0) menuOption = 0;			
		if(menuOption > 6) menuOption = 6;

		if(saveSlot < 0) saveSlot = 0;
		if(saveSlot > 9) saveSlot = 9;
		
		while(pad == gp2x_joystick_read(0));
		pad = gp2x_joystick_read(0);

		textClear();
	}
}
Beispiel #6
0
void handleOptionsMenu(void)
{

	BOOL isSelected = FALSE;
	int menuOption = 0;
		
	emu_ReadConfig();
	gp2x_video_RGB_setscaling(320, 240);
	textClear();
	while(!isSelected) {
		int clock = currentConfig.CPUclock;
		int frameskip = currentConfig.Frameskip;
		int videomode = currentConfig.videoMode;
		int vol = currentConfig.volume;
		unsigned long pad = gp2x_joystick_read(0);
		
		gp2x_printf(0, 1, 1, "Potator2x 1.0 by Normmatt\n\n");
		
		gp2x_printf(0, 15, 15 + 2*8, "videoMode      %s",videoMode);
		gp2x_printf(0, 15, 15 + 3*8, "show_fps       %d",currentConfig.show_fps);
		gp2x_printf(0, 15, 15 + 4*8, "enable_sound   %d",currentConfig.enable_sound);
		gp2x_printf(0, 15, 15 + 5*8, "SoundRate      %d",currentConfig.SoundRate);
		gp2x_printf(0, 15, 15 + 6*8, "Frameskip      %d",currentConfig.Frameskip);
		gp2x_printf(0, 15, 15 + 7*8, "CPUclock       %d",clocklist[currentConfig.CPUclock]);
		gp2x_printf(0, 15, 15 + 8*8, "volume         %d",currentConfig.volume);
		gp2x_printf(0, 15, 15 + 9*8, "Save and Exit");
		gp2x_printf(0, 15, 15 + 10*8, "Exit");

		gp2x_printf(0, 170, 1, "MenuOption = %d",menuOption);

		gp2x_printf(0, 0, (31 + (menuOption*8)), "->");

		gp2x_video_RGB_flip(0);

		if(pad & GP2X_RIGHT) {
			if(menuOption == OPTION_VIDEOMODE) if(videomode < 2) currentConfig.videoMode++;
			if(menuOption == OPTION_SHOWFPS) if(currentConfig.show_fps==0) currentConfig.show_fps=1; else currentConfig.show_fps=0;
			if(menuOption == OPTION_ENABLESOUND) if(currentConfig.enable_sound==0) currentConfig.enable_sound=1; else currentConfig.enable_sound=0;
			if(menuOption == OPTION_SOUNDRATE) currentConfig.SoundRate*=2;
			if(menuOption == OPTION_FRAMESKIP) if (frameskip < 9) frameskip++;
			if(menuOption == OPTION_CPUCLOCK) if(clock < sizeof(clocklist)) clock++;
			if(menuOption == OPTION_VOLUME) if (vol < 255) vol+= (pad & GP2X_RIGHT) ? 1 : 0;
		}
			
		if(pad & GP2X_LEFT) {
			if(menuOption == OPTION_VIDEOMODE) if(videomode > 0) currentConfig.videoMode--;
			if(menuOption == OPTION_SHOWFPS) if(currentConfig.show_fps==0) currentConfig.show_fps=1; else currentConfig.show_fps=0;
			if(menuOption == OPTION_ENABLESOUND) if(currentConfig.enable_sound==0) currentConfig.enable_sound=1; else currentConfig.enable_sound=0;
			if(menuOption == OPTION_SOUNDRATE) currentConfig.SoundRate/=2;
			if(menuOption == OPTION_FRAMESKIP) if (frameskip > 0) frameskip--;
			if(menuOption == OPTION_CPUCLOCK) if(clock > 0) clock--;
			if(menuOption == OPTION_VOLUME) if (vol > 0) vol-= (pad & GP2X_LEFT) ? 1 : 0;
		}
			
		if(pad & GP2X_DOWN) {
			menuOption++;
			textClear();
		}
			
		if(pad & GP2X_UP) {
			menuOption--;
			textClear();
		}

		if(pad & GP2X_VOL_DOWN) if(pad & GP2X_START)
			exitMenu();
			
		if(pad & GP2X_X) {
			switch(menuOption){
			  case OPTION_SAVEEXIT: 
				  emu_WriteConfig(); 
				  return;
			  case OPTION_EXIT: 
				  //gp2x_sound_rate(currentConfig.SoundRate); 
				  return;
			  default: break;
			}
		}

		switch(currentConfig.videoMode)
		{
			case 0: sprintf(videoMode,"Slow"); break;
			case 1: sprintf(videoMode,"Quick"); break;
			case 2: sprintf(videoMode,"Full Screen"); break;
			default: sprintf(videoMode,""); break;
		}

		if(currentConfig.SoundRate <= 11025) currentConfig.SoundRate = 11025;
		if(currentConfig.SoundRate >= 44100) currentConfig.SoundRate = 44100;

		currentConfig.Frameskip = frameskip;
		currentConfig.CPUclock  = clock;

		currentConfig.volume = vol;

		if(menuOption < 0) menuOption = 0;			
		if(menuOption > 8) menuOption = 8;
		
		while(pad == gp2x_joystick_read(0));
		pad = gp2x_joystick_read(0);

		textClear();
	}
}
Beispiel #7
0
void handleFileMenu(void)
{

	BOOL isSelected = FALSE;
	s32 curFile = 0;
	int virtualFile = 0;
		
	fillList();
	textClear();
	while(!isSelected) {
		unsigned long pad = gp2x_joystick_read(0);
		printList(curFile);
		gp2x_printf(0, 170, 1, "VirtualFile = %d",virtualFile);
		gp2x_printf(0, 170, 10, "File Count = %d",fileCounter);

		if(FileList[virtualFile].isRunable){
			gp2x_default_font.fg = 0x6700;
			gp2x_printf(NULL, 0, (33 + (virtualFile*8)), "->");
		} else {
			gp2x_default_font.fg = 0xFFFF;
			gp2x_printf(NULL, 0, (33 + (virtualFile*8)), "->");
		}

		gp2x_default_font.fg = 0xFFFF;
			
		if(curFile)
			gp2x_printf(NULL, 200, 22, "^\n|");
			
		if((curFile + 18 != fileCounter) && fileCounter > 19)
			gp2x_printf(NULL, 200, 200, "|\nv");

		gp2x_video_RGB_flip(0);
			
		if(pad & GP2X_RIGHT) {
			virtualFile += 5;
			if(virtualFile > 18)
				curFile += virtualFile - 18;
			textClear();
		}
			
		if(pad & GP2X_LEFT) {
			virtualFile -= 5;
			if(virtualFile < 0)
				curFile += virtualFile;
			textClear();
		}
			
		if(pad & GP2X_DOWN) {
			virtualFile++;
			textClear();
		}
			
		if(pad & GP2X_UP) {
			virtualFile--;
			textClear();
		}

		if(pad & GP2X_VOL_DOWN) if(pad & GP2X_START) 
			exitMenu();
			
		if(pad & GP2X_X) {
			if(FileList[curFile + virtualFile].fType == FT_DIR) {
				chdir(FileList[curFile + virtualFile].fName);
				fillList();
				virtualFile = curFile = 0;
			} else if(FileList[curFile + virtualFile].isRunable) {
				//textClear();
				//gp2x_printf(0, 1, 1, "Loading...\n\n%s", FileList[curFile + virtualFile].fName);
				//gp2x_video_RGB_flip(0);
				RESIZE();
				loadROM(FileList[curFile + virtualFile].fName);
				textClear();
				supervision_load((u8*)buffer, (uint32)buffer_size);
				textClear();
				return;
			}
		}

		//if(pad & GP2X_A) return;
		
		if(virtualFile < 0) {
			virtualFile = 0;
			--curFile;
			if(curFile < 0)
				curFile = 0;
		}
			
		if(fileCounter < 19) {
			if(virtualFile >= fileCounter)
				virtualFile = fileCounter-1;
		} else {
			if(virtualFile > 18) {
				virtualFile = 18;
				++curFile;
				if(curFile + 18 > fileCounter)
					curFile = fileCounter - 19;
			}
		}
		
		while(pad == gp2x_joystick_read(0));
		pad = gp2x_joystick_read(0);

		textClear();
	}
}
Beispiel #8
0
DialogMenu::DialogMenu(QWidget *parent) :    QDialog(parent),    ui(new Ui::DialogMenu)
{
    ui->setupUi(this);
    // *** -= КИРИЛИЗАЦИЯ !!! =- ***
    QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
    //без курсор
    this->setCursor(QCursor(Qt::BlankCursor));
    //connect buttons handlers
    connect(ui->btnMenuExit,SIGNAL(clicked()),this,SLOT(exitMenu()));
    connect(ui->btnSetDateTime,SIGNAL(clicked()),this,SLOT(setDateTime()));
    connect(ui->btnLoadRecipies,SIGNAL(clicked()),this,SLOT(loadRecipies()));
    connect(ui->btnSaveRecepies,SIGNAL(clicked()),this,SLOT(saveRecepies()));    
    connect(ui->btnAbort,SIGNAL(clicked()),this,SLOT(onAbort()));
    connect(ui->btnReport,SIGNAL(clicked()),this,SLOT(Report()));

    connect(ui->btnHumiditySandUp,SIGNAL(clicked()),this,SLOT(onHumiditySandUp()));
    connect(ui->btnHumiditySandDwn,SIGNAL(clicked()),this,SLOT(onHumiditySandDown()));
    connect(ui->btnHumidityFractionUp,SIGNAL(clicked()),this,SLOT(onHumidityFractionUp()));
    connect(ui->btnHumidityFractionDwn,SIGNAL(clicked()),this,SLOT(onHumidityFractionDown()));
    connect(ui->btnDumpTimeUp,SIGNAL(clicked()),this,SLOT(onDumpTimeUp()));
    connect(ui->btnDumpTimeDwn,SIGNAL(clicked()),this,SLOT(onDumpTimeDown()));

    connect(ui->btnAdvCementUp,SIGNAL(clicked()),this,SLOT(onCementAdvUp()));
    connect(ui->btnAdvCementDwn,SIGNAL(clicked()),this,SLOT(onCementAdvDwn()));

    connect(ui->btnAdvFractUp,SIGNAL(clicked()),this,SLOT(onFractAdvUp()));
    connect(ui->btnAdvFracDwn,SIGNAL(clicked()),this,SLOT(onFractAdvDwn()));

    connect(ui->btnAdvSandUp,SIGNAL(clicked()),this,SLOT(onSandAdvUp()));
    connect(ui->btnAdvSandDwn,SIGNAL(clicked()),this,SLOT(onSandAdvDwn()));

    connect(ui->btnAdvPepelUp,SIGNAL(clicked()),this,SLOT(onPepelAdvUp()));
    connect(ui->btnAdvPepelDwn,SIGNAL(clicked()),this,SLOT(onPepelAdvDwn()));

    //Date/Time update
    connect(&clockTimer,SIGNAL(timeout()),this,SLOT(clockTick()));
    clockTimer.start(1000);

    ui->lineHumidityFraction->setText(QString("%1").arg(globals.HumidityFraction));
    ui->lineHumiditySand->setText(QString("%1").arg(globals.HumiditySand));
    ui->lineDumpTime->setText(QString("%1").arg(globals.DumpTime));

    ui->lineAdvCement->setText(QString::number(globals.AdvScaleCement,'f',0));
    ui->lineAdvFraction->setText(QString::number(globals.AdvScaleFraction,'f',0));
    ui->lineAdvPepel->setText(QString::number(globals.AdvScalePepelina,'f',0));
    ui->lineAdvSand->setText(QString::number(globals.AdvScaleSand,'f',0));

    humidityChanged=false;

    //В зависимост от текущото състояние някои корекции могат да бъдат забранени.
    switch(states.State)
    {
    case Idle:
        //в това състояние всички бутони за достъпни освен ПРЕКРАТИ ЗАЯВКА
        ui->btnHumidityFractionDwn->setEnabled(true);
        ui->btnHumidityFractionUp->setEnabled(true);
        ui->lineHumidityFraction->setEnabled(true);

        ui->btnHumiditySandUp->setEnabled(true);
        ui->btnHumiditySandDwn->setEnabled(true);
        ui->lineHumiditySand->setEnabled(true);

        ui->btnDumpTimeUp->setEnabled(true);
        ui->btnDumpTimeDwn->setEnabled(true);
        ui->lineDumpTime->setEnabled(true);

        ui->btnAbort->setEnabled(false);
        ui->btnLoadRecipies->setEnabled(true);
        ui->btnSaveRecepies->setEnabled(true);
        ui->btnSetDateTime->setEnabled(true);

        ui->btnAdvCementUp->setEnabled(true);
        ui->btnAdvCementDwn->setEnabled(true);
        ui->lineAdvCement->setEnabled(true);

        ui->btnAdvFractUp->setEnabled(true);
        ui->btnAdvFracDwn->setEnabled(true);
        ui->lineAdvFraction->setEnabled(true);

        ui->btnAdvPepelUp->setEnabled(true);
        ui->btnAdvPepelDwn->setEnabled(true);
        ui->lineAdvPepel->setEnabled(true);

        ui->btnAdvSandUp->setEnabled(true);
        ui->btnAdvSandDwn->setEnabled(true);
        ui->lineAdvSand->setEnabled(true);

        break;

    case Fail:
    case Start:
    case Run:
    case Abort:
    case PowerDown:
        ui->btnHumidityFractionDwn->setEnabled(false);
        ui->btnHumidityFractionUp->setEnabled(false);
        ui->lineHumidityFraction->setEnabled(false);

        ui->btnHumiditySandUp->setEnabled(false);
        ui->btnHumiditySandDwn->setEnabled(false);
        ui->lineHumiditySand->setEnabled(false);

        ui->btnDumpTimeUp->setEnabled(false);
        ui->btnDumpTimeDwn->setEnabled(false);
        ui->lineDumpTime->setEnabled(false);

        ui->btnAbort->setEnabled(false);
        ui->btnLoadRecipies->setEnabled(false);
        ui->btnSaveRecepies->setEnabled(false);
        ui->btnSetDateTime->setEnabled(false);

        ui->btnAdvCementUp->setEnabled(false);
        ui->btnAdvCementDwn->setEnabled(false);
        ui->lineAdvCement->setEnabled(false);

        ui->btnAdvFractUp->setEnabled(false);
        ui->btnAdvFracDwn->setEnabled(false);
        ui->lineAdvFraction->setEnabled(false);

        ui->btnAdvPepelUp->setEnabled(false);
        ui->btnAdvPepelDwn->setEnabled(false);
        ui->lineAdvPepel->setEnabled(false);

        ui->btnAdvSandUp->setEnabled(false);
        ui->btnAdvSandDwn->setEnabled(false);
        ui->lineAdvSand->setEnabled(false);

        break;

    case Paused:       
        ui->btnHumidityFractionDwn->setEnabled(false);
        ui->btnHumidityFractionUp->setEnabled(false);
        ui->lineHumidityFraction->setEnabled(false);

        ui->btnHumiditySandUp->setEnabled(false);
        ui->btnHumiditySandDwn->setEnabled(false);
        ui->lineHumiditySand->setEnabled(false);

        ui->btnDumpTimeUp->setEnabled(false);
        ui->btnDumpTimeDwn->setEnabled(false);
        ui->lineDumpTime->setEnabled(false);

        ui->btnAbort->setEnabled(true);
        ui->btnLoadRecipies->setEnabled(false);
        ui->btnSaveRecepies->setEnabled(false);
        ui->btnSetDateTime->setEnabled(false);

        ui->btnAdvCementUp->setEnabled(false);
        ui->btnAdvCementDwn->setEnabled(false);
        ui->lineAdvCement->setEnabled(false);

        ui->btnAdvFractUp->setEnabled(false);
        ui->btnAdvFracDwn->setEnabled(false);
        ui->lineAdvFraction->setEnabled(false);

        ui->btnAdvPepelUp->setEnabled(false);
        ui->btnAdvPepelDwn->setEnabled(false);
        ui->lineAdvPepel->setEnabled(false);

        ui->btnAdvSandUp->setEnabled(false);
        ui->btnAdvSandDwn->setEnabled(false);
        ui->lineAdvSand->setEnabled(false);
        break;
    }
}