void LSWProgressTimer::scheduleProgressTimer(float dt)
{
    auto progressTimer = (ProgressTimer *)getChildByTag(100);
    progressTimer->setPercentage(progressTimer->getPercentage() + 10);
    if (progressTimer->getPercentage() >= 100)
    {
        unscheduleAllSelectors();
    }
}
Example #2
0
void CSlider::pointFromValue(int nValue, CCPoint& tOutPoint)
{
	float fPercentage = getPercentage();
	switch( m_eDirection )
	{
	case eProgressBarDirectionLeftToRight:
		{
			tOutPoint.x = m_tProgressSize.width * fPercentage + (m_tCenterPoint.x - m_tProgressSize.width / 2);
			tOutPoint.y = m_tCenterPoint.y;
		}
		break;
	case eProgressBarDirectionRightToLeft:
		{
			tOutPoint.x = m_tProgressSize.width - (m_tProgressSize.width * fPercentage) + (m_tCenterPoint.x - m_tProgressSize.width / 2);
			tOutPoint.y = m_tCenterPoint.y;
		}
		break;
	case eProgressBarDirectionBottomToTop:
		{
			tOutPoint.x = m_tCenterPoint.x;
			tOutPoint.y = m_tProgressSize.height * fPercentage + (m_tCenterPoint.y - m_tProgressSize.height / 2);
		}
		break;
	case eProgressBarDirectionTopToBottom:
		{
			tOutPoint.x = m_tCenterPoint.x;
			tOutPoint.y = m_tProgressSize.height - (m_tProgressSize.height * fPercentage) + (m_tCenterPoint.y - m_tProgressSize.height / 2);
		}
		break;
	default:
		break;
	}
}
Example #3
0
void ProgressBarNode::GoToPercentage( float val, float duration /*=0.f*/,ProgressChangedHandler* handler/*=NULL*/ )
{
	if (handler!=NULL)
	{
		mProgressChangedHandler=handler;
	}

	float progressDuration = Math::IsZero(duration) ? (val / 100.f * mProtoData.duration()) : duration;

	CCProgressFromTo* progressTo = CCProgressFromTo::create(progressDuration,getPercentage(),val);
	CC_NEW_CALLFUNC_MEMBER(callback, ProgressBarNode,float, this, OnAchievePercentageCallback,val);
	runAction(CCSequence::createWithTwoActions(progressTo, callback));
}
Example #4
0
QList<QList<float> > Graphics::adjustValues()
{
    QList < QList < float > > retorno;

    retorno = data;

    for (int i = 0; i < data.length(); i++){
        for (int j = 0; j < data[0].length(); j++){
            retorno[i][j] = data[i][j] * getPercentage() / 100;
        }
    }

    return retorno;
}
void Assessment::displayList(QWidget* wgtNav)
{
    stringstream outString;
    QListWidget* listWidget = wgtNav->findChild<QListWidget*>("lwgtAssess");
    QListWidget* listPercent = wgtNav->findChild<QListWidget*>("lwgtPercent");

    listWidget->clear();
    listPercent->clear();
    listWidget->addItem(QString::fromStdString(name));
    outString << fixed << setprecision(2) << getPercentage() << "%";
    listPercent->addItem(QString::fromStdString(outString.str()));
    listWidget->addItem("------------------------");
    listPercent->addItem("---");
    for (iter = opps.begin(); iter != opps.end(); iter++)
    {
        listWidget->addItem(QString::fromStdString((*iter)->getAssessName()));
        outString.str("");
        outString << fixed << setprecision(2) << (*iter)->getPercentage() << "%";
        listPercent->addItem(QString::fromStdString(outString.str()));
    }
}
Example #6
0
void CProgressBar::getScissorRectByPercentage(CCRect& tRect)
{
	float fPercentage = getPercentage();
	switch( m_eDirection )
	{
	case eProgressBarDirectionLeftToRight:
		{
			tRect.origin = CCPointZero;
			tRect.size.width = m_tProgressSize.width * fPercentage;
			tRect.size.height = m_tProgressSize.height;
		}
		break;
	case eProgressBarDirectionRightToLeft:
		{
			tRect.origin.x = m_tProgressSize.width - m_tProgressSize.width * fPercentage;
			tRect.size.width = m_tProgressSize.width * fPercentage;
			tRect.origin.y = 0;
			tRect.size.height = m_tProgressSize.height;
		}
		break;
	case eProgressBarDirectionBottomToTop:
		{
			tRect.origin.x = 0;
			tRect.origin.y = m_tProgressSize.height - m_tProgressSize.height * fPercentage;
			tRect.size.width = m_tProgressSize.width;
			tRect.size.height = m_tProgressSize.height * fPercentage;
		}
		break;
	case eProgressBarDirectionTopToBottom:
		{
			tRect.origin = CCPointZero;
			tRect.size.width = m_tProgressSize.width;
			tRect.size.height = m_tProgressSize.height * fPercentage;
		}
		break;
	default:
		break;
	}
}
Example #7
0
	void TransferApi::onTick(const Transfer* aTransfer, bool aIsDownload) noexcept {
		auto t = getTransfer(aTransfer->getToken());
		if (!t) {
			return;
		}

		t->setSpeed(aTransfer->getAverageSpeed());
		t->setBytesTransferred(aTransfer->getPos());
		t->setTimeLeft(aTransfer->getSecondsLeft());

		uint64_t timeSinceStarted = GET_TICK() - t->getStarted();
		if (timeSinceStarted < 1000) {
			t->setStatusString("Starting...");
		} else {
			t->setStatusString(STRING_F(RUNNING_PCT, t->getPercentage()));
		}

		view.onItemUpdated(t, { 
			TransferUtils::PROP_STATUS, TransferUtils::PROP_BYTES_TRANSFERRED, 
			TransferUtils::PROP_SPEED, TransferUtils::PROP_SECONDS_LEFT
		});
	}
string Assessment::toString(int n)
{
	stringstream outString;
	for (int i = 0; i < n; i++)
	{
		outString << "---";
	}
	outString << name << " : " << getPercentage() << "% : " << getMark()
		<< "/" << getTotal() << " : " << getWeightedMark() << "/" << getWeight()
		<< endl;

	for (iter = opps.begin(); iter != opps.end(); iter++)
	{
		outString << (*iter)->toString(n + 1);
	}
	//for (int i = 0; i < n; i++)
	//{
	//	outString << "---";
	//}	
	//outString << "_______________________________\n";
	return outString.str();	
}
void Assessment::listDetail(QWidget* wgtDetail)
{
    QListWidget* listTitles = wgtDetail->findChild<QListWidget*>("lwgtTitles");
    QListWidget* listValues = wgtDetail->findChild<QListWidget*>("lwgtValues");
    wgtDetail->findChild<QDoubleSpinBox*>("sedMark")->hide();
    wgtDetail->findChild<QLabel*>("lblName")->show();
    wgtDetail->findChild<QLabel*>("lblMark")->hide();
    wgtDetail->findChild<QLabel*>("lblTotal")->hide();
    wgtDetail->findChild<QLabel*>("lblName")->setText(QString::fromStdString(getAssessName()));
    stringstream outString;
    listTitles->clear();
    listValues->clear();

    listTitles->addItem(QString::fromStdString("Current Mark:"));
            outString << fixed << setprecision(2) << getPercentage() << "%";
    listValues->addItem(QString::fromStdString(outString.str()));

    listTitles->addItem(QString::fromStdString("Weighted:"));
            outString.str("");
            outString << fixed << setprecision(2) << getWeightedMark() << "/" << getWeight();
    listValues->addItem(QString::fromStdString(outString.str()));
}
Example #10
0
void EventReceiver::checkEvents()
{
    //Need to capture/update each device
    keyboard->capture();
    if (joystick) joystick->capture();

    OIS::JoyStickState joystickState;
    if (joystick) joystickState = joystick->getJoyStickState();
    
#if 0
    if (test_kc == 0)
    {
        test_kc = KeyConfig::getKeyConfig(keyboard, joystickState, deadZone, false);
        if (test_kc)
        {
            dprintf(MY_DEBUG_INFO, "test_kc assigned: %d\n", test_kc->key);
            //assert(0);
        }
    }
    else
    {
        float pressed = test_kc->getPercentage(keyboard, joystickState);
        if (pressed > deadZone)
        {
            dprintf(MY_DEBUG_INFO, "test_kc pressed: %f\n", pressed);
        }
    }
    if (keyboard->isKeyDown(OIS::KC_ESCAPE))
    {
        delete test_kc;
        test_kc = 0;
    }
    

    //printf("%s\n", keyboard->isKeyDown(OIS::KC_K)?"true":"false");
    /*
    printf("Axes: %lu\n", joystickState.mAxes.size());
    for (unsigned int i = 0; i < joystickState.mAxes.size(); i++)
    {
        printf("\t%u: %d (%d)\n", i, joystickState.mAxes[i].abs, joystickState.mAxes[i].rel);
    }
    printf("Sliders:\n");
    for (unsigned int i = 0; i < 4; i++)
    {
        printf("\t%u: %d, %d\n", i, joystickState.mSliders[i].abX, joystickState.mSliders[i].abY);
    }
    */
#else // 0 or 1
    
    if (MenuManager::getInstance()->getMenuInput())
    {
        /*
        if (IS_PRESSED(SWITCH_INPUT))
        {
            MenuManager::getInstance()->clearEventReceiver();
            MenuPageEditor::menuPageEditor->activateAction();
        }
        */
    }
    else
    {
    
        // the real event check

        // mouse
        /*
        mouse->capture();
        const OIS::MouseState mouseState = mouse->getMouseState();
        if (mouseState.buttonDown(OIS::MB_Left))
        {
            printf("mouse button left down\n");
        }

        if (mouseState.buttonDown(OIS::MB_Right))
        {
            printf("mouse button right down\n");
        }

        if (mouseState.buttonDown(OIS::MB_Middle))
        {
            printf("mouse button middle down\n");
        }
        */

        // other
            float perc = 0.f;
            if (IS_PRESSED(BRAKE) && (perc = getPercentage(BRAKE, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
            {
                //dprintf(MY_DEBUG_NOTE, "brake pressed: %f\n", perc);
                Player::getInstance()->setFirstPressed();
                Player::getInstance()->getVehicle()->setTorque(perc/*perc*/);
            }
            else
            if (IS_PRESSED(ACCELERATE) && (perc = getPercentage(ACCELERATE, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
            {
                //dprintf(MY_DEBUG_NOTE, "accelerate pressed: %f\n", perc);
                Player::getInstance()->setFirstPressed();
                Player::getInstance()->getVehicle()->setTorque(-1.0f*perc/*perc*/);
            }
            else
            {
                if (Settings::getInstance()->AIPlayer == false ||
                    Settings::getInstance()->editorMode ||
                    Player::getInstance()->getStarter() == 0)
                {
                    Player::getInstance()->getVehicle()->setTorque(0);
                }
            }

        if (Settings::getInstance()->AIPlayer == false ||
            Settings::getInstance()->editorMode ||
            Player::getInstance()->getStarter() == 0)
        {
            if (IS_PRESSED(CLUTCH) && (perc = getPercentage(CLUTCH, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
            {
                //dprintf(MY_DEBUG_NOTE, "accelerate pressed: %f\n", perc);
                Player::getInstance()->getVehicle()->setClutch(perc*perc);
            }

            const float steerRatePressed = Settings::getInstance()->steerRatePressed; // 0.2f
            float steerRate = Settings::getInstance()->steerRate; // 0.5f
            float desiredSteer = 0.0f;
            perc = 0.0f;
            if (Settings::getInstance()->linearSteering)
            {
                if (IS_PRESSED(LEFT) && (perc = getPercentage(LEFT, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
                {
                    //dprintf(MY_DEBUG_NOTE, "left pressed: %f\n", perc);
                    //Player::getInstance()->getVehicle()->setSteer(-1.0f*perc*perc);
                    desiredSteer = -1.0f*perc;
                }
                else
                if (IS_PRESSED(RIGHT) && (perc = getPercentage(RIGHT, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
                {
                    //dprintf(MY_DEBUG_NOTE, "right pressed: %f\n", perc);
                    //Player::getInstance()->getVehicle()->setSteer(perc*perc);
                    desiredSteer = perc;
                }
                else
                {
                    //Player::getInstance()->getVehicle()->setSteer(0.0f);
                }
                if (perc > Settings::getInstance()->joystickDeadZone)
                {
                    steerRate = steerRatePressed;
                }
            }
            else
            {
                if (IS_PRESSED(LEFT) && (perc = getPercentage(LEFT, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
                {
                    //dprintf(MY_DEBUG_NOTE, "left pressed: %f\n", perc);
                    //Player::getInstance()->getVehicle()->setSteer(-1.0f*perc*perc);
                    desiredSteer = -1.0f*perc*perc;
                }
                else
                if (IS_PRESSED(RIGHT) && (perc = getPercentage(RIGHT, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
                {
                    //dprintf(MY_DEBUG_NOTE, "right pressed: %f\n", perc);
                    //Player::getInstance()->getVehicle()->setSteer(perc*perc);
                    desiredSteer = perc*perc;
                }
                else
                {
                    //Player::getInstance()->getVehicle()->setSteer(0.0f);
                }
                if (perc*perc > Settings::getInstance()->joystickDeadZone)
                {
                    steerRate = steerRatePressed;
                }
            }
            //printf("steer rate: %f\n", steerRate);
            if (lastSteer + steerRate < desiredSteer)
            {
                lastSteer += steerRate;
            }
            else if (lastSteer - steerRate > desiredSteer)
            {
                lastSteer -= steerRate;
            }
            else
            {
                lastSteer = desiredSteer;
            }

            Player::getInstance()->getVehicle()->setSteer(lastSteer);

            if (IS_PRESSED(HANDBRAKE))
            {
                //dprintf(MY_DEBUG_NOTE, "brake pressed\n");
                Player::getInstance()->getVehicle()->setHandbrake(1.0f);
            }
            else
            {
                Player::getInstance()->getVehicle()->setHandbrake(0);
            }

            if (Settings::getInstance()->manualGearShifting)
            {
                if (Settings::getInstance()->sequentialGearShifting)
                {
                    if (IS_PRESSED(GEAR_UP) && getPressed(GEAR_UP))
                    {
                        Player::getInstance()->getVehicle()->incGear();
                    }
                    if (IS_PRESSED(GEAR_DOWN) && getPressed(GEAR_DOWN))
                    {
                        Player::getInstance()->getVehicle()->decGear();
                    }
                }
                else
                {
                    if (IS_PRESSED(GEAR_1))
                    {
                        Player::getInstance()->getVehicle()->setGear(1);
                    }
                    else
                    if (IS_PRESSED(GEAR_2))
                    {
                        Player::getInstance()->getVehicle()->setGear(2);
                    }
                    else
                    if (IS_PRESSED(GEAR_3))
                    {
                        Player::getInstance()->getVehicle()->setGear(3);
                    }
                    else
                    if (IS_PRESSED(GEAR_4))
                    {
                        Player::getInstance()->getVehicle()->setGear(4);
                    }
                    else
                    if (IS_PRESSED(GEAR_5))
                    {
                        Player::getInstance()->getVehicle()->setGear(5);
                    }
                    else
                    if (IS_PRESSED(GEAR_6))
                    {
                        Player::getInstance()->getVehicle()->setGear(6);
                    }
                    else
                    if (IS_PRESSED(GEAR_R))
                    {
                        Player::getInstance()->getVehicle()->setGear(-1);
                    }
                    else
                    {
                        Player::getInstance()->getVehicle()->setGear(0);
                    }
                }
            }
        } // if (Settings::getInstance()->AIPlayer == false || Settings::getInstance()->editorMode)

        if (IS_PRESSED(PHYSICS))
        {
            TheGame::getInstance()->setPhysicsOngoing(!TheGame::getInstance()->getPhysicsOngoing());
        }
        /*else
        {
            TheGame::getInstance()->setPhysicsOngoing(false);
        }*/

        if (IS_PRESSED(FPS_CAMERA))
        {
            dprintf(MY_DEBUG_NOTE, "switch camera\n");
            TheGame::getInstance()->switchCamera();
        }

        if (IS_PRESSED(SWITCH_HUD))
        {
            dprintf(MY_DEBUG_NOTE, "switch hud\n");
            Hud::getInstance()->setVisible(!Hud::getInstance()->getVisible());
        }

        if (IS_PRESSED(LOOK_LEFT) && getPressed(LOOK_LEFT))
        {
            Player::getInstance()->lookLeft(true);
        }
        else if (getReleased(LOOK_LEFT))
        {
            Player::getInstance()->lookLeft(false);
        }

        if (IS_PRESSED(LOOK_RIGHT) && getPressed(LOOK_RIGHT))
        {
            Player::getInstance()->lookRight(true);
        }
        else if (getReleased(LOOK_RIGHT))
        {
            Player::getInstance()->lookRight(false);
        }

        if (IS_PRESSED(CHANGE_VIEW))
        {
            Player::getInstance()->switchToNextView();
        }

        if (IS_PRESSED(OPEN_EDITOR))
        {
            if (Settings::getInstance()->editorMode)
            {
                MenuManager::getInstance()->open(MenuManager::MP_EDITOR);
            }
        }

        if (IS_PRESSED(RESET_VEHICLE))
        {
            Player::getInstance()->resetVehicle(irr::core::vector3df(
                    TheGame::getInstance()->getCamera()->getPosition().X,
                    TheEarth::getInstance()->getHeight(TheGame::getInstance()->getCamera()->getPosition())+2.5f,
                    TheGame::getInstance()->getCamera()->getPosition().Z));
        }

        if (IS_PRESSED(REPAIR_VEHICLE))
        {
            Player::getInstance()->repairVehicle();
        }

        if (IS_PRESSED(SWITCH_INPUT))
        {
            MenuManager::getInstance()->refreshEventReceiver();
            MenuPageEditor::menuPageEditor->refreshAction();
        }

        if (IS_PRESSED(INC_FPS_SPEED))
        {
            TheGame::getInstance()->incFPSSpeed();
        }

        if (IS_PRESSED(DEC_FPS_SPEED))
        {
            TheGame::getInstance()->decFPSSpeed();
        }

        //if (Settings::getInstance()->navigationAssistant == false)
        //{
            if (IS_PRESSED(ROADBOOK_NEXT))
            {
                Player::getInstance()->stepItiner();
                Hud::getInstance()->updateRoadBook();
            }
            else if (IS_PRESSED(ROADBOOK_PREV))
            {
                Player::getInstance()->stepBackItiner();
                Hud::getInstance()->updateRoadBook();
            }
            if (IS_PRESSED(RESET_PARTIAL))
            {
                Player::getInstance()->resetDistance();
            }
        //}

        if (IS_PRESSED(EXIT_TO_MENU))
        {
            MenuManager::getInstance()->open(MenuManager::MP_INGAME);
        }
#ifdef DETECT_MEM_LEAKS
        if (IS_PRESSED(PRINT_MEM_LEAKS))
        {
            VLDReportLeaks();
            //_CrtDumpMemoryLeaks();
            //assert(0);
        }
        if (IS_PRESSED(PRINT_MEM_LEAKS_IRR))
        {
            TheGame::getInstance()->getSmgr()->addTerrainSceneNode("fake/path");
            //_CrtDumpMemoryLeaks();
            //assert(0);
        }
#endif // DETECT_MEM_LEAKS
    }
#endif // 0 or 1
}
/*****************************  getFormaldehydeGasPercentage **********************************
Input:   rs_ro_ratio - Rs divided by Ro
Output:  ppm of the target gas
Remarks: This function passes different curves to the getPercentage function which 
         calculates the ppm (parts per million) of the target gas.
************************************************************************************/ 
int WSP2110::getFormaldehydeGasPercentage(float rs_ro_ratio, float ro)
{
  return getPercentage(rs_ro_ratio,ro,HCHOCurve);
}
/*****************************  getFormaldehydeGasPercentage **********************************
Input:   rs_ro_ratio - Rs divided by Ro
Output:  ppm of the target gas
Remarks: This function passes different curves to the getPercentage function which 
         calculates the ppm (parts per million) of the target gas.
************************************************************************************/ 
int WSP2110::getHydrogenGasPercentage(float rs_ro_ratio, float ro)
{
  return getPercentage(rs_ro_ratio,ro,H2Curve);
}