void MainWindow::replaceData( QString sourceFile, QString destFile, bool noHexUid ) { QString path = QDir::currentPath(); QFile infile(sourceFile); if (!infile.open(QIODevice::ReadWrite | QIODevice::Text)) return; QTextStream in(&infile); QFile outfile(destFile); if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text)) return; QTextStream out(&outfile); while (!in.atEnd()) { QString line = in.readLine(); line.replace(QString("#replace#"), widgetName()); if( noHexUid ) { line.replace(QString("#replaceuid#"), widgetUidNoHex()); } else { line.replace(QString("#replaceuid#"), widgetUid()); } out << line << "\n"; } }
void RendererCreator::generateBuildFile() { QString widgetName( iUi.widgetName().toLower() ); replaceData("data/renderingplugin/group/bld.inf", widgetName + "/renderingplugin/group/bld.inf"); }
void RendererCreator::generateHeader() { QString widgetName( iUi.widgetName().toLower() ); QString rendererName( iUi.rendererName().toLower() ); replaceData("data/renderingplugin/inc/renderer.h", widgetName + "/renderingplugin/inc/" + rendererName + "renderer.h"); }
void RendererCreator::generateSource() { QString widgetName( iUi.widgetName().toLower() ); QString rendererName( iUi.rendererName().toLower() ); replaceData("data/renderingplugin/src/renderer.cpp", widgetName + "/renderingplugin/src/" + rendererName + "renderer.cpp"); }
void RendererCreator::generateMMP() { QString widgetName( iUi.widgetName().toLower() ); QString rendererName( iUi.rendererName().toLower() ); replaceData("data/renderingplugin/group/renderer.mmp", widgetName + "/renderingplugin/group/" + rendererName + "renderer.mmp"); }
void MainWindow::generateMainBuildFile() { QDir dir; dir.mkpath( widgetName().toLower() + "/group"); dir.setPath( widgetName().toLower() + "/group"); QFile file( dir.filePath("bld.inf")); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return; QTextStream out(&file); generateLicense( out ); //out << "#include \"../publisherif/group/bld.inf\"\n"; out << "#include \"../testpublisher/group/bld.inf\"\n"; out << "#include \"../widget/group/bld.inf\"\n"; if( ui->renderingCheckBox->isChecked() ) { out << "#include \"../renderingplugin/group/bld.inf\"\n\n"; } out << "// End of File\n"; }
void AbstractAudioScopeWidget::slotReceiveAudio(const audioShortVector &sampleData, int freq, int num_channels, int num_samples) { #ifdef DEBUG_AASW qDebug() << "Received audio for " << widgetName() << '.'; #endif m_audioFrame = sampleData; m_freq = freq; m_nChannels = num_channels; m_nSamples = num_samples; m_newData.fetchAndAddAcquire(1); AbstractScopeWidget::slotRenderZoneUpdated(); }
void AbstractScopeWidget::slotAutoRefreshToggled(bool autoRefresh) { #ifdef DEBUG_ASW qDebug() << "Auto-refresh switched to " << autoRefresh << " in " << widgetName() << " (Visible: " << isVisible() << '/' << this->visibleRegion().isEmpty() << ')'; #endif if (isVisible()) { // Notify listeners whether we accept new frames now emit requestAutoRefresh(autoRefresh); } // TODO only if depends on input if (autoRefresh) { //forceUpdate(); m_requestForcedUpdate = true; } }
bool pawsItemDescriptionWindow::OnButtonPressed(int /*mouseButton*/, int /*keyModifier*/, pawsWidget* widget) { csString widgetName(widget->GetName()); if ( widgetName == "StudyButton" ) { pawsWidget* widget = PawsManager::GetSingleton().FindWidget("CraftWindow"); if ( widget ) widget->Show(); return true; } // Since it is not study button we can easily just close the window. Hide(); PawsManager::GetSingleton().SetCurrentFocusedWidget( NULL ); return true; }
void AbstractScopeWidget::forceUpdate(bool doUpdate) { #ifdef DEBUG_ASW qDebug() << "Forced update called in " << widgetName() << ". Arg: " << doUpdate; #endif if (!doUpdate) { return; } m_requestForcedUpdate = true; m_newHUDUpdates.fetchAndAddRelaxed(1); m_newScopeUpdates.fetchAndAddRelaxed(1); m_newBackgroundUpdates.fetchAndAddRelaxed(1); prodHUDThread(); prodScopeThread(); prodBackgroundThread(); }
QString ScriptObject::executeProcess(bool blocking) { int index = ( states().findIndex( currentState()) ); if (index == -1) { printError(i18n("Invalid state for associated text.")); return QString(); } QString evalText = m_associatedText[index]; if ((KommanderWidget::useInternalParser && !evalText.startsWith("#!")) || evalText.startsWith("#!kommander")) { evalAssociatedText(evalText); return global(widgetName() + "_RESULT"); } else { MyProcess process(this); process.setBlocking(blocking); return process.run(evalAssociatedText(evalText)); } }
bool pawsExchangeWindow::OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget ) { csString widgetName(widget->GetName()); if ( widgetName == "SmallInvButton" ) { pawsWidget* widget = PawsManager::GetSingleton().FindWidget("SmallInventoryWindow"); if ( widget ) widget->Show(); return true; } if ( widget->GetID() == EXCHANGE_ACCEPT ) { bool empty=true; for ( int x = 0; x < EXCHANGE_SLOT_COUNT; x++ ) { if ( !offeringSlots[x]->IsEmpty() || !receivingSlots[x]->IsEmpty() ) { empty=false; } } if ( offeringMoneyWidget->IsNoAmount() && receivingMoneyWidget->IsNoAmount() && empty) { PawsManager::GetSingleton().CreateWarningBox("Maybe you want to actually give or get something before accepting the trade?"); return false; } else { SendAccept(); return true; } } return true; }
void AbstractScopeWidget::slotRenderZoneUpdated() { m_newHUDFrames.fetchAndAddRelaxed(1); m_newScopeFrames.fetchAndAddRelaxed(1); m_newBackgroundFrames.fetchAndAddRelaxed(1); #ifdef DEBUG_ASW qDebug() << "Data incoming at " << widgetName() << ". New frames total HUD/Scope/Background: " << m_newHUDFrames << '/' << m_newScopeFrames << '/' << m_newBackgroundFrames; #endif if (this->visibleRegion().isEmpty()) { #ifdef DEBUG_ASW qDebug() << "Scope of widget " << m_widgetName << " is not at the top, not rendering."; #endif } else { if (m_aAutoRefresh->isChecked()) { prodHUDThread(); prodScopeThread(); prodBackgroundThread(); } } }
// ---------------------------------------------------------------------------- // // ---------------------------------------------------------------------------- // void CWrtHarvester::LaunchWidgetOperationL( SWidgetOperation aOperation ) { HBufC* widgetName( GetAppNameLC( iApaSession, aOperation.iUid) ); HandleWidgetCommandL( iApaSession, *widgetName, aOperation.iUid, aOperation.iOperation ); CleanupStack::PopAndDestroy( widgetName ); }
widgetName(double v, QString b, QString a) : version(v), before(b), after(a) {} double version; QString before; QString after; }; struct propertyName : public widgetName { propertyName(double v, QString b, QString a, QString c = QString()) : widgetName(v, b, a), clss(c) {} QString clss; }; const int widgs = 1; widgetName widgetTable[1] = { widgetName(3.3, QLatin1String("before"), QLatin1String("after")), }; const int props = 1; propertyName propertyTable[1] = { propertyName(3.0, QLatin1String("resizeable"), QLatin1String("resizable")), // we need to fix a spelling error in 3.0 }; /* \internal */ void DomTool::fixAttributes(QDomNodeList &nodes, double version) { QDomNode n; QDomNodeList nl; for (int i = 0; i < (int) nodes.count(); ++i) {
bool pawsContainerDescWindow::OnButtonPressed(int /*mouseButton*/, int /*keyModifier*/, pawsWidget* widget) { csString widgetName(widget->GetName()); if ( widgetName == "SmallInvButton" ) { pawsWidget* widget = PawsManager::GetSingleton().FindWidget("SmallInventoryWindow"); if ( widget ) widget->Show(); return true; } // Check to see if player attempts to take and stack everything else if(widgetName == "TakeStackAll") { GEMClientObject* oldtarget = psengine->GetCharManager()->GetTarget(); EID oldID; if(oldtarget) { oldID = oldtarget->GetEID(); } //printf("selecting containerID %d, oldID %d\n", containerID, oldID); psUserActionMessage setnewtarget(0, containerID, "select"); setnewtarget.SendMessage(); //printf("taking all\n"); // Attempt to grab all items in the container. psengine->GetCmdHandler()->Execute("/takestackall"); //printf("selecting oldID %d\n", oldID); psUserActionMessage setoldtarget(0, oldID, "select"); setoldtarget.SendMessage(); } // Check to see if player attempts to take everything else if (widgetName == "TakeAll") { GEMClientObject* oldtarget = psengine->GetCharManager()->GetTarget(); EID oldID; if(oldtarget) { oldID = oldtarget->GetEID(); } //printf("selecting containerID %d, oldID %d\n", containerID, oldID); psUserActionMessage setnewtarget(0, containerID, "select"); setnewtarget.SendMessage(); //printf("taking all\n"); // Attempt to grab all items in the container. psengine->GetCmdHandler()->Execute("/takeall"); //printf("selecting oldID %d\n", oldID); psUserActionMessage setoldtarget(0, oldID, "select"); setoldtarget.SendMessage(); } // Check to see if this was the view button. if ( widget->GetID() == VIEW_BUTTON ) { if ( psengine->GetSlotManager()->IsDragging() ) { psViewItemDescription out(psengine->GetSlotManager()->HoldingContainerID(), psengine->GetSlotManager()->HoldingSlotID()); out.SendMessage(); psengine->GetSlotManager()->CancelDrag(); } return true; } /* Ahhem! - internal memoír for tzaeru to not forget uncommenting this & completing the bottom most this. */ else if ( widget->GetID() == INVENTORY_BUTTON ) { if ( psengine->GetSlotManager()->IsDragging() ) { pawsInventoryWindow* inv = (pawsInventoryWindow*)PawsManager::GetSingleton().FindWidget("InventoryWindow"); pawsSlot* slot = inv->GetFreeSlot(); if(!slot) { PawsManager::GetSingleton().CreateWarningBox("Your inventory is full!"); return true; } psengine->GetSlotManager()->Handle(slot); } return true; } else if ( widget->GetID() == COMBINE_BUTTON || widget->GetID() == UNCOMBINE_BUTTON ) { GEMClientObject* oldtarget = psengine->GetCharManager()->GetTarget(); EID oldID; if(oldtarget) { oldID = oldtarget->GetEID(); } //printf("selecting containerID %d, oldID %d\n", containerID, oldID); psUserActionMessage setnewtarget(0, containerID, "select"); setnewtarget.SendMessage(); //printf("combining\n"); if(widget->GetID() == COMBINE_BUTTON) psengine->GetCmdHandler()->Execute("/combine"); else psengine->GetCmdHandler()->Execute("/uncombine"); //printf("selecting oldID %d\n", oldID); psUserActionMessage setoldtarget(0, oldID, "select"); setoldtarget.SendMessage(); } return true; }
void MainWindow::on_pushButton_clicked() { if( widgetName().isEmpty() || widgetUid().isEmpty() ) { QMessageBox msgBox; msgBox.setText("Widget name and UID must be given."); msgBox.exec(); return; } bool ok; uint uidVal = widgetUid().toUInt(&ok, 16 ); if( widgetUid().length() != 10 || !widgetUid().startsWith( "0x",Qt::CaseInsensitive ) || !ok ) { QMessageBox msgBox; msgBox.setText("UID must be in 4 byte hexadecimal format\n 0x11223344."); msgBox.exec(); return; } if( uidVal >= 2147483648 ) //0x80000000 { QMessageBox msgBox; msgBox.setText("UID must be less than\n 0x80000000."); msgBox.exec(); return; } if (widgetLayout().length() == 0 && !rendererCheckBox().isChecked()) { QMessageBox msgBox; msgBox.setText("Layout data not available yet."); msgBox.exec(); return; } generateMainBuildFile(); PublisherCreator* publisherCreator = new PublisherCreator(*this); delete publisherCreator; WidgetCreator* widgetCreator = new WidgetCreator(*this); delete widgetCreator; if( ui->renderingCheckBox->isChecked() ) { if( rendererName().isEmpty() || rendererUid().isEmpty() ) { QMessageBox msgBox; msgBox.setText("Renderer name and UID must be given."); msgBox.exec(); return; } if( rendererUid().length() != 10 || !rendererUid().startsWith( "0x",Qt::CaseInsensitive )) { QMessageBox msgBox; msgBox.setText("UID must be in hexadecimal format\n 0x11223344."); msgBox.exec(); return; } RendererCreator * renderer = new RendererCreator(*this); delete renderer; } QMessageBox msgBox; msgBox.setText("Widget created."); msgBox.exec(); return; }
QImage AudioSpectrum::renderAudioScope(uint, const QVector<int16_t> audioFrame, const int freq, const int num_channels, const int num_samples, const int) { if ( audioFrame.size() > 63 && m_innerScopeRect.width() > 0 && m_innerScopeRect.height() > 0 // <= 0 if widget is too small (resized by user) ) { if (!m_customFreq) { m_freqMax = freq / 2; } QTime start = QTime::currentTime(); #ifdef DETECT_OVERMODULATION bool overmodulated = false; int overmodulateCount = 0; for (int i = 0; i < audioFrame.size(); i++) { if ( audioFrame[i] == std::numeric_limits<int16_t>::max() || audioFrame[i] == std::numeric_limits<int16_t>::min()) { overmodulateCount++; if (overmodulateCount > 3) { overmodulated = true; break; } } } if (overmodulated) { colorizeFactor = 1; } else { if (colorizeFactor > 0) { colorizeFactor -= .08; if (colorizeFactor < 0) { colorizeFactor = 0; } } } #endif // Determine the window size to use. It should be // * not bigger than the number of samples actually available // * divisible by 2 int fftWindow = ui->windowSize->itemData(ui->windowSize->currentIndex()).toInt(); if (fftWindow > num_samples) { fftWindow = num_samples; } if ((fftWindow & 1) == 1) { fftWindow--; } // Show the window size used, for information ui->labelFFTSizeNumber->setText(QVariant(fftWindow).toString()); // Get the spectral power distribution of the input samples, // using the given window size and function float freqSpectrum[fftWindow/2]; FFTTools::WindowType windowType = (FFTTools::WindowType) ui->windowFunction->itemData(ui->windowFunction->currentIndex()).toInt(); m_fftTools.fftNormalized(audioFrame, 0, num_channels, freqSpectrum, windowType, fftWindow, 0); // Store the current FFT window (for the HUD) and run the interpolation // for easy pixel-based dB value access QVector<float> dbMap; m_lastFFTLock.acquire(); m_lastFFT = QVector<float>(fftWindow/2); memcpy(m_lastFFT.data(), &(freqSpectrum[0]), fftWindow/2 * sizeof(float)); uint right = ((float) m_freqMax)/(m_freq/2) * (m_lastFFT.size() - 1); dbMap = FFTTools::interpolatePeakPreserving(m_lastFFT, m_innerScopeRect.width(), 0, right, -180); m_lastFFTLock.release(); #ifdef DEBUG_AUDIOSPEC QTime drawTime = QTime::currentTime(); #endif // Draw the spectrum QImage spectrum(m_scopeRect.size(), QImage::Format_ARGB32); spectrum.fill(qRgba(0,0,0,0)); const uint w = m_innerScopeRect.width(); const uint h = m_innerScopeRect.height(); const uint leftDist = m_innerScopeRect.left() - m_scopeRect.left(); const uint topDist = m_innerScopeRect.top() - m_scopeRect.top(); QColor spectrumColor(AbstractScopeWidget::colDarkWhite); int yMax; #ifdef DETECT_OVERMODULATION if (colorizeFactor > 0) { QColor col = AbstractScopeWidget::colHighlightDark; QColor spec = spectrumColor; float f = std::sin(M_PI_2 * colorizeFactor); spectrumColor = QColor( (int) (f * col.red() + (1-f) * spec.red()), (int) (f * col.green() + (1-f) * spec.green()), (int) (f * col.blue() + (1-f) * spec.blue()), spec.alpha() ); // Limit the maximum colorization for non-overmodulated frames to better // recognize consecutively overmodulated frames if (colorizeFactor > MAX_OVM_COLOR) { colorizeFactor = MAX_OVM_COLOR; } } #endif #ifdef AUDIOSPEC_LINES QPainter davinci(&spectrum); davinci.setPen(QPen(QBrush(spectrumColor.rgba()), 1, Qt::SolidLine)); #endif for (uint i = 0; i < w; i++) { yMax = (dbMap[i] - m_dBmin) / (m_dBmax-m_dBmin) * (h-1); if (yMax < 0) { yMax = 0; } else if (yMax >= (int)h) { yMax = h-1; } #ifdef AUDIOSPEC_LINES davinci.drawLine(leftDist + i, topDist + h-1, leftDist + i, topDist + h-1 - yMax); #else for (int y = 0; y < yMax && y < (int)h; y++) { spectrum.setPixel(leftDist + i, topDist + h-y-1, spectrumColor.rgba()); } #endif } // Calculate the peak values. Use the new value if it is bigger, otherwise adapt to lower // values using the Moving Average formula if (m_aShowMax->isChecked()) { davinci.setPen(QPen(QBrush(AbstractScopeWidget::colHighlightLight), 2)); if (m_peaks.size() != fftWindow/2) { m_peaks = QVector<float>(m_lastFFT); } else { for (int i = 0; i < fftWindow/2; i++) { if (m_lastFFT[i] > m_peaks[i]) { m_peaks[i] = m_lastFFT[i]; } else { m_peaks[i] = ALPHA_MOVING_AVG * m_lastFFT[i] + (1-ALPHA_MOVING_AVG) * m_peaks[i]; } } } int prev = 0; m_peakMap = FFTTools::interpolatePeakPreserving(m_peaks, m_innerScopeRect.width(), 0, right, -180); for (uint i = 0; i < w; i++) { yMax = (m_peakMap[i] - m_dBmin) / (m_dBmax-m_dBmin) * (h-1); if (yMax < 0) { yMax = 0; } else if (yMax >= (int)h) { yMax = h-1; } davinci.drawLine(leftDist + i-1, topDist + h-prev-1, leftDist + i, topDist + h-yMax-1); spectrum.setPixel(leftDist + i, topDist + h-yMax-1, AbstractScopeWidget::colHighlightLight.rgba()); prev = yMax; } } #ifdef DEBUG_AUDIOSPEC m_showTotal++; m_timeTotal += drawTime.elapsed(); qDebug() << widgetName() << " took " << drawTime.elapsed() << " ms for drawing. Average: " << ((float)m_timeTotal/m_showTotal) ; #endif emit signalScopeRenderingFinished(start.elapsed(), 1); return spectrum; } else { emit signalScopeRenderingFinished(0, 1); return QImage(); } }
void AbstractGfxScopeWidget::mouseReleaseEvent(QMouseEvent *event) { AbstractScopeWidget::mouseReleaseEvent(event); emit signalFrameRequest(widgetName()); }
void AbstractGfxScopeWidget::slotAutoRefreshToggled(bool autoRefresh) { if (autoRefresh) { emit signalFrameRequest(widgetName()); } }
GUCEF::GUI::CWidget* CFormBackendImp::CreateAndHookWrapperForWindow( CEGUI::Window* window ) {GUCE_TRACE; GUCEF::GUI::CWidget* widgetWrapper = NULL; CString typeName( CString( window->getType().c_str() ).SubstrToChar( '/', false ) ); if ( "Button" == typeName ) { widgetWrapper = new CButtonImp(); static_cast< CButtonImp* >( widgetWrapper )->Hook( static_cast< CEGUI::PushButton* >( window ) ); } else if ( "Editbox" == typeName ) { widgetWrapper = new CEditboxImp(); static_cast< CEditboxImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Editbox* >( window ) ); } else if ( "Listbox" == typeName ) { widgetWrapper = new CListboxImp(); static_cast< CListboxImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Listbox* >( window ) ); } else if ( "StaticImage" == typeName ) { CString widgetName( CString( window->getName().c_str() ).SubstrToChar( '/', false ) ); if ( widgetName == "RenderContext" ) { widgetWrapper = new CRenderContextImp(); static_cast< CRenderContextImp* >( widgetWrapper )->Hook( window ); } else { widgetWrapper = new CImageFrameImp(); static_cast< CImageFrameImp* >( widgetWrapper )->Hook( window ); } } else if ( "StaticText" == typeName ) { widgetWrapper = new CLabelImp(); static_cast< CLabelImp* >( widgetWrapper )->Hook( window ); } else if ( "Checkbox" == typeName ) { widgetWrapper = new CCheckboxImp(); static_cast< CCheckboxImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Checkbox* >( window ) ); } else if ( "Combobox" == typeName ) { widgetWrapper = new CComboboxImp(); static_cast< CComboboxImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Combobox* >( window ) ); } if ( "TabControl" == typeName ) { widgetWrapper = new CTabControlImp(); static_cast< CTabControlImp* >( widgetWrapper )->Hook( static_cast< CEGUI::TabControl* >( window ) ); } else if ( "TabContentPane" == typeName ) { widgetWrapper = new CTabContentPaneImp(); static_cast< CTabContentPaneImp* >( widgetWrapper )->Hook( window ); } else if ( "FrameWindow" == typeName ) { widgetWrapper = new CWindowImp(); static_cast< CWindowImp* >( widgetWrapper )->Hook( static_cast< CEGUI::FrameWindow* >( window ) ); } else if ( "MultiColumnList" == typeName ) { widgetWrapper = new CGridViewImp(); static_cast< CGridViewImp* >( widgetWrapper )->Hook( static_cast< CEGUI::MultiColumnList* >( window ) ); } else if ( "Spinner" == typeName ) { widgetWrapper = new CSpinnerImp(); static_cast< CSpinnerImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Spinner* >( window ) ); } else if ( "DefaultWindow" == typeName ) { widgetWrapper = new TBasicWidgetImp(); static_cast< TBasicWidgetImp* >( widgetWrapper )->Hook( window ); } GUCEF_DEBUG_LOG( 0, "Wrapped and hooked GUI widget for CEGUI widget of type " + typeName ); return widgetWrapper; }
void AbstractScopeWidget::init() { m_widgetName = widgetName(); readConfig(); }