Example #1
0
void GW_PlatformSDL::initialize()
{
    if (!initialized_)
    {
        GWDBG_OUTPUT("SDL: Initialize");

        // initialize SDL video
        if ( SDL_Init( sdlinit(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_TIMER) ) < 0 )
            throw GW_Exception(string("Unable to init SDL: "+string(SDL_GetError())));

#ifndef GW_NO_SDL_MIXER
        if ( Mix_OpenAudio(22050, AUDIO_S16SYS, 1, audiobufsize_get()) < 0)
            throw GW_Exception(string("Unable to init SDL_mixer: "+string(Mix_GetError())));
#endif

#ifndef GW_NO_SDL_TTF
        if ( TTF_Init() < 0 )
            throw GW_Exception(string("Unable to init SDL_ttf: "+string(TTF_GetError())));
#endif

#ifndef GW_NO_SDL_MIXER
        Mix_AllocateChannels(6);
        sound_volume(75);
#endif

        custom_initialize();

        // make sure SDL cleans up before exit
        atexit(SDL_Quit);

        // set application icon
        plat_init();

        // create a new window
        window_ = SDL_CreateWindow("Game & Watch simulator - by Hitnrun / ZsoltK & Madrigal",
                                   SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                                   width_, height_,
                                   fullscreen_ ?  SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_SHOWN);
        if ( !window_ )
            throw GW_Exception(string("Unable to allocate game window: " + string(SDL_GetError())));

        renderer_ = SDL_CreateRenderer(window_, -1, SDL_RENDERER_ACCELERATED);
        if ( !renderer_ )
            throw GW_Exception(string("Unable to allocate renderer: " + string(SDL_GetError())));


        // Let SDL & GPU do the scaling
        SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
        SDL_RenderSetLogicalSize(renderer_, width_, height_);

        SDL_ShowCursor(SDL_DISABLE);

#ifndef GW_NO_SDL_TTF
        // load font
        //font_=TTF_OpenFont( bf::path( bf::path(platformdata_get() ) / "andalemo.ttf" ).string().c_str(), fontsize_get() );
        string pfont(platformdata_get() + "/" + "andalemo.ttf" );
        font_=TTF_OpenFont( pfont.c_str(), fontsize_get() );
        if (!font_)
            throw GW_Exception(string("Unable to load font: "+string(TTF_GetError())));
#endif

        initialized_=true;
    }
}
Example #2
0
void mainwindow::printf(sdetails *sdt)
{
    int tsno = 0 ;
    fmt = "Printer";
    pt_type = ui.ptcombo->currentIndex();//fields,complete


    if(ui.outbox->currentIndex() == 0)//pdf,printer
    {
        fmt = "PDF  ";
        printer2->setOutputFileName(pdfpath + sdt->stroll + ".pdf");
        painter = new QPainter(printer2);
        valw = (printer2->width()/printer2->widthMM());
        valh = (printer2->height()/printer2->heightMM());
    }
    else
    {
        printer->setDocName(sdt->stroll);
        painter = new QPainter(printer);
        valw = (printer->width()/printer->widthMM());
        valh = (printer->height()/printer->heightMM());
    }
    QFont pfont("MonoType",32);
    QPointF pt;
    QFont paintfont("Bitstream Vera Serif",11);
    QFont snofont("Bitstream Vera Serif",18);

    switch (pt_type)
    {
    case PRINT_ALL :
        //Setting up the actual scene
        setacscene();

        if(ui.gbcno->isChecked())
        {
            // QFont ;
            // s_no2->setFont();
            // QString ctemp;
            // s_no2->setPlainText(ctemp.sprintf("%04",sno);
        }
        sname2->setFont(pfont);
        sname2->setPlainText(sdt->stname);

        fname2->setFont(pfont);
        fname2->setPlainText(sdt->ftname);

        sdetail2->setFont(pfont);
        sdetail2->setPlainText(sdt->sds);

        periodfrom2->setFont(pfont);
        periodfrom2->setPlainText(sdt->fyear);

        periodto2->setFont(pfont);
        periodto2->setPlainText(sdt->tyear);

        roll2->setFont(pfont);
        roll2->setPlainText(sdt->stroll);

        date2->setFont(pfont);
        date2->setPlainText(dt);

        gen2->setFont(pfont);
        gen2->setPlainText(sdt->co);

        purposetext2->setFont(pfont);
        purpose2->setFont(pfont);

        if(!sdt->p_pose.isEmpty())
        {
            purposetext2->setPlainText(" This Certificate is issued for the Purpose of : ");
            purpose2->setPlainText(sdt->p_pose);
        }
        else
        {
            purposetext2->setPlainText("");
            purpose2->setPlainText("");
        }

        scene2->render(painter); //,QRectF(0,0,printer->width(),printer->height()));
        painter->end();
        delete scene2;
        break;
    case PRINT_FIELDS:

        painter->setFont(snofont);
        if(ui.gbcno->isChecked())
        {

            pt.setX(lt.at(0) * valw);
            pt.setY(lt.at(1) * valh);
            painter->drawText (pt,tempx.sprintf("%04d",sno));

            tsno = sno;
            ++sno;

            // Reset Certificate ID to 0001 on reaching
            // the Max value set by User
            if(sno == ui.sbreset->value())
                ui.sbcno->setValue(1);

            ui.sbcno->setValue(sno);
        }

        painter->setFont(paintfont);
        pt.setX(lt.at(2) * valw);
        pt.setY(lt.at(3) * valh);
        painter->drawText ( pt, dt );

        pt.setX(lt.at(4) * valw);
        pt.setY(lt.at(5) * valh);
        painter->drawText ( pt,sdt->stname);

        pt.setX(lt.at(6) * valw);
        pt.setY(lt.at(7) * valh);
        painter->drawText (pt,sdt->co);

        pt.setX(lt.at(8) * valw);
        pt.setY(lt.at(9) * valh);
        painter->drawText (pt,sdt->ftname);

        pt.setX(lt.at(10)* valw);
        pt.setY(lt.at(11)* valh);
        painter->drawText (pt,sdt->stroll);

        pt.setX(lt.at(12) * valw);
        pt.setY(lt.at(13) * valh);
        painter->drawText (pt,sdt->sds);

        pt.setX(lt.at(14) * valw);
        pt.setY(lt.at(15) * valh);
        painter->drawText (pt,sdt->fyear);


        pt.setX(lt.at(16) * valw);
        pt.setY(lt.at(17) * valh);
        painter->drawText ( pt, sdt->tyear);

        if(!sdt->p_pose.isEmpty())
        {
            pt.setX(lt.at(18) * valw);
            pt.setY(lt.at(19) * valh);
            painter->drawText (pt,"This Certificate is issued for the Purpose of : ");

            pt.setX(lt.at(20) * valw);
            pt.setY(lt.at(21) * valh) ;
            painter->drawText (pt,sdt->p_pose);
        }

        painter->end();

        break;
    }

    logmanager->write(tempx.setNum(tsno)+" :: " + sdt->stroll + " |  "+"Certificate Type : Bonafide  |  "+"Format : " + fmt +"  |  Time : "+QTime::currentTime().toString());
    clist.replace(0,clist.at(0) + 1);
    clist.replace(1,clist.at(1) + 1);
    ui.ltotalptd->setText(tempx.setNum(clist.at(0)));
    ui.ltotalp->setText(tempx.setNum(clist.at(1)));

    logmanager->setLastSnoRollNo(sno,sdt->stroll);
    delete painter;
}