Exemplo n.º 1
0
void ThreadList::updateThreads(const ProcessInfo* processInfo, SymbolInfo *symInfo)
{
	this->selected_threads.clear();
	DeleteAllItems();
	this->threads.clear();
	ok_button->Enable(false);
	all_button->Enable(false);

	if(processInfo != NULL)
	{
		this->process_handle = processInfo->getProcessHandle();
		this->syminfo = symInfo;

		this->threads = processInfo->threads;

		int numDisplayedThreads = getNumDisplayedThreads();
		for(int i=0; i<numDisplayedThreads; ++i)
		{
			long tmp = this->InsertItem(i, "", -1);
			SetItemData(tmp, i);
		}

		all_button->Enable(this->threads.size() != 0);

		lastTime = wxGetLocalTimeMillis();
		updateTimes();
		updateSorting();
		fillList();
	}
}
Exemplo n.º 2
0
void DlgPrintPrep::on_comboBoxMaterial_currentIndexChanged(const QString &arg1)
{
    m_pTerminal->getMatCat()->setCurMatIndex(ui->comboBoxMaterial->currentIndex());
    m_pTerminal->getMatCat()->setCurXYIndex(((ui->lineEditXYPixelSizeMicrons->text().toInt()-25)/25)-1);
    if(!m_bInitializing){
        QSettings settings;
        settings.setValue("CurrentMaterialLabel",arg1);
    }
    // Determine times based on thickness
    double dTattach = m_pTerminal->getMatCat()->getCurTattach().toDouble();
    ui->lineEditTattach->setText(QString::number(dTattach,'f',3));
    m_iTattachMS = dTattach*1000;

    int iNumAttach = m_pTerminal->getMatCat()->getCurNumberAttach().toInt();
    ui->lineEditNumAttach->setText(QString::number(iNumAttach));
    m_iNumAttach = iNumAttach;

    int iTbaseMS = m_pTerminal->getMatCat()->getCurTbaseAtZinMS(m_pCPJ->getZLayermm());
    ui->lineEditTbase->setText(QString::number((double)iTbaseMS/1000.0,'f',3));
    m_iTbaseMS = iTbaseMS;

    int iToverMS = m_pTerminal->getMatCat()->getCurToverAtZinMS(m_pCPJ->getZLayermm());
    ui->lineEditTOver->setText(QString::number((double)iToverMS/1000.0,'f',3));
    m_iToverMS = iToverMS;
    updateTimes();
}
Exemplo n.º 3
0
void B9Print::print3D(CrushedPrintJob* pCPJ, int iXOff, int iYOff, int iTbase, int iTover, int iTattach, int iNumAttach, int iLastLayer, bool bPrintPreview, bool bUsePrimaryMonitor, bool bIsMirrored)
{
    //注意:如果,iLastLayer<1,打印所有层。
   //如果bPrintPreview,运行,则无需打开投影机

    m_iMinimumTintMS = m_vSettings.value("m_iMinimumTintMS",50).toInt(); // 抓取旧值
    if(m_iMinimumTintMS>500)
        m_iMinimumTintMS=555; //不应该得到这个大的,解决它。
    else if (m_iMinimumTintMS<50)
        m_iMinimumTintMS=56;  //或者这个小值
    m_vSettings.setValue("m_iMinimumTintMS",(int)((double)m_iMinimumTintMS*.9)); //再回到90%,它的最后一个值,只是为了保持接近边缘
    m_iPrintState = PRINT_NO;
    m_pTerminal->setEnabled(false);
    m_pCPJ = pCPJ;
    m_pTerminal->createNormalizedMask(m_pCPJ->getXYPixelmm());
    m_iTbase = iTbase; m_iTover = iTover; m_iTattach = iTattach; m_iNumAttach = iNumAttach;
    m_iXOff = iXOff; m_iYOff = iYOff;
    m_iCurLayerNumber = 0;
    m_iPaused = PAUSE_NO;
    m_bAbort = false;
    m_iLastLayer = iLastLayer;
    if(m_iLastLayer<1)m_iLastLayer = m_pCPJ->getTotalLayers();

    m_pTerminal->setUsePrimaryMonitor(bUsePrimaryMonitor);
    m_pTerminal->setPrintPreview(bPrintPreview);
    m_pTerminal->onScreenCountChanged();

    ui->lineEditJobName->setText(m_pCPJ->getName());
    ui->lineEditJobDescription->setText(m_pCPJ->getDescription());
    ui->progressBarPrintProgress->setMinimum(0);
    ui->progressBarPrintProgress->setMaximum(m_iLastLayer);
    ui->progressBarPrintProgress->setValue(0);
    ui->lineEditLayerCount->setText("Total Layers To Print: "+QString::number(m_iLastLayer)+"  Powering up the projector.");

    ui->lcdNumberTime->display(m_pTerminal->getEstCompleteTime(m_iCurLayerNumber,m_iLastLayer,m_pCPJ->getZLayermm(),m_iTbase+m_iTover).toString("hh:mm"));
    QString sTimeUpdate = updateTimes();
    setProjMessage("Total Layers to print: "+QString::number(m_iLastLayer)+"  "+sTimeUpdate);
	if(m_pTerminal->getIsVirtualDevice())
	{
		m_iPrintState = PRINT_SETUP1;
	}
    if(!bPrintPreview){
        //打开投影机,并设置以毫秒为预热时间
        ui->pushButtonPauseResume->setEnabled(false);
        ui->pushButtonAbort->setEnabled(false);
        m_pTerminal->rcIsMirrored(bIsMirrored);
        m_pTerminal->rcSetWarmUpDelay(20000);
        m_pTerminal->rcProjectorPwr(true);
    }
    else {
        ui->lineEditProjectorStatus->setText("OFF:  'Print Preview' Mode");
        ui->pushButtonPauseResume->setEnabled(true);
        ui->pushButtonAbort->setEnabled(true);
        m_iPrintState = PRINT_SETUP1;
        m_dLayerThickness = m_pCPJ->getZLayer().toDouble();
        m_pTerminal->rcBasePrint(-m_pTerminal->getHardZDownMM()); //动态Z零,过度直到我们按下硬件和电机“跳过”
    }
}
Exemplo n.º 4
0
DlgPrintPrep::DlgPrintPrep(CrushedPrintJob* pCPJ, B9Terminal* pTerminal, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DlgPrintPrep)
{
    m_bInitializing = true;
    ui->setupUi(this);
    m_pTerminal = pTerminal;
    m_pCPJ = pCPJ;
    m_iTattachMS=0;
    m_iNumAttach = 1;
    m_iTbaseMS=0;
    m_iToverMS=0;
    m_bDryRun = false;
    m_bMirrored = false;

    ui->pushButtonResetPrintAll->setEnabled(false);

    m_iLastLayer = 0;
    ui->spinBoxLayersToPrint->setMinimum(1);
    ui->spinBoxLayersToPrint->setMaximum(m_pCPJ->getTotalLayers());
    ui->spinBoxLayersToPrint->setValue(m_pCPJ->getTotalLayers());


    ui->lineEditName->setText(m_pCPJ->getName());
    ui->lineEditDescription->setText(m_pCPJ->getDescription());
    ui->lineEditXYPixelSizeMicrons->setText(QString::number(1000*m_pCPJ->getXYPixelmm()));
    ui->lineEditZSizeMicrons->setText(QString::number(1000*m_pCPJ->getZLayermm()));

    double dVolume = m_pCPJ->getTotalWhitePixels()*m_pCPJ->getZLayermm()*m_pCPJ->getXYPixelmm()*m_pCPJ->getXYPixelmm()/1000;
    ui->lineEditVolume->setText(QString::number(dVolume,'f',1));

    m_pTerminal->getMatCat()->setCurXYIndex(((ui->lineEditXYPixelSizeMicrons->text().toInt()-25)/25)-1);

    for(int i=0; i<m_pTerminal->getMatCat()->getMaterialCount(); i++){
        ui->comboBoxMaterial->addItem(m_pTerminal->getMatCat()->getMaterialLabel(i));
    }

    QSettings settings;
    int index = ui->comboBoxMaterial->findText(settings.value("CurrentMaterialLabel","B9R-1-Red").toString());
    if(index<0)index=0;
    ui->comboBoxMaterial->setCurrentIndex(index);
    m_pTerminal->getMatCat()->setCurMatIndex(index);
    settings.setValue("CurrentXYLabel",ui->lineEditXYPixelSizeMicrons->text()+" (µm)");

    updateTimes();

    ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Print");
    ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
    ui->checkBoxStep1->setEnabled(true);
    ui->checkBoxStep2->setEnabled(false);
    ui->pushButtonStep3->setEnabled(false);
    ui->checkBoxStep4->setEnabled(false);
    ui->checkBoxStep5->setEnabled(false);

    m_bInitializing = false;
}
Exemplo n.º 5
0
void ThreadList::updateThreads(const ProcessInfo* processInfo, SymbolInfo *symInfo)
{
	this->selected_threads.clear();
	DeleteAllItems();
	this->threads.clear();
	ok_button->Enable(false);

	if(processInfo != NULL)
	{
		this->process_handle = processInfo->getProcessHandle();
		this->syminfo = symInfo;

		this->threads = processInfo->threads;
		for(int i=0; i<(int)this->threads.size(); ++i)
		{
			long tmp = this->InsertItem(i, "", -1);
			SetItemData(tmp, i);
		}

		all_button->Enable(this->threads.size() != 0);

		lastTime = wxGetLocalTimeMillis();
		updateTimes();

		// We need to wait a bit before we can get any useful CPU usage data.
		{
			timer.Stop();
			int steps = 20;
			wxProgressDialog dlg("Sleepy", "Searching for threads...", steps);
			for (int n=0;n<steps;n++)
			{
				Sleep(200/steps);
				dlg.Update(n);
			}
			timer.Start(UPDATE_DELAY);
		}

		// Now we've waited, we can grab the data again.
		updateTimes();
		updateSorting();
		fillList();
	}
}
Exemplo n.º 6
0
void DigitalTube::countDown(){
  if(!start) return;
  if(totalMinutes==0){
    digitalWrite(8,LOW);
    start=false;
    return;
  }
  totalMinutes--;  
  updateTimes(totalMinutes);
}
Exemplo n.º 7
0
void DevicePluginDateTime::postSetupDevice(Device *device)
{
    if (device->deviceClassId() == todayDeviceClassId) {
        QDateTime zoneTime = QDateTime::currentDateTime().toTimeZone(m_timeZone);
        updateTimes();
        onMinuteChanged(zoneTime);
        onHourChanged(zoneTime);
        onDayChanged(zoneTime);
    }
}
Exemplo n.º 8
0
    void Gsr::initialize(Real T) {

        volsteptimesArray_ = Array(volstepdates_.size());

        updateTimes();

        QL_REQUIRE(volatilities_.size() == volsteptimes_.size() + 1,
                   "there must be n+1 volatilities ("
                       << volatilities_.size()
                       << ") for n volatility step times ("
                       << volsteptimes_.size() << ")");
        // sigma_ =
        // PiecewiseConstantParameter(volsteptimes_,PositiveConstraint());
        sigma_ = PiecewiseConstantParameter(volsteptimes_, NoConstraint());

        QL_REQUIRE(reversions_.size() == 1 ||
                       reversions_.size() == volsteptimes_.size() + 1,
                   "there must be 1 or n+1 reversions ("
                       << reversions_.size()
                       << ") for n volatility step times ("
                       << volsteptimes_.size() << ")");
        if (reversions_.size() == 1) {
            reversion_ = ConstantParameter(reversions_[0]->value(), NoConstraint());
        } else {
            reversion_ =
                PiecewiseConstantParameter(volsteptimes_, NoConstraint());
        }

        for (Size i = 0; i < sigma_.size(); i++) {
            sigma_.setParam(i, volatilities_[i]->value());
        }
        for (Size i = 0; i < reversion_.size(); i++) {
            reversion_.setParam(i, reversions_[i]->value());
        }

        stateProcess_ = boost::shared_ptr<GsrProcess>(new GsrProcess(
            volsteptimesArray_, sigma_.params(), reversion_.params(), T));

        registerWith(termStructure());

        registerWith(stateProcess_);
        for(Size i=0;i<reversions_.size();++i)
            registerWith(reversions_[i]);

        for(Size i=0;i<volatilities_.size();++i)
            registerWith(volatilities_[i]);

    }
Exemplo n.º 9
0
void GlfwGraphics::runOpenGLLoop()
{
	do
	{
		updateSize();
		updateTimes();

		m_listener.render();

		// Swap buffers
		::glfwSwapBuffers();

	} // Check if the ESC key was pressed or the window was closed
	while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &&
		::glfwGetWindowParam( GLFW_OPENED ) );
}
Exemplo n.º 10
0
void B9Print::exposureOfTOverLayersFinished(){
    if(m_iPrintState==PRINT_NO)return;

    m_pTerminal->rcSetCPJ(NULL); //空白
    //循环到下一层或完成
    if(m_iPaused==PAUSE_WAIT){
        m_iPaused=PAUSE_YES;
        m_pTerminal->rcSTOP();
        m_pTerminal->rcCloseVat();
        ui->pushButtonPauseResume->setText("Resume");
        ui->pushButtonPauseResume->setEnabled(true);
        ui->pushButtonAbort->setEnabled(true);
        ui->lineEditLayerCount->setText("Paused.  Manual positioning toggle switches are enabled.");
        m_pTerminal->rcSetProjMessage(" Paused.  Manual toggle switches are enabled.  Press 'p' when to resume printing, 'A' to abort.");
        return;
    }

    if(m_bAbort){
        //已完成
        m_pTerminal->rcSetCPJ(NULL); //blank
        ui->pushButtonAbort->setText("Abort");
        m_iPrintState = PRINT_ABORT;
        on_signalAbortPrint();
        return;
    }
    else if(m_iCurLayerNumber==m_iLastLayer-1){
        // 已完成,释放并升高
        ui->pushButtonAbort->setEnabled(false);
        ui->pushButtonPauseResume->setEnabled(false);
        m_iPrintState=PRINT_DONE;
        m_pTerminal->rcFinishPrint(50.8); //完成在当前的Z轴位置+50.8毫米,将投影机关闭
        ui->lineEditLayerCount->setText("Finished!");
        setProjMessage("Finished!");
        return;
    }
    else
    {
        //操作下一图层
        m_iCurLayerNumber++;  //设置下一图层数值
        m_pTerminal->rcNextPrint(curLayerIndexMM());
        m_iPrintState = PRINT_RELEASING;
        ui->lineEditLayerCount->setText("Releasing Layer "+QString::number(m_iCurLayerNumber)+", repositioning to layer "+QString::number(m_iCurLayerNumber+1));
        QString sTimeUpdate = updateTimes();
        setProjMessage("(Press'p' to pause, 'A' to ABORT)  " + sTimeUpdate+"  Release and cycle to Layer "+QString::number(m_iCurLayerNumber+1)+" of "+QString::number(m_iLastLayer));
     }
}
 inline
 PiecewiseZeroSpreadedTermStructure::PiecewiseZeroSpreadedTermStructure(
                                const Handle<YieldTermStructure>& h,
                                const std::vector<Handle<Quote> >& spreads,
                                const std::vector<Date>& dates,
                                Compounding comp,
                                Frequency freq,
                                const DayCounter& dc)
 : originalCurve_(h), spreads_(spreads), dates_(dates),
   times_(dates_.size()), comp_(comp), freq_(freq), dc_(dc) {
     QL_REQUIRE(!spreads_.empty(), "no spreads given");
     QL_REQUIRE(spreads_.size() == dates_.size(),
                "spread and date vector have different sizes");
     registerWith(originalCurve_);
     for (Size i = 0; i < spreads_.size(); i++)
         registerWith(spreads_[i]);
     updateTimes();
 }
Exemplo n.º 12
0
/******************************************************************************
* Called after a new selection has been made in the time zone combo box.
* Re-evaluates the time specification to use.
*/
void AlarmTimeWidget::slotTimeZoneChanged()
{
	if (mNoTimeZone->isChecked())
		mTimeSpec = KDateTime::ClockTime;
	else
	{
		KTimeZone tz = mTimeZone->timeZone();
		mTimeSpec = tz.isValid() ? KDateTime::Spec(tz) : KDateTime::LocalZone;
	}
	if (!mTimeZoneBox->isVisible()  &&  mTimeSpec != Preferences::timeZone())
	{
		// The current time zone is not the default one, so
		// show the time zone selection controls
		showTimeZoneSelector();
	}
	mMinDateTime = mMinDateTime.toTimeSpec(mTimeSpec);
	mMaxDateTime = mMaxDateTime.toTimeSpec(mTimeSpec);
	updateTimes();
}
Exemplo n.º 13
0
void B9Print::exposeTBaseLayer(){
    //发布暨复位周期内完成,时间露出新的图层
    if(m_iPrintState==PRINT_NO || m_iPrintState == PRINT_ABORT)return;

    if(m_iPrintState==PRINT_SETUP1){
        //我们使用 - getHardZDownMM()过渡,并获得在这里,
        //现在重置当前位置为0,并拉升至+ getZFlushMM
        m_pTerminal->rcResetCurrentPositionPU(0);
        m_pTerminal->rcBasePrint(m_pTerminal->getZFlushMM());
        m_iPrintState = PRINT_SETUP2;
        return;
    }

    if(m_iPrintState==PRINT_SETUP2){
        //现在,我们应复位当前位置为0,并继续
        m_pTerminal->rcResetCurrentPositionPU(0);
        m_iPrintState = PRINT_RELEASING;
    }

    if(m_iPrintState == PRINT_DONE){
        m_iPrintState=PRINT_NO;
        m_pTerminal->setEnabled(true);
        if(m_pTerminal->getPrintPreview()){
            m_pTerminal->setPrintPreview(false);
            m_pTerminal->setUsePrimaryMonitor(false);
        }
        m_pTerminal->onScreenCountChanged();
        hide();
        return;
    }

    if(m_bAbort){
        //完成后释放和提高
        m_pTerminal->rcSetCPJ(NULL); //空白
        ui->pushButtonAbort->setText("Abort");
         m_iPrintState = PRINT_ABORT;
        on_signalAbortPrint();
        return;
    }

    //启动TBASE打印曝光
    ui->progressBarPrintProgress->setValue(m_iCurLayerNumber+1);
    ui->lineEditLayerCount->setText("Creating Layer "+QString::number(m_iCurLayerNumber+1)+" of "+QString::number(m_iLastLayer)+",  "+QString::number(100.0*(double)(m_iCurLayerNumber+1)/(double)m_iLastLayer,'f',1)+"% Complete");
    setSlice(m_iCurLayerNumber);
    m_vClock.start(); //图像就在那里,启动时钟运行!
    QString sTimeUpdate = updateTimes();
    if(m_iPaused==PAUSE_WAIT){
        ui->lineEditLayerCount->setText("Pausing...");
        setProjMessage("Pausing...");
    }
    else{
        setProjMessage("(Press'p' to pause, 'A' to ABORT)  " + sTimeUpdate+"  Creating Layer "+QString::number(m_iCurLayerNumber+1)+" of "+QString::number(m_iLastLayer));
    }
    m_iPrintState = PRINT_EXPOSING;
    //设置计时器
    int iAdjExposure = m_pTerminal->getLampAdjustedExposureTime(m_iTbase);
    if(m_iCurLayerNumber<m_iNumAttach) iAdjExposure = m_pTerminal->getLampAdjustedExposureTime(m_iTattach);  //第一层可以具有不同的曝光时延
    if(iAdjExposure>0){
        QTimer::singleShot(iAdjExposure-m_vClock.elapsed(), this, SLOT(startExposeTOverLayers()));
        return;
    }
    else
    {
        startExposeTOverLayers(); // 如果这是获取调用,我们正在获取太长时间了!
        qDebug() << "EXPOSURE TIMING ERROR:  Tbase exposed for too long!, Tbase is set too small or computer too slow?" << iAdjExposure;
        return;
    }
}
Exemplo n.º 14
0
 void performCalculations() const {
     Lgm::performCalculations();
     updateTimes();
     parametrization()->update();
 }
Exemplo n.º 15
0
void DlgPrintPrep::on_spinBoxLayersToPrint_valueChanged(int arg1)
{
    m_iLastLayer = arg1;
    ui->pushButtonResetPrintAll->setEnabled(m_pCPJ->getTotalLayers()!=m_iLastLayer);
    updateTimes();
}
Exemplo n.º 16
0
void DlgPrintPrep::on_pushButtonReleaseCycle_clicked()
{
    m_pTerminal->updateCycleValues();
    updateTimes();
}
Exemplo n.º 17
0
void ThreadList::OnTimer(wxTimerEvent& WXUNUSED(event))
{
	updateTimes();
}
Exemplo n.º 18
0
void Menu::play()
{
    mapSelected="";
    playLoop=true;
    fadingToLeave=false;

    while (playLoop)
    {
        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
                case SDL_QUIT:
                fadingToLeave=true;
                playLoop=false;
                command="quit";
                break;

                case SDL_MOUSEMOTION:
                    lastCursorX=event.button.x;
                    lastCursorY=event.button.y;
                    for(unsigned int i=0;i<m_buttons.size();i++)
                        m_buttons[i].updateCursor(Vector3D(event.button.x,event.button.y,0));
                break;

                case SDL_MOUSEBUTTONUP:
                if(event.button.button==SDL_BUTTON_LEFT)
                {
                    for(unsigned int i=0;i<m_buttons.size();i++)
                    {
                        if(m_buttons[i].getClicable() && m_buttons[i].clic(Vector3D(event.button.x,event.button.y,0)))
                        {
                            clicOn(m_buttons[i].getName(),true);
                            break;
                        }
                    }
                }
                else if(event.button.button==SDL_BUTTON_RIGHT)
                {
                    for(unsigned int i=0;i<m_buttons.size();i++)
                    {
                        if(m_buttons[i].getClicable() && m_buttons[i].clic(Vector3D(event.button.x,event.button.y,0)))
                        {
                            clicOn(m_buttons[i].getName(),false);
                            break;
                        }
                    }
                }
                else if(event.button.button==SDL_BUTTON_WHEELUP)
                {
                    if(curMenu=="editor")
                        for(unsigned int i=9;i<m_buttons.size();i++)
                        {
                            m_buttons[i].translate(0,-0.05);
                            if(m_buttons[i].getPos().Y>0.4 || m_buttons[i].getPos().Y<0.1)
                                m_buttons[i].setVisible(false);
                            else
                                m_buttons[i].setVisible(true);
                        }
                }
                else if(event.button.button==SDL_BUTTON_WHEELDOWN)
                {
                    if(curMenu=="editor")
                        for(unsigned int i=9;i<m_buttons.size();i++)
                        {
                            m_buttons[i].translate(0,0.05);
                            if(m_buttons[i].getPos().Y>0.4 || m_buttons[i].getPos().Y<0.1)
                                m_buttons[i].setVisible(false);
                            else
                                m_buttons[i].setVisible(true);
                        }
                }
                break;

                case SDL_KEYDOWN:
                switch(event.key.keysym.sym)
                {
                    case SDLK_KP_ENTER:
                    break;
                    case SDLK_RETURN:
                    break;
                    case SDLK_SPACE:
                    break;
                    default:
                    break;
                }
                break;

                case SDL_KEYUP:
                switch(event.key.keysym.sym)
                {
                    case SDLK_KP_ENTER:
                    break;
                    case SDLK_RETURN:
                    break;
                    case SDLK_ESCAPE:
                        clicOn("back",true);
                    break;
                    default:
                    break;
                }
                break;
            }
        }

        //update stuff
        updateTimes();
        //m_online->update();

        m_video->update(ft);

        m_bg.update(ft);
        for(unsigned int i=0;i<m_buttons.size();i++)
            m_buttons[i].update(ft);


        draw();

        SDL_Delay(20);


        if(fadingToLeave)
        {
            if(Video::getInstance()->getFade()->getFading()==false)
            {
                Video::getInstance()->getFade()->startFadeIn();
            }
            if(Video::getInstance()->getFade()->getAlpha()>=1)
            {
                playLoop=false;
                fadingToLeave=false;
            }
        }
    }

    Gsounds::getInstance()->freeAll();
}
Exemplo n.º 19
0
void ThreadList::OnTimer(wxTimerEvent& event)
{
	updateTimes();
}
 inline void PiecewiseZeroSpreadedTermStructure::update() {
     updateTimes();
     ZeroYieldStructure::update();
 }
Exemplo n.º 21
0
 void performCalculations() const {
     Gaussian1dModel::performCalculations();
     updateTimes();
     updateSmiles();
     updateNumeraireTabulation();
 }
bool CUpnpBrowserGui::selectItem(std::string id)
{
	bool loop = true;
	bool endall = false;
	bool refresh = true;
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;
	std::vector<UPnPEntry> *entries = NULL;

	unsigned int liststart = 0;
	unsigned int selected = 0;
	unsigned int total = 0;

	printf("selectItem: [%s]\n", id.c_str());
	if (!getItems(id, liststart, entries, total))
		return endall;

	while (loop) {
		updateTimes();

		if (refresh) {
			printf("selectItem: refresh, timeout = %d\n", (int) timeout);
			if (!timeout)
				paintItems(entries, selected - liststart, total - liststart, liststart);
			refresh=false;
		}

		g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display
		neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat;

		if (msg == CRCInput::RC_timeout) {
			// nothing
		}
		else if (msg == CRCInput::RC_home) {
			loop=false;
			endall=true;
		}
		else if (!timeout && (msg == CRCInput::RC_left)) {
			loop=false;
		}
		else if (!timeout && (msg_repeatok == (neutrino_msg_t) g_settings.key_list_start)) {
			updateItemSelection(id, entries, 0, selected, liststart);
		}
		else if (!timeout && (msg_repeatok == (neutrino_msg_t) g_settings.key_list_end)) {
			updateItemSelection(id, entries, total-1, selected, liststart);
		}
		else if (!timeout && (msg_repeatok == CRCInput::RC_up || (int) msg == g_settings.key_pageup)) {
			int step = ((int) msg == g_settings.key_pageup) ? m_listmaxshow : 1;  // browse or step 1
			int new_selected = selected - step;
			if (new_selected < 0) {
				if (selected != 0 && step != 1)
					new_selected = 0;
				else
					new_selected = total - 1;
			}
			updateItemSelection(id, entries, new_selected, selected, liststart);
		}
		else if (!timeout && (msg_repeatok == CRCInput::RC_down || (int) msg == g_settings.key_pagedown)) {
			int step =  ((int) msg == g_settings.key_pagedown) ? m_listmaxshow : 1;  // browse or step 1
			int new_selected = selected + step;
			if (new_selected >= (int) total) {
				if ((total - m_listmaxshow -1 < selected) && (selected != (total - 1)) && (step != 1))
					new_selected = total - 1;
				else if (((total / m_listmaxshow) + 1) * m_listmaxshow == total + m_listmaxshow) // last page has full entries
					new_selected = 0;
				else
					new_selected = ((step == (int) m_listmaxshow) && (new_selected < (int) (((total / m_listmaxshow)+1) * m_listmaxshow))) ? (total - 1) : 0;
			}
			updateItemSelection(id, entries, new_selected, selected, liststart);
		}
		else if (!timeout && (msg == CRCInput::RC_ok || msg == CRCInput::RC_right)) {
			if ((selected - liststart) >= (*entries).size())
				continue;
			if ((*entries)[selected - liststart].isdir) {
				endall=selectItem((*entries)[selected - liststart].id);
				if (endall)
					loop=false;
				refresh=true;
			} else {
				m_folderplay = false;
				int preferred=(*entries)[selected - liststart].preferred;
				if (preferred != -1)
				{
					std::string &mime = (*entries)[selected - liststart].mime;
					if (mime.substr(0,6) == "audio/")
					{
						m_playing_entry = (*entries)[selected - liststart];
						m_playing_entry_is_shown = false;
						playAudio((*entries)[selected - liststart].resources[preferred].url, (*entries)[selected - liststart].type);
					}
					else if (mime.substr(0,6) == "video/")
					{
						m_frameBuffer->Clear();
						playVideo((*entries)[selected - liststart].title, (*entries)[selected - liststart].resources[preferred].url);
						m_frameBuffer->showFrame("mp3.jpg");
						refresh = true;
					}
					else if (mime.substr(0,6) == "image/")
					{
						videoDecoder->setBlank(true);
						showPicture((*entries)[selected - liststart].resources[preferred].url);
						m_playid = selected;
						while (true)
						{
							g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout

							if (msg == CRCInput::RC_home || msg == CRCInput::RC_ok)
								break;
							else if (msg == CRCInput::RC_right || msg == CRCInput::RC_down) {
								m_playfolder = id;
								m_playid = (m_playid + 1)%total;
								playnext();
							}
							else if (msg == CRCInput::RC_left || msg == CRCInput::RC_up) {
								m_playfolder = id;
								m_playid--;
								if (m_playid < 0)
									m_playid = total - 1;
								playnext();
							} else
								CNeutrinoApp::getInstance()->handleMsg(msg, data);
						}
						m_frameBuffer->Clear();
						videoDecoder->setBlank(false);
						refresh = true;
					}
				}
			}
		}
		else if (msg == CRCInput::RC_play) {
			if ((selected - liststart) >= (*entries).size())
				continue;
			m_folderplay = true;
			m_playfolder = (*entries)[selected - liststart].id;
			m_playid = 0;
			playnext();
			m_playid++;
		}
		else if (msg == CRCInput::RC_yellow) {
			if (CAudioPlayer::getInstance()->getState() != CBaseDec::STOP)
				CAudioPlayer::getInstance()->stop();
			m_folderplay = false;
		}
		else if (m_folderplay && msg == (neutrino_msg_t) CRCInput::RC_stop) {
			timeout = 0;
			m_folderplay = false;
			m_frameBuffer->Clear();
			refresh = true;
		}
		else if (m_folderplay && msg == (neutrino_msg_t) CRCInput::RC_prev) {
			timeout = 0;
			m_playid -= 2;
			if (m_playid < 0)
				m_playid = 0;
		}
		else if (m_folderplay && msg == (neutrino_msg_t) CRCInput::RC_next) {
			timeout = 0;
			if (CAudioPlayer::getInstance()->getState() != CBaseDec::STOP)
				CAudioPlayer::getInstance()->stop();
		}
		else if (msg == NeutrinoMessages::RECORD_START ||
				msg == NeutrinoMessages::ZAPTO ||
				msg == NeutrinoMessages::STANDBY_ON ||
				msg == NeutrinoMessages::SHUTDOWN ||
				msg == NeutrinoMessages::SLEEPTIMER)
		{
			loop = false;
			g_RCInput->postMsg(msg, data);
		}
#if 0
		else if (msg == NeutrinoMessages::EVT_TIMER)
		{
			CNeutrinoApp::getInstance()->handleMsg(msg, data);
		}
		else if (msg > CRCInput::RC_MaxRC)
#endif
		else
		{
			if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all)
				loop = false;
			//refresh=true;
		}

		if (m_folderplay && ((!timeout || (timeout <= time(NULL))) && (CAudioPlayer::getInstance()->getState() == CBaseDec::STOP))) {
			playnext();
			m_playid++;
		}
	}

	delete entries;
	timeout = 0;
	m_frameBuffer->Clear();

	return endall;
}
Exemplo n.º 23
0
 void performCalculations() const {
     Gaussian1dModel::performCalculations();
     updateTimes();
 }
Exemplo n.º 24
0
void AlarmTimeWidget::init(Mode mode, const QString& title)
{
	static const QString recurText = i18nc("@info/plain",
	                                       "If a recurrence is configured, the start date/time will be adjusted "
	                                       "to the first recurrence on or after the entered date/time."); 
	static const QString tzText = i18nc("@info/plain",
	                                    "This uses KAlarm's default time zone, set in the Configuration dialog.");

	QWidget* topWidget;
	if (title.isEmpty())
		topWidget = this;
	else
	{
		QBoxLayout* layout = new QVBoxLayout(this);
		layout->setMargin(0);
		layout->setSpacing(0);
		topWidget = new QGroupBox(title, this);
		layout->addWidget(topWidget);
	}
	mDeferring = mode & DEFER_TIME;
	mButtonGroup = new ButtonGroup(this);
	connect(mButtonGroup, SIGNAL(buttonSet(QAbstractButton*)), SLOT(slotButtonSet(QAbstractButton*)));
	QVBoxLayout* topLayout = new QVBoxLayout(topWidget);
	topLayout->setSpacing(KDialog::spacingHint());
	topLayout->setMargin(title.isEmpty() ? 0 : KDialog::marginHint());

	// At time radio button/label
	mAtTimeRadio = new RadioButton((mDeferring ? i18nc("@option:radio", "Defer to date/time:") : i18nc("@option:radio", "At date/time:")), topWidget);
	mAtTimeRadio->setFixedSize(mAtTimeRadio->sizeHint());
	mAtTimeRadio->setWhatsThis(mDeferring ? i18nc("@info:whatsthis", "Reschedule the alarm to the specified date and time.")
	                                      : i18nc("@info:whatsthis", "Specify the date, or date and time, to schedule the alarm."));
	mButtonGroup->addButton(mAtTimeRadio);

	// Date edit box
	mDateEdit = new DateEdit(topWidget);
	connect(mDateEdit, SIGNAL(dateEntered(const QDate&)), SLOT(dateTimeChanged()));
	mDateEdit->setWhatsThis(i18nc("@info:whatsthis",
	      "<para>Enter the date to schedule the alarm.</para>"
	      "<para>%1</para>", (mDeferring ? tzText : recurText)));
	mAtTimeRadio->setFocusWidget(mDateEdit);

	// Time edit box and Any time checkbox
	KHBox* timeBox = new KHBox(topWidget);
	timeBox->setSpacing(2*KDialog::spacingHint());
	mTimeEdit = new TimeEdit(timeBox);
	mTimeEdit->setFixedSize(mTimeEdit->sizeHint());
	connect(mTimeEdit, SIGNAL(valueChanged(int)), SLOT(dateTimeChanged()));
	mTimeEdit->setWhatsThis(i18nc("@info:whatsthis",
	      "<para>Enter the time to schedule the alarm.</para>"
	      "<para>%1</para>"
	      "<para>%2</para>", (mDeferring ? tzText : recurText), TimeSpinBox::shiftWhatsThis()));

	mAnyTime = -1;    // current status is uninitialised
	if (mode == DEFER_TIME)
	{
		mAnyTimeAllowed = false;
		mAnyTimeCheckBox = 0;
	}
	else
	{
		mAnyTimeAllowed = true;
		mAnyTimeCheckBox = new CheckBox(i18nc("@option:check", "Any time"), timeBox);
		mAnyTimeCheckBox->setFixedSize(mAnyTimeCheckBox->sizeHint());
		connect(mAnyTimeCheckBox, SIGNAL(toggled(bool)), SLOT(slotAnyTimeToggled(bool)));
		mAnyTimeCheckBox->setWhatsThis(i18nc("@info:whatsthis",
		      "Check to specify only a date (without a time) for the alarm. The alarm will trigger at the first opportunity on the selected date."));
	}

	// 'Time from now' radio button/label
	mAfterTimeRadio = new RadioButton((mDeferring ? i18nc("@option:radio", "Defer for time interval:") : i18nc("@option:radio", "Time from now:")), topWidget);
	mAfterTimeRadio->setFixedSize(mAfterTimeRadio->sizeHint());
	mAfterTimeRadio->setWhatsThis(mDeferring ? i18nc("@info:whatsthis", "Reschedule the alarm for the specified time interval after now.")
	                                         : i18nc("@info:whatsthis", "Schedule the alarm after the specified time interval from now."));
	mButtonGroup->addButton(mAfterTimeRadio);

	// Delay time spin box
	mDelayTimeEdit = new TimeSpinBox(1, maxDelayTime, topWidget);
	mDelayTimeEdit->setValue(1439);
	mDelayTimeEdit->setFixedSize(mDelayTimeEdit->sizeHint());
	connect(mDelayTimeEdit, SIGNAL(valueChanged(int)), SLOT(delayTimeChanged(int)));
	mDelayTimeEdit->setWhatsThis(mDeferring ? i18nc("@info:whatsthis", "<para>%1</para><para>%2</para>", i18n_TimeAfterPeriod(), TimeSpinBox::shiftWhatsThis())
	                                        : i18nc("@info:whatsthis", "<para>%1</para><para>%2</para><para>%3</para>", i18n_TimeAfterPeriod(), recurText, TimeSpinBox::shiftWhatsThis()));
	mAfterTimeRadio->setFocusWidget(mDelayTimeEdit);

	// Set up the layout, either narrow or wide
	QGridLayout* grid = new QGridLayout();
	grid->setMargin(0);
	topLayout->addLayout(grid);
	if (mDeferring)
	{
		grid->addWidget(mAtTimeRadio, 0, 0);
		grid->addWidget(mDateEdit, 0, 1, Qt::AlignLeft);
		grid->addWidget(timeBox, 1, 1, Qt::AlignLeft);
		grid->setColumnStretch(2, 1);
		topLayout->addStretch();
		QHBoxLayout* layout = new QHBoxLayout();
		topLayout->addLayout(layout);
		layout->addWidget(mAfterTimeRadio);
		layout->addWidget(mDelayTimeEdit);
		layout->addStretch();
	}
	else
	{
		grid->addWidget(mAtTimeRadio, 0, 0, Qt::AlignLeft);
		grid->addWidget(mDateEdit, 0, 1, Qt::AlignLeft);
		grid->addWidget(timeBox, 0, 2, Qt::AlignLeft);
		grid->setRowStretch(1, 1);
		grid->addWidget(mAfterTimeRadio, 2, 0, Qt::AlignLeft);
		grid->addWidget(mDelayTimeEdit, 2, 1, Qt::AlignLeft);

		// Time zone selection push button
		mTimeZoneButton = new PushButton(i18nc("@action:button", "Time Zone..."), topWidget);
		connect(mTimeZoneButton, SIGNAL(clicked()), SLOT(showTimeZoneSelector()));
		mTimeZoneButton->setWhatsThis(i18nc("@info:whatsthis",
		      "Choose a time zone for this alarm which is different from the default time zone set in KAlarm's configuration dialog."));
		grid->addWidget(mTimeZoneButton, 2, 2, 1, 2, Qt::AlignRight);

		grid->setColumnStretch(2, 1);
		topLayout->addStretch();

		QHBoxLayout* layout = new QHBoxLayout();
		topLayout->addLayout(layout);
		layout->setSpacing(2*KDialog::spacingHint());

		// Time zone selector
		mTimeZoneBox = new KHBox(topWidget);   // this is to control the QWhatsThis text display area
		mTimeZoneBox->setMargin(0);
		mTimeZoneBox->setSpacing(KDialog::spacingHint());
		QLabel* label = new QLabel(i18nc("@label:listbox", "Time zone:"), mTimeZoneBox);
		mTimeZone = new TimeZoneCombo(mTimeZoneBox);
		mTimeZone->setMaxVisibleItems(15);
		connect(mTimeZone, SIGNAL(activated(int)), SLOT(slotTimeZoneChanged()));
		mTimeZoneBox->setWhatsThis(i18nc("@info:whatsthis", "Select the time zone to use for this alarm."));
		label->setBuddy(mTimeZone);
		layout->addWidget(mTimeZoneBox);

		// Time zone checkbox
		mNoTimeZone = new CheckBox(i18nc("@option:check", "Ignore time zone"), topWidget);
		connect(mNoTimeZone, SIGNAL(toggled(bool)), SLOT(slotTimeZoneToggled(bool)));
		mNoTimeZone->setWhatsThis(i18nc("@info:whatsthis",
		                                "<para>Check to use the local computer time, ignoring time zones.</para>"
		                                "<para>You are recommended not to use this option if the alarm has a "
		                                "recurrence specified in hours/minutes. If you do, the alarm may "
		                                "occur at unexpected times after daylight saving time shifts.</para>"));
		layout->addWidget(mNoTimeZone);
		layout->addStretch();

		// Initially show only the time zone button, not time zone selector
		mTimeZoneBox->hide();
		mNoTimeZone->hide();
	}

	// Initialise the radio button statuses
	mAtTimeRadio->setChecked(true);
	slotButtonSet(mAtTimeRadio);

	// Timeout every minute to update alarm time fields.
	MinuteTimer::connect(this, SLOT(updateTimes()));
}
Exemplo n.º 25
0
bool CUpnpBrowserGui::selectItem(std::string id)
{
	bool loop = true;
	bool endall = false;
	bool changed = true;
	bool rchanged = true;
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;
	std::vector<UPnPEntry> *entries;
	unsigned int index, selected, dirnum;

	index = 0;
	selected = 0;
	dirnum = 0;
	entries = NULL;

	while (loop)
	{
		updateTimes();		
		
		if (rchanged)
		{
			if (entries)
				delete entries;
			
			entries = NULL;

			std::list<UPnPAttribute>attribs;
			std::list<UPnPAttribute>results;
			std::list<UPnPAttribute>::iterator i;
			std::stringstream sindex;
			std::stringstream scount;
			unsigned int returned = 0;

			bool rfound = false;
			bool nfound = false;
			bool tfound = false;

			sindex << index;
			scount << m_listmaxshow;

			attribs.push_back(UPnPAttribute("ObjectID", id));
			attribs.push_back(UPnPAttribute("BrowseFlag", "BrowseDirectChildren"));
			attribs.push_back(UPnPAttribute("Filter", "*"));
			attribs.push_back(UPnPAttribute("StartingIndex", sindex.str()));
			attribs.push_back(UPnPAttribute("RequestedCount", scount.str()));
			attribs.push_back(UPnPAttribute("SortCriteria", ""));

			results = m_devices[m_selecteddevice].SendSOAP("urn:schemas-upnp-org:service:ContentDirectory:1", "Browse", attribs);
			for (i = results.begin(); i != results.end(); i++)
			{
				if (i->first == "NumberReturned")
				{
					returned = atoi(i->second.c_str());
					nfound = true;
				}
				if (i->first == "TotalMatches")
				{
					dirnum = atoi(i->second.c_str());
					tfound = true;
				}
				if (i->first == "Result")
				{
					entries = decodeResult(i->second);
					rfound = true;
				}
			}
			if (!entries)
				return endall;
			if (!nfound || !tfound || !rfound)
			{
				delete entries;
				return endall;
			}
			if (returned != entries->size())
			{
				delete entries;
				return endall;
			}

			if (returned == 0)
			{
				delete entries;
				return endall;
			}
			rchanged=false;
			changed=true;
		}

		if (changed)
		{
			paintItem(entries, selected - index, dirnum - index, index);
			changed = false;
		}
		
		m_frameBuffer->blit();

		g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display
		neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat;

		if( msg == CRCInput::RC_timeout)
		{
			// nothing
		}
		else if(msg == CRCInput::RC_home)
		{
			loop = false;
			endall = true;
		}
		else if(msg == CRCInput::RC_left)
		{
			loop = false;
		}

		else if (msg_repeatok == CRCInput::RC_up && selected > 0)
		{
			selected--;
			if (selected < index)
			{
				index -= m_listmaxshow;
				rchanged = true;
			}
			changed = true;
		}

		else if( (msg == CRCInput::RC_yellow || (int) msg == g_settings.key_channelList_pageup) && selected > 0)
		{
			if (index > 0)
			{
				index-=m_listmaxshow;
				selected-=m_listmaxshow;
				rchanged=true;
			}
			else
				selected=0;
			changed = true;
		}
		else if (msg_repeatok == CRCInput::RC_down && selected + 1 < dirnum)
		{
			selected++;
			if (selected + 1 > index + m_listmaxshow)
			{
				index += m_listmaxshow;
				rchanged = true;
			}
			changed=true;
		}
		else if( (msg == CRCInput::RC_green || (int) msg == g_settings.key_channelList_pagedown)&& selected + 1 < dirnum)
		{
			if (index < ((dirnum - 1) / m_listmaxshow) * m_listmaxshow)
			{
				index += m_listmaxshow;
				selected += m_listmaxshow;
				if (selected + 1 >= dirnum)
					selected = dirnum - 1;
				rchanged = true;
			}
			else
				selected = dirnum - 1;
			changed = true;
		}
		else if(msg == CRCInput::RC_right)
		{
			if ((*entries)[selected - index].isdir)
			{
				endall = selectItem((*entries)[selected - index].id);
				if (endall)
					loop = false;
			}
			changed = true;
		}
		else if(msg == CRCInput::RC_ok)
		{
			if (!(*entries)[selected - index].isdir)
			{
				m_folderplay = false;
				
				int preferred = (*entries)[selected - index].preferred;
				if (preferred != -1)
				{
					std::string protocol, prot, network, mime, additional;
					protocol=(*entries)[selected - index].resources[preferred].protocol;
					splitProtocol(protocol, prot, network, mime, additional);
					
					if (mime == "audio/mpeg")
					{
						CAudioPlayerGui tmpAudioPlayerGui;
			
						CAudiofileExt audiofile((*entries)[selected - index].resources[preferred].url, CFile::EXTENSION_MP3);
						tmpAudioPlayerGui.addToPlaylist(audiofile);
						tmpAudioPlayerGui.exec(NULL, "urlplayback");
					}
					else if ((mime == "image/gif") || (mime == "image/jpeg"))
					{
						CPictureViewerGui tmpPictureViewerGui;
						CPicture pic;
						struct stat statbuf;
						
						pic.Filename = (*entries)[selected - index].resources[preferred].url;
						std::string tmp = (*entries)[selected - index].resources[preferred].url.substr((*entries)[selected - index].resources[preferred].url.rfind('/') + 1);
						pic.Name = tmp.substr(0, tmp.rfind('.'));
						pic.Type = tmp.substr(tmp.rfind('.') + 1);
						
						if(stat(pic.Filename.c_str(), &statbuf) != 0)
							printf("stat error");
						pic.Date = statbuf.st_mtime;
										
						tmpPictureViewerGui.addToPlaylist(pic);
						tmpPictureViewerGui.exec(NULL, "urlplayback");

						changed = true;
					}

					else if (mime.substr(0,6) == "video/")
					{
						m_frameBuffer->ClearFrameBuffer();
						m_frameBuffer->blit();	
						
						CFile file;
						file.Name = (*entries)[selected - index].resources[preferred].url.c_str(); //FIXME
						
						CMoviePlayerGui tmpMoviePlayerGui;
						tmpMoviePlayerGui.addToPlaylist(file);
						tmpMoviePlayerGui.exec(NULL, "urlplayback");
						
						changed = true;
					}
					
					m_playing_entry = (*entries)[selected - index];
				}

			} 
			else 
			{
				m_folderplay = true;
				m_playfolder = (*entries)[selected - index].id;
				m_playid = 0;
				playnext();
			}
			
			changed = true;
		}
		else if( msg == CRCInput::RC_red)
		{
			if(CAudioPlayer::getInstance()->getState() != CBaseDec::STOP)
				CAudioPlayer::getInstance()->stop();
			m_folderplay = false;
		}
		else if(msg == NeutrinoMessages::RECORD_START ||
			msg == NeutrinoMessages::ZAPTO ||
			msg == NeutrinoMessages::STANDBY_ON ||
			msg == NeutrinoMessages::SHUTDOWN ||
			msg == NeutrinoMessages::SLEEPTIMER)
		{
			loop = false;
			g_RCInput->postMsg(msg, data);
		}

		else if(msg == NeutrinoMessages::EVT_TIMER)
		{
			CNeutrinoApp::getInstance()->handleMsg( msg, data );
		}
		else
		{
			if( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
				loop = false;
			changed = true;
		}

		if (m_folderplay && (CAudioPlayer::getInstance()->getState() == CBaseDec::STOP))
			playnext();
								
		m_frameBuffer->blit();	
	}
	
	if (entries)
		delete entries;
	
	m_frameBuffer->ClearFrameBuffer();
	m_frameBuffer->blit();
	
	return endall;
}
Exemplo n.º 26
0
bool CUpnpBrowserGui::selectItem(std::string id)
{
	bool loop = true;
	bool endall = false;
	bool changed = true;
	bool rchanged = true;
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;
	std::vector<UPnPEntry> *entries;
	unsigned int index, selected, dirnum;

	index=0;
	selected=0;
	dirnum=0;
	entries=NULL;

	while (loop)
	{
		updateTimes();
		if (rchanged)
		{
			if (entries)
				delete entries;
			entries=NULL;

			std::list<UPnPAttribute>attribs;
			std::list<UPnPAttribute>results;
			std::list<UPnPAttribute>::iterator i;
			std::stringstream sindex;
			std::stringstream scount;
			unsigned int returned = 0;

			bool rfound = false;
			bool nfound = false;
			bool tfound = false;

			sindex << index;
			scount << m_listmaxshow;

			attribs.push_back(UPnPAttribute("ObjectID", id));
			attribs.push_back(UPnPAttribute("BrowseFlag", "BrowseDirectChildren"));
			attribs.push_back(UPnPAttribute("Filter", "*"));
			attribs.push_back(UPnPAttribute("StartingIndex", sindex.str()));
			attribs.push_back(UPnPAttribute("RequestedCount", scount.str()));
			attribs.push_back(UPnPAttribute("SortCriteria", ""));
#if 0
			try
			{
				results=m_devices[m_selecteddevice].SendSOAP("urn:schemas-upnp-org:service:ContentDirectory:1", "Browse", attribs);
			}
			catch (std::runtime_error error)
			{
				ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, error.what(), CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw");
				if (entries)
					delete entries;
				return endall;
			}
#endif
			results=m_devices[m_selecteddevice].SendSOAP("urn:schemas-upnp-org:service:ContentDirectory:1", "Browse", attribs);
			for (i=results.begin(); i!=results.end(); i++)
			{
				if (i->first=="NumberReturned")
				{
					returned=atoi(i->second.c_str());
					nfound=true;
				}
				if (i->first=="TotalMatches")
				{
					dirnum=atoi(i->second.c_str());
					tfound=true;
				}
				if (i->first=="Result")
				{
					entries=decodeResult(i->second);
					rfound=true;
				}
			}
			if (!entries)
				return endall;
			if (!nfound || !tfound || !rfound)
			{
				delete entries;
				return endall;
			}
			if (returned != entries->size())
			{
				delete entries;
				return endall;
			}

			if (returned == 0)
			{
				delete entries;
				return endall;
			}
			rchanged=false;
			changed=true;
		}

		if (changed)
		{
			paintItem(entries, selected - index, dirnum - index, index);
			changed=false;
		}

		g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display
		neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat;

		if( msg == CRCInput::RC_timeout)
		{
			// nothing
		}
		else if(msg == CRCInput::RC_home)
		{
			loop=false;
			endall=true;
		}
		else if(msg == CRCInput::RC_left)
		{
			loop=false;
		}

		else if (msg_repeatok == CRCInput::RC_up && selected > 0)
		{
			selected--;
			if (selected < index)
			{
				index-=m_listmaxshow;
				rchanged=true;
			}
			changed=true;
		}

		else if(msg == CRCInput::RC_green && selected > 0)
		{
			if (index > 0)
			{
				index-=m_listmaxshow;
				selected-=m_listmaxshow;
				rchanged=true;
			}
			else
				selected=0;
			changed=true;
		}
		else if (msg_repeatok == CRCInput::RC_down && selected + 1 < dirnum)
		{
			selected++;
			if (selected + 1 > index + m_listmaxshow)
			{
				index+=m_listmaxshow;
				rchanged=true;
			}
			changed=true;
		}
		else if(msg == CRCInput::RC_red && selected + 1 < dirnum)
		{
			if (index < ((dirnum - 1) / m_listmaxshow) * m_listmaxshow)
			{
				index+=m_listmaxshow;
				selected+=m_listmaxshow;
				if (selected + 1 >= dirnum)
					selected=dirnum - 1;
				rchanged=true;
			}
			else
				selected=dirnum - 1;
			changed=true;
		}
		else if(msg == CRCInput::RC_right)
		{
			if ((*entries)[selected - index].isdir)
			{
				endall=selectItem((*entries)[selected - index].id);
				if (endall)
					loop=false;
			}
			changed=true;
		}
		else if(msg == CRCInput::RC_ok)
		{
			if (!(*entries)[selected - index].isdir)
			{
				m_folderplay = false;
				int preferred=(*entries)[selected - index].preferred;
				if (preferred != -1)
				{
					std::string protocol, prot, network, mime, additional;
					protocol=(*entries)[selected - index].resources[preferred].protocol;
					splitProtocol(protocol, prot, network, mime, additional);
					if (mime == "audio/mpeg")
					{
						CAudiofile mp3((*entries)[selected - index].resources[preferred].url, CFile::FILE_MP3);
						CAudioPlayer::getInstance()->play(&mp3, g_settings.audioplayer_highprio == 1);
					}
					else if (mime == "audio/x-vorbis+ogg")
					{
						CAudiofile mp3((*entries)[selected - index].resources[preferred].url, CFile::FILE_OGG);
						CAudioPlayer::getInstance()->play(&mp3, g_settings.audioplayer_highprio == 1);
					}
					m_playing_entry = (*entries)[selected - index];
#if 0
// #ifdef ENABLE_PICTUREVIEWER
					else if ((mime == "image/gif") || (mime == "image/jpeg"))
					{
						CPictureViewer *viewer = new CPictureViewer();
						bool loop=true;
						viewer->SetScaling((CPictureViewer::ScalingMode)g_settings.picviewer_scaling);
						viewer->SetVisible(g_settings.screen_StartX, g_settings.screen_EndX, g_settings.screen_StartY, g_settings.screen_EndY);

						if(g_settings.video_Format==1)
							viewer->SetAspectRatio(16.0/9);
						else if(g_settings.video_Format==0)
						{
							CControldClient cdc;
							cdc.setVideoFormat(CControldClient::VIDEOFORMAT_4_3);
							viewer->SetAspectRatio(4.0/3);
						}
						else
							viewer->SetAspectRatio(4.0/3);

						m_frameBuffer->setMode(720, 576, 16);
						m_frameBuffer->setTransparency(0);
						viewer->ShowImage((*entries)[selected - index].resources[preferred].url, true);
						while (loop)
						{
							g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display

							if( msg == CRCInput::RC_home)
								loop=false;
						}
						m_frameBuffer->setMode(720, 576, 8 * sizeof(fb_pixel_t));
						m_frameBuffer->setBlendLevel(g_settings.gtx_alpha1, g_settings.gtx_alpha2);
						m_frameBuffer->ClearFrameBuffer();
						delete viewer;
					}
// #endif
#endif
				}

			} 
Exemplo n.º 27
0
void Game::play(string path)
{
    pathTest=path;
    ini();

    //SDL_EnableKeyRepeat(10, 0);


    playLoop=true;
    fadingToLeave=false;

    while (playLoop)
    {

        if(m_chat.boxOpened())
            m_chat.checkKeyboard();
        else
        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
                case SDL_QUIT:
                fadingToLeave=true;
                playLoop=false;
                command="quit";
                break;

                case SDL_MOUSEMOTION:
                m_camera.onMouseMotion(event.motion);
                break;

                case SDL_MOUSEBUTTONUP:
                if(event.button.button==SDL_BUTTON_LEFT)
                {
                    if(m_mode=="play")
                    {
                        if(playerList[0]->getLife()>0)
                        {
                            Vector3D dir=(m_camera.getTarget()-(playerList[0]->getPos()+Vector3D(0,0,1))).normalize();

                            if(castSpell(playerList[0],"rope",dir))
                            {
                                infosSocket s;
                                s.confirmationID=-1;
                                s.type=2;

                                s.variable[1]=playerList[0]->getPos().X;
                                s.variable[2]=playerList[0]->getPos().Y;
                                s.variable[3]=playerList[0]->getPos().Z;
                                s.variable[4]=dir.X;
                                s.variable[5]=dir.Y;
                                s.variable[6]=dir.Z;

                                m_online->sendSocket(s);//add socket to queue
                            }
                        }

                    }
                    else if(m_mode=="spectate")
                    {
                        switchSpectate(1);
                    }
                }
                if(event.button.button==SDL_BUTTON_RIGHT)
                {
                    if(m_mode=="play")
                    {
                        if(playerList[0]->getLife()>0)
                        {
                            playerList[0]->unlinkRope();

                            infosSocket s;
                            s.confirmationID=-1;
                            s.type=3;
                            m_online->sendSocket(s);//add socket to queue
                        }
                    }
                    else if(m_mode=="spectate")
                    {
                        switchSpectate(-1);
                    }
                }
                if(event.button.button==SDL_BUTTON_WHEELUP)
                {
                    Video::getInstance()->incrFOV(1);
                }
                if(event.button.button==SDL_BUTTON_WHEELDOWN)
                {
                    Video::getInstance()->incrFOV(-1);
                }
                break;

                case SDL_KEYDOWN:
                switch(event.key.keysym.sym)
                {
                    case SDLK_KP_ENTER:
                    if(m_chat.active())
                        m_chat.openTextBox(playerList[0]->getIdOnline(),0.1);
                    break;
                    case SDLK_RETURN:
                    if(m_chat.active())
                        m_chat.openTextBox(playerList[0]->getIdOnline(),0.1);
                    break;
                    case SDLK_a:
                    playerList[0]->pressKey(LEFT,true);
                    break;
                    case SDLK_d:
                    playerList[0]->pressKey(RIGHT,true);
                    break;
                    case SDLK_w:
                    playerList[0]->pressKey(UP,true);
                    break;
                    case SDLK_s:
                    playerList[0]->pressKey(DOWN,true);
                    break;
                    case SDLK_e:
                    playerList[0]->pressKey(KEY_E,true);
                    break;
                    case SDLK_SPACE:
                    if(playerList[0]->getLife()>0)
                    {
                        if(shiftPushed)
                        {
                            if(castSpell(playerList[0],"longjump"))
                            {
                                infosSocket s;
                                s.confirmationID=-1;
                                s.type=15;

                                s.variable[1]=playerList[0]->getPos().X;
                                s.variable[2]=playerList[0]->getPos().Y;
                                s.variable[3]=playerList[0]->getPos().Z;

                                m_online->sendSocket(s);//add socket to queue
                            }

                        }
                        else
                            castSpell(playerList[0],"jump");
                    }
                    break;

                    case SDLK_LSHIFT:
                        playerList[0]->setGasing(true);
                        shiftPushed=true;
                    break;
                    default:
                    break;
                }
                break;

                case SDL_KEYUP:
                switch(event.key.keysym.sym)
                {
                    case SDLK_KP_ENTER:
                    if(m_chat.active())
                        m_chat.enterUp();
                    break;
                    case SDLK_RETURN:
                    if(m_chat.active())
                        m_chat.enterUp();
                    break;
                    case SDLK_ESCAPE:
                    fadingToLeave=true;
                    command="menu";
                    break;
                    case SDLK_a:
                    playerList[0]->pressKey(LEFT,false);
                    break;
                    case SDLK_d:
                    playerList[0]->pressKey(RIGHT,false);
                    break;
                    case SDLK_w:
                    playerList[0]->pressKey(UP,false);
                    break;
                    case SDLK_s:
                    playerList[0]->pressKey(DOWN,false);
                    break;
                    case SDLK_e:
                    playerList[0]->pressKey(KEY_E,false);
                    break;
                    case SDLK_r:
                    if(playerList.size()==1 &&
                       (!Online::getInstance()->active() || Online::getInstance()->inControl()))//if youre alone its ok
                    {
                        infosSocket s;
                        s.confirmationID=m_online->nextConfirmationID();
                        s.type=6;
                        m_online->sendSocket(s);//add socket to queue


                        Map::getInstance()->restart();

                        Interface::getInstance()->setTarget(playerList[0]);
                        m_camera.setCible(playerList[0]);
                        m_camera.setMode("play");
                        m_mode="play";

                        m_chat.newMessage("Map reset.",-2);
                    }
                    break;
                    case SDLK_k:
                    break;
                    case SDLK_c:
                    if(grabCursor)
                    {
                        SDL_ShowCursor(SDL_ENABLE);//pas de curseur
                        SDL_WM_GrabInput(SDL_GRAB_OFF);
                        grabCursor=false;
                    }
                    else
                    {
                        SDL_ShowCursor(SDL_DISABLE);//pas de curseur
                        SDL_WM_GrabInput(SDL_GRAB_ON);
                        grabCursor=true;
                    }
                    break;
                    case SDLK_LSHIFT:
                        playerList[0]->setGasing(false);
                        shiftPushed=false;
                    break;
                    case SDLK_SPACE:
                    if(playerList[0]->getLife()>0)
                    {
                        if(shiftPushed)
                        {
                            if(castSpell(playerList[0],"longjump"))
                            {
                                infosSocket s;
                                s.confirmationID=-1;
                                s.type=15;

                                s.variable[1]=playerList[0]->getPos().X;
                                s.variable[2]=playerList[0]->getPos().Y;
                                s.variable[3]=playerList[0]->getPos().Z;

                                m_online->sendSocket(s);//add socket to queue
                            }

                        }
                        else
                            castSpell(playerList[0],"jump");
                    }
                    break;
                    default:
                    break;
                }
                break;
            }
        }

        //update stuff
        updateTimes();
        updateMultiplayer();
        m_online->update();

        Gsounds::getInstance()->update(m_camera.getPos().toLeft(),Vector3D(0,0,0),m_camera.getDir().toLeft(),Vector3D(0,0,1));

        m_video->update(ft);
        Map::getInstance()->update(ft);

        Effects::getInstance()->update(ft);

        Tracer::getInstance()->traceCerr("debug","1");

        Interface::getInstance()->setMode(m_mode);
        Interface::getInstance()->update(ft);
        handleCommands();
        handleTracer();

        Tracer::getInstance()->traceCerr("debug","2");

        updateCamMode();

        //you just died
        if(playerList[0]->getLife()<=0 && !alreadyDead)
        {
            alreadyDead=true;
            Interface::getInstance()->warning("../data/textures/interface/warning/died.png",0.03);


            //send chat msg
            stringstream ss;
            int dc=playerList[0]->getDeathCause();

            if(dc==0)
                ss << playerList[0]->getOnlineName() << " mysteriously died.";
            else if(dc==1)
                ss << playerList[0]->getOnlineName() << " burned to death.";
            else if(dc==2)
                ss << playerList[0]->getOnlineName() << " committed suicide.";
            else if(dc==3)
                ss << playerList[0]->getOnlineName() << " exploded in pieces.";

            char* tempChar=stringtochar(ss.str());
            m_chat.newMessage(tempChar,-2);
            delete tempChar;
        }
        else if(playerList[0]->getLife()>0)
            alreadyDead=false;

        Tracer::getInstance()->traceCerr("debug","3");

        //endlevel
        if(checkEndLevel())
            endLevel();

        //crosshair
        Map::getInstance()->simulateRopeForCrosshair(playerList[0],
                                       (m_camera.getTarget()-(playerList[0]->getPos()+Vector3D(0,0,1))).normalize(),
                                       Interface::getInstance()->getCrosshair());

        draw();

        m_video->afterDraw();

        //fps calcul
        m_fps++;
        m_fpsTime.couler();
        if(m_fpsTime.ecouler(1000))
        {
            Interface::getInstance()->setFPS(m_fps);
            m_fps=0;
            m_fpsTime.reset();
        }

        Tracer::getInstance()->traceCerr("debug","8");

        SDL_Delay(10);



        if(fadingToLeave)
        {
            if(Video::getInstance()->getFade()->getFading()==false)
            {
                Video::getInstance()->getFade()->setR(0);
                Video::getInstance()->getFade()->setG(0);
                Video::getInstance()->getFade()->setB(0);
                Video::getInstance()->getFade()->startFadeIn();
            }
            if(Video::getInstance()->getFade()->getAlpha()>=1)
            {
                playLoop=false;
                fadingToLeave=false;
            }
        }
    }


    close();
}