예제 #1
0
void GUIEngine::run()
{
	// Always create clouds because they may or may not be
	// needed based on the game selected
	video::IVideoDriver* driver = m_device->getVideoDriver();

	cloudInit();

	unsigned int text_height = g_fontengine->getTextHeight();

	while(m_device->run() && (!m_startgame) && (!m_kill))
	{
		//check if we need to update the "upper left corner"-text
		if (text_height != g_fontengine->getTextHeight()) {
			updateTopLeftTextSize();
			text_height = g_fontengine->getTextHeight();
		}

		driver->beginScene(true, true, video::SColor(255,140,186,250));

		if (m_clouds_enabled)
		{
			cloudPreProcess();
			drawOverlay(driver);
		}
		else
			drawBackground(driver);

		drawHeader(driver);
		drawFooter(driver);

		m_device->getGUIEnvironment()->drawAll();

		driver->endScene();

		if (m_clouds_enabled)
			cloudPostProcess();
		else
			sleep_ms(25);

		m_script->step();

#ifdef __ANDROID__
		m_menu->getAndroidUIInput();
#endif
	}
}
예제 #2
0
void GUIEngine::run()
{
	// Always create clouds because they may or may not be
	// needed based on the game selected
	video::IVideoDriver* driver = m_device->getVideoDriver();

	cloudInit();

	while(m_device->run() && (!m_startgame) && (!m_kill)) {
		driver->beginScene(true, true, video::SColor(255,140,186,250));

		if (m_clouds_enabled)
		{
			cloudPreProcess();
			drawOverlay(driver);
		}
		else
			drawBackground(driver);

		drawHeader(driver);
		drawFooter(driver);

		m_device->getGUIEnvironment()->drawAll();

		driver->endScene();

		if (m_clouds_enabled)
			cloudPostProcess();
		else
			sleep_ms(25);

		m_script->step();

#ifdef __ANDROID__
		m_menu->getAndroidUIInput();
#endif
	}
}
예제 #3
0
void CalPrintJournal::print( QPainter &p, int width, int height )
{
  int x=0, y=0;
  Journal::List journals( mCalendar->journals() );
  if ( mUseDateRange ) {
    Journal::List allJournals = journals;
    journals.clear();
    Journal::List::Iterator it = allJournals.begin();
    for ( ; it != allJournals.end(); ++it ) {
      QDate dt = (*it)->dtStart().date();
      if ( mFromDate <= dt && dt <= mToDate ) {
        journals.append( *it );
      }
    }
  }

  drawHeader( p, i18n("Journal entries"), QDate(), QDate(), QRect( 0, 0, width, headerHeight() ) );
  y = headerHeight() + 15;

  Journal::List::Iterator it = journals.begin();
  for ( ; it != journals.end(); ++it ) {
    drawJournal( *it, p, x, y, width, height );
  }
}
예제 #4
0
int main()
{
    time_t t;                       /* Used for random seed */

    /* Genrate random seed, make sure this goes before all the other */
    srand(time(&t));

    int fishX = 0;                  /* Holds the fish X (EAST/WEST) postion */
    int fishDepth = 0;              /* Holds the fish depth of the fish */
    int fishZ = 0;                  /* Holds the fish Z (NORTH/SOUTH) postion */
    int boatX = 0;                  /* Holds boat X (EAST/WEST) postion */
    int netDepth = 0;               /* Holds net depth */
    int boatZ = 0;                  /* Holds the boat Z (NORTH/SOUTH) postion */
    int turnsTaken = 0;             /* Holds the amount of moves taken to find the fish */
    int win = FALSE;                /* Holds the game win state */

    /* Hide the fish/catch :) */
    fishX = getRandomNumber(BOXSIZE);
    fishDepth = getRandomNumber(BOXSIZE);
    fishZ = getRandomNumber(BOXSIZE);

    /* For testing only, show the fish location */
    /*printf("fishN/S=%d, fishE/W=%d, fishDepth=%d\n",fishZ,fishX,fishDepth); */

    drawHeader();
    drawSubHeader();

    do {
    /* Get user input */
    printf("\nEnter your NORTH/SOUTH position : ");
    scanf("%d",&boatZ);
    printf("Enter your WEST/EAST postion : ");
    scanf("%d",&boatX);
    printf("Enter your net depth : ");
    scanf("%d",&netDepth);

    turnsTaken++;

    /* Check for a win */
    if(boatX == fishX && netDepth == fishDepth && boatZ == fishZ)
        {
         win = TRUE;
         clearScreen(10);
         printf("\nWell done! You took %d turns to find the fish.\n",turnsTaken);
         drawEndOfGame();
        }
    else /* If no win found, try again */
        {
        clearScreen(18);
        drawHeader();
        printf("Turns taken = :     %d\n",turnsTaken);
        printf("======================================\n");
        printf("Sorry, no fish found, please try again.\n");
        printf("Soner : More *** = closer\n\n");

        /* Compare boat position to fish position and report on it */

        /* NORTH/SOUTH */
        if(boatZ < fishZ)
            {
            printf("Sonar Report : Fish located more NORTH : ");
            sonarReport(boatZ, fishZ);
            }
        else if(boatZ > fishZ)
            {
            printf("Sonar Report : Fish located more SOUTH : ");
            sonarReport(boatZ, fishZ);
            }
        else if(boatZ == fishZ)
            {
            printf("NORTH/SOUTH postion found at           : %d\n",boatZ);
            }

        /* WEST/EAST */
        if(boatX < fishX)
            {
            printf("Sonar Report : Fish located more EAST  : ");
            sonarReport(boatX, fishX);
            }
        else if(boatX > fishX)
            {
            printf("Sonar Report : Fish located more WEST  : ");
            sonarReport(boatX, fishX);
            }
        else if(boatX == fishX)
            {
            printf("WEST/EAST postion found at             : %d\n",boatX);
            }

        /* NET DEPTH */
        if(netDepth < fishDepth)
            {
            printf("Sonar Report : Fish located DEEPER     : ");
            sonarReport(netDepth, fishDepth);
            }
        else if(netDepth > fishDepth)
            {
            printf("Sonar Report : Fish located SHALLOWER  : ");
            sonarReport(netDepth, fishDepth);
            }
        else if(netDepth == fishDepth)
            {
            printf("DEPTH postion found at                 : %d\n",netDepth);
            }
        }

    }while (win == FALSE);

    getchar();
    return EXIT_SUCCESS;
}
예제 #5
0
void View::drawNavigation() {
    drawHeader();
    drawFooter();
}
예제 #6
0
    void OGUIFileBrowser::draw() {
        // ToDo (damiles): Create scroll for more files in window
        if (_is_file_browser_visible) {
            NVGcontext *vg = (NVGcontext *) _window->vg;
            nvgBeginPath(vg);
            nvgRect(vg, 0, 0, _window->getWindowWidth(), _window->getWindowHeight());
            nvgFillColor(vg, nvgRGBA(28, 30, 34, 255));
            nvgFill(vg);

            // sep line
            nvgBeginPath(vg);
            nvgMoveTo(vg, 200, 40);
            nvgLineTo(vg, 200, _window->getWindowHeight());
            nvgFillColor(vg, nvgRGBA(0,0,0,255));
            nvgFill(vg);

            nvgBeginPath(vg);
            nvgMoveTo(vg, 0, 40);
            nvgLineTo(vg, _window->getWindowWidth(), 40);
            nvgFillColor(vg, nvgRGBA(0,0,0,255));
            nvgFill(vg);

            nvgBeginPath(vg);
            nvgMoveTo(vg, 200, _window->getWindowHeight()-40);
            nvgLineTo(vg, _window->getWindowWidth(), _window->getWindowHeight()-40);
            nvgFillColor(vg, nvgRGBA(0,0,0,255));
            nvgFill(vg);

            // Draw accept and cancel buttons
            if(drawBasicButton(vg, this->_window, "Accept", _window->getWindowWidth()-100, _window->getWindowHeight()-30, 90, 20, _window->mouse_x, _window->mouse_y)){
                _is_file_browser_visible=0;
            }

            if(drawBasicButton(vg, this->_window, "Close", _window->getWindowWidth()-200, _window->getWindowHeight()-30, 90, 20, _window->mouse_x, _window->mouse_y)){
                _file_browser_result= NULL;
                _is_file_browser_visible=0;
            }

            // Draw de devices we found
            drawHeader(vg, "System", 0, 40, 200);

            // Draw system files
            int x=10;
            int y=75;
            for(int i=0; i<_system.size(); i++){
                OGUIFile *file= _system.at(i);
                if( file->draw(vg, x, y, _window->mouse_x, _window->mouse_y) ){ // is clicked
                    _file_browser_result= file;
                    if(_file_browser_result!=NULL) {
                        if (_file_browser_result->_is_dir
                            && _actual_folder.compare(_file_browser_result->_path) != 0) {
                            readFolder(_file_browser_result->_path);
                            _actual_folder= _file_browser_result->_path;
                            _file_browser_result = NULL;
                        }
                    }
                }
                y+=22;

            }



            // Draw files
            x=210;
            y=50;
            int max_height= _window->getWindowHeight()-80;
            for(int i=0; i<_file_list.size(); i++){
                OGUIFile *file= _file_list.at(i);
                if( file->draw(vg, x, y, _window->mouse_x, _window->mouse_y) ){ // is clicked
                    _file_browser_result= file;
                    if(_file_browser_result!=NULL) {
                        if (_file_browser_result->_is_dir
                            && _actual_folder.compare(_file_browser_result->_path) != 0) {
                            readFolder(_file_browser_result->_path);
                            _actual_folder= _file_browser_result->_path;
                            _file_browser_result = NULL;
                        }
                    }
                }
                y+=22;
                if(y>=max_height){
                    x+=202;
                    y=50;
                }
            }

            // Show icon in header
            nvgFontSize(vg, 16.0f);
            nvgFontFace(vg, "icons");
            nvgTextAlign(vg,NVG_ALIGN_LEFT|NVG_ALIGN_TOP);
            nvgFillColor(vg, nvgRGBA(0,0,0,255));
            nvgText(vg, 10, 11, "\uF115", NULL);
            nvgFillColor(vg, nvgRGBA(255, 255, 255, 255));
            nvgText(vg, 11, 13, "\uF115", NULL);
            nvgFillColor(vg, nvgRGBA(255,255,255,255));

            // show path in header
            nvgFontSize(vg, 18.0f);
            nvgFontFace(vg, "sans-bold");
            nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_TOP);
            nvgFillColor(vg, nvgRGBA(0, 0, 0, 255));
            nvgText(vg, 35, 10, resolved_path, NULL);
            nvgFillColor(vg, nvgRGBA(255, 255, 255, 255));
            nvgText(vg, 36, 12, resolved_path, NULL);

            if(_file_browser_result!=NULL) {
                if (_file_browser_result->_is_dir == false) {
                    // show file in footer
                    nvgFontSize(vg, 18.0f);
                    nvgFontFace(vg, "sans-bold");
                    nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_TOP);
                    nvgFillColor(vg, nvgRGBA(0, 0, 0, 255));
                    nvgText(vg, 209, _window->getWindowHeight()-32, _file_browser_result->_file_name.c_str(), NULL);
                    nvgFillColor(vg, nvgRGBA(255, 255, 255, 255));
                    nvgText(vg, 210, _window->getWindowHeight()-30, _file_browser_result->_file_name.c_str(), NULL);

                    // Draw preview if its image
                    if(_file_browser_result->isImage()){
                        x=0;
                        y=_window->getWindowHeight()-200;

                        drawHeader(vg, "Preview", 0, y-30, 200);


                        int w=200;
                        int h=200;
                        NVGpaint bg;
                        // Box
                        bg = nvgBoxGradient(vg, x+1,y+1+1.5f, w-2,h-2, 3,4, nvgRGBA(255,255,255,32), nvgRGBA(32,32,32,32));
                        nvgBeginPath(vg);
                        nvgRoundedRect(vg, x+1,y+1, w-2,h-2, 4-1);
                        nvgFillPaint(vg, bg);
                        nvgFill(vg);

                        nvgBeginPath(vg);
                        nvgRoundedRect(vg, x+0.5f,y+0.5f, w-1,h-1, 4-0.5f);
                        nvgStrokeColor(vg, nvgRGBA(0,0,0,48));
                        nvgStroke(vg);

                        // Image preview
                        if(_preview_image==-1){
                            _preview_image= nvgCreateImageRGBA(vg, 150, 150, 0, _file_browser_result->getPreview());
                        }else{
                            nvgUpdateImage(vg, _preview_image, _file_browser_result->getPreview());
                        }

                        NVGpaint imgPaint = nvgImagePattern(vg, 25, y+25, 150, 150, 0, _preview_image, 1);
                        nvgBeginPath(vg);
                        nvgRect(vg, 25, y+25, 150,150);
                        nvgFillPaint(vg, imgPaint);
                        nvgFill(vg);
                    }


                }
            }


        }
    }
예제 #7
0
void BeerStatsFrame::drawContent(QPainter &painter, int panel, int offset)
{
    vector<QStringDoublePair> pairs;

    switch(panel)
    {
        case 0: // today's pours
        {
            drawHeader(painter, QString("today's pours"), offset);

            map<User*, int> userPours;
            vector<Pour*> pours = Pour::PoursByKegId[CurrentKeg->Id];
            double now = time(NULL);
            for (int i=0; i<pours.size(); i++)
            {
                Pour* pour = pours[i];
                if (now - pour->Time >= 0.5 * Constants::Day)
                    continue;
                User* user = User::UsersById[pour->UserId];
                userPours[user]++;
            }

            map<User*, int>::iterator iter;
            for (iter = userPours.begin(); iter != userPours.end(); iter++)
                pairs.push_back(QStringDoublePair(QString(iter->first->Name.c_str()),iter->second));


            if (pairs.size() == 0)
                drawNone(painter, QString("none"), offset);
            else
                drawTiles(painter, pairs, offset);
        }
        break;
        case 1: //pours by day
        {
            drawHeader(painter, QString("pours by day"), offset);

            // DOW of week pours
            vector<int> dowPours = Pour::GetPoursByDow(CurrentKeg);
            //int dowPours[] = {22, 5, 12, 13, 11, 24, 20};
            int maxDowPours = 0;
            for (int i=0; i<7; i++)
                maxDowPours = max(dowPours[i], maxDowPours);

            for (int i=0; i<7; i++)
                pairs.push_back(QStringDoublePair(dowNames[i],dowPours[i]/(double)maxDowPours));

            if (maxDowPours == 0)
                drawNone(painter, QString("none"), offset);

            drawBars(painter, pairs, offset);
        }
        break;
        case 2: // pours by user
        {
            drawHeader(painter, QString("pours by user"), offset);

            if (CurrentKeg == NULL)
            {
                drawNone(painter, QString("none"), offset);
                return;
            }

            map<User*, int> userPours = Pour::GetPoursByUser(CurrentKeg);
            int maxPours = 0;
            map<User*, int>::iterator iter;
            for (iter = userPours.begin(); iter != userPours.end(); iter++)
                maxPours = max(maxPours, iter->second);

            for (iter = userPours.begin(); iter != userPours.end(); iter++)
                pairs.push_back(QStringDoublePair(QString(iter->first->Name.c_str()),iter->second/(double)maxPours));

            if (maxPours == 0)
                drawNone(painter, QString("none"), offset);
            else
                drawBars(painter, pairs, offset);
        }
        break;
    }
}
예제 #8
0
void CalPrintYear::print( QPainter &p, int width, int height )
{
  QRect headerBox( 0, 0, width, headerHeight() );
  const KCalendarSystem *calsys = calendarSystem();
  KLocale *locale = KGlobal::locale();
  if ( !calsys || !locale ) {
    return;
  }

  QDate start;
  calsys->setYMD( start, mYear, 1, 1 );

  // Determine the nr of months and the max nr of days per month (dependent on
  // calendar system!!!!)
  QDate temp( start );
  int months = calsys->monthsInYear( start );
  int maxdays = 1;
  for ( int i = 1; i< months; ++i ) {
    maxdays = qMax( maxdays, temp.daysInMonth() );
    temp = calsys->addMonths( temp, 1 );
  }

  // Now determine the months per page so that the printout fits on
  // exactly mPages pages
  int monthsPerPage = ( months - 1 ) / mPages + 1;
  int pages = ( months - 1 ) / monthsPerPage + 1;
  int thismonth = 0;
  temp = start;
  for ( int page = 0; page < pages; ++page ) {
    if ( page > 0 ) {
      mPrinter->newPage();
    }
    QDate end( calsys->addMonths( start, monthsPerPage ) );
    end = calsys->addDays( end, -1 );
    QString stdate = locale->formatDate( start );
    QString endate = locale->formatDate( end );
    QString title;
    if ( orientation() == QPrinter::Landscape ) {
      title = i18nc( "date from - to", "%1 - %2", stdate, endate );
    } else {
      title = i18nc( "date from -\nto", "%1 -\n%2", stdate, endate );
    }
    drawHeader( p, title, calsys->addMonths( start, -1 ),
                calsys->addMonths( start, monthsPerPage ), headerBox );

    QRect monthesBox( headerBox );
    monthesBox.setTop( monthesBox.bottom() + padding() );
    monthesBox.setBottom( height );

    drawBox( p, BOX_BORDER_WIDTH, monthesBox );
    float monthwidth = float( monthesBox.width() ) / float( monthsPerPage );

    for ( int j=0; j<monthsPerPage; ++j ) {
      if ( ++thismonth > months ) {
        break;
      }
      int xstart = int( j * monthwidth + 0.5 );
      int xend = int( ( j + 1 ) * monthwidth + 0.5 );
      QRect monthBox( xstart, monthesBox.top(), xend - xstart, monthesBox.height() );
      drawMonth( p, temp, monthBox, maxdays, mSubDaysEvents, mHolidaysEvents );

      temp = calsys->addMonths( temp, 1 );
    }
    start = calsys->addMonths( start, monthsPerPage );
  }
}
예제 #9
0
void
xQGanttListView::paintEvent(QPaintEvent * /*e*/)
{
    drawHeader();
}
예제 #10
0
void GUIEngine::run()
{
	// Always create clouds because they may or may not be
	// needed based on the game selected
	video::IVideoDriver *driver = RenderingEngine::get_video_driver();

	cloudInit();

	unsigned int text_height = g_fontengine->getTextHeight();

	irr::core::dimension2d<u32> previous_screen_size(g_settings->getU16("screen_w"),
		g_settings->getU16("screen_h"));

	while (RenderingEngine::run() && (!m_startgame) && (!m_kill)) {

		const irr::core::dimension2d<u32> &current_screen_size =
			RenderingEngine::get_video_driver()->getScreenSize();
		// Verify if window size has changed and save it if it's the case
		// Ensure evaluating settings->getBool after verifying screensize
		// First condition is cheaper
		if (previous_screen_size != current_screen_size &&
				current_screen_size != irr::core::dimension2d<u32>(0,0) &&
				g_settings->getBool("autosave_screensize")) {
			g_settings->setU16("screen_w", current_screen_size.Width);
			g_settings->setU16("screen_h", current_screen_size.Height);
			previous_screen_size = current_screen_size;
		}

		//check if we need to update the "upper left corner"-text
		if (text_height != g_fontengine->getTextHeight()) {
			updateTopLeftTextSize();
			text_height = g_fontengine->getTextHeight();
		}

		driver->beginScene(true, true, video::SColor(255,140,186,250));

		if (m_clouds_enabled)
		{
			cloudPreProcess();
			drawOverlay(driver);
		}
		else
			drawBackground(driver);

		drawHeader(driver);
		drawFooter(driver);

		RenderingEngine::get_gui_env()->drawAll();

		driver->endScene();

		if (m_clouds_enabled)
			cloudPostProcess();
		else
			sleep_ms(25);

		m_script->step();

#ifdef __ANDROID__
		m_menu->getAndroidUIInput();
#endif
	}
}
예제 #11
0
void Menu::drawMainMenu(){
    drawHeader();
    gra->drawText(250, 200, "Nowa gra", 30);
    gra->drawText(250, 240, "O grze", 30);
    gra->render();
}