示例#1
0
void ImportWidget::handleImportRequest()
{
    Utils::FileName dir = m_pathChooser->fileName();
    emit importFrom(dir);

    m_pathChooser->setFileName(m_pathChooser->baseFileName());
}
示例#2
0
void PixelShaderEditor::onInitialize()
{
   m_resourceMgr = &ResourcesManager::getInstance();

   ASSERT( m_resourceMgr != NULL );

   // setup ui
   m_ui.setupUi( this );

   // create a toolbar
   QString iconsDir = m_resourceMgr->getFilesystem().getShortcut( "editorIcons" ).c_str();
   QToolBar* toolbar = new QToolBar( m_ui.toolbarFrame );
   m_ui.toolbarFrame->layout()->addWidget( toolbar );

   // load some common icons
   m_linkActiveIcon = QIcon( iconsDir + "linkActive.png" );
   m_linkInactiveIcon = QIcon( iconsDir + "linkInactive.png" );

   // set the editor up
   m_scriptEditor = new TextEditWidget( m_ui.editorFrame, toolbar );
   m_ui.editorFrame->layout()->addWidget( m_scriptEditor );
   QFont font( "Courier", 12 );
   m_scriptEditor->setFont( font );
   m_scriptEditor->setSyntaxHighlighter( new ShaderSyntaxHighlighter() );
   m_scriptEditor->setPlainText( m_shader.getScript().c_str() );
   connect( m_scriptEditor, SIGNAL( textChanged() ), this, SLOT( onScriptModified() ) );
   m_docModified = false;

   // set the properties
   {
      const PixelShaderParams& params = m_shader.getParams();

      // geometry group box
      {
         m_ui.cullingMode->setCurrentIndex( params.m_cullingMode - 1 );
         connect( m_ui.cullingMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) );
      }

      // depth group box
      {
         m_ui.zBufferEnabled->setChecked( params.m_useZBuffer );
         connect( m_ui.zBufferEnabled, SIGNAL( toggled( bool ) ), this, SLOT( onParamChange() ) );

         m_ui.zBufferWriteEnabled->setChecked( params.m_writeToZBuffer );
         connect( m_ui.zBufferWriteEnabled, SIGNAL( toggled( bool ) ), this, SLOT( onParamChange() ) );

         m_ui.depthTestFuncCombo->setCurrentIndex( params.m_depthTestFunc - 1 );
         connect( m_ui.depthTestFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) );
      }

      // alpha test group box
      {
         m_ui.alphaTest->setChecked( params.m_useAlphaTest );
         connect( m_ui.alphaTest, SIGNAL( toggled( bool ) ), this, SLOT( onParamChange() ) );

         m_ui.alphaTestFuncCombo->setCurrentIndex( params.m_alphaTestFunc - 1 );
         connect( m_ui.alphaTestFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) );

         // create the reference color picker
         {
            QLayout* layout = m_ui.alphaTestRefColor->layout();

            Color color;
            color.setFromLong( params.m_alphaTestRefVal );
            m_alphaTestRefColor = new ColorFrame( m_ui.alphaTestRefColor, color );
            layout->addWidget( m_alphaTestRefColor );
            connect( m_alphaTestRefColor, SIGNAL( changed( const QColor& ) ), this, SLOT( onParamChange() ) );
         }
      }

      // blending group box
      {
         m_ui.useAlphaBlend->setChecked( params.m_useBlending );
         connect( m_ui.useAlphaBlend, SIGNAL( toggled( bool ) ), this, SLOT( onParamChange() ) );

         m_ui.blendSrcFuncCombo->setCurrentIndex( params.m_blendSourceFunc - 1 );
         connect( m_ui.blendSrcFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) );

         m_ui.blendDestFuncCombo->setCurrentIndex( params.m_blendDestFunc - 1 );
         connect( m_ui.blendDestFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) );
      }

      // separate alpha blending group box
      {
         m_ui.useSeparatedAlphaBlending->setChecked( params.m_useSeparateAlphaBlend );
         connect( m_ui.useSeparatedAlphaBlending, SIGNAL( toggled( bool ) ), this, SLOT( onParamChange() ) );

         m_ui.alphaBlendSrcFuncCombo->setCurrentIndex( params.m_alphaBlendSourceFunc - 1 );
         connect( m_ui.alphaBlendSrcFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) );

         m_ui.alphaBlendDestFuncCombo->setCurrentIndex( params.m_alphaBlendDestFunc - 1 );
         connect( m_ui.alphaBlendDestFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) );
      }

      // stencil operations group box
      {
         m_ui.useStencil->setChecked( params.m_stencilEnable );
         connect( m_ui.useStencil, SIGNAL( toggled( bool ) ), this, SLOT( onParamChange() ) );

         m_ui.stencilFailCombo->setCurrentIndex( params.m_stencilFail - 1 );
         connect( m_ui.stencilFailCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) );

         m_ui.stencilZFailCombo->setCurrentIndex( params.m_stencilZFail - 1 );
         connect( m_ui.stencilZFailCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) );

         m_ui.stencilPassCombo->setCurrentIndex( params.m_stencilPass - 1 );
         connect( m_ui.stencilPassCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) );

         m_ui.stencilFuncCombo->setCurrentIndex( params.m_stencilFunc - 1 );
         connect( m_ui.stencilFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) );

         m_stencilRef = new HexEditor( m_ui.stencilRefFrame, params.m_stencilRef );
         m_ui.stencilRefFrame->layout()->addWidget( m_stencilRef );

         m_stencilMask = new HexEditor( m_ui.stencilMaskFrame, params.m_stencilMask );
         m_ui.stencilMaskFrame->layout()->addWidget( m_stencilMask );

         m_stencilWriteMask = new HexEditor( m_ui.stencilWriteMaskFrame, params.m_stencilWriteMask );
         m_ui.stencilWriteMaskFrame->layout()->addWidget( m_stencilWriteMask );
      }

      refreshRenderingParamsUI();
   }

   // set texture stages tabs
   {
      initializeTextureStagesTab();
   }

   // initialize the toolbar

   // file management
   {
      QAction* actionSave = new QAction( QIcon( iconsDir + tr( "/saveFile.png" ) ), tr( "Save" ), toolbar );
      actionSave->setShortcut( QKeySequence( tr( "Ctrl+S" ) ) );
      toolbar->addAction( actionSave );
      connect( actionSave, SIGNAL( triggered() ), this, SLOT( save() ) );

      QAction* actionImportFrom = new QAction( QIcon( iconsDir + tr( "/import.png" ) ), tr( "Import" ), toolbar );
      toolbar->addAction( actionImportFrom );
      connect( actionImportFrom, SIGNAL( triggered() ), this, SLOT( importFrom() ) );

      QAction* actionExportTo = new QAction( QIcon( iconsDir + tr( "/export.png" ) ), tr( "Export" ), toolbar );
      toolbar->addAction( actionExportTo );
      connect( actionExportTo, SIGNAL( triggered() ), this, SLOT( exportTo() ) );

      toolbar->addSeparator();
   }

   // script edition commands
   {
      QAction* actionUndo = new QAction( QIcon( iconsDir + tr( "/undo.png" ) ), tr( "Undo" ), toolbar );
      actionUndo->setShortcut( QKeySequence( tr( "Ctrl+Z" ) ) );
      toolbar->addAction( actionUndo );
      connect( actionUndo, SIGNAL( triggered() ), m_scriptEditor, SLOT( undo() ) );

      QAction* actionRedo = new QAction( QIcon( iconsDir + tr( "/redo.png" ) ), tr( "Redo" ), toolbar );
      actionRedo->setShortcut( QKeySequence( tr( "Ctrl+Y" ) ) );
      toolbar->addAction( actionRedo );
      connect( actionRedo, SIGNAL( triggered() ), m_scriptEditor, SLOT( redo() ) );

      toolbar->addSeparator();
   }

   // building commands
   {
      QAction* actionCompile = new QAction( QIcon( iconsDir + tr( "/play.png" ) ), tr( "Compile" ), toolbar );
      actionCompile->setShortcut( QKeySequence( tr( "F5" ) ) );
      toolbar->addAction( actionCompile );
      connect( actionCompile, SIGNAL( triggered() ), this, SLOT( compile() ) );
   }

   show();
}
示例#3
0
/* PaletteEntryPanel::handleAction
 * Handles the action [id]. Returns true if the action was handled,
 * false otherwise
 *******************************************************************/
bool PaletteEntryPanel::handleAction(string id)
{
	// Ignore if hidden
	if (!isActivePanel())
		return false;

	// Only interested in "ppal_" events
	if (!id.StartsWith("ppal_"))
		return false;

	// Add to custom palettes
	if (id == "ppal_addcustom")
	{
		addCustomPalette();
		return true;
	}

	// Test palette
	else if (id == "ppal_test")
	{
		testPalette();
		return true;
	}

	// Export As
	else if (id == "ppal_exportas")
	{
		exportAs();
		return true;
	}

	// Import From
	else if (id == "ppal_importfrom")
	{
		importFrom();
		return true;
	}

	// Generate Palettes
	if (id == "ppal_generate")
	{
		generatePalettes();
		return true;
	}

	// Generate Colormaps
	if (id == "ppal_colormap")
	{
		generateColormaps();
		return true;
	}

	// Colourise
	else if (id == "ppal_colourise")
	{
		colourise();
		return true;
	}

	// Tint
	else if (id == "ppal_tint")
	{
		tint();
		return true;
	}

	// Tweak
	else if (id == "ppal_tweak")
	{
		tweak();
		return true;
	}

	// Invert
	else if (id == "ppal_invert")
	{
		invert();
		return true;
	}

	// Move Up
	else if (id == "ppal_moveup")
	{
		move(true);
		return true;
	}

	// Move Down
	else if (id == "ppal_movedown")
	{
		move(false);
		return true;
	}

	// Duplicate
	else if (id == "ppal_duplicate")
	{
		duplicate();
		return true;
	}

	// Remove
	else if (id == "ppal_remove")
	{
		clearOne();
		return true;
	}

	// Remove Others
	else if (id == "ppal_removeothers")
	{
		clearOthers();
		return true;
	}

	// Some debug/reverse engineering stuff
	else if (id == "ppal_report")
	{
		analysePalettes();
		return true;
	}

	return false;
}