void CTown::update() { smokeTimer += CTimer::dt * 3; for (int a = 0; a<4; a++) { if (getSliderAim((eTownSlider)a)>getSlider((eTownSlider)a)) setStat("slider" + IntToStr(a), getSlider((eTownSlider)a) + 0.01*CTimer::dt); if (getSliderAim((eTownSlider)a) < getSlider((eTownSlider)a)) setStat("slider" + IntToStr(a), getSlider((eTownSlider)a) - 0.01*CTimer::dt); } bool fu = 0, fb = 0; for (int a = 0; a < townOrders.size(); a++) { double prog = getMap()->getDeltaTime(); if (townOrders[a].unit == -1) { if (!fb) townOrders[a].progress += prog, fb = 1; } else if (!fu) { fu = 1; townOrders[a].progress += prog*double(getAttrib("trainingTime")); townOrders[a].morale += getAttrib("baseMorale")*CUnit::getUnit(getOwner(), townOrders[a].unit).getStat("baseMorale")*prog / townOrders[a].costs[(int)RES_TIME]; } if (townOrders[a].progress > townOrders[a].costs[(int)RES_TIME]) { if (townOrders[a].unit == -1) addBuild(townOrders[a].build, 1); else { CUnit unit = CUnit::getUnit(getOwner(), townOrders[a].unit); unit.setStat("morale", townOrders[a].morale); std::vector<int> armies; CArmy::getArmiesInPoint(getCenter(), 20, armies); CArmy* a; if (armies.size() == 0) a = getMap()->addArmy(getCenter(), getOwner()); else a = getMap()->getArmy(armies[0]); a->addUnit(&unit); } townOrders.erase(townOrders.begin() + a); a--; } } }
void OptionsSoundMenu::show() { _volMusic = ConfigMan.getDouble("volume_music", 1.0); _volSFX = ConfigMan.getDouble("volume_sfx" , 1.0); _volVoice = ConfigMan.getDouble("volume_voice", 1.0); _volVideo = ConfigMan.getDouble("volume_video", 1.0); updateVolume(_volMusic, Sound::kSoundTypeMusic, "MusicLabel"); updateVolume(_volSFX , Sound::kSoundTypeSFX , "SoundFXLabel"); updateVolume(_volVoice, Sound::kSoundTypeVoice, "VoicesLabel"); getSlider("MusicSlider" , true)->setState(_volMusic * 20); getSlider("SoundFXSlider", true)->setState(_volSFX * 20); getSlider("VoicesSlider" , true)->setState(_volVoice * 20); GUI::show(); }
void Controller::dragSlider(double x, double y){ try{ getSlider(x,y)->setSelection(true); glfwSetMousePosCallback(MousePosCallback); } catch(...){ throw eFileNotFoundException(); } }
void OptionsGameMenu::show() { _difficulty = CLIP(ConfigMan.getInt("difficulty", 0), 0, 2); getSlider("DiffSlider", true)->setState(_difficulty); updateDifficulty(_difficulty); GUI::show(); }
void OptionsVideoMenu::callbackActive(Widget &widget) { if ((widget.getTag() == "CancelButton") || (widget.getTag() == "XButton")) { revertChanges(); _returnCode = 1; return; } if (widget.getTag() == "OkButton") { adoptChanges(); _returnCode = 2; return; } if (widget.getTag() == "VideoModeButton") { sub(*_resolution); return; } if (widget.getTag() == "AdvVideoButton") { sub(*_advanced); return; } if (widget.getTag() == "GammaSlider") { float gamma = dynamic_cast<WidgetSlider &>(widget).getState() / 10.0; GfxMan.setGamma(gamma + 0.1); return; } if (widget.getTag() == "GammaResetButton") { GfxMan.setGamma(_gamma); int gammaValue = CLIP(_gamma - 0.1f, 0.0f, 1.9f) * 10; getSlider("GammaSlider", true)->setState(gammaValue); return; } if (widget.getTag() == "TextureSlider") { _textureLevel = dynamic_cast<WidgetSlider &>(widget).getState(); updateTextureQualityLabel(); return; } if (widget.getTag() == "ApplyButton") { ConfigMan.setInt("texturepack", _textureLevel); return; } }
void OptionsFeedbackMenu::updateTooltipDelay(uint32 UNUSED(tooltipDelay)) { WidgetLabel &ttDelayLabel = *getLabel ("ToolTipValue" , true); WidgetSlider &ttDelaySlider = *getSlider("TooltipSlider", true); const float ttDelay = ((float) (ttDelaySlider.getState() + 1)) / 10.0; const Common::UString secString = TalkMan.getString(kStringSec); const Common::UString ttDelayText = Common::UString::sprintf("%3.1f %s", ttDelay, secString.c_str()); ttDelayLabel.setText(ttDelayText); }
void OptionsVideoMenu::show() { _gamma = GfxMan.getGamma(); if (_gamma == 0.0) { getWidget("GammaSlider" , true)->setDisabled(true); getWidget("GammaResetButton", true)->setDisabled(true); } else { getWidget("GammaSlider" , true)->setDisabled(false); getWidget("GammaResetButton", true)->setDisabled(false); } int gammaValue = CLIP(_gamma - 0.1f, 0.0f, 1.9f) * 10; getSlider("GammaSlider", true)->setState(gammaValue); _textureLevel = ConfigMan.getInt("texturepack", 1); getSlider("TextureSlider", true)->setState(_textureLevel); updateTextureQualityLabel(); GUI::show(); }
void OptionsFeedbackMenu::adoptChanges() { uint32 tooltipDelay = (getSlider("TooltipSlider", true)->getState() + 1) * 100; ConfigMan.setInt("tooltipdelay", tooltipDelay, true); bool mouseoverFeedback = getCheckBox("MouseoverBox", true)->getState(); ConfigMan.setBool("mouseoverfeedback", mouseoverFeedback, true); uint32 feedbackMode = 2; if (getCheckBox("BubblesOff", true)->getState()) feedbackMode = 0; else if (getCheckBox("BubblesTextOnly", true)->getState()) feedbackMode = 1; else if (getCheckBox("BubblesFull", true)->getState()) feedbackMode = 2; ConfigMan.setInt("feedbackmode", feedbackMode, true); }
void OptionsVideoAdvancedMenu::show() { _oldFSAA = MAX(GfxMan.getCurrentFSAA(), 0); _fsaa = _oldFSAA; int fsaa = _oldFSAA; if (fsaa > 0) fsaa = MAX(0, Common::intLog2(fsaa)); getSlider("AntiAliasSlider", true)->setState(fsaa); updateFSAALabel(fsaa); WidgetCheckBox *largeFonts = getCheckBox("UseLargeFont"); if (largeFonts) largeFonts->setState(ConfigMan.getBool("largefonts")); GUI::show(); }
void OptionsFeedbackMenu::show() { uint32 tooltipDelay = (CLIP(ConfigMan.getInt("tooltipdelay", 100), 100, 2700) / 100) - 1; getSlider("TooltipSlider", true)->setState(tooltipDelay); updateTooltipDelay(tooltipDelay); getCheckBox("MouseoverBox", true)->setState(ConfigMan.getBool("mouseoverfeedback")); uint32 feedbackMode = CLIP(ConfigMan.getInt("feedbackmode", 2), 0, 2); if (feedbackMode == 0) getCheckBox("BubblesOff", true)->setState(true); else if (feedbackMode == 1) getCheckBox("BubblesTextOnly", true)->setState(true); else if (feedbackMode == 2) getCheckBox("BubblesFull", true)->setState(true); GUI::show(); }
void MantaStats::update() { ofxManta::update(); if (!IsConnected()) { return; } // pad velocities int idx = 0; for (int row=0; row<6; row++) { for (int col=0; col<8; col++) { padVelocity[row][col] = ofLerp(padVelocity[row][col], getPad(row, col) - prevPad[row][col], 0.1); prevPad[row][col] = getPad(row, col); idx++; } } // slider velocities for (int i=0; i<2; i++) { sliderVelocity[i] = ofLerp(sliderVelocity[i], getSlider(i) - prevSlider[i], velocityLerpRate); prevSlider[i] = getSlider(i); } // button velocities for (int i=0; i<4; i++) { buttonVelocity[i] = ofLerp(buttonVelocity[i], getButton(i) - prevButton[i], velocityLerpRate); prevButton[i] = getButton(i); } // finger stats float _padSum = 0; float _padAverage = 0; float _width = 0; float _height = 0; float _whRatio = 0; float _numPads = 0; fingers.clear(); fingerValues.clear(); ofPoint fingersMin = ofPoint(1, 1); ofPoint fingersMax = ofPoint(0, 0); float currentValue; for (int row=0; row<6; row++) { for (int col=0; col<8; col++) { currentValue = getPad(row, col); if (currentValue > 0) { ofPoint fingerPos = getPositionAtPad(row, col); fingers.push_back(fingerPos); fingerValues.push_back(currentValue); _numPads+=1.0; _padSum += currentValue; if (fingerPos.x > fingersMax.x) fingersMax.x = fingerPos.x; if (fingerPos.x < fingersMin.x) fingersMin.x = fingerPos.x; if (fingerPos.y > fingersMax.y) fingersMax.y = fingerPos.y; if (fingerPos.y < fingersMin.y) fingersMin.y = fingerPos.y; } } } _padAverage = fingers.size() > 0 ? _padSum / _numPads : 0.0; float _perimeter = 0.0; float _area = 0.0; float _averageInterFingerDistance = 0.0; // stats on finger groups if (fingers.size() < 2) { _width = 0; _height = 0; _whRatio = 0; _perimeter = 0; _area = 0; _averageInterFingerDistance = 0; fingersHull.resize(0); } else if (fingers.size() == 2) { _width = fingersMax.x - fingersMin.x; _height = fingersMax.y - fingersMin.y; _whRatio = _width / (1.0 + _height); _perimeter = (pow(fingers[0].x - fingers[1].x, 2)+ pow(fingers[0].y - fingers[1].y, 2)); _area = 0; _averageInterFingerDistance = _perimeter; fingersHull.resize(0); } else { _width = fingersMax.x - fingersMin.x; _height = fingersMax.y - fingersMin.y; _whRatio = _width / (1.0 + _height); fingersHull = convexHull.getConvexHull(fingers); for (int i=0; i<fingersHull.size()-1; i++) { _perimeter += (pow(fingersHull[i].x - fingersHull[(i+1)].x, 2)+ pow(fingersHull[i].y - fingersHull[(i+1)].y, 2)); } _area = convexHull.getArea(fingersHull); _averageInterFingerDistance = _perimeter / (float) (fingersHull.size()-1); } numPadsVelocity = ofLerp(numPadsVelocity, _numPads-numPads, velocityLerpRate); perimeterVelocity = ofLerp(perimeterVelocity, _perimeter-perimeter, velocityLerpRate); areaVelocity = ofLerp(areaVelocity, _area-area, velocityLerpRate); averageInterFingerDistanceVelocity = ofLerp(averageInterFingerDistanceVelocity, _averageInterFingerDistance-averageInterFingerDistance, velocityLerpRate); padSumVelocity = ofLerp(padSumVelocity, _padSum-padSum, velocityLerpRate); padAverageVelocity = ofLerp(padAverageVelocity, _padAverage-padAverage, velocityLerpRate); widthVelocity = ofLerp(widthVelocity, _width-padWidth, velocityLerpRate); heightVelocity = ofLerp(heightVelocity, _height-padHeight, velocityLerpRate); whRatioVelocity = ofLerp(whRatioVelocity, _whRatio-whRatio, velocityLerpRate); if (abs(numPadsVelocity) < EPSILON) numPadsVelocity = 0; if (abs(padSumVelocity) < EPSILON) padSumVelocity = 0; if (abs(padAverageVelocity) < EPSILON) padAverageVelocity = 0; if (abs(centroidVelocityX) < EPSILON) centroidVelocityX = 0; if (abs(centroidVelocityY) < EPSILON) centroidVelocityY = 0; if (abs(weightedCentroidVelocityX) < EPSILON) weightedCentroidVelocityX = 0; if (abs(weightedCentroidVelocityY) < EPSILON) weightedCentroidVelocityY = 0; if (abs(averageInterFingerDistanceVelocity) < EPSILON) averageInterFingerDistanceVelocity = 0; if (abs(perimeterVelocity) < EPSILON) perimeterVelocity = 0; if (abs(areaVelocity) < EPSILON) areaVelocity = 0; if (abs(widthVelocity) < EPSILON) widthVelocity = 0; if (abs(heightVelocity) < EPSILON) heightVelocity = 0; if (abs(whRatioVelocity) < EPSILON) whRatioVelocity = 0; // centroid and weighted centroid ofPoint _centroid, _weightedCentroid; for (int i=0; i<fingers.size(); i++) { _centroid += fingers[i]; _weightedCentroid += (fingers[i] * fingerValues[i] / _padSum); } _centroid /= _numPads; centroidVelocityX = ofLerp(centroidVelocityX, _centroid.x-centroidX, velocityLerpRate); centroidVelocityY = ofLerp(centroidVelocityY, _centroid.y-centroidY, velocityLerpRate); weightedCentroidVelocityX = ofLerp(weightedCentroidVelocityX, _weightedCentroid.x-weightedCentroidX, velocityLerpRate); weightedCentroidVelocityY = ofLerp(weightedCentroidVelocityY, _weightedCentroid.y-weightedCentroidY, velocityLerpRate); // update stats compareStats(9, &padWidth, _width); compareStats(11, &padHeight, _height); compareStats(12, &whRatio, _whRatio); compareStats(6, &perimeter, _perimeter); compareStats(8, &area, _area); compareStats(10, &averageInterFingerDistance, _averageInterFingerDistance); compareStats(2, &padSum, _padSum); compareStats(4, &padAverage, _padAverage); compareStats(0, &numPads, _numPads); compareStats(1, ¢roidX, _centroid.x); compareStats(3, ¢roidY, _centroid.y); compareStats(5, &weightedCentroidX, _weightedCentroid.x); compareStats(7, &weightedCentroidY, _weightedCentroid.y); }
Controller::Controller(void){ // initialize attributes colour.r = 135/255.0; colour.g = 129/255.0; colour.b = 190/255.0; grayShade = 1; polygonWidth = 1; bezierT = 0.5; quadraticSplineT = cubicSplineT = cubicInterpolationT = 0.25; bezierDepth = quadraticSplineDepth = cubicSplineDepth = cubicInterpolationDepth = 3; smoothPolygonT = 1/3.0; hardness = Polygon::SMOOTH; try{ buttonM = ButtonModel::getInstance(); sliderM = SliderModel::getInstance(); polygonM = PolygonModel::getInstance(); canvas = Canvas::getInstance(); currentColour = CurrentColour::getInstance(); currentColour->setColour(colour.r, colour.g, colour.b); if(getButton("lineStrip") != NULL) getButton("lineStrip")->setActivation(true); if(getButton("smoothness") != NULL) getButton("smoothness")->setActivation(true); if(getSlider("widthSlider") != NULL) getSlider("widthSlider")->setValue(polygonWidth); if(getSlider("bezierT") != NULL) getSlider("bezierT")->setValue(bezierT); if(getSlider("quadraticSplineT") != NULL) getSlider("quadraticSplineT")->setValue(quadraticSplineT); if(getSlider("cubicSplineT") != NULL) getSlider("cubicSplineT")->setValue(cubicSplineT); if(getSlider("cubicInterpolationT") != NULL) getSlider("cubicInterpolationT")->setValue(cubicInterpolationT); if(getSlider("bezierDepth") != NULL) getSlider("bezierDepth")->setValue(bezierDepth); if(getSlider("quadraticSplineDepth") != NULL) getSlider("quadraticSplineDepth")->setValue(quadraticSplineDepth); if(getSlider("cubicSplineDepth") != NULL) getSlider("cubicSplineDepth")->setValue(cubicSplineDepth); if(getSlider("cubicInterpolationDepth") != NULL) getSlider("cubicInterpolationDepth")->setValue(cubicInterpolationDepth); if(getSlider("smoothPolygonT") != NULL) getSlider("smoothPolygonT")->setValue(smoothPolygonT); if(getSlider("colourShade") != NULL) getSlider("colourShade")->setValue(grayShade); window = View::getInstance(); } catch(...){ throw eFileNotFoundException(); } }
void MantaController::update() { if (!connected) { connected = getConnected(); return; } // pad velocities int idx = 0; for (int row=0; row<6; row++) { for (int col=0; col<8; col++) { padVelocity[row][col] = ofLerp(padVelocity[row][col], getPad(row, col) - prevPad[row][col], 0.1); prevPad[row][col] = getPad(row, col); idx++; } } // slider velocities for (int i=0; i<2; i++) { sliderVelocity[i] = ofLerp(sliderVelocity[i], getSlider(i) - prevSlider[i], velocityLerpRate); prevSlider[i] = getSlider(i); } // button velocities for (int i=0; i<4; i++) { buttonVelocity[i] = ofLerp(buttonVelocity[i], getButton(i) - prevButton[i], velocityLerpRate); prevButton[i] = getButton(i); } // finger stats float _padSum = 0; float _padAverage = 0; float _width = 0; float _height = 0; float _whRatio = 0; float _numPads = 0; fingers.clear(); fingerValues.clear(); ofPoint fingersMin = ofPoint(1, 1); ofPoint fingersMax = ofPoint(0, 0); float currentValue; for (int row=0; row<6; row++) { for (int col=0; col<8; col++) { currentValue = getPad(row, col); if (currentValue > 0) { ofPoint fingerPos = getPositionAtPad(row, col); fingers.push_back(fingerPos); fingerValues.push_back(currentValue); _numPads+=1.0; _padSum += currentValue; if (fingerPos.x > fingersMax.x) fingersMax.x = fingerPos.x; if (fingerPos.x < fingersMin.x) fingersMin.x = fingerPos.x; if (fingerPos.y > fingersMax.y) fingersMax.y = fingerPos.y; if (fingerPos.y < fingersMin.y) fingersMin.y = fingerPos.y; } } } _padAverage = fingers.size() > 0 ? _padSum / _numPads : 0.0; float _perimeter = 0.0; float _averageInterFingerDistance = 0.0; // stats on finger groups if (fingers.size() < 2) { _width = 0; _height = 0; _whRatio = 0; _perimeter = 0; _averageInterFingerDistance = 0; fingersHull.resize(0); fingersHullNormalized.resize(0); } else if (fingers.size() == 2) { _width = fingersMax.x - fingersMin.x; _height = fingersMax.y - fingersMin.y; _whRatio = _width / (1.0 + _height); _perimeter = (pow(fingers[0].x - fingers[1].x, 2)+ pow(fingers[0].y - fingers[1].y, 2)); _averageInterFingerDistance = _perimeter; fingersHull.resize(0); fingersHullNormalized.resize(0); } else { _width = fingersMax.x - fingersMin.x; _height = fingersMax.y - fingersMin.y; _whRatio = _width / _height; fingersHull = convexHull.getConvexHull(fingers); fingersHullNormalized.resize(fingersHull.size()); for (int i=0; i<fingersHull.size(); i++) { fingersHullNormalized[i].x = (fingersHull[i].x - fingersMin.x) / (fingersMax.x - fingersMin.x); fingersHullNormalized[i].y = (fingersHull[i].y - fingersMin.y) / (fingersMax.y - fingersMin.y); } for (int i=0; i<fingersHull.size()-1; i++) { _perimeter += (pow(fingersHull[i].x - fingersHull[(i+1)].x, 2)+ pow(fingersHull[i].y - fingersHull[(i+1)].y, 2)); } _averageInterFingerDistance = _perimeter / (float) (fingersHull.size()-1); } numPadsVelocity = ofLerp(numPadsVelocity, _numPads-numPads, velocityLerpRate); perimeterVelocity = ofLerp(perimeterVelocity, _perimeter-perimeter, velocityLerpRate); averageInterFingerDistanceVelocity = ofLerp(averageInterFingerDistanceVelocity, _averageInterFingerDistance-averageInterFingerDistance, velocityLerpRate); padSumVelocity = ofLerp(padSumVelocity, _padSum-padSum, velocityLerpRate); padAverageVelocity = ofLerp(padAverageVelocity, _padAverage-padAverage, velocityLerpRate); widthVelocity = ofLerp(widthVelocity, _width-padWidth, velocityLerpRate); heightVelocity = ofLerp(heightVelocity, _height-padHeight, velocityLerpRate); whRatioVelocity = ofLerp(whRatioVelocity, _whRatio-whRatio, velocityLerpRate); padWidth = _width; padHeight = _height; whRatio = _whRatio; perimeter = _perimeter; averageInterFingerDistance = _averageInterFingerDistance; padSum = _padSum; padAverage = _padAverage; numPads = _numPads; // centroid and weighted centroid ofPoint _centroid, _weightedCentroid; for (int i=0; i<fingers.size(); i++) { _centroid += fingers[i]; _weightedCentroid += (fingers[i] * fingerValues[i] / padSum); } _centroid /= _numPads; centroidVelocityX = ofLerp(centroidVelocityX, _centroid.x-centroidX, velocityLerpRate); centroidVelocityY = ofLerp(centroidVelocityY, _centroid.y-centroidY, velocityLerpRate); weightedCentroidVelocityX = ofLerp(weightedCentroidVelocityX, _weightedCentroid.x-weightedCentroidX, velocityLerpRate); weightedCentroidVelocityY = ofLerp(weightedCentroidVelocityY, _weightedCentroid.y-weightedCentroidY, velocityLerpRate); centroidX = _centroid.x; centroidY = _centroid.y; weightedCentroidX = _weightedCentroid.x; weightedCentroidY = _weightedCentroid.y; }
// ------------ // SetMsg void TableRender::SetMsg(std::string msg) { m_typedMsg = msg; getSlider()->setNumber(float(atof(msg.c_str()))); }
void OptionsGameMenu::adoptChanges() { ConfigMan.setInt("difficulty", getSlider("DiffSlider", true)->getState(), true); }
float CTown::getPPOn(eTownSlider s) { return getSlider(s)*getRealPP(); }
int ofxUIEventArgs::getInt() { return getSlider()->getValue(); }
double ofxUIEventArgs::getDouble() { return getSlider()->getValue(); }
float ofxUIEventArgs::getFloat() { return getSlider()->getValue(); }