void GuiFrequencyCurve::onDraw(sf::RenderTarget& window) { GuiPanel::onDraw(window); if (frequency >= 0 && frequency <= SpaceShip::max_frequency) { float w = (rect.width - 40) / (SpaceShip::max_frequency + 1); for(int n=0; n<=SpaceShip::max_frequency; n++) { float x = rect.left + 20 + w * n; float f; if (frequency_is_beam) f = frequencyVsFrequencyDamageFactor(frequency, n); else f = frequencyVsFrequencyDamageFactor(n, frequency); f = Tween<float>::linear(f, 0.5, 1.5, 0.1, 1.0); float h = (rect.height - 50) * f; sf::RectangleShape bar(sf::Vector2f(w * 0.8, h)); bar.setPosition(x, rect.top + rect.height - 10 - h); if (more_damage_is_positive) bar.setFillColor(sf::Color(255 * (1.0 - f), 255 * f, 0)); else bar.setFillColor(sf::Color(255 * f, 255 * (1.0 - f), 0)); window.draw(bar); if (my_spaceship && ((frequency_is_beam && n == my_spaceship->getShieldsFrequency()) || (!frequency_is_beam && n == my_spaceship->beam_frequency))) { sf::Sprite image; textureManager.setTexture(image, "gui/SelectorArrow"); image.setPosition(x + w / 2.0, rect.top + rect.height - 20 - h); image.setRotation(-90); image.setScale(0.2, 0.2); window.draw(image); } } int mouse_freq_nr = int((InputHandler::getMousePos().x - rect.left - 20) / w); string text = ""; if (rect.contains(InputHandler::getMousePos()) && mouse_freq_nr >= 0 && mouse_freq_nr <= SpaceShip::max_frequency) { if (frequency_is_beam) text = frequencyToString(mouse_freq_nr) + " " + string(int(frequencyVsFrequencyDamageFactor(frequency, mouse_freq_nr) * 100)) + "% dmg"; else text = frequencyToString(mouse_freq_nr) + " " + string(int(frequencyVsFrequencyDamageFactor(mouse_freq_nr, frequency) * 100)) + "% dmg"; }else{ if (more_damage_is_positive) text = "Damage with your beams"; else text = "Damage on your shields"; } drawText(window, sf::FloatRect(rect.left, rect.top, rect.width, 40), text, ACenter, 20); }else{ drawText(window, rect, "No data", ACenter, 35); } }
void DailyRollingFileAppender::computeFrequency() { // Q_ASSERT_X(, "DailyRollingFileAppender::computeFrequency()", "Lock must be held by caller") const DateTime start_time(QDate(1999, 1, 1), QTime(0, 0)); const QString start_string = start_time.toString(mDatePattern); mActiveDatePattern.clear(); if (start_string != static_cast<DateTime>(start_time.addSecs(60)).toString(mDatePattern)) mFrequency = MINUTELY_ROLLOVER; else if (start_string != static_cast<DateTime>(start_time.addSecs(60 * 60)).toString(mDatePattern)) mFrequency = HOURLY_ROLLOVER; else if (start_string != static_cast<DateTime>(start_time.addSecs(60 * 60 * 12)).toString(mDatePattern)) mFrequency = HALFDAILY_ROLLOVER; else if (start_string != static_cast<DateTime>(start_time.addDays(1)).toString(mDatePattern)) mFrequency = DAILY_ROLLOVER; else if (start_string != static_cast<DateTime>(start_time.addDays(7)).toString(mDatePattern)) mFrequency = WEEKLY_ROLLOVER; else if (start_string != static_cast<DateTime>(start_time.addMonths(1)).toString(mDatePattern)) mFrequency = MONTHLY_ROLLOVER; else { LogError e = LOG4QT_QCLASS_ERROR(QT_TR_NOOP("The pattern '%1' does not specify a frequency for appender '%2'"), APPENDER_INVALID_PATTERN_ERROR); e << mDatePattern << name(); logger()->error(e); return; } mActiveDatePattern = mDatePattern; logger()->trace("Frequency set to %2 using date pattern %1", mActiveDatePattern, frequencyToString()); }
QDebug DailyRollingFileAppender::debug(QDebug &rDebug) const { QString layout_name; if (layout()) layout_name = layout()->name(); QString codec_name; if (encoding()) codec_name = QLatin1String(encoding()->name()); rDebug.nospace() << "DailyRollingFileAppender(" << "name:" << name() << " " << "activedatepattern:" << mActiveDatePattern << " " << "appendfile:" << appendFile() << " " << "bufferedio:" << bufferedIo() << " " << "datepattern:" << datePattern() << " " << "encoding:" << codec_name << " " << "frequency:" << frequencyToString() << " " << "file:" << fileName() << " " << "filepath:" << filePath() << " " << "suffix:" << suffix() << " " << "fullFileName:" << fullFileName() << " " << "filter:" << firstFilter() << " " << "immediateflush:" << immediateFlush() << " " << "isactive:" << isActive() << " " << "isclosed:" << isClosed() << " " << "layout:" << layout_name << " " << "referencecount:" << referenceCount() << " " << "rollovertime:" << mRollOverTime << "threshold:" << threshold().toString() << "writer:" << writer() << ")"; return rDebug.space(); }
void GuiShieldFrequencySelect::onDraw(sf::RenderTarget& window) { if (my_spaceship) { current_frequency->setText(frequencyToString(my_spaceship->shield_frequency)); //calibrate_progressbar->setVisible(my_spaceship->shield_calibration_delay > 0.0); //calibrate_progressbar->setValue(my_spaceship->shield_calibration_delay); current_frequency->setVisible(true); //calibrate_button->setEnable(!calibrate_progressbar->isVisible()); //new_frequency->setEnable(!calibrate_progressbar->isVisible()); } GuiBox::onDraw(window); }
GuiShieldFrequencySelect::GuiShieldFrequencySelect(GuiContainer* owner, string id) : GuiElement(owner, id) { (new GuiShieldsEnableButton(this, "SHIELDS_ENABLE"))->setPosition(0, 0, ATopLeft)->setSize(GuiElement::GuiSizeMax, 50); calibrate_button = new GuiButton(this, "", "Calibrate", [this]() { if (my_spaceship) my_spaceship->commandSetShieldFrequency(new_frequency->getSelectionIndex()); }); calibrate_button->setPosition(0, 50, ATopLeft)->setSize(280 * 0.55, 50); new_frequency = new GuiSelector(this, "", nullptr); new_frequency->setPosition(280 * 0.55, 50, ATopLeft)->setSize(280 * 0.45, 50); for(int n=0; n<=SpaceShip::max_frequency; n++) { new_frequency->addEntry(frequencyToString(n), string(n)); } new_frequency->setSelectionIndex(0); }
GuiShieldFrequencySelect::GuiShieldFrequencySelect(GuiContainer* owner, string id) : GuiElement(owner, id) { current_frequency = new GuiKeyValueDisplay(this, "", 0.65, "Shield Frequency", "400Thz"); current_frequency->setTextSize(30)->setPosition(0, 0, ATopLeft)->setSize(GuiElement::GuiSizeMax, 50); calibrate_button = new GuiButton(this, "", "Calibrate", [this]() { if (my_spaceship) my_spaceship->commandSetShieldFrequency(new_frequency->getSelectionIndex()); }); calibrate_button->setPosition(0, 50, ATopLeft)->setSize(320 * 0.60, 50); new_frequency = new GuiSelector(this, "", nullptr); new_frequency->setPosition(320 * 0.65, 50, ATopLeft)->setSize(320 * 0.40, 50); for(int n=0; n<=SpaceShip::max_frequency; n++) { new_frequency->addEntry(frequencyToString(n), string(n)); } new_frequency->setSelectionIndex(0); calibrate_progressbar = new GuiProgressbar(this, id + "_CAL_PROGRESS", PlayerSpaceship::shield_calibration_time, 0.0, 0.0); calibrate_progressbar->setPosition(0, 0, ATopLeft)->setSize(GuiElement::GuiSizeMax, 50); calibrate_progressbar->setText("Calibrating..."); }