From fb3f069a38f3dcaba6560bcb955f3073874d41e6 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 15 Jul 2013 05:51:25 +0200 Subject: [PATCH] Should be able to save QColor based QVariant too. --HG-- branch : gsoc2013-dfighter --- code/nel/src/misc/variant.cpp | 8 ++++---- .../src/plugins/material_editor/prop_browser_ctrl.cpp | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/code/nel/src/misc/variant.cpp b/code/nel/src/misc/variant.cpp index 0514b2d59..1689775a5 100644 --- a/code/nel/src/misc/variant.cpp +++ b/code/nel/src/misc/variant.cpp @@ -245,6 +245,10 @@ namespace NLMISC void CVariant::fromString( const std::string &s, EVarType t ) { + type = t; + sval = ""; + std::fill( uvalue.vval, uvalue.vval + VARIANT_VVAL_END, 0.0 ); + if( s.empty() ) return; @@ -282,7 +286,6 @@ namespace NLMISC case Vector4: { - std::fill( uvalue.vval, uvalue.vval + VARIANT_VVAL_END, 0.0 ); std::stringstream ss = s; for( int i = 0; i < 4; i++ ) @@ -297,7 +300,6 @@ namespace NLMISC case Matrix4: { - std::fill( uvalue.vval, uvalue.vval + VARIANT_VVAL_END, 0.0 ); std::stringstream ss = s; for( int i = 0; i < 16; i++ ) @@ -310,8 +312,6 @@ namespace NLMISC } } - type = t; - } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/prop_browser_ctrl.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/prop_browser_ctrl.cpp index 33396dabe..69aa154a2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/prop_browser_ctrl.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/prop_browser_ctrl.cpp @@ -287,6 +287,15 @@ namespace MaterialEditor { QString label = p->propertyName(); std::string value = p->valueText().toUtf8().data(); + + if( v.type() == QVariant::Color ) + { + QColor c = v.value< QColor >(); + value.clear(); + QString val = "%1 %2 %3 %4"; + val = val.arg( c.red() ).arg( c.green() ).arg( c.blue() ).arg( c.alpha() ); + value = val.toUtf8().data(); + } CNelMaterialProxy m = nel3dIface->getMaterial(); CRenderPassProxy pass = m.getPass( currentPass.toUtf8().data() );