mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-23 15:46:18 +00:00
ADDED: #1471 Nel3D widget ( based on Dnk's similar widget ), NelGUI widget skeletons. NelGUI widget will be the widget which renders the GUI library's output and forward the input for it.
This commit is contained in:
parent
a840d7ad24
commit
19a087a0f7
9 changed files with 272 additions and 1 deletions
|
@ -126,6 +126,9 @@ namespace NLGUI
|
|||
/// Delete all textures and the like and reset the view renderer
|
||||
void reset();
|
||||
|
||||
/// Release the resources of CViewRenderer, and delete the Singleton
|
||||
static void release();
|
||||
|
||||
/// Retrieves the 3d driver we are using
|
||||
static NL3D::UDriver* getDriver();
|
||||
|
||||
|
|
|
@ -184,6 +184,18 @@ namespace NLGUI
|
|||
_Material.setTexture(3, NULL);
|
||||
_Material.setZBias(0);
|
||||
}
|
||||
|
||||
void CViewRenderer::release()
|
||||
{
|
||||
if( instance != NULL )
|
||||
{
|
||||
instance->reset();
|
||||
delete instance;
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* reset: reset the whole view renderer
|
||||
*/
|
||||
|
|
|
@ -20,6 +20,8 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
|
|||
proc_editor.h
|
||||
property_browser_ctrl.h
|
||||
project_window.h
|
||||
nel3d_widget.h
|
||||
nelgui_widget.h
|
||||
)
|
||||
|
||||
SET(OVQT_PLUGIN_GUI_EDITOR_UIS
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "proc_editor.h"
|
||||
#include "project_file_parser.h"
|
||||
#include "project_window.h"
|
||||
#include "nelgui_widget.h"
|
||||
|
||||
namespace GUIEditor
|
||||
{
|
||||
|
@ -51,7 +52,10 @@ namespace GUIEditor
|
|||
widgetProps = new CWidgetProperties;
|
||||
linkEditor = new LinkEditor;
|
||||
procEditor = new ProcEditor;
|
||||
projectWindow = new ProjectWindow();
|
||||
projectWindow = new ProjectWindow;
|
||||
viewPort = new NelGUIWidget;
|
||||
setCentralWidget( viewPort );
|
||||
|
||||
createMenus();
|
||||
readSettings();
|
||||
|
||||
|
@ -74,6 +78,8 @@ namespace GUIEditor
|
|||
browserCtrl.setup();
|
||||
dock->setWidget( tb );
|
||||
addDockWidget( Qt::RightDockWidgetArea, dock );
|
||||
|
||||
viewPort->init();
|
||||
}
|
||||
|
||||
GUIEditorWindow::~GUIEditorWindow()
|
||||
|
@ -91,6 +97,9 @@ namespace GUIEditor
|
|||
|
||||
delete projectWindow;
|
||||
projectWindow = NULL;
|
||||
|
||||
delete viewPort;
|
||||
viewPort = NULL;
|
||||
}
|
||||
|
||||
QUndoStack *GUIEditorWindow::undoStack() const
|
||||
|
@ -163,6 +172,10 @@ namespace GUIEditor
|
|||
a = new QAction( "Project Window", this );
|
||||
connect( a, SIGNAL( triggered( bool ) ), projectWindow, SLOT( show() ) );
|
||||
m->addAction( a );
|
||||
|
||||
a = new QAction( "Clear Viewport", this );
|
||||
connect( a, SIGNAL( triggered( bool ) ), viewPort, SLOT( clear() ) );
|
||||
m->addAction( a );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace GUIEditor
|
|||
class LinkEditor;
|
||||
class ProcEditor;
|
||||
class ProjectWindow;
|
||||
class NelGUIWidget;
|
||||
|
||||
class GUIEditorWindow: public QMainWindow
|
||||
{
|
||||
|
@ -63,6 +64,7 @@ private:
|
|||
LinkEditor *linkEditor;
|
||||
ProcEditor *procEditor;
|
||||
ProjectWindow *projectWindow;
|
||||
NelGUIWidget *viewPort;
|
||||
|
||||
CPropBrowserCtrl browserCtrl;
|
||||
QString currentProject;
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel3d_widget.h"
|
||||
#include "nel/3d/u_driver.h"
|
||||
#include "nel/3d/text_context.h"
|
||||
#include "nel/misc/rgba.h"
|
||||
#include "nel/misc/path.h"
|
||||
|
||||
|
||||
namespace GUIEditor
|
||||
{
|
||||
Nel3DWidget::Nel3DWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
driver = NULL;
|
||||
textContext = NULL;
|
||||
}
|
||||
|
||||
Nel3DWidget::~Nel3DWidget()
|
||||
{
|
||||
if( driver != NULL )
|
||||
{
|
||||
if( textContext != NULL )
|
||||
{
|
||||
driver->deleteTextContext( textContext );
|
||||
textContext = NULL;
|
||||
}
|
||||
|
||||
driver->release();
|
||||
delete driver;
|
||||
driver = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Nel3DWidget::init()
|
||||
{
|
||||
nlassert( driver == NULL );
|
||||
|
||||
driver = NL3D::UDriver::createDriver( 0, false, 0 );
|
||||
driver->setMatrixMode2D11();
|
||||
driver->setDisplay( winId(), NL3D::UDriver::CMode( width(), height(), 32, true ) );
|
||||
}
|
||||
|
||||
void Nel3DWidget::createTextContext( std::string fontFile )
|
||||
{
|
||||
if( driver == NULL )
|
||||
return;
|
||||
|
||||
std::string font;
|
||||
|
||||
try
|
||||
{
|
||||
font = NLMISC::CPath::lookup( fontFile );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
nlinfo( "Font %s cannot be found, cannot create textcontext!", fontFile.c_str() );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if( textContext != NULL )
|
||||
{
|
||||
driver->deleteTextContext( textContext );
|
||||
textContext = NULL;
|
||||
}
|
||||
|
||||
textContext = driver->createTextContext( font );
|
||||
}
|
||||
|
||||
void Nel3DWidget::clear()
|
||||
{
|
||||
if( driver == NULL )
|
||||
return;
|
||||
driver->clearBuffers( NLMISC::CRGBA::Black );
|
||||
driver->swapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef NEL3D_WIDGET_H
|
||||
#define NEL3D_WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class UDriver;
|
||||
class UTextContext;
|
||||
}
|
||||
|
||||
namespace GUIEditor
|
||||
{
|
||||
/// Nel 3D interface to Qt
|
||||
class Nel3DWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Nel3DWidget( QWidget *parent = NULL );
|
||||
virtual ~Nel3DWidget();
|
||||
|
||||
virtual void init();
|
||||
void createTextContext( std::string fontFile );
|
||||
|
||||
NL3D::UDriver* getDriver() const{ return driver; }
|
||||
NL3D::UTextContext* getTextContext() const{ return textContext; }
|
||||
|
||||
public Q_SLOTS:
|
||||
void clear();
|
||||
|
||||
private:
|
||||
NL3D::UDriver *driver;
|
||||
NL3D::UTextContext *textContext;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nelgui_widget.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/gui/view_renderer.h"
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
namespace GUIEditor
|
||||
{
|
||||
std::set< std::string > hwCursors;
|
||||
|
||||
NelGUIWidget::NelGUIWidget( QWidget *parent ) :
|
||||
Nel3DWidget( parent )
|
||||
{
|
||||
}
|
||||
|
||||
NelGUIWidget::~NelGUIWidget()
|
||||
{
|
||||
NLGUI::CViewRenderer::release();
|
||||
|
||||
}
|
||||
|
||||
void NelGUIWidget::init()
|
||||
{
|
||||
NLMISC::CPath::addSearchPath( "fonts" );
|
||||
|
||||
Nel3DWidget::init();
|
||||
createTextContext( "Ryzom.ttf" );
|
||||
|
||||
NLGUI::CViewRenderer::setDriver( getDriver() );
|
||||
NLGUI::CViewRenderer::setTextContext( getTextContext() );
|
||||
NLGUI::CViewRenderer::hwCursors = &hwCursors;
|
||||
NLGUI::CViewRenderer::getInstance()->init();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef NELGUI_WIDGET_H
|
||||
#define NELGUI_WIDGET_H
|
||||
|
||||
#include "nel3d_widget.h"
|
||||
|
||||
namespace GUIEditor
|
||||
{
|
||||
/// Qt viewport for the Nel GUI library
|
||||
class NelGUIWidget : public Nel3DWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NelGUIWidget( QWidget *parent = NULL );
|
||||
~NelGUIWidget();
|
||||
|
||||
void init();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue