From 7d831ac5aa1d8543c8d3261ba4362ce895857605 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 15 Oct 2014 19:54:35 +0200 Subject: [PATCH 01/31] TEMPORARILY add the login texture map to new project by default. --- code/studio/src/plugins/gui_editor/new_gui_dlg.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp b/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp index 3c9208dfc..43faabf79 100644 --- a/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp +++ b/code/studio/src/plugins/gui_editor/new_gui_dlg.cpp @@ -25,6 +25,9 @@ QDialog( parent ) { m_ui.setupUi( this ); + // Login texture map - temporaty measure until we add default textures for widgets to use + m_ui.mapList->addItem( "texture_interfaces_v3_login.tga" ); + connect( m_ui.okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) ); connect( m_ui.cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); connect( m_ui.projectDirTB, SIGNAL( clicked( bool ) ), this, SLOT( onProjectDirTBClicked() ) ); From 090502f10596dba5dd945b505fb5f4d9a88aeb1d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 15 Oct 2014 20:03:46 +0200 Subject: [PATCH 02/31] Default texture for CtrlButton. --- code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml b/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml index c081f3dae..b52bb73a5 100644 --- a/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml +++ b/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml @@ -12,17 +12,17 @@ tx_normal string - + tp_quit.tga tx_pushed string - + tp_quit.tga tx_over string - + tp_quit.tga scale From ab3a68a647b05956607e6099d450a4891189656f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 15 Oct 2014 20:07:13 +0200 Subject: [PATCH 03/31] CtrlButton textures should be selectable in the texture chooser! --- code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml b/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml index b52bb73a5..2454f7035 100644 --- a/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml +++ b/code/studio/src/plugins/gui_editor/widgets/CtrlButton.xml @@ -11,17 +11,17 @@ tx_normal - string + texture tp_quit.tga tx_pushed - string + texture tp_quit.tga tx_over - string + texture tp_quit.tga From f7d0f496c48b7353431fe3a82677ccac4982dc61 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 15 Oct 2014 20:20:44 +0200 Subject: [PATCH 04/31] A Kami will be the default texture for Bitmaps. --- code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml b/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml index 7d78f6c40..1c22d67cd 100644 --- a/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml +++ b/code/studio/src/plugins/gui_editor/widgets/ViewBitmap.xml @@ -37,7 +37,7 @@ texture texture - + log_kami.tga scale From 42a0a7d4431c13b3f7d805b7e9989408256b2763 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 15 Oct 2014 23:30:36 +0200 Subject: [PATCH 05/31] Render every 25ms instead of 200ms --- code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp b/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp index e9712ce4e..4852b227f 100644 --- a/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp +++ b/code/studio/src/plugins/gui_editor/nelgui_ctrl.cpp @@ -188,7 +188,7 @@ namespace GUIEditor void NelGUICtrl::onGUILoaded() { - timerID = startTimer( 200 ); + timerID = startTimer( 25 ); guiLoaded = true; Q_EMIT guiLoadComplete(); From 715fdd1ddf2822a7cf6671108a98f69383b50f2b Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 16 Oct 2014 20:25:19 +0200 Subject: [PATCH 06/31] Implemented CGroupEditBoxDecor a decorated CGroupEditBox. --- .../nel/include/nel/gui/group_editbox_decor.h | 49 +++ code/nel/include/nel/gui/interface_element.h | 8 + code/nel/src/gui/group_editbox.cpp | 12 +- code/nel/src/gui/group_editbox_decor.cpp | 357 ++++++++++++++++++ code/nel/src/gui/link_hack.cpp | 2 + code/nel/src/gui/widget_manager.cpp | 6 + .../gui_editor/widget_info_tree_node.h | 4 + .../gui_editor/widgets/GroupEditBoxDecor.xml | 68 ++++ 8 files changed, 503 insertions(+), 3 deletions(-) create mode 100644 code/nel/include/nel/gui/group_editbox_decor.h create mode 100644 code/nel/src/gui/group_editbox_decor.cpp create mode 100644 code/studio/src/plugins/gui_editor/widgets/GroupEditBoxDecor.xml diff --git a/code/nel/include/nel/gui/group_editbox_decor.h b/code/nel/include/nel/gui/group_editbox_decor.h new file mode 100644 index 000000000..a2b540608 --- /dev/null +++ b/code/nel/include/nel/gui/group_editbox_decor.h @@ -0,0 +1,49 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2014 Laszlo Kis-Adam +// 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 . + +#ifndef GROUP_EDITBOX_DECOR +#define GROUP_EDITBOX_DECOR + +#include "nel/gui/group_editbox.h" + +namespace NLGUI +{ + /// Decorated CGroupEditBox + class CGroupEditBoxDecor : public CGroupEditBox + { + public: + DECLARE_UI_CLASS( CGroupEditBoxDecor ) + + CGroupEditBoxDecor( const TCtorParam ¶m ); + ~CGroupEditBoxDecor(); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + bool parse( xmlNodePtr cur, CInterfaceGroup *parent ); + void draw(); + void updateCoords(); + + static void forceLink(); + + private: + class EBDPrivate *_Pvt; + }; +} + +#endif + diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index c1f6d20e7..e2f9ffc87 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -117,6 +117,7 @@ namespace NLGUI editorSelected = false; serializable = true; + _EditorSelectable = true; } // dtor @@ -531,9 +532,16 @@ namespace NLGUI /// Aligns the element to the other element specified void alignTo( CInterfaceElement *other ); + /// Specifies if the widget can be selected in the editor + void setEditorSelectable( bool b ){ _EditorSelectable = b; } + + /// Tells if the widget can be selected in the editor + bool isEditorSelectable() const{ return _EditorSelectable; } + protected: bool editorSelected; + bool _EditorSelectable; static bool editorMode; diff --git a/code/nel/src/gui/group_editbox.cpp b/code/nel/src/gui/group_editbox.cpp index 92ae46703..8c8ae867c 100644 --- a/code/nel/src/gui/group_editbox.cpp +++ b/code/nel/src/gui/group_editbox.cpp @@ -1548,13 +1548,17 @@ namespace NLGUI { _ViewText->setParent( this ); _ViewText->setIdRecurse( "edit_text" ); - _ViewText->setHardText( "sometext" ); + _ViewText->setHardText( "" ); _ViewText->setPosRef( Hotspot_TL ); _ViewText->setParentPosRef( Hotspot_TL ); addView( _ViewText ); + + sint32 w,h; + w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() ); + h = std::max( sint32( _ViewText->getFontHeight() ), getH() ); - setH( _ViewText->getFontHeight() ); - setW( _ViewText->getFontWidth() * _ViewText->getText().size() ); + setH( h ); + setW( w ); } else @@ -1562,6 +1566,8 @@ namespace NLGUI } } + _ViewText->setEditorSelectable( false ); + // For MultiLine editbox, clip the end space, else weird when edit space at end of line (nothing happens) if(_ViewText) _ViewText->setMultiLineClipEndSpace(true); diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp new file mode 100644 index 000000000..50241789e --- /dev/null +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -0,0 +1,357 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2014 Laszlo Kis-Adam +// 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 . + +#include "stdpch.h" +#include "nel/gui/group_editbox_decor.h" +#include "nel/gui/view_bitmap.h" + +namespace NLGUI +{ + class EBDPrivate + { + public: + enum Textures + { + BG, + L, + R, + TM, + BM, + TL, + TR, + BL, + BR, + TCOUNT + }; + + EBDPrivate() + { + for( int i = 0; i < TCOUNT; i++ ) + { + _Textures.push_back( new CViewBitmap( CViewBase::TCtorParam() ) ); + } + } + + ~EBDPrivate() + { + for( int i = 0; i < _Textures.size(); i++ ) + delete _Textures[ i ]; + _Textures.clear(); + } + + void draw() + { + for( int i = 0; i < _Textures.size(); i++ ) + { + CViewBitmap *bm = _Textures[ i ]; + bm->draw(); + } + } + + void updateCoords() + { + for( int i = 0; i < _Textures.size(); i++ ) + { + CViewBitmap *bm = _Textures[ i ]; + bm->fitTexture(); + } + + // W and H parameters depend on the sizes of the other textures + // Negative sizes mean that the sizes are that much smaller than the parent + sint32 w,h; + h = _Textures[ TL ]->getHReal() + _Textures[ BL ]->getHReal(); + h *= -1; + _Textures[ L ]->setH( h ); + + h = _Textures[ TR ]->getHReal() + _Textures[ BR ]->getHReal(); + h *= -1; + _Textures[ R ]->setH( h ); + + w = _Textures[ TL ]->getWReal() + _Textures[ TR ]->getWReal(); + w *= -1; + _Textures[ TM ]->setW( w ); + + w = _Textures[ BL ]->getWReal() + _Textures[ BR ]->getWReal(); + w *= -1; + _Textures[ BM ]->setW( w ); + + h = _Textures[ TM ]->getHReal() + _Textures[ BM ]->getHReal(); + h *= -1; + w = _Textures[ L ]->getWReal() + _Textures[ R ]->getWReal(); + w *= -1; + _Textures[ BG ]->setW( w ); + _Textures[ BG ]->setH( h ); + + for( int i = 0; i < _Textures.size(); i++ ) + { + CViewBitmap *bm = _Textures[ i ]; + bm->updateCoords(); + } + } + + void setup( CInterfaceGroup *parent ) + { + for( int i = 0; i < _Textures.size(); i++ ) + { + CViewBitmap *bm = _Textures[ i ]; + bm->setParent( parent ); + bm->setParentPos( parent ); + bm->setParentSize( parent ); + bm->setEditorSelectable( false ); + } + + _Textures[ TL ]->setPosRef( Hotspot_TL ); + _Textures[ TL ]->setParentPosRef( Hotspot_TL ); + + _Textures[ TM ]->setPosRef( Hotspot_TM ); + _Textures[ TM ]->setParentPosRef( Hotspot_TM ); + _Textures[ TM ]->setScale( true ); + _Textures[ TM ]->setSizeRef( "w" ); + + _Textures[ TR ]->setPosRef( Hotspot_TR ); + _Textures[ TR ]->setParentPosRef( Hotspot_TR ); + + _Textures[ BL ]->setPosRef( Hotspot_BL ); + _Textures[ BL ]->setParentPosRef( Hotspot_BL ); + + _Textures[ BM ]->setPosRef( Hotspot_BM ); + _Textures[ BM ]->setParentPosRef( Hotspot_BM ); + _Textures[ BM ]->setScale( true ); + _Textures[ BM ]->setSizeRef( "w" ); + + _Textures[ BR ]->setPosRef( Hotspot_BR ); + _Textures[ BR ]->setParentPosRef( Hotspot_BR ); + + _Textures[ L ]->setPosRef( Hotspot_ML ); + _Textures[ L ]->setParentPosRef( Hotspot_ML ); + _Textures[ L ]->setScale( true ); + _Textures[ L ]->setSizeRef( "h" ); + + _Textures[ R ]->setPosRef( Hotspot_MR ); + _Textures[ R ]->setParentPosRef( Hotspot_MR ); + _Textures[ R ]->setScale( true ); + _Textures[ R ]->setSizeRef( "h" ); + + _Textures[ BG ]->setPosRef( Hotspot_MM ); + _Textures[ BG ]->setParentPosRef( Hotspot_MM ); + _Textures[ BG ]->setScale( true ); + _Textures[ BG ]->setSizeRef( "wh" ); + _Textures[ BG ]->setRenderLayer( -1 ); + } + + std::vector< CViewBitmap* > _Textures; + }; + + NLMISC_REGISTER_OBJECT( CViewBase, CGroupEditBoxDecor, std::string, "edit_box_decor" ); + + CGroupEditBoxDecor::CGroupEditBoxDecor( const TCtorParam ¶m ) : + CGroupEditBox( param ) + { + _Pvt = new EBDPrivate(); + _Pvt->setup( this ); + } + + CGroupEditBoxDecor::~CGroupEditBoxDecor() + { + delete _Pvt; + _Pvt = NULL; + } + + std::string CGroupEditBoxDecor::getProperty( const std::string &name ) const + { + if( name == "tx_tl" ) + { + return _Pvt->_Textures[ EBDPrivate::TL ]->getTexture(); + } + else + if( name == "tx_tm" ) + { + return _Pvt->_Textures[ EBDPrivate::TM ]->getTexture(); + } + else + if( name == "tx_tr" ) + { + return _Pvt->_Textures[ EBDPrivate::TR ]->getTexture(); + } + else + if( name == "tx_bl" ) + { + return _Pvt->_Textures[ EBDPrivate::BL ]->getTexture(); + } + else + if( name == "tx_bm" ) + { + return _Pvt->_Textures[ EBDPrivate::BM ]->getTexture(); + } + else + if( name == "tx_br" ) + { + return _Pvt->_Textures[ EBDPrivate::BR ]->getTexture(); + } + else + if( name == "tx_l" ) + { + return _Pvt->_Textures[ EBDPrivate::L ]->getTexture(); + } + else + if( name == "tx_r" ) + { + return _Pvt->_Textures[ EBDPrivate::R ]->getTexture(); + } + else + if( name == "tx_bg" ) + { + return _Pvt->_Textures[ EBDPrivate::BG ]->getTexture(); + } + else + return CGroupEditBox::getProperty( name ); + } + + void CGroupEditBoxDecor::setProperty( const std::string &name, const std::string &value ) + { + if( name == "tx_tl" ) + { + _Pvt->_Textures[ EBDPrivate::TL ]->setTexture( value ); + } + else + if( name == "tx_tm" ) + { + _Pvt->_Textures[ EBDPrivate::TM ]->setTexture( value ); + } + else + if( name == "tx_tr" ) + { + _Pvt->_Textures[ EBDPrivate::TR ]->setTexture( value ); + } + else + if( name == "tx_bl" ) + { + _Pvt->_Textures[ EBDPrivate::BL ]->setTexture( value ); + } + else + if( name == "tx_bm" ) + { + _Pvt->_Textures[ EBDPrivate::BM ]->setTexture( value ); + } + else + if( name == "tx_br" ) + { + _Pvt->_Textures[ EBDPrivate::BR ]->setTexture( value ); + } + else + if( name == "tx_l" ) + { + _Pvt->_Textures[ EBDPrivate::L ]->setTexture( value ); + } + else + if( name == "tx_r" ) + { + _Pvt->_Textures[ EBDPrivate::R ]->setTexture( value ); + } + else + if( name == "tx_bg" ) + { + _Pvt->_Textures[ EBDPrivate::BG ]->setTexture( value ); + } + else + CGroupEditBox::setProperty( name, value ); + } + + xmlNodePtr CGroupEditBoxDecor::serialize( xmlNodePtr parentNode, const char *type ) const + { + xmlNodePtr node = CGroupEditBox::serialize( parentNode, type ); + if( node == NULL ) + return NULL; + + xmlSetProp( node, BAD_CAST "tx_tl", BAD_CAST _Pvt->_Textures[ EBDPrivate::TL ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_tr", BAD_CAST _Pvt->_Textures[ EBDPrivate::TM ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_tm", BAD_CAST _Pvt->_Textures[ EBDPrivate::TR ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_bl", BAD_CAST _Pvt->_Textures[ EBDPrivate::BL ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_bm", BAD_CAST _Pvt->_Textures[ EBDPrivate::BM ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_br", BAD_CAST _Pvt->_Textures[ EBDPrivate::BR ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_l", BAD_CAST _Pvt->_Textures[ EBDPrivate::L ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_r", BAD_CAST _Pvt->_Textures[ EBDPrivate::R ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_bg", BAD_CAST _Pvt->_Textures[ EBDPrivate::BG ]->getTexture().c_str() ); + + return node; + } + + bool CGroupEditBoxDecor::parse( xmlNodePtr cur, CInterfaceGroup *parent ) + { + if( !CGroupEditBox::parse( cur, parent ) ) + return false; + + CXMLAutoPtr prop; + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_tl" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::TL ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_tm" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::TM ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_tr" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::TR ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_bl" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::BL ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_bm" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::BM ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_br" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::BR ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_l" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::L ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_r" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::R ]->setTexture( ( const char* )prop ); + + prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_bg" ); + if( prop ) + _Pvt->_Textures[ EBDPrivate::BG ]->setTexture( ( const char* )prop ); + + return true; + } + + void CGroupEditBoxDecor::draw() + { + CGroupEditBox::draw(); + + _Pvt->draw(); + } + + void CGroupEditBoxDecor::updateCoords() + { + CGroupEditBox::updateCoords(); + _Pvt->updateCoords(); + } + + void CGroupEditBoxDecor::forceLink() + { + } +} + + diff --git a/code/nel/src/gui/link_hack.cpp b/code/nel/src/gui/link_hack.cpp index 06a8c23e8..3ecc6fb0a 100644 --- a/code/nel/src/gui/link_hack.cpp +++ b/code/nel/src/gui/link_hack.cpp @@ -20,6 +20,7 @@ #include "nel/gui/dbview_number.h" #include "nel/gui/dbview_quantity.h" #include "nel/gui/view_pointer.h" +#include "nel/gui/group_editbox_decor.h" namespace NLGUI { @@ -39,5 +40,6 @@ namespace NLGUI force_link_dbgroup_select_number_cpp(); force_link_dbgroup_combo_box_cpp(); force_link_group_wheel_cpp(); + CGroupEditBoxDecor::forceLink(); } } \ No newline at end of file diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 81fbaf28b..4591d7554 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -2436,6 +2436,9 @@ namespace NLGUI CCtrlBase *ctrl= _CtrlsUnderPointer[i]; if (ctrl && ctrl->isCapturable() && ctrl->isInGroup( pNewCurrentWnd ) ) { + if( CInterfaceElement::getEditorMode() && !ctrl->isEditorSelectable() ) + continue; + uint d = ctrl->getDepth( pNewCurrentWnd ); if (d > nMaxDepth) { @@ -2454,6 +2457,9 @@ namespace NLGUI CViewBase *v = _ViewsUnderPointer[i]; if( ( v != NULL ) && v->isInGroup( pNewCurrentWnd ) ) { + if( CInterfaceElement::getEditorMode() && !v->isEditorSelectable() ) + continue; + _CapturedView = v; captured = true; break; diff --git a/code/studio/src/plugins/gui_editor/widget_info_tree_node.h b/code/studio/src/plugins/gui_editor/widget_info_tree_node.h index 0de9e6977..8aefe6f0f 100644 --- a/code/studio/src/plugins/gui_editor/widget_info_tree_node.h +++ b/code/studio/src/plugins/gui_editor/widget_info_tree_node.h @@ -75,6 +75,10 @@ namespace GUIEditor // copy the properties to the child, since they inherit them for( std::vector< SPropEntry >::const_iterator itr = this->info.props.begin(); itr != this->info.props.end(); ++itr ) { + // Don't add property if already exists, since it's an override. + if( node->hasProperty( itr->propName ) ) + continue; + node->addProperty( *itr ); } } diff --git a/code/studio/src/plugins/gui_editor/widgets/GroupEditBoxDecor.xml b/code/studio/src/plugins/gui_editor/widgets/GroupEditBoxDecor.xml new file mode 100644 index 000000000..67865e707 --- /dev/null +++ b/code/studio/src/plugins/gui_editor/widgets/GroupEditBoxDecor.xml @@ -0,0 +1,68 @@ + +
+ GroupEditBoxDecor + CGroupEditBoxDecor + edit_box_decor + GroupEditBox + + false + +
+ + + w + int + 150 + + + h + int + 25 + + + tx_tl + texture + log_eb_tl.tga + + + tx_tm + texture + log_eb_t.tga + + + tx_tr + texture + log_eb_tr.tga + + + tx_bl + texture + log_eb_bl.tga + + + tx_bm + texture + log_eb_b.tga + + + tx_br + texture + log_eb_br.tga + + + tx_l + texture + log_eb_l.tga + + + tx_r + texture + log_eb_r.tga + + + tx_bg + texture + log_eb_m.tga + + +
From 9b8991038da36de61d9e9eb9d110ed696d92fac2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 16 Oct 2014 20:29:36 +0200 Subject: [PATCH 07/31] Allow selection of CGroupEditBox. --- code/nel/src/gui/group_editbox.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/nel/src/gui/group_editbox.cpp b/code/nel/src/gui/group_editbox.cpp index 8c8ae867c..049222210 100644 --- a/code/nel/src/gui/group_editbox.cpp +++ b/code/nel/src/gui/group_editbox.cpp @@ -1336,6 +1336,11 @@ namespace NLGUI // if click, and not frozen, then get the focus if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && !_Frozen) { + if( getEditorMode() ) + { + return CViewBase::handleEvent( event ); + } + _SelectingText = true; stopParentBlink(); CWidgetManager::getInstance()->setCaptureKeyboard (this); From 50625d3e293e99d099d4def4865220763ae41708 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 16 Oct 2014 20:58:47 +0200 Subject: [PATCH 08/31] Update decorated edit box decoration coords while dragging. --- code/nel/include/nel/gui/group_editbox_decor.h | 2 ++ code/nel/src/gui/group_editbox_decor.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/gui/group_editbox_decor.h b/code/nel/include/nel/gui/group_editbox_decor.h index a2b540608..153f48a25 100644 --- a/code/nel/include/nel/gui/group_editbox_decor.h +++ b/code/nel/include/nel/gui/group_editbox_decor.h @@ -31,6 +31,8 @@ namespace NLGUI CGroupEditBoxDecor( const TCtorParam ¶m ); ~CGroupEditBoxDecor(); + void moveBy( sint32 x, sint32 y ); + std::string getProperty( const std::string &name ) const; void setProperty( const std::string &name, const std::string &value ); xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index 50241789e..dd6b58b66 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -150,7 +150,6 @@ namespace NLGUI _Textures[ BG ]->setParentPosRef( Hotspot_MM ); _Textures[ BG ]->setScale( true ); _Textures[ BG ]->setSizeRef( "wh" ); - _Textures[ BG ]->setRenderLayer( -1 ); } std::vector< CViewBitmap* > _Textures; @@ -171,6 +170,13 @@ namespace NLGUI _Pvt = NULL; } + void CGroupEditBoxDecor::moveBy( sint32 x, sint32 y ) + { + CInterfaceElement::moveBy( x, y ); + + _Pvt->updateCoords(); + } + std::string CGroupEditBoxDecor::getProperty( const std::string &name ) const { if( name == "tx_tl" ) From 2a07542bf24dba2af834a58840a553119c6e16e9 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 16 Oct 2014 21:03:58 +0200 Subject: [PATCH 09/31] Save decorated edit box as such. --- code/nel/src/gui/group_editbox_decor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index dd6b58b66..78de4ead0 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -283,6 +283,7 @@ namespace NLGUI if( node == NULL ) return NULL; + xmlSetProp( node, BAD_CAST "type", BAD_CAST "edit_box_decor" ); xmlSetProp( node, BAD_CAST "tx_tl", BAD_CAST _Pvt->_Textures[ EBDPrivate::TL ]->getTexture().c_str() ); xmlSetProp( node, BAD_CAST "tx_tr", BAD_CAST _Pvt->_Textures[ EBDPrivate::TM ]->getTexture().c_str() ); xmlSetProp( node, BAD_CAST "tx_tm", BAD_CAST _Pvt->_Textures[ EBDPrivate::TR ]->getTexture().c_str() ); From 25b57502394eb6277817d89619abd2c7ff2c71ca Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 17 Oct 2014 16:01:50 +0200 Subject: [PATCH 10/31] Fixed a typo that messed up the textures of decorated editbox. --- code/nel/src/gui/group_editbox_decor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index 78de4ead0..899ea660c 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -285,8 +285,8 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "type", BAD_CAST "edit_box_decor" ); xmlSetProp( node, BAD_CAST "tx_tl", BAD_CAST _Pvt->_Textures[ EBDPrivate::TL ]->getTexture().c_str() ); - xmlSetProp( node, BAD_CAST "tx_tr", BAD_CAST _Pvt->_Textures[ EBDPrivate::TM ]->getTexture().c_str() ); - xmlSetProp( node, BAD_CAST "tx_tm", BAD_CAST _Pvt->_Textures[ EBDPrivate::TR ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_tr", BAD_CAST _Pvt->_Textures[ EBDPrivate::TR ]->getTexture().c_str() ); + xmlSetProp( node, BAD_CAST "tx_tm", BAD_CAST _Pvt->_Textures[ EBDPrivate::TM ]->getTexture().c_str() ); xmlSetProp( node, BAD_CAST "tx_bl", BAD_CAST _Pvt->_Textures[ EBDPrivate::BL ]->getTexture().c_str() ); xmlSetProp( node, BAD_CAST "tx_bm", BAD_CAST _Pvt->_Textures[ EBDPrivate::BM ]->getTexture().c_str() ); xmlSetProp( node, BAD_CAST "tx_br", BAD_CAST _Pvt->_Textures[ EBDPrivate::BR ]->getTexture().c_str() ); From 68fa12686743a3e5eda9c1cd11c8ccc6a32715b5 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 17 Oct 2014 21:18:26 +0200 Subject: [PATCH 11/31] Create the viewtext of the decorated edit box when the box is created, also adjust it so the text is drawn to the right of the left texture. --- code/nel/include/nel/gui/group_editbox.h | 4 ++ code/nel/src/gui/group_editbox.cpp | 59 +++++++++++++----------- code/nel/src/gui/group_editbox_decor.cpp | 8 ++++ 3 files changed, 43 insertions(+), 28 deletions(-) diff --git a/code/nel/include/nel/gui/group_editbox.h b/code/nel/include/nel/gui/group_editbox.h index 7ea2ab529..771bdc482 100644 --- a/code/nel/include/nel/gui/group_editbox.h +++ b/code/nel/include/nel/gui/group_editbox.h @@ -283,6 +283,10 @@ namespace NLGUI sint32 _ViewTextDeltaX; + CViewText* getVT() const{ return _ViewText; } + + void createViewText(); + private: void setupDisplayText(); void makeTopWindow(); diff --git a/code/nel/src/gui/group_editbox.cpp b/code/nel/src/gui/group_editbox.cpp index 049222210..0dd4ffbda 100644 --- a/code/nel/src/gui/group_editbox.cpp +++ b/code/nel/src/gui/group_editbox.cpp @@ -1536,40 +1536,43 @@ namespace NLGUI CInterfaceGroup::clearViews(); } + // ---------------------------------------------------------------------------- + + void CGroupEditBox::createViewText() + { + nlwarning("Interface: CGroupEditBox: text 'edit_text' missing or bad type"); + nlwarning( "Trying to create a new 'edit_text' for %s", getId().c_str() ); + _ViewText = dynamic_cast< CViewText* >( CInterfaceFactory::createClass( "text" ) ); + if( _ViewText == NULL ) + { + nlwarning( "Failed to create new 'edit_text' for %s", getId().c_str() ); + return; + } + + _ViewText->setParent( this ); + _ViewText->setIdRecurse( "edit_text" ); + _ViewText->setHardText( "" ); + _ViewText->setPosRef( Hotspot_ML ); + _ViewText->setParentPosRef( Hotspot_ML ); + addView( _ViewText ); + + sint32 w,h; + w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() ); + h = std::max( sint32( _ViewText->getFontHeight() ), getH() ); + + setH( h ); + setW( w ); + } + // ---------------------------------------------------------------------------- void CGroupEditBox::setup() { // bind to the controls - _ViewText = dynamic_cast(CInterfaceGroup::getView("edit_text")); + if( _ViewText == NULL ) + _ViewText = dynamic_cast(CInterfaceGroup::getView("edit_text")); if(_ViewText == NULL) - { - nlwarning("Interface: CGroupEditBox: text 'edit_text' missing or bad type"); - if( editorMode ) - { - nlwarning( "Trying to create a new 'edit_text' for %s", getId().c_str() ); - _ViewText = dynamic_cast< CViewText* >( CInterfaceFactory::createClass( "text" ) ); - if( _ViewText != NULL ) - { - _ViewText->setParent( this ); - _ViewText->setIdRecurse( "edit_text" ); - _ViewText->setHardText( "" ); - _ViewText->setPosRef( Hotspot_TL ); - _ViewText->setParentPosRef( Hotspot_TL ); - addView( _ViewText ); - - sint32 w,h; - w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() ); - h = std::max( sint32( _ViewText->getFontHeight() ), getH() ); - - setH( h ); - setW( w ); - - } - else - nlwarning( "Failed to create new 'edit_text' for %s", getId().c_str() ); - } - } + createViewText(); _ViewText->setEditorSelectable( false ); diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index 899ea660c..a5a2c8239 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -18,6 +18,7 @@ #include "stdpch.h" #include "nel/gui/group_editbox_decor.h" #include "nel/gui/view_bitmap.h" +#include "nel/gui/view_text.h" namespace NLGUI { @@ -162,6 +163,10 @@ namespace NLGUI { _Pvt = new EBDPrivate(); _Pvt->setup( this ); + + createViewText(); + getVT()->setSerializable( false ); + getVT()->setEditorSelectable( false ); } CGroupEditBoxDecor::~CGroupEditBoxDecor() @@ -352,6 +357,9 @@ namespace NLGUI void CGroupEditBoxDecor::updateCoords() { + sint32 tw = _Pvt->_Textures[ EBDPrivate::L ]->getWReal(); + getVT()->setX( tw + 1 ); + CGroupEditBox::updateCoords(); _Pvt->updateCoords(); } From 50486109df5f090a11d1db798fd553d525337af7 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 17 Oct 2014 21:23:00 +0200 Subject: [PATCH 12/31] Don't add non-selectable widgets to the hierarchy tree. --- code/studio/src/plugins/gui_editor/widget_hierarchy.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/studio/src/plugins/gui_editor/widget_hierarchy.cpp b/code/studio/src/plugins/gui_editor/widget_hierarchy.cpp index 343d8efd8..17e7f6e57 100644 --- a/code/studio/src/plugins/gui_editor/widget_hierarchy.cpp +++ b/code/studio/src/plugins/gui_editor/widget_hierarchy.cpp @@ -166,6 +166,9 @@ namespace GUIEditor std::vector< CCtrlBase* >::const_iterator citr; for( citr = controls.begin(); citr != controls.end(); ++citr ) { + if( !(*citr)->isEditorSelectable() ) + continue; + QTreeWidgetItem *subItem = new QTreeWidgetItem( item ); subItem->setText( 0, makeNodeName( (*citr)->getId() ).c_str() ); widgetHierarchyMap[ (*citr)->getId() ] = subItem; @@ -176,6 +179,9 @@ namespace GUIEditor std::vector< CViewBase* >::const_iterator vitr; for( vitr = views.begin(); vitr != views.end(); ++vitr ) { + if( !(*vitr)->isEditorSelectable() ) + continue; + QTreeWidgetItem *subItem = new QTreeWidgetItem( item ); subItem->setText( 0, makeNodeName( (*vitr)->getId() ).c_str() ); widgetHierarchyMap[ (*vitr)->getId() ] = subItem; From c96c030b258dc0f47b7560eccd47b4e7009fb307 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 17 Oct 2014 22:25:30 +0200 Subject: [PATCH 13/31] set the Id of the text properly when loading the decorated edit box. --- code/nel/src/gui/group_editbox_decor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index a5a2c8239..fd7f1110d 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -345,6 +345,8 @@ namespace NLGUI if( prop ) _Pvt->_Textures[ EBDPrivate::BG ]->setTexture( ( const char* )prop ); + getVT()->setIdRecurse( "edit_text" ); + return true; } From 3193ab11dee72301bda1e0923a24675fd10c7298 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 20 Oct 2014 18:51:53 +0200 Subject: [PATCH 14/31] When setting the Id of the decorated edit box, set the Id of the text as well. --- code/nel/include/nel/gui/group_editbox_decor.h | 2 ++ code/nel/src/gui/group_editbox_decor.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/code/nel/include/nel/gui/group_editbox_decor.h b/code/nel/include/nel/gui/group_editbox_decor.h index 153f48a25..975177612 100644 --- a/code/nel/include/nel/gui/group_editbox_decor.h +++ b/code/nel/include/nel/gui/group_editbox_decor.h @@ -33,6 +33,8 @@ namespace NLGUI void moveBy( sint32 x, sint32 y ); + void setIdRecurse( const std::string &newID ); + std::string getProperty( const std::string &name ) const; void setProperty( const std::string &name, const std::string &value ); xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; diff --git a/code/nel/src/gui/group_editbox_decor.cpp b/code/nel/src/gui/group_editbox_decor.cpp index fd7f1110d..ae31513de 100644 --- a/code/nel/src/gui/group_editbox_decor.cpp +++ b/code/nel/src/gui/group_editbox_decor.cpp @@ -182,6 +182,12 @@ namespace NLGUI _Pvt->updateCoords(); } + void CGroupEditBoxDecor::setIdRecurse( const std::string &newID ) + { + CInterfaceElement::setIdRecurse( newID ); + _ViewText->setIdRecurse( _ViewText->getShortId() ); + } + std::string CGroupEditBoxDecor::getProperty( const std::string &name ) const { if( name == "tx_tl" ) From 112d137addd857b10f387dd6875a31f4940e223a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 20 Oct 2014 20:57:08 +0200 Subject: [PATCH 15/31] DBViewNumber shouldn't crash anymore. --- code/nel/include/nel/gui/dbview_number.h | 4 +--- code/nel/include/nel/gui/interface_property.h | 9 +++++++++ code/nel/src/gui/dbview_number.cpp | 11 +++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/code/nel/include/nel/gui/dbview_number.h b/code/nel/include/nel/gui/dbview_number.h index 2c76a255d..bfa963fb6 100644 --- a/code/nel/include/nel/gui/dbview_number.h +++ b/code/nel/include/nel/gui/dbview_number.h @@ -55,9 +55,7 @@ namespace NLGUI static void forceLink(); protected: - - sint64 getVal() { if (_Modulo == 0) return (_Number.getSInt64() / _Divisor); - else return (_Number.getSInt64() / _Divisor)%_Modulo; } + sint64 getVal(); protected: diff --git a/code/nel/include/nel/gui/interface_property.h b/code/nel/include/nel/gui/interface_property.h index 63a62ef0e..4ed6e701e 100644 --- a/code/nel/include/nel/gui/interface_property.h +++ b/code/nel/include/nel/gui/interface_property.h @@ -47,6 +47,15 @@ namespace NLGUI _VolatileValue = NULL; } + /// Tells if this property has a value + bool hasValue() const + { + if( _VolatileValue != NULL ) + return true; + else + return false; + } + NLMISC::CCDBNodeLeaf* getNodePtr() const { return _VolatileValue; diff --git a/code/nel/src/gui/dbview_number.cpp b/code/nel/src/gui/dbview_number.cpp index a0b6dfb02..bd193c47d 100644 --- a/code/nel/src/gui/dbview_number.cpp +++ b/code/nel/src/gui/dbview_number.cpp @@ -249,5 +249,16 @@ namespace NLGUI { } + sint64 CDBViewNumber::getVal() + { + if( !_Number.hasValue() ) + return 0; + + if( _Modulo == 0 ) + return _Number.getSInt64() / _Divisor; + else + return ( _Number.getSInt64() / _Divisor ) % _Modulo; + } + } From 38d2366a715d18ed1c4facd416633ce93730f272 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 20 Oct 2014 22:21:59 +0200 Subject: [PATCH 16/31] it's not a bad idea to store the value in the right variable... --- code/nel/src/gui/dbview_number.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/gui/dbview_number.cpp b/code/nel/src/gui/dbview_number.cpp index bd193c47d..e844bf4c0 100644 --- a/code/nel/src/gui/dbview_number.cpp +++ b/code/nel/src/gui/dbview_number.cpp @@ -121,7 +121,7 @@ namespace NLGUI { sint64 i; if( fromString( value, i ) ) - _Divisor = i; + _Modulo = i; return; } else From 173bf9e7734310b02e4124e0bc889949e7726edd Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 20 Oct 2014 22:27:33 +0200 Subject: [PATCH 17/31] Default text for DBViewNumber. --- code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml b/code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml index 36a7d23ce..99cc153ce 100644 --- a/code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml +++ b/code/studio/src/plugins/gui_editor/widgets/DBViewNumber.xml @@ -9,6 +9,11 @@ + + hardtext + string + 0 + value string From b6c9cc5498e6f7e69d90bcda1123c9c46edc724e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 20 Oct 2014 22:49:46 +0200 Subject: [PATCH 18/31] CDBViewQuantity shouldn't crash in the editor. --- code/nel/src/gui/dbview_quantity.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/code/nel/src/gui/dbview_quantity.cpp b/code/nel/src/gui/dbview_quantity.cpp index ad651f582..12dfce4b8 100644 --- a/code/nel/src/gui/dbview_quantity.cpp +++ b/code/nel/src/gui/dbview_quantity.cpp @@ -157,14 +157,17 @@ namespace NLGUI // *************************************************************************** void CDBViewQuantity::draw () { - // change text - sint32 val= _Number.getSInt32(); - sint32 valMax= _NumberMax.getSInt32(); - if(_Cache!=val || _CacheMax!=valMax) + if( _Number.hasValue() && _NumberMax.hasValue() ) { - _Cache= val; - _CacheMax=valMax; - buildTextFromCache(); + // change text + sint32 val= _Number.getSInt32(); + sint32 valMax= _NumberMax.getSInt32(); + if(_Cache!=val || _CacheMax!=valMax) + { + _Cache= val; + _CacheMax=valMax; + buildTextFromCache(); + } } // parent call From cc52abcfa06b731a8fee546cb3195e703a0db650 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 17 Feb 2015 03:12:26 +0100 Subject: [PATCH 19/31] CMsgBoxDisplayer should not present a dialog now, but write the report to a file then attempt to launch the error reporter application. Which ofc doesn't exist yet in this commit. --- code/nel/src/misc/debug.cpp | 2 +- code/nel/src/misc/report.cpp | 293 ++------------------------------- code/ryzom/client/src/init.cpp | 2 + 3 files changed, 19 insertions(+), 278 deletions(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index c7667acc2..2d09f5ef8 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -83,7 +83,7 @@ using namespace std; #define LOG_IN_FILE NEL_LOG_IN_FILE // If true, debug system will trap crash even if the application is in debugger -static const bool TrapCrashInDebugger = false; +static const bool TrapCrashInDebugger = true; #ifdef DEBUG_NEW #define new DEBUG_NEW diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 20b2b1c11..39f27de5f 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -42,25 +42,14 @@ using namespace std; namespace NLMISC { -#ifdef NL_OS_WINDOWS -static HWND sendReport=NULL; -#endif - //old doesn't work on visual c++ 7.1 due to default parameter typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile = "", bool onlyCheck = false); typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile, bool onlyCheck); -#define DELETE_OBJECT(a) if((a)!=NULL) { DeleteObject (a); a = NULL; } - static TEmailFunction EmailFunction = NULL; void setReportEmailFunction (void *emailFunction) { EmailFunction = (TEmailFunction)emailFunction; - -#ifdef NL_OS_WINDOWS - if (sendReport) - EnableWindow(sendReport, FALSE); -#endif } #ifndef NL_OS_WINDOWS @@ -73,91 +62,26 @@ void report () #else -// Windows specific version - -static string Body; -static string Subject; -static string AttachedFile; - -static HWND checkIgnore=NULL; -static HWND debug=NULL; -static HWND ignore=NULL; -static HWND quit=NULL; -static HWND dialog=NULL; - -static bool NeedExit; -static TReportResult Result; -static bool IgnoreNextTime; -static bool CanSendMailReport= false; - -static bool DebugDefaultBehavior, QuitDefaultBehavior; - -static void sendEmail() +TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile) { - if (CanSendMailReport && SendMessage(sendReport, BM_GETCHECK, 0, 0) != BST_CHECKED) + std::string fname; + + time_t s = time( NULL ); + fname = std::string( "log_" ) + toString( s ) + ".txt"; + + std::ofstream f; + f.open( fname.c_str() ); + if( f.good() ) { - bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false); - if (res) - { - // EnableWindow(sendReport, FALSE); - // MessageBox (dialog, "The email was successfully sent", "email", MB_OK); -#ifndef NL_NO_DEBUG_FILES - CFile::createEmptyFile(getLogDirectory() + "report_sent"); -#endif - } - else - { -#ifndef NL_NO_DEBUG_FILES - CFile::createEmptyFile(getLogDirectory() + "report_failed"); -#endif - // MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); - } + f << body; + f.close(); + + NLMISC::launchProgram( "rcerror", fname ); } - else - { -#ifndef NL_NO_DEBUG_FILES - CFile::createEmptyFile(getLogDirectory() + "report_refused"); -#endif - } -} -static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - //MSGFILTER *pmf; + NLMISC::CFile::deleteFile( fname ); + - if (message == WM_COMMAND && HIWORD(wParam) == BN_CLICKED) - { - if ((HWND) lParam == checkIgnore) - { - IgnoreNextTime = !IgnoreNextTime; - } - else if ((HWND) lParam == debug) - { - sendEmail(); - NeedExit = true; - Result = ReportDebug; - if (DebugDefaultBehavior) - { - NLMISC_BREAKPOINT; - } - } - else if ((HWND) lParam == ignore) - { - sendEmail(); - NeedExit = true; - Result = ReportIgnore; - } - else if ((HWND) lParam == quit) - { - sendEmail(); - NeedExit = true; - Result = ReportQuit; - - if (QuitDefaultBehavior) - { - // ace: we cannot call exit() because it's call the static object dtor and can crash the application - // if the dtor call order is not good. - //exit(EXIT_SUCCESS); #ifdef NL_OS_WINDOWS #ifndef NL_COMP_MINGW // disable the Windows popup telling that the application aborted and disable the dr watson report. @@ -166,193 +90,8 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM #endif // quit without calling atexit or static object dtors. abort(); - } - } - /*else if ((HWND) lParam == sendReport) - { - if (EmailFunction != NULL) - { - bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false); - if (res) - { - EnableWindow(sendReport, FALSE); - MessageBox (dialog, "The email was successfully sent", "email", MB_OK); - CFile::createEmptyFile(getLogDirectory() + "report_sent"); - } - else - { - MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); - } - } - }*/ - } - else if (message == WM_CHAR) - { - if (wParam == 27) - { - // ESC -> ignore - sendEmail(); - NeedExit = true; - Result = ReportIgnore; - } - } - return DefWindowProc (hWnd, message, wParam, lParam); -} - -TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile) -{ - // register the window - static bool AlreadyRegister = false; - if(!AlreadyRegister) - { - WNDCLASSW wc; - memset (&wc,0,sizeof(wc)); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = (WNDPROC)WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = GetModuleHandle(NULL); - wc.hIcon = NULL; - wc.hCursor = LoadCursor(NULL,IDC_ARROW); - wc.hbrBackground = (HBRUSH)COLOR_WINDOW; - wc.lpszClassName = L"NLReportWindow"; - wc.lpszMenuName = NULL; - if (!RegisterClassW(&wc)) return ReportError; - AlreadyRegister = true; - } - - ucstring formatedTitle = title.empty() ? ucstring("NeL report") : ucstring(title); - - - // create the window - dialog = CreateWindowW (L"NLReportWindow", (LPCWSTR)formatedTitle.c_str(), WS_DLGFRAME | WS_CAPTION /*| WS_THICKFRAME*/, CW_USEDEFAULT, CW_USEDEFAULT, 456, 400, NULL, NULL, GetModuleHandle(NULL), NULL); - - // create the font - HFONT font = CreateFont (-12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); - - Subject = subject; - AttachedFile = attachedFile; - - // create the edit control - HWND edit = CreateWindowW (L"EDIT", NULL, WS_BORDER | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_READONLY | ES_LEFT | ES_MULTILINE, 7, 70, 429, 212, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (edit, WM_SETFONT, (WPARAM) font, TRUE); - - // set the edit text limit to lot of :) - SendMessage (edit, EM_LIMITTEXT, ~0U, 0); - - Body = addSlashR (body); - - // set the message in the edit text - SendMessage (edit, WM_SETTEXT, (WPARAM)0, (LPARAM)Body.c_str()); - - if (enableCheckIgnore) - { - // create the combo box control - checkIgnore = CreateWindowW (L"BUTTON", L"Don't display this report again", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_CHECKBOX, 7, 290, 429, 18, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (checkIgnore, WM_SETFONT, (WPARAM) font, TRUE); - - if(ignoreNextTime) - { - SendMessage (checkIgnore, BM_SETCHECK, BST_CHECKED, 0); - } - } - - // create the debug button control - debug = CreateWindowW (L"BUTTON", L"Debug", WS_CHILD | WS_VISIBLE, 7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (debug, WM_SETFONT, (WPARAM) font, TRUE); - - if (debugButton == 0) - EnableWindow(debug, FALSE); - - // create the ignore button control - ignore = CreateWindowW (L"BUTTON", L"Ignore", WS_CHILD | WS_VISIBLE, 75+7+7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (ignore, WM_SETFONT, (WPARAM) font, TRUE); - - if (ignoreButton == 0) - EnableWindow(ignore, FALSE); - - // create the quit button control - quit = CreateWindowW (L"BUTTON", L"Quit", WS_CHILD | WS_VISIBLE, 75+75+7+7+7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (quit, WM_SETFONT, (WPARAM) font, TRUE); - - if (quitButton == 0) - EnableWindow(quit, FALSE); - - // create the debug button control - sendReport = CreateWindowW (L"BUTTON", L"Don't send the report", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 7, 315+32, 429, 18, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (sendReport, WM_SETFONT, (WPARAM) font, TRUE); - - string formatedHeader; - if (header.empty()) - { - formatedHeader = "This application stopped to display this report."; - } - else - { - formatedHeader = header; - } - - // ace don't do that because it s slow to try to send a mail - //CanSendMailReport = sendReportButton && EmailFunction != NULL && EmailFunction("", "", "", "", "", true); - CanSendMailReport = sendReportButton && EmailFunction != NULL; - - if (CanSendMailReport) - formatedHeader += " Send report will only email the contents of the box below. Please, send it to help us (it could take few minutes to send the email, be patient)."; - else - EnableWindow(sendReport, FALSE); - - ucstring uc = ucstring::makeFromUtf8(formatedHeader); - - // create the label control - HWND label = CreateWindowW (L"STATIC", (LPCWSTR)uc.c_str(), WS_CHILD | WS_VISIBLE /*| SS_WHITERECT*/, 7, 7, 429, 51, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (label, WM_SETFONT, (WPARAM) font, TRUE); - - - DebugDefaultBehavior = debugButton==1; - QuitDefaultBehavior = quitButton==1; - - IgnoreNextTime = ignoreNextTime; - - // show until the cursor really show :) - while (ShowCursor(TRUE) < 0) - ; - - SetWindowPos (dialog, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); - - SetFocus(dialog); - SetForegroundWindow(dialog); - - NeedExit = false; - - while(!NeedExit) - { - MSG msg; - while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessageW(&msg); - } - nlSleep (1); - } - - // set the user result - ignoreNextTime = IgnoreNextTime; - - ShowWindow(dialog, SW_HIDE); - - - - DELETE_OBJECT(sendReport) - DELETE_OBJECT(quit) - DELETE_OBJECT(ignore) - DELETE_OBJECT(debug) - DELETE_OBJECT(checkIgnore) - DELETE_OBJECT(edit) - DELETE_OBJECT(label) - DELETE_OBJECT(dialog) - - return Result; + return ReportQuit; } #endif diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 6958fe790..c7fdc97f8 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -539,6 +539,8 @@ void checkDriverVersion() void checkDriverDepth () { + nlassert( false ); + // Check desktop is in 32 bit else no window mode allowed. if (ClientCfg.Windowed) { From e962a413234dbcc1485fea9a08914d05ee223274 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 19 Feb 2015 00:20:18 +0100 Subject: [PATCH 20/31] Added the Ryzom Core Error Reporter's skeleton. --- code/nel/CMakeLists.txt | 3 ++ code/nel/rcerror/CMakeLists.txt | 37 +++++++++++++ code/nel/rcerror/rcerror.cpp | 50 ++++++++++++++++++ code/nel/rcerror/rcerror_socket.cpp | 20 +++++++ code/nel/rcerror/rcerror_socket.h | 23 ++++++++ code/nel/rcerror/rcerror_widget.cpp | 70 ++++++++++++++++++++++++ code/nel/rcerror/rcerror_widget.h | 47 +++++++++++++++++ code/nel/rcerror/rcerror_widget.ui | 82 +++++++++++++++++++++++++++++ 8 files changed, 332 insertions(+) create mode 100644 code/nel/rcerror/CMakeLists.txt create mode 100644 code/nel/rcerror/rcerror.cpp create mode 100644 code/nel/rcerror/rcerror_socket.cpp create mode 100644 code/nel/rcerror/rcerror_socket.h create mode 100644 code/nel/rcerror/rcerror_widget.cpp create mode 100644 code/nel/rcerror/rcerror_widget.h create mode 100644 code/nel/rcerror/rcerror_widget.ui diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index 53bf071e3..00290d097 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -84,3 +84,6 @@ IF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) ADD_SUBDIRECTORY(tools) ENDIF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) +IF(WITH_QT) + ADD_SUBDIRECTORY(rcerror) +ENDIF(WITH_QT) diff --git a/code/nel/rcerror/CMakeLists.txt b/code/nel/rcerror/CMakeLists.txt new file mode 100644 index 000000000..412da9b6c --- /dev/null +++ b/code/nel/rcerror/CMakeLists.txt @@ -0,0 +1,37 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SRC_DIR} ${QT_INCLUDES}) +FILE(GLOB RCERROR_SRC *.cpp) +FILE(GLOB RCERROR_HDR *h) + +SET(RCERROR_MOC_HDR +rcerror_socket.h +rcerror_widget.h +) + +SET(RCERROR_UI +rcerror_widget.ui +) + +SET(QT_USE_QTGUI TRUE) +SET(QT_USE_QTNETWORK TRUE) +SET(QT_USE_QTMAIN TRUE) +SET(QT_USE_QTOPENGL FALSE) +SET(QT_USE_QTXML FALSE) + +INCLUDE(${QT_USE_FILE}) +ADD_DEFINITIONS(${QT_DEFINITIONS}) + +QT4_WRAP_CPP(RCERROR_MOC_SRC ${RCERROR_MOC_HDR}) +QT4_WRAP_UI(RCERROR_UI_HDR ${RCERROR_UI}) + +SOURCE_GROUP(QtResources FILES ${RCERROR_UI}) +SOURCE_GROUP(QtGeneratedUiHdr FILES ${RCERROR_UI_HDR}) +SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${RCERROR_MOC_SRC}) +SOURCE_GROUP("source files" FILES ${RCERROR_SRC}) +SOURCE_GROUP("header files" FILES ${RCERROR_HDR}) + +ADD_EXECUTABLE(rcerror WIN32 MACOSX_BUNDLE ${RCERROR_SRC} ${RCERROR_MOC_HDR} ${RCERROR_MOC_SRC} ${RCERROR_UI_HDR}) +TARGET_LINK_LIBRARIES(rcerror ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) + +NL_DEFAULT_PROPS(rcerror "Ryzom Core Error Reporter") +NL_ADD_RUNTIME_FLAGS(rcerror) + diff --git a/code/nel/rcerror/rcerror.cpp b/code/nel/rcerror/rcerror.cpp new file mode 100644 index 000000000..6fa876e81 --- /dev/null +++ b/code/nel/rcerror/rcerror.cpp @@ -0,0 +1,50 @@ +// Ryzom Core MMORPG framework - Error Reporter +// +// Copyright (C) 2015 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// 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 . + + +#include "rcerror_widget.h" +#include +#include + +int main( int argc, char **argv ) +{ + QApplication app( argc, argv ); + +#if 0 + + if( argc < 2 ) + { + QMessageBox::information( NULL, + QObject::tr( "Error" ), + QObject::tr( "Need to specify a path to the error report." ) ); + return 1; + } +#endif + + RCErrorWidget w; + +#if 0 + w.setFileName( argv[ 1 ] ); +#else + w.setFileName( "log.log" ); +#endif + + w.show(); + + return app.exec(); +} \ No newline at end of file diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/rcerror/rcerror_socket.cpp new file mode 100644 index 000000000..f39946423 --- /dev/null +++ b/code/nel/rcerror/rcerror_socket.cpp @@ -0,0 +1,20 @@ +// Ryzom Core MMORPG framework - Error Reporter +// +// Copyright (C) 2015 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// 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 . + +#include "rcerror_socket.h" + diff --git a/code/nel/rcerror/rcerror_socket.h b/code/nel/rcerror/rcerror_socket.h new file mode 100644 index 000000000..8cd9f54ad --- /dev/null +++ b/code/nel/rcerror/rcerror_socket.h @@ -0,0 +1,23 @@ +// Ryzom Core MMORPG framework - Error Reporter +// +// Copyright (C) 2015 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// 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 . + + +#ifndef RCERROR_SOCKET +#define RCERROR_SOCKET +#endif + diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp new file mode 100644 index 000000000..a50b273d3 --- /dev/null +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -0,0 +1,70 @@ +// Ryzom Core MMORPG framework - Error Reporter +// +// Copyright (C) 2015 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// 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 . + + +#include "rcerror_widget.h" +#include +#include +#include + +RCErrorWidget::RCErrorWidget( QWidget *parent ) : +QWidget( parent ) +{ + m_ui.setupUi( this ); + QTimer::singleShot( 1, this, SLOT( onLoad() ) ); + + connect( m_ui.sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) ); + connect( m_ui.canceButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); + connect( m_ui.emailCB, SIGNAL( stateChanged( int ) ), this, SLOT( onCBClicked() ) ); +} + +RCErrorWidget::~RCErrorWidget() +{ +} + +void RCErrorWidget::onLoad() +{ + QFile f( m_fileName ); + bool b = f.open( QFile::ReadOnly | QFile::Text ); + if( !b ) + { + return; + } + + QTextStream ss( &f ); + m_ui.reportEdit->setPlainText( ss.readAll() ); + f.close(); +} + +void RCErrorWidget::onSendClicked() +{ + close(); +} + +void RCErrorWidget::onCancelClicked() +{ + close(); +} + +void RCErrorWidget::onCBClicked() +{ + m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() ); +} + + + diff --git a/code/nel/rcerror/rcerror_widget.h b/code/nel/rcerror/rcerror_widget.h new file mode 100644 index 000000000..ae5629e55 --- /dev/null +++ b/code/nel/rcerror/rcerror_widget.h @@ -0,0 +1,47 @@ +// Ryzom Core MMORPG framework - Error Reporter +// +// Copyright (C) 2015 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// 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 . + + +#ifndef RCERROR_WIDGET +#define RCERROR_SOCKET + + +#include "ui_rcerror_widget.h" + +class RCErrorWidget : public QWidget +{ + Q_OBJECT +public: + RCErrorWidget( QWidget *parent = NULL ); + ~RCErrorWidget(); + + void setFileName( const char *fn ){ m_fileName = fn; } + +private Q_SLOTS: + void onLoad(); + void onSendClicked(); + void onCancelClicked(); + void onCBClicked(); + +private: + Ui::RCErrorWidget m_ui; + QString m_fileName; +}; + +#endif + diff --git a/code/nel/rcerror/rcerror_widget.ui b/code/nel/rcerror/rcerror_widget.ui new file mode 100644 index 000000000..72e5f92f5 --- /dev/null +++ b/code/nel/rcerror/rcerror_widget.ui @@ -0,0 +1,82 @@ + + + RCErrorWidget + + + Qt::ApplicationModal + + + + 0 + 0 + 400 + 407 + + + + Ryzom Core error report + + + + + + What were you doing when the crash occured? + + + + + + + + + + Contents of the report ( automatically generated ) + + + + + + + true + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Email me if you have further questions, or updates on this issue + + + + + + + false + + + Enter your email address here + + + + + + + Send + + + + + + + Cancel + + + + + + + + From aca8314fdb4aeff0065f57b2f038f5398f6cf951 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 01:59:04 +0100 Subject: [PATCH 21/31] Implemented the bug report Qt app and an example web app that takes the report. --- code/nel/rcerror/rcerror_data.h | 33 ++++++++ code/nel/rcerror/rcerror_socket.cpp | 46 +++++++++++ code/nel/rcerror/rcerror_socket.h | 26 ++++++ code/nel/rcerror/rcerror_widget.cpp | 25 +++++- code/nel/rcerror/rcerror_widget.h | 7 +- code/web/rcerror_web/config.inc.php | 30 +++++++ code/web/rcerror_web/log.inc.php | 45 +++++++++++ code/web/rcerror_web/rcerror.php | 112 ++++++++++++++++++++++++++ code/web/rcerror_web/rcerror_test.htm | 19 +++++ 9 files changed, 341 insertions(+), 2 deletions(-) create mode 100644 code/nel/rcerror/rcerror_data.h create mode 100644 code/web/rcerror_web/config.inc.php create mode 100644 code/web/rcerror_web/log.inc.php create mode 100644 code/web/rcerror_web/rcerror.php create mode 100644 code/web/rcerror_web/rcerror_test.htm diff --git a/code/nel/rcerror/rcerror_data.h b/code/nel/rcerror/rcerror_data.h new file mode 100644 index 000000000..146102038 --- /dev/null +++ b/code/nel/rcerror/rcerror_data.h @@ -0,0 +1,33 @@ +// Ryzom Core MMORPG framework - Error Reporter +// +// Copyright (C) 2015 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// 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 . + + +#ifndef RCERROR_DATA +#define RCERROR_DATA + +#include + + +struct RCErrorData +{ + QString description; + QString report; + QString email; +}; + +#endif diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/rcerror/rcerror_socket.cpp index f39946423..d84f69ec8 100644 --- a/code/nel/rcerror/rcerror_socket.cpp +++ b/code/nel/rcerror/rcerror_socket.cpp @@ -17,4 +17,50 @@ // along with this program. If not, see . #include "rcerror_socket.h" +#include +#include +#include + +namespace +{ + static const char *BUG_URL = "http://192.168.2.67/dfighter/r.php"; +} + +class RCErrorSocketPvt +{ +public: + QNetworkAccessManager mgr; +}; + +RCErrorSocket::RCErrorSocket( QObject *parent ) : +QObject( parent ) +{ + m_pvt = new RCErrorSocketPvt(); + + connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished() ) ); +} + +RCErrorSocket::~RCErrorSocket() +{ + delete m_pvt; +} + +void RCErrorSocket::sendReport( const RCErrorData &data ) +{ + QUrl params; + params.addQueryItem( "report", data.report ); + params.addQueryItem( "descr", data.description ); + params.addQueryItem( "email", data.email ); + + QUrl url( BUG_URL ); + QNetworkRequest request( url ); + request.setRawHeader( "Connection", "close" ); + + m_pvt->mgr.post( request, params.encodedQuery() ); +} + +void RCErrorSocket::onFinished() +{ + Q_EMIT reportSent(); +} diff --git a/code/nel/rcerror/rcerror_socket.h b/code/nel/rcerror/rcerror_socket.h index 8cd9f54ad..ee0f510b1 100644 --- a/code/nel/rcerror/rcerror_socket.h +++ b/code/nel/rcerror/rcerror_socket.h @@ -19,5 +19,31 @@ #ifndef RCERROR_SOCKET #define RCERROR_SOCKET + +#include +#include "rcerror_data.h" + +class RCErrorSocketPvt; + +class RCErrorSocket : public QObject +{ + Q_OBJECT + +public: + RCErrorSocket( QObject *parent ); + ~RCErrorSocket(); + + void sendReport( const RCErrorData &data ); + +Q_SIGNALS: + void reportSent(); + +private Q_SLOTS: + void onFinished(); + +private: + RCErrorSocketPvt *m_pvt; +}; + #endif diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp index a50b273d3..faded0afa 100644 --- a/code/nel/rcerror/rcerror_widget.cpp +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -18,23 +18,32 @@ #include "rcerror_widget.h" +#include "rcerror_socket.h" +#include "rcerror_data.h" #include #include #include +#include RCErrorWidget::RCErrorWidget( QWidget *parent ) : QWidget( parent ) { m_ui.setupUi( this ); + + m_socket = new RCErrorSocket( this ); + QTimer::singleShot( 1, this, SLOT( onLoad() ) ); connect( m_ui.sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) ); connect( m_ui.canceButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); connect( m_ui.emailCB, SIGNAL( stateChanged( int ) ), this, SLOT( onCBClicked() ) ); + + connect( m_socket, SIGNAL( reportSent() ), this, SLOT( onReportSent() ) ); } RCErrorWidget::~RCErrorWidget() { + m_socket = NULL; } void RCErrorWidget::onLoad() @@ -53,7 +62,14 @@ void RCErrorWidget::onLoad() void RCErrorWidget::onSendClicked() { - close(); + m_ui.sendButton->setEnabled( false ); + + RCErrorData data; + data.description = m_ui.descriptionEdit->toPlainText(); + data.report = m_ui.reportEdit->toPlainText(); + data.email = m_ui.emailEdit->text(); + + m_socket->sendReport( data ); } void RCErrorWidget::onCancelClicked() @@ -66,5 +82,12 @@ void RCErrorWidget::onCBClicked() m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() ); } +void RCErrorWidget::onReportSent() +{ + QMessageBox::information( this, + tr( "Report sent" ), + tr( "The report has been sent." ) ); + close(); +} diff --git a/code/nel/rcerror/rcerror_widget.h b/code/nel/rcerror/rcerror_widget.h index ae5629e55..869838e41 100644 --- a/code/nel/rcerror/rcerror_widget.h +++ b/code/nel/rcerror/rcerror_widget.h @@ -18,11 +18,13 @@ #ifndef RCERROR_WIDGET -#define RCERROR_SOCKET +#define RCERROR_WIDGET #include "ui_rcerror_widget.h" +class RCErrorSocket; + class RCErrorWidget : public QWidget { Q_OBJECT @@ -37,10 +39,13 @@ private Q_SLOTS: void onSendClicked(); void onCancelClicked(); void onCBClicked(); + + void onReportSent(); private: Ui::RCErrorWidget m_ui; QString m_fileName; + RCErrorSocket *m_socket; }; #endif diff --git a/code/web/rcerror_web/config.inc.php b/code/web/rcerror_web/config.inc.php new file mode 100644 index 000000000..fe4b3e928 --- /dev/null +++ b/code/web/rcerror_web/config.inc.php @@ -0,0 +1,30 @@ + +// +// 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 . + +class BugReportConfig +{ + static public $dbhost = "localhost"; + static public $dbport = "3306"; + static public $dbdb = "bugs"; + static public $dbuser = "bugs"; + static public $dbpw = "bugs"; +} + +?> diff --git a/code/web/rcerror_web/log.inc.php b/code/web/rcerror_web/log.inc.php new file mode 100644 index 000000000..71deee24f --- /dev/null +++ b/code/web/rcerror_web/log.inc.php @@ -0,0 +1,45 @@ + +// +// 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 . + +/// Simple file logger class +class Logger +{ + private $lf = NULL; + + function __construct() + { + $this->lf = fopen( 'log.txt', 'a' ); + if( $this->lf === FALSE ) + exit( 1 ); + } + + function __destruct() + { + fclose( $this->lf ); + } + + public function log( $msg ) + { + $date = date( "[M d, Y H:i:s] " ); + fwrite( $this->lf, $date . $msg . "\n" ); + } +} + +?> diff --git a/code/web/rcerror_web/rcerror.php b/code/web/rcerror_web/rcerror.php new file mode 100644 index 000000000..d20214d11 --- /dev/null +++ b/code/web/rcerror_web/rcerror.php @@ -0,0 +1,112 @@ + +// +// 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 . + +require_once( 'config.inc.php' ); +require_once( 'log.inc.php' ); + +/// Example web application that takes bug reports from the bug reporter Qt app +class BugReportGatherApp +{ + private $db = NULL; + private $logger = NULL; + + function __construct() + { + $this->logger = new Logger(); + } + + private function logPOSTVars() + { + $report = ""; + $descr = ""; + $email = ""; + + if( isset( $_POST[ 'report' ] ) ) + $report = $_POST[ 'report' ]; + + if( isset( $_POST[ 'descr' ] ) ) + $descr = $_POST[ 'descr' ]; + + if( isset( $_POST[ 'email' ] ) ) + $email = $_POST[ 'email' ]; + + $this->logger->log( 'report: ' . "\n" . $report ); + $this->logger->log( 'description: ' . "\n" . $descr ); + $this->logger->log( 'email: ' . "\n" . $email ); + } + + private function buildQuery() + { + $report = ""; + $descr = ""; + $email = ""; + + if( isset( $_POST[ 'report' ] ) ) + $report = $_POST[ 'report' ]; + + if( isset( $_POST[ 'descr' ] ) ) + $descr = $_POST[ 'descr' ]; + + if( isset( $_POST[ 'email' ] ) ) + $email = $_POST[ 'email' ]; + + $report = $this->db->real_escape_string( $report ); + $descr = $this->db->real_escape_string( $descr ); + $email = $this->db->real_escape_string( $email ); + + + $q = "INSERT INTO `bugs` (`report`,`description`,`email`) VALUES ("; + $q .= "'$report',"; + $q .= "'$descr',"; + $q .= "'$email')"; + + return $q; + } + + public function exec() + { + //$this->logPOSTVars(); + + $this->db = new mysqli( BugReportConfig::$dbhost, BugReportConfig::$dbuser, BugReportConfig::$dbpw, BugReportConfig::$dbdb, BugReportConfig::$dbport ); + if( mysqli_connect_error() ) + { + $this->logger->log( "Connection error :(" ); + $this->logger->log( mysqli_connect_error() ); + return; + } + + $q = $this->buildQuery(); + $result = $this->db->query( $q ); + if( $result !== TRUE ) + { + $this->logger->log( "Query failed :(" ); + $this->logger->log( 'Query: ' . $q ); + $this->logPOSTVars(); + } + + $this->db->close(); + } +} + + +$app = new BugReportGatherApp(); +$app->exec(); + +?> diff --git a/code/web/rcerror_web/rcerror_test.htm b/code/web/rcerror_web/rcerror_test.htm new file mode 100644 index 000000000..eb314d3f7 --- /dev/null +++ b/code/web/rcerror_web/rcerror_test.htm @@ -0,0 +1,19 @@ + +Ryzom Core Error Report Web application test harness + +
+ + + + + + + + + +
Description
Report
Email
+ +
+
+ + From a92f816f557b249bb21f0230afcb228ff1fcc793 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 02:03:33 +0100 Subject: [PATCH 22/31] Probably a good idea to look for rcerror as rcerror.exe on Windows. --- code/nel/src/misc/report.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 39f27de5f..1a94e17a6 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -76,7 +76,11 @@ TReportResult report (const std::string &title, const std::string &header, const f << body; f.close(); +#ifdef NL_OS_WINDOWS + NLMISC::launchProgram( "rcerror.exe", fname ); +#else NLMISC::launchProgram( "rcerror", fname ); +#endif } NLMISC::CFile::deleteFile( fname ); From 04480a32909fd8ca260093e8ee09da940e6f9d0b Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 02:35:11 +0100 Subject: [PATCH 23/31] Unfortunately on Windows argc and argv parameters are unreliable inside a Qt application, so I had to hardcode the report file name. :( --- code/nel/rcerror/rcerror.cpp | 19 +------------------ code/nel/rcerror/rcerror_widget.cpp | 5 ++++- code/nel/src/misc/report.cpp | 8 +------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/code/nel/rcerror/rcerror.cpp b/code/nel/rcerror/rcerror.cpp index 6fa876e81..0d5088167 100644 --- a/code/nel/rcerror/rcerror.cpp +++ b/code/nel/rcerror/rcerror.cpp @@ -25,25 +25,8 @@ int main( int argc, char **argv ) { QApplication app( argc, argv ); -#if 0 - - if( argc < 2 ) - { - QMessageBox::information( NULL, - QObject::tr( "Error" ), - QObject::tr( "Need to specify a path to the error report." ) ); - return 1; - } -#endif - RCErrorWidget w; - -#if 0 - w.setFileName( argv[ 1 ] ); -#else - w.setFileName( "log.log" ); -#endif - + w.setFileName( "rcerrorlog.txt" ); w.show(); return app.exec(); diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp index faded0afa..6c31533ad 100644 --- a/code/nel/rcerror/rcerror_widget.cpp +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -52,7 +52,10 @@ void RCErrorWidget::onLoad() bool b = f.open( QFile::ReadOnly | QFile::Text ); if( !b ) { - return; + QMessageBox::information( this, + tr( "No log file found" ), + tr( "There was no log file found, therefore nothing to report. Exiting..." ) ); + close(); } QTextStream ss( &f ); diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 1a94e17a6..88c707aaa 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -64,10 +64,7 @@ void report () TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile) { - std::string fname; - - time_t s = time( NULL ); - fname = std::string( "log_" ) + toString( s ) + ".txt"; + std::string fname = "rcerrorlog.txt"; std::ofstream f; f.open( fname.c_str() ); @@ -83,9 +80,6 @@ TReportResult report (const std::string &title, const std::string &header, const #endif } - NLMISC::CFile::deleteFile( fname ); - - #ifdef NL_OS_WINDOWS #ifndef NL_COMP_MINGW // disable the Windows popup telling that the application aborted and disable the dr watson report. From 52bb68f547a9ae862b346dc4aa841c6133a4decc Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 02:44:22 +0100 Subject: [PATCH 24/31] Override the cursor while sending the report. --- code/nel/rcerror/rcerror_socket.cpp | 2 +- code/nel/rcerror/rcerror_widget.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/rcerror/rcerror_socket.cpp index d84f69ec8..6b1fd932d 100644 --- a/code/nel/rcerror/rcerror_socket.cpp +++ b/code/nel/rcerror/rcerror_socket.cpp @@ -23,7 +23,7 @@ namespace { - static const char *BUG_URL = "http://192.168.2.67/dfighter/r.php"; + static const char *BUG_URL = "http://192.168.2.66/dfighter/r.php"; } class RCErrorSocketPvt diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp index 6c31533ad..e02090e0d 100644 --- a/code/nel/rcerror/rcerror_widget.cpp +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -66,6 +66,7 @@ void RCErrorWidget::onLoad() void RCErrorWidget::onSendClicked() { m_ui.sendButton->setEnabled( false ); + QApplication::setOverrideCursor( Qt::WaitCursor ); RCErrorData data; data.description = m_ui.descriptionEdit->toPlainText(); @@ -87,6 +88,8 @@ void RCErrorWidget::onCBClicked() void RCErrorWidget::onReportSent() { + QApplication::setOverrideCursor( Qt::ArrowCursor ); + QMessageBox::information( this, tr( "Report sent" ), tr( "The report has been sent." ) ); From 31907ca35f805ae5783b50e0869154772b68862e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 02:54:05 +0100 Subject: [PATCH 25/31] Tell the user if the report couldn't be sent. --- code/nel/rcerror/rcerror_socket.cpp | 10 +++++++--- code/nel/rcerror/rcerror_socket.h | 4 +++- code/nel/rcerror/rcerror_widget.cpp | 11 +++++++++++ code/nel/rcerror/rcerror_widget.h | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/rcerror/rcerror_socket.cpp index 6b1fd932d..8a011c046 100644 --- a/code/nel/rcerror/rcerror_socket.cpp +++ b/code/nel/rcerror/rcerror_socket.cpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace { @@ -37,7 +38,7 @@ QObject( parent ) { m_pvt = new RCErrorSocketPvt(); - connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished() ) ); + connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished( QNetworkReply* ) ) ); } RCErrorSocket::~RCErrorSocket() @@ -59,8 +60,11 @@ void RCErrorSocket::sendReport( const RCErrorData &data ) m_pvt->mgr.post( request, params.encodedQuery() ); } -void RCErrorSocket::onFinished() +void RCErrorSocket::onFinished( QNetworkReply *reply ) { - Q_EMIT reportSent(); + if( reply->error() != QNetworkReply::NoError ) + Q_EMIT reportFailed(); + else + Q_EMIT reportSent(); } diff --git a/code/nel/rcerror/rcerror_socket.h b/code/nel/rcerror/rcerror_socket.h index ee0f510b1..a37fa32d0 100644 --- a/code/nel/rcerror/rcerror_socket.h +++ b/code/nel/rcerror/rcerror_socket.h @@ -24,6 +24,7 @@ #include "rcerror_data.h" class RCErrorSocketPvt; +class QNetworkReply; class RCErrorSocket : public QObject { @@ -37,9 +38,10 @@ public: Q_SIGNALS: void reportSent(); + void reportFailed(); private Q_SLOTS: - void onFinished(); + void onFinished( QNetworkReply *reply ); private: RCErrorSocketPvt *m_pvt; diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp index e02090e0d..a28afbca6 100644 --- a/code/nel/rcerror/rcerror_widget.cpp +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -39,6 +39,7 @@ QWidget( parent ) connect( m_ui.emailCB, SIGNAL( stateChanged( int ) ), this, SLOT( onCBClicked() ) ); connect( m_socket, SIGNAL( reportSent() ), this, SLOT( onReportSent() ) ); + connect( m_socket, SIGNAL( reportFailed() ), this, SLOT( onReportFailed() ) ); } RCErrorWidget::~RCErrorWidget() @@ -97,3 +98,13 @@ void RCErrorWidget::onReportSent() close(); } +void RCErrorWidget::onReportFailed() +{ + QApplication::setOverrideCursor( Qt::ArrowCursor ); + + QMessageBox::information( this, + tr( "Report failed" ), + tr( "Failed to send the report..." ) ); + + close(); +} \ No newline at end of file diff --git a/code/nel/rcerror/rcerror_widget.h b/code/nel/rcerror/rcerror_widget.h index 869838e41..1dd51c2af 100644 --- a/code/nel/rcerror/rcerror_widget.h +++ b/code/nel/rcerror/rcerror_widget.h @@ -41,6 +41,7 @@ private Q_SLOTS: void onCBClicked(); void onReportSent(); + void onReportFailed(); private: Ui::RCErrorWidget m_ui; From 7e2e2ae56b75edc79e7de563f8d08d7c4a9351f6 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 02:56:22 +0100 Subject: [PATCH 26/31] Oups --- code/ryzom/client/src/init.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index c7fdc97f8..6958fe790 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -539,8 +539,6 @@ void checkDriverVersion() void checkDriverDepth () { - nlassert( false ); - // Check desktop is in 32 bit else no window mode allowed. if (ClientCfg.Windowed) { From 0eb8913a20f288e6aae6f1d103549d233fe74361 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 03:22:02 +0100 Subject: [PATCH 27/31] Typo... --- code/nel/rcerror/rcerror_data.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/rcerror/rcerror_data.h b/code/nel/rcerror/rcerror_data.h index 146102038..9f12b12fd 100644 --- a/code/nel/rcerror/rcerror_data.h +++ b/code/nel/rcerror/rcerror_data.h @@ -20,7 +20,7 @@ #ifndef RCERROR_DATA #define RCERROR_DATA -#include +#include struct RCErrorData From d33da5fe44abdc8fcfd29492c44b6d41667dd618 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 21 Feb 2015 20:01:44 +0100 Subject: [PATCH 28/31] Install rcerror --- code/nel/rcerror/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/nel/rcerror/CMakeLists.txt b/code/nel/rcerror/CMakeLists.txt index 412da9b6c..51522cf0c 100644 --- a/code/nel/rcerror/CMakeLists.txt +++ b/code/nel/rcerror/CMakeLists.txt @@ -35,3 +35,5 @@ TARGET_LINK_LIBRARIES(rcerror ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) NL_DEFAULT_PROPS(rcerror "Ryzom Core Error Reporter") NL_ADD_RUNTIME_FLAGS(rcerror) +INSTALL(TARGETS rcerror RUNTIME DESTINATION ${NL_BIN_PREFIX}) + From 566d21f64e67e230edfee57647bcc5b0f3e01b9b Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 21 Feb 2015 21:28:56 +0100 Subject: [PATCH 29/31] Use CMsgBoxDisplayer on platforms other than Windows as well. --- code/nel/src/misc/debug.cpp | 8 +------- code/nel/src/misc/displayer.cpp | 2 -- code/nel/src/misc/report.cpp | 12 ------------ 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 2d09f5ef8..aaa551f1f 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -1193,13 +1193,7 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog) INelContext::getInstance().setAssertLog(new CLog (CLog::LOG_ASSERT)); sd = new CStdDisplayer ("DEFAULT_SD"); - -#ifdef NL_OS_WINDOWS - if (TrapCrashInDebugger || !IsDebuggerPresent ()) - { - DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD"); - } -#endif + DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD"); #if LOG_IN_FILE if (logInFile) diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index d48c44d02..35ae27964 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -529,7 +529,6 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes // in release "" void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message) { -#ifdef NL_OS_WINDOWS bool needSpace = false; // stringstream ss; @@ -720,7 +719,6 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m } */ } -#endif } diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 88c707aaa..b165e29f5 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -52,16 +52,6 @@ void setReportEmailFunction (void *emailFunction) EmailFunction = (TEmailFunction)emailFunction; } -#ifndef NL_OS_WINDOWS - -// GNU/Linux, do nothing - -void report () -{ -} - -#else - TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile) { std::string fname = "rcerrorlog.txt"; @@ -92,7 +82,5 @@ TReportResult report (const std::string &title, const std::string &header, const return ReportQuit; } -#endif - } // NLMISC From 8a571b8689561cd772987fafc5a52f2d4f81af71 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 21 Feb 2015 22:32:11 +0100 Subject: [PATCH 30/31] A little cleanup of CMsgBoxDisplayer. --- code/nel/include/nel/misc/report.h | 17 +-- code/nel/src/misc/debug.cpp | 2 +- code/nel/src/misc/displayer.cpp | 174 +---------------------------- code/nel/src/misc/report.cpp | 19 +--- 4 files changed, 7 insertions(+), 205 deletions(-) diff --git a/code/nel/include/nel/misc/report.h b/code/nel/include/nel/misc/report.h index 11745b6e3..6bf3df959 100644 --- a/code/nel/include/nel/misc/report.h +++ b/code/nel/include/nel/misc/report.h @@ -21,21 +21,8 @@ namespace NLMISC { -/** Display a custom message box. - * - * \param title set the title of the report. If empty, it'll display "NeL report". - * \param header message displayed before the edit text box. If empty, it displays the default message. - * \param body message displayed in the edit text box. This string will be sent by email. - * \param debugButton 0 for disabling it, 1 for enable with default behaviors (generate a breakpoint), 2 for enable with no behavior - * - * - * - * \return the button clicked or error - */ - -enum TReportResult { ReportDebug, ReportIgnore, ReportQuit, ReportError }; - -TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const std::string &attachedFile = ""); +/// Prepares the error report, writes it to disk and launches the error reporter +void report ( const std::string &body ); /** call this in the main of your appli to enable email: setReportEmailFunction (sendEmail); */ diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index aaa551f1f..67c8cb0f3 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -553,7 +553,7 @@ public: // yoyo: allow only to send the crash report once. Because users usually click ignore, // which create noise into list of bugs (once a player crash, it will surely continues to do it). bool i = false; - report (progname+shortExc, "", subject, _Reason, true, 1, true, 1, !isCrashAlreadyReported(), i, NL_CRASH_DUMP_FILE); + report ( _Reason ); // no more sent mail for crash setCrashAlreadyReported(true); diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index 35ae27964..8296d1c0b 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -529,114 +529,7 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes // in release "" void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message) { - - bool needSpace = false; -// stringstream ss; - string str; - - // create the string for the clipboard - - if (args.Date != 0) - { - str += dateToHumanString(args.Date); - needSpace = true; - } - - if (args.LogType != CLog::LOG_NO) - { - //if (needSpace) { ss << " "; needSpace = false; } - if (needSpace) { str += " "; needSpace = false; } - str += logTypeToString(args.LogType); - needSpace = true; - } - - if (!args.ProcessName.empty()) - { - //if (needSpace) { ss << " "; needSpace = false; } - if (needSpace) { str += " "; needSpace = false; } - str += args.ProcessName; - needSpace = true; - } - - if (args.FileName != NULL) - { - //if (needSpace) { ss << " "; needSpace = false; } - if (needSpace) { str += " "; needSpace = false; } - str += CFile::getFilename(args.FileName); - needSpace = true; - } - - if (args.Line != -1) - { - //if (needSpace) { ss << " "; needSpace = false; } - if (needSpace) { str += " "; needSpace = false; } - str += NLMISC::toString(args.Line); - needSpace = true; - } - - if (args.FuncName != NULL) - { - //if (needSpace) { ss << " "; needSpace = false; } - if (needSpace) { str += " "; needSpace = false; } - str += args.FuncName; - needSpace = true; - } - - if (needSpace) { str += ": "; needSpace = false; } - - str += message; - - CSystemUtils::copyTextToClipboard(str); - - // create the string on the screen - needSpace = false; -// stringstream ss2; - string str2; - -#ifdef NL_DEBUG - if (!args.ProcessName.empty()) - { - if (needSpace) { str2 += " "; needSpace = false; } - str2 += args.ProcessName; - needSpace = true; - } - - if (args.FileName != NULL) - { - if (needSpace) { str2 += " "; needSpace = false; } - str2 += CFile::getFilename(args.FileName); - needSpace = true; - } - - if (args.Line != -1) - { - if (needSpace) { str2 += " "; needSpace = false; } - str2 += NLMISC::toString(args.Line); - needSpace = true; - } - - if (args.FuncName != NULL) - { - if (needSpace) { str2 += " "; needSpace = false; } - str2 += args.FuncName; - needSpace = true; - } - - if (needSpace) { str2 += ": "; needSpace = false; } - -#endif // NL_DEBUG - - str2 += message; - str2 += "\n\n(this message was copied in the clipboard)"; - -/* if (IsDebuggerPresent ()) - { - // Must break in assert call - DebugNeedAssert = true; - } - else -*/ { - + // Display the report string body; @@ -656,69 +549,8 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m body += "Reason: " + toString(message); body += args.CallstackAndLog; - - string subject; - - // procname is host/service_name-sid we only want the service_name to avoid redondant mail - string procname; - string::size_type pos = args.ProcessName.find ("/"); - if (pos == string::npos) - { - procname = args.ProcessName; - } - else - { - string::size_type pos2 = args.ProcessName.find ("-", pos+1); - if (pos2 == string::npos) - { - procname = args.ProcessName.substr (pos+1); - } - else - { - procname = args.ProcessName.substr (pos+1, pos2-pos-1); - } - } - - subject += procname + " NeL " + toString(LogTypeToString[0][args.LogType]) + " " + (args.FileName?string(args.FileName):"") + " " + toString(args.Line) + " " + (args.FuncName?string(args.FuncName):""); - - // Check the envvar NEL_IGNORE_ASSERT - if (getenv ("NEL_IGNORE_ASSERT") == NULL) - { - // yoyo: allow only to send the crash report once. Because users usually click ignore, - // which create noise into list of bugs (once a player crash, it will surely continues to do it). - std::string filename = getLogDirectory() + NL_CRASH_DUMP_FILE; - - if (ReportDebug == report (args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)), "", subject, body, true, 2, true, 1, !isCrashAlreadyReported(), IgnoreNextTime, filename.c_str())) - { - INelContext::getInstance().setDebugNeedAssert(true); - } - - // no more sent mail for crash - setCrashAlreadyReported(true); - } - -/* // Check the envvar NEL_IGNORE_ASSERT - if (getenv ("NEL_IGNORE_ASSERT") == NULL) - { - // Ask the user to continue, debug or ignore - int result = MessageBox (NULL, ss2.str().c_str (), logTypeToString(args.LogType, true), MB_ABORTRETRYIGNORE | MB_ICONSTOP); - if (result == IDABORT) - { - // Exit the program now - exit (EXIT_FAILURE); - } - else if (result == IDRETRY) - { - // Give the debugger a try - DebugNeedAssert = true; - } - else if (result == IDIGNORE) - { - // Continue, do nothing - } - } -*/ } - + + report( body ); } diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index b165e29f5..54c456ade 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -22,23 +22,8 @@ #include "nel/misc/report.h" #include "nel/misc/path.h" -#ifdef NL_OS_WINDOWS -# ifndef NL_COMP_MINGW -# define NOMINMAX -# endif -# include -# include -# include -#endif // NL_OS_WINDOWS - -#define NL_NO_DEBUG_FILES 1 - using namespace std; -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - namespace NLMISC { @@ -52,7 +37,7 @@ void setReportEmailFunction (void *emailFunction) EmailFunction = (TEmailFunction)emailFunction; } -TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile) +void report ( const std::string &body ) { std::string fname = "rcerrorlog.txt"; @@ -78,8 +63,6 @@ TReportResult report (const std::string &title, const std::string &header, const #endif // quit without calling atexit or static object dtors. abort(); - - return ReportQuit; } From 98cc1f03f8f3d54e411546ff3bf9e0290cda2a6d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 21 Feb 2015 22:34:02 +0100 Subject: [PATCH 31/31] Removed unused references to CMsgBoxDisplayer. --- code/ryzom/client/src/connection.cpp | 1 - code/ryzom/client/src/init.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index 8b07cc7f2..22354e436 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -103,7 +103,6 @@ extern uint32 Version; // Client Version. extern UDriver *Driver; extern UTextContext *TextContext; extern bool game_exit; -extern CMsgBoxDisplayer MsgBoxError; extern CSoundManager *SoundMngr; diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 6958fe790..f0fd40dae 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -142,7 +142,6 @@ using namespace std; // Ligo primitive class CLigoConfig LigoConfig; -CMsgBoxDisplayer MsgBoxError; CClientChatManager ChatMngr; bool LastScreenSaverEnabled = false;